Changeset 34777 in webkit for trunk/JavaScriptCore/VM/Machine.cpp


Ignore:
Timestamp:
Jun 24, 2008, 2:19:56 PM (17 years ago)
Author:
[email protected]
Message:

Groundwork for reimplementing the slow script dialog

Reviewed by Cameron.

Add special loop opcodes as groundwork for slow script
termination. Also added a few assertions to prevent us
from accidentally coalescing conditional jump operands
in a way that might bypass the slow script opcodes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/Machine.cpp

    r34754 r34777  
    896896    JSValue** k = codeBlock->jsValues.data();
    897897    Profiler** enabledProfilerReference = Profiler::enabledProfilerReference();
    898 
     898   
    899899    registerFile->setSafeForReentry(false);
    900900#define VM_CHECK_EXCEPTION() \
     
    909909    OpcodeStats::resetLastInstruction();
    910910#endif
    911 
     911   
     912#define CHECK_FOR_TIMEOUT()
     913   
    912914#if HAVE(COMPUTED_GOTO)
    913915    #define NEXT_OPCODE goto *vPC->u.opcode
     
    18881890        NEXT_OPCODE;
    18891891    }
     1892    BEGIN_OPCODE(op_loop_if_true) {
     1893        /* loop_if_true cond(r) target(offset)
     1894         
     1895           Jumps to offset target from the current instruction, if and
     1896           only if register cond converts to boolean as true.
     1897
     1898           Additionally this loop instruction may terminate JS execution is
     1899           the JS timeout is reached.
     1900         */
     1901        int cond = (++vPC)->u.operand;
     1902        int target = (++vPC)->u.operand;
     1903        if (r[cond].u.jsValue->toBoolean(exec)) {
     1904            vPC += target;
     1905            CHECK_FOR_TIMEOUT();
     1906            NEXT_OPCODE;
     1907        }
     1908       
     1909        ++vPC;
     1910        NEXT_OPCODE;
     1911    }
    18901912    BEGIN_OPCODE(op_jtrue) {
    18911913        /* jtrue cond(r) target(offset)
     
    19171939        }
    19181940
     1941        ++vPC;
     1942        NEXT_OPCODE;
     1943    }
     1944    BEGIN_OPCODE(op_loop_if_less) {
     1945        /* loop_if_less src1(r) src2(r) target(offset)
     1946
     1947           Checks whether register src1 is less than register src2, as
     1948           with the ECMAScript '<' operator, and then jumps to offset
     1949           target from the current instruction, if and only if the
     1950           result of the comparison is true.
     1951
     1952           Additionally this loop instruction may terminate JS execution is
     1953           the JS timeout is reached.
     1954         */
     1955        JSValue* src1 = r[(++vPC)->u.operand].u.jsValue;
     1956        JSValue* src2 = r[(++vPC)->u.operand].u.jsValue;
     1957        int target = (++vPC)->u.operand;
     1958       
     1959        bool result = jsLess(exec, src1, src2);
     1960        VM_CHECK_EXCEPTION();
     1961       
     1962        if (result) {
     1963            vPC += target;
     1964            CHECK_FOR_TIMEOUT();
     1965            NEXT_OPCODE;
     1966        }
     1967       
    19191968        ++vPC;
    19201969        NEXT_OPCODE;
Note: See TracChangeset for help on using the changeset viewer.