Changeset 147184 in webkit
- Timestamp:
- Mar 28, 2013, 5:09:56 PM (12 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r147150 r147184 1 2013-03-28 Geoffrey Garen <ggaren@apple.com> 2 3 Simplified the bytecode by removing op_jmp_scopes 4 https://bugs.webkit.org/show_bug.cgi?id=113545 5 6 Reviewed by Filip Pizlo. 7 8 We already have op_pop_scope and op_jmp, so we don't need op_jmp_scopes. 9 Using op_jmp_scopes was also adding a "jump to self" to codegen for 10 return statements, which was pretty silly. 11 12 * JavaScriptCore.order: 13 * bytecode/CodeBlock.cpp: 14 (JSC::CodeBlock::dumpBytecode): 15 * bytecode/Opcode.h: 16 (JSC::padOpcodeName): 17 * bytecode/PreciseJumpTargets.cpp: 18 (JSC::computePreciseJumpTargets): 19 * bytecompiler/BytecodeGenerator.cpp: 20 (JSC::BytecodeGenerator::emitComplexPopScopes): 21 (JSC::BytecodeGenerator::emitPopScopes): 22 * bytecompiler/BytecodeGenerator.h: 23 (BytecodeGenerator): 24 * bytecompiler/NodesCodegen.cpp: 25 (JSC::ContinueNode::emitBytecode): 26 (JSC::BreakNode::emitBytecode): 27 (JSC::ReturnNode::emitBytecode): 28 * jit/JIT.cpp: 29 (JSC::JIT::privateCompileMainPass): 30 * jit/JIT.h: 31 * jit/JITOpcodes.cpp: 32 * jit/JITOpcodes32_64.cpp: 33 * jit/JITStubs.cpp: 34 * jit/JITStubs.h: 35 * llint/LLIntSlowPaths.cpp: 36 * llint/LLIntSlowPaths.h: 37 * llint/LowLevelInterpreter.asm: 38 1 39 2013-03-28 Mark Hahnenberg <mhahnenberg@apple.com> 2 40 -
trunk/Source/JavaScriptCore/JavaScriptCore.order
r146318 r147184 1271 1271 _cti_op_nstricteq 1272 1272 __ZN3JSC14LogicalNotNode30emitBytecodeInConditionContextERNS_17BytecodeGeneratorEPNS_5LabelES4_b 1273 __ZN3JSC3JIT18emit_op_jmp_scopesEPNS_11InstructionE1274 1273 _cti_op_negate 1275 1274 __ZN3JSCL16mathProtoFuncMaxEPNS_9ExecStateE … … 1472 1471 __ZNK3JSC11Interpreter18retrieveLastCallerEPNS_9ExecStateERiRlRNS_7UStringERNS_7JSValueE 1473 1472 __ZN3JSC23createNotAFunctionErrorEPNS_9ExecStateENS_7JSValueE 1474 _cti_op_jmp_scopes1475 1473 __ZNK3WTF6String6latin1Ev 1476 1474 __ZN3JSC3JIT30privateCompileGetByIdProtoListEPNS_17StructureStubInfoEPNS_30PolymorphicAccessStructureListEiPNS_9StructureES6_RKNS_10IdentifierERKNS_12PropertySlotEmPNS_9ExecStateE -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r146669 r147184 1448 1448 break; 1449 1449 } 1450 case op_jmp_scopes: {1451 int scopeDelta = (++it)->u.operand;1452 int offset = (++it)->u.operand;1453 out.printf("[%4d] jmp_scopes\t^%d, %d(->%d)", location, scopeDelta, offset, location + offset);1454 break;1455 }1456 1450 case op_catch: { 1457 1451 int r0 = (++it)->u.operand; -
trunk/Source/JavaScriptCore/bytecode/Opcode.h
r145000 r147184 173 173 macro(op_jngreater, 4) \ 174 174 macro(op_jngreatereq, 4) \ 175 macro(op_jmp_scopes, 3) \176 175 macro(op_loop, 2) \ 177 176 macro(op_loop_if_true, 3) \ -
trunk/Source/JavaScriptCore/bytecode/PreciseJumpTargets.cpp
r141931 r147184 62 62 case op_jeq_null: 63 63 case op_jneq_null: 64 case op_jmp_scopes:65 64 case op_loop_if_true: 66 65 case op_loop_if_false: -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r146318 r147184 2243 2243 } 2244 2244 2245 PassRefPtr<Label> BytecodeGenerator::emitComplexJumpScopes(Label* target,ControlFlowContext* topScope, ControlFlowContext* bottomScope)2245 void BytecodeGenerator::emitComplexPopScopes(ControlFlowContext* topScope, ControlFlowContext* bottomScope) 2246 2246 { 2247 2247 while (topScope > bottomScope) { … … 2257 2257 2258 2258 if (nNormalScopes) { 2259 size_t begin = instructions().size();2260 2261 2259 // We need to remove a number of dynamic scopes to get to the next 2262 2260 // finally block 2263 emitOpcode(op_jmp_scopes); 2264 instructions().append(nNormalScopes); 2265 2266 // If topScope == bottomScope then there isn't actually a finally block 2267 // left to emit, so make the jmp_scopes jump directly to the target label 2268 if (topScope == bottomScope) { 2269 instructions().append(target->bind(begin, instructions().size())); 2270 return target; 2271 } 2272 2273 // Otherwise we just use jmp_scopes to pop a group of scopes and go 2274 // to the next instruction 2275 RefPtr<Label> nextInsn = newLabel(); 2276 instructions().append(nextInsn->bind(begin, instructions().size())); 2277 emitLabel(nextInsn.get()); 2261 while (nNormalScopes--) 2262 emitOpcode(op_pop_scope); 2263 2264 // If topScope == bottomScope then there isn't a finally block left to emit. 2265 if (topScope == bottomScope) 2266 return; 2278 2267 } 2279 2268 … … 2365 2354 } 2366 2355 } 2367 return emitJump(target); 2368 } 2369 2370 PassRefPtr<Label> BytecodeGenerator::emitJumpScopes(Label* target, int targetScopeDepth) 2356 } 2357 2358 void BytecodeGenerator::emitPopScopes(int targetScopeDepth) 2371 2359 { 2372 2360 ASSERT(scopeDepth() - targetScopeDepth >= 0); 2373 ASSERT(target->isForward());2374 2361 2375 2362 size_t scopeDelta = scopeDepth() - targetScopeDepth; 2376 2363 ASSERT(scopeDelta <= m_scopeContextStack.size()); 2377 2364 if (!scopeDelta) 2378 return emitJump(target); 2379 2380 if (m_finallyDepth) 2381 return emitComplexJumpScopes(target, &m_scopeContextStack.last(), &m_scopeContextStack.last() - scopeDelta); 2382 2383 size_t begin = instructions().size(); 2384 2385 emitOpcode(op_jmp_scopes); 2386 instructions().append(scopeDelta); 2387 instructions().append(target->bind(begin, instructions().size())); 2388 return target; 2365 return; 2366 2367 if (!m_finallyDepth) { 2368 while (scopeDelta--) 2369 emitOpcode(op_pop_scope); 2370 return; 2371 } 2372 2373 emitComplexPopScopes(&m_scopeContextStack.last(), &m_scopeContextStack.last() - scopeDelta); 2389 2374 } 2390 2375 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r146318 r147184 487 487 PassRefPtr<Label> emitJumpIfNotFunctionCall(RegisterID* cond, Label* target); 488 488 PassRefPtr<Label> emitJumpIfNotFunctionApply(RegisterID* cond, Label* target); 489 PassRefPtr<Label> emitJumpScopes(Label* target,int targetScopeDepth);489 void emitPopScopes(int targetScopeDepth); 490 490 491 491 RegisterID* emitGetPropertyNames(RegisterID* dst, RegisterID* base, RegisterID* i, RegisterID* size, Label* breakTarget); … … 563 563 ALWAYS_INLINE void rewindUnaryOp(); 564 564 565 PassRefPtr<Label> emitComplexJumpScopes(Label* target,ControlFlowContext* topScope, ControlFlowContext* bottomScope);565 void emitComplexPopScopes(ControlFlowContext* topScope, ControlFlowContext* bottomScope); 566 566 567 567 typedef HashMap<double, JSValue> NumberMap; -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r146318 r147184 1786 1786 ASSERT(scope); 1787 1787 1788 generator.emitJumpScopes(scope->continueTarget(), scope->scopeDepth()); 1788 generator.emitPopScopes(scope->scopeDepth()); 1789 generator.emitJump(scope->continueTarget()); 1789 1790 return dst; 1790 1791 } … … 1800 1801 ASSERT(scope); 1801 1802 1802 generator.emitJumpScopes(scope->breakTarget(), scope->scopeDepth()); 1803 generator.emitPopScopes(scope->scopeDepth()); 1804 generator.emitJump(scope->breakTarget()); 1803 1805 return dst; 1804 1806 } … … 1813 1815 if (dst == generator.ignoredResult()) 1814 1816 dst = 0; 1815 RegisterID* r0 = m_value ? generator.emitNode(dst, m_value) : generator.emitLoad(dst, jsUndefined()); 1816 RefPtr<RegisterID> returnRegister ;1817 1818 RefPtr<RegisterID> returnRegister = m_value ? generator.emitNode(dst, m_value) : generator.emitLoad(dst, jsUndefined()); 1817 1819 if (generator.scopeDepth()) { 1818 RefPtr<Label> l0 = generator.newLabel(); 1819 if (generator.hasFinaliser()) { 1820 returnRegister = generator.emitMove(generator.newTemporary(), r0); 1821 r0 = returnRegister.get(); 1822 } 1823 generator.emitJumpScopes(l0.get(), 0); 1824 generator.emitLabel(l0.get()); 1825 } 1820 returnRegister = generator.emitMove(generator.newTemporary(), returnRegister.get()); 1821 generator.emitPopScopes(0); 1822 } 1823 1826 1824 generator.emitDebugHook(WillLeaveCallFrame, firstLine(), lastLine(), charPosition()); 1827 return generator.emitReturn(r 0);1825 return generator.emitReturn(returnRegister.get()); 1828 1826 } 1829 1827 -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r145000 r147184 294 294 DEFINE_OP(op_jfalse) 295 295 DEFINE_OP(op_jmp) 296 DEFINE_OP(op_jmp_scopes)297 296 DEFINE_OP(op_jneq_null) 298 297 DEFINE_OP(op_jneq_ptr) -
trunk/Source/JavaScriptCore/jit/JIT.h
r145000 r147184 679 679 void emit_op_jfalse(Instruction*); 680 680 void emit_op_jmp(Instruction*); 681 void emit_op_jmp_scopes(Instruction*);682 681 void emit_op_jneq_null(Instruction*); 683 682 void emit_op_jneq_ptr(Instruction*); -
trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp
r144137 r147184 718 718 store64(TrustedImm64(JSValue::encode(JSValue())), Address(regT3, OBJECT_OFFSETOF(JSGlobalData, exception))); 719 719 emitPutVirtualRegister(currentInstruction[1].u.operand); 720 }721 722 void JIT::emit_op_jmp_scopes(Instruction* currentInstruction)723 {724 JITStubCall stubCall(this, cti_op_jmp_scopes);725 stubCall.addArgument(TrustedImm32(currentInstruction[1].u.operand));726 stubCall.call();727 addJump(jump(), currentInstruction[2].u.operand);728 720 } 729 721 -
trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp
r142769 r147184 1033 1033 } 1034 1034 1035 void JIT::emit_op_jmp_scopes(Instruction* currentInstruction)1036 {1037 JITStubCall stubCall(this, cti_op_jmp_scopes);1038 stubCall.addArgument(TrustedImm32(currentInstruction[1].u.operand));1039 stubCall.call();1040 addJump(jump(), currentInstruction[2].u.operand);1041 }1042 1043 1035 void JIT::emit_op_switch_imm(Instruction* currentInstruction) 1044 1036 { -
trunk/Source/JavaScriptCore/jit/JITStubs.cpp
r146669 r147184 3307 3307 } 3308 3308 3309 DEFINE_STUB_FUNCTION(void, op_jmp_scopes)3310 {3311 STUB_INIT_STACK_FRAME(stackFrame);3312 3313 unsigned count = stackFrame.args[0].int32();3314 CallFrame* callFrame = stackFrame.callFrame;3315 3316 JSScope* tmp = callFrame->scope();3317 while (count--)3318 tmp = tmp->next();3319 callFrame->setScope(tmp);3320 }3321 3322 3309 DEFINE_STUB_FUNCTION(void, op_put_by_index) 3323 3310 { -
trunk/Source/JavaScriptCore/jit/JITStubs.h
r144043 r147184 411 411 void JIT_STUB cti_op_debug(STUB_ARGS_DECLARATION) WTF_INTERNAL; 412 412 void JIT_STUB cti_op_end(STUB_ARGS_DECLARATION) WTF_INTERNAL; 413 void JIT_STUB cti_op_jmp_scopes(STUB_ARGS_DECLARATION) WTF_INTERNAL;414 413 void JIT_STUB cti_op_pop_scope(STUB_ARGS_DECLARATION) WTF_INTERNAL; 415 414 void JIT_STUB cti_op_profile_did_call(STUB_ARGS_DECLARATION) WTF_INTERNAL; -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.cpp
r146552 r147184 1205 1205 } 1206 1206 1207 LLINT_SLOW_PATH_DECL(slow_path_jmp_scopes)1208 {1209 LLINT_BEGIN();1210 unsigned count = pc[1].u.operand;1211 JSScope* tmp = exec->scope();1212 while (count--)1213 tmp = tmp->next();1214 exec->setScope(tmp);1215 pc += pc[2].u.operand;1216 LLINT_END();1217 }1218 1219 1207 LLINT_SLOW_PATH_DECL(slow_path_jtrue) 1220 1208 { -
trunk/Source/JavaScriptCore/llint/LLIntSlowPaths.h
r133688 r147184 175 175 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_put_by_index); 176 176 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_put_getter_setter); 177 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_jmp_scopes);178 177 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_jtrue); 179 178 LLINT_SLOW_PATH_HIDDEN_DECL(slow_path_jfalse); -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm
r146459 r147184 974 974 975 975 976 _llint_op_jmp_scopes:977 traceExecution()978 callSlowPath(_llint_slow_path_jmp_scopes)979 dispatch(0)980 981 982 976 _llint_op_loop_if_true: 983 977 traceExecution()
Note:
See TracChangeset
for help on using the changeset viewer.