Changeset 34777 in webkit for trunk/JavaScriptCore
- Timestamp:
- Jun 24, 2008, 2:19:56 PM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r34773 r34777 1 2008-06-24 Oliver Hunt <[email protected]> 2 3 Reviewed by Cameron. 4 5 Add special loop opcodes as groundwork for slow script 6 termination. Also added a few assertions to prevent us 7 from accidentally coalescing conditional jump operands 8 in a way that might bypass the slow script opcodes. 9 10 * JavaScriptCore.xcodeproj/project.pbxproj: 11 * VM/CodeGenerator.cpp: 12 (KJS::CodeGenerator::emitJumpIfTrueMayCombine): 13 (KJS::CodeGenerator::emitJumpScopes): 14 * VM/LabelID.h: 15 * VM/Machine.cpp: 16 (KJS::Machine::privateExecute): 17 * VM/Machine.h: 18 * VM/Opcode.h: 19 1 20 2008-06-24 Darin Adler <[email protected]> 2 21 -
trunk/JavaScriptCore/VM/CodeGenerator.cpp
r34758 r34777 421 421 PassRefPtr<LabelID> CodeGenerator::emitJump(LabelID* target) 422 422 { 423 ASSERT(target->isForwardLabel()); 423 424 emitOpcode(op_jmp); 424 425 instructions().append(target->offsetFrom(instructions().size())); … … 437 438 if (cond->index() == dstIndex) { 438 439 rewindBinaryOp(); 439 emitOpcode( op_jless);440 emitOpcode(target->isForwardLabel() ? op_jless : op_loop_if_less); 440 441 instructions().append(src1Index); 441 442 instructions().append(src2Index); … … 450 451 PassRefPtr<LabelID> CodeGenerator::emitJumpIfTrue(RegisterID* cond, LabelID* target) 451 452 { 452 emitOpcode( op_jtrue);453 emitOpcode(target->isForwardLabel() ? op_jtrue : op_loop_if_true); 453 454 instructions().append(cond->index()); 454 455 instructions().append(target->offsetFrom(instructions().size())); … … 458 459 PassRefPtr<LabelID> CodeGenerator::emitJumpIfFalse(RegisterID* cond, LabelID* target) 459 460 { 461 ASSERT(target->isForwardLabel()); 460 462 emitOpcode(op_jfalse); 461 463 instructions().append(cond->index()); … … 1032 1034 { 1033 1035 ASSERT(scopeDepth() - targetScopeDepth >= 0); 1036 ASSERT(target->isForwardLabel()); 1034 1037 1035 1038 size_t scopeDelta = scopeDepth() - targetScopeDepth; -
trunk/JavaScriptCore/VM/LabelID.h
r34372 r34777 99 99 } 100 100 101 bool isForwardLabel() { return m_location == invalidLocation; } 101 102 private: 102 103 typedef Vector<int, 8> JumpVector; -
trunk/JavaScriptCore/VM/Machine.cpp
r34754 r34777 896 896 JSValue** k = codeBlock->jsValues.data(); 897 897 Profiler** enabledProfilerReference = Profiler::enabledProfilerReference(); 898 898 899 899 registerFile->setSafeForReentry(false); 900 900 #define VM_CHECK_EXCEPTION() \ … … 909 909 OpcodeStats::resetLastInstruction(); 910 910 #endif 911 911 912 #define CHECK_FOR_TIMEOUT() 913 912 914 #if HAVE(COMPUTED_GOTO) 913 915 #define NEXT_OPCODE goto *vPC->u.opcode … … 1888 1890 NEXT_OPCODE; 1889 1891 } 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 } 1890 1912 BEGIN_OPCODE(op_jtrue) { 1891 1913 /* jtrue cond(r) target(offset) … … 1917 1939 } 1918 1940 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 1919 1968 ++vPC; 1920 1969 NEXT_OPCODE; -
trunk/JavaScriptCore/VM/Machine.h
r34684 r34777 128 128 129 129 int m_reentryDepth; 130 130 131 #if HAVE(COMPUTED_GOTO) 131 132 Opcode m_opcodeTable[numOpcodeIDs]; // Maps OpcodeID => Opcode for compiling -
trunk/JavaScriptCore/VM/Opcode.h
r34497 r34777 98 98 macro(op_jless) \ 99 99 macro(op_jmp_scopes) \ 100 macro(op_loop_if_true) \ 101 macro(op_loop_if_less) \ 100 102 \ 101 103 macro(op_new_func) \
Note:
See TracChangeset
for help on using the changeset viewer.