Changeset 113136 in webkit
- Timestamp:
- Apr 3, 2012, 9:25:56 PM (14 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 13 edited
-
ChangeLog (modified) (1 diff)
-
bytecode/CodeBlock.cpp (modified) (1 diff)
-
bytecode/Opcode.h (modified) (1 diff)
-
bytecompiler/BytecodeGenerator.cpp (modified) (4 diffs)
-
bytecompiler/BytecodeGenerator.h (modified) (4 diffs)
-
bytecompiler/NodesCodegen.cpp (modified) (5 diffs)
-
interpreter/Interpreter.cpp (modified) (1 diff)
-
jit/JIT.cpp (modified) (3 diffs)
-
jit/JIT.h (modified) (4 diffs)
-
jit/JITOpcodes.cpp (modified) (1 diff)
-
jit/JITOpcodes32_64.cpp (modified) (1 diff)
-
llint/LowLevelInterpreter32_64.asm (modified) (1 diff)
-
llint/LowLevelInterpreter64.asm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r113126 r113136 1 2012-04-02 Filip Pizlo <fpizlo@apple.com> 2 3 jsr/sret should be removed 4 https://bugs.webkit.org/show_bug.cgi?id=82986 5 <rdar://problem/11017015> 6 7 Reviewed by Sam Weinig and Geoff Garen. 8 9 Replaces jsr/sret with finally block inlining. 10 11 * bytecode/CodeBlock.cpp: 12 (JSC::CodeBlock::dump): 13 * bytecode/Opcode.h: 14 (JSC): 15 (JSC::padOpcodeName): 16 * bytecompiler/BytecodeGenerator.cpp: 17 (JSC::BytecodeGenerator::pushFinallyContext): 18 (JSC::BytecodeGenerator::emitComplexJumpScopes): 19 (JSC): 20 * bytecompiler/BytecodeGenerator.h: 21 (FinallyContext): 22 (BytecodeGenerator): 23 * bytecompiler/NodesCodegen.cpp: 24 (JSC::TryNode::emitBytecode): 25 * interpreter/Interpreter.cpp: 26 (JSC::Interpreter::privateExecute): 27 * jit/JIT.cpp: 28 (JSC::JIT::privateCompileMainPass): 29 (JSC::JIT::privateCompile): 30 * jit/JIT.h: 31 (JIT): 32 * jit/JITOpcodes.cpp: 33 (JSC): 34 * jit/JITOpcodes32_64.cpp: 35 (JSC): 36 * llint/LowLevelInterpreter32_64.asm: 37 * llint/LowLevelInterpreter64.asm: 38 1 39 2012-04-03 Mark Rowe <mrowe@apple.com> 2 40 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r111264 r113136 1247 1247 int k0 = (++it)->u.operand; 1248 1248 dataLog("[%4d] throw_reference_error\t %s\n", location, constantName(exec, k0, getConstant(k0)).data()); 1249 break;1250 }1251 case op_jsr: {1252 int retAddrDst = (++it)->u.operand;1253 int offset = (++it)->u.operand;1254 dataLog("[%4d] jsr\t\t %s, %d(->%d)\n", location, registerName(exec, retAddrDst).data(), offset, location + offset);1255 break;1256 }1257 case op_sret: {1258 int retAddrSrc = (++it)->u.operand;1259 dataLog("[%4d] sret\t\t %s\n", location, registerName(exec, retAddrSrc).data());1260 1249 break; 1261 1250 } -
trunk/Source/JavaScriptCore/bytecode/Opcode.h
r109007 r113136 190 190 macro(op_throw_reference_error, 2) \ 191 191 \ 192 macro(op_jsr, 3) \193 macro(op_sret, 2) \194 \195 192 macro(op_debug, 4) \ 196 193 macro(op_profile_will_call, 2) \ -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r112555 r113136 1 1 /* 2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2009, 2012 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca> 4 4 * Copyright (C) 2012 Igalia, S.L. … … 2005 2005 } 2006 2006 2007 void BytecodeGenerator::pushFinallyContext( Label* target, RegisterID* retAddrDst)2007 void BytecodeGenerator::pushFinallyContext(StatementNode* finallyBlock) 2008 2008 { 2009 2009 ControlFlowContext scope; 2010 2010 scope.isFinallyBlock = true; 2011 FinallyContext context = { target, retAddrDst }; 2011 FinallyContext context = { 2012 finallyBlock, 2013 m_scopeContextStack.size(), 2014 m_switchContextStack.size(), 2015 m_forInContextStack.size(), 2016 m_labelScopes.size(), 2017 m_finallyDepth, 2018 m_dynamicScopeDepth 2019 }; 2012 2020 scope.finallyContext = context; 2013 2021 m_scopeContextStack.append(scope); … … 2135 2143 emitLabel(nextInsn.get()); 2136 2144 } 2137 2145 2146 Vector<ControlFlowContext> savedScopeContextStack; 2147 Vector<SwitchInfo> savedSwitchContextStack; 2148 Vector<ForInContext> savedForInContextStack; 2149 SegmentedVector<LabelScope, 8> savedLabelScopes; 2138 2150 while (topScope > bottomScope && topScope->isFinallyBlock) { 2139 emitJumpSubroutine(topScope->finallyContext.retAddrDst, topScope->finallyContext.finallyAddr); 2151 // Save the current state of the world while instating the state of the world 2152 // for the finally block. 2153 FinallyContext finallyContext = topScope->finallyContext; 2154 bool flipScopes = finallyContext.scopeContextStackSize != m_scopeContextStack.size(); 2155 bool flipSwitches = finallyContext.switchContextStackSize != m_switchContextStack.size(); 2156 bool flipForIns = finallyContext.forInContextStackSize != m_forInContextStack.size(); 2157 bool flipLabelScopes = finallyContext.labelScopesSize != m_labelScopes.size(); 2158 int topScopeIndex = -1; 2159 int bottomScopeIndex = -1; 2160 if (flipScopes) { 2161 topScopeIndex = topScope - m_scopeContextStack.begin(); 2162 bottomScopeIndex = bottomScope - m_scopeContextStack.begin(); 2163 savedScopeContextStack = m_scopeContextStack; 2164 m_scopeContextStack.shrink(finallyContext.scopeContextStackSize); 2165 } 2166 if (flipSwitches) { 2167 savedSwitchContextStack = m_switchContextStack; 2168 m_switchContextStack.shrink(finallyContext.switchContextStackSize); 2169 } 2170 if (flipForIns) { 2171 savedForInContextStack = m_forInContextStack; 2172 m_forInContextStack.shrink(finallyContext.forInContextStackSize); 2173 } 2174 if (flipLabelScopes) { 2175 savedLabelScopes = m_labelScopes; 2176 while (m_labelScopes.size() > finallyContext.labelScopesSize) 2177 m_labelScopes.removeLast(); 2178 } 2179 int savedFinallyDepth = m_finallyDepth; 2180 m_finallyDepth = finallyContext.finallyDepth; 2181 int savedDynamicScopeDepth = m_dynamicScopeDepth; 2182 m_dynamicScopeDepth = finallyContext.dynamicScopeDepth; 2183 2184 // Emit the finally block. 2185 emitNode(finallyContext.finallyBlock); 2186 2187 // Restore the state of the world. 2188 if (flipScopes) { 2189 m_scopeContextStack = savedScopeContextStack; 2190 topScope = &m_scopeContextStack[topScopeIndex]; // assert it's within bounds 2191 bottomScope = m_scopeContextStack.begin() + bottomScopeIndex; // don't assert, since it the index might be -1. 2192 } 2193 if (flipSwitches) 2194 m_switchContextStack = savedSwitchContextStack; 2195 if (flipForIns) 2196 m_forInContextStack = savedForInContextStack; 2197 if (flipLabelScopes) 2198 m_labelScopes = savedLabelScopes; 2199 m_finallyDepth = savedFinallyDepth; 2200 m_dynamicScopeDepth = savedDynamicScopeDepth; 2201 2140 2202 --topScope; 2141 2203 } … … 2215 2277 emitOpcode(op_throw_reference_error); 2216 2278 instructions().append(addConstantValue(jsString(globalData(), message))->index()); 2217 }2218 2219 PassRefPtr<Label> BytecodeGenerator::emitJumpSubroutine(RegisterID* retAddrDst, Label* finally)2220 {2221 size_t begin = instructions().size();2222 2223 emitOpcode(op_jsr);2224 instructions().append(retAddrDst->index());2225 instructions().append(finally->bind(begin, instructions().size()));2226 emitLabel(newLabel().get()); // Record the fact that the next instruction is implicitly labeled, because op_sret will return to it.2227 return finally;2228 }2229 2230 void BytecodeGenerator::emitSubroutineReturn(RegisterID* retAddrSrc)2231 {2232 emitOpcode(op_sret);2233 instructions().append(retAddrSrc->index());2234 2279 } 2235 2280 -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r110033 r113136 1 1 /* 2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2009, 2012 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca> 4 4 * Copyright (C) 2012 Igalia, S.L. … … 72 72 73 73 struct FinallyContext { 74 Label* finallyAddr; 75 RegisterID* retAddrDst; 74 StatementNode* finallyBlock; 75 unsigned scopeContextStackSize; 76 unsigned switchContextStackSize; 77 unsigned forInContextStackSize; 78 unsigned labelScopesSize; 79 int finallyDepth; 80 int dynamicScopeDepth; 76 81 }; 77 82 … … 480 485 PassRefPtr<Label> emitJumpScopes(Label* target, int targetScopeDepth); 481 486 482 PassRefPtr<Label> emitJumpSubroutine(RegisterID* retAddrDst, Label*);483 void emitSubroutineReturn(RegisterID* retAddrSrc);484 485 487 RegisterID* emitGetPropertyNames(RegisterID* dst, RegisterID* base, RegisterID* i, RegisterID* size, Label* breakTarget); 486 488 RegisterID* emitNextPropertyName(RegisterID* dst, RegisterID* base, RegisterID* i, RegisterID* size, RegisterID* iter, Label* target); … … 505 507 bool hasFinaliser() { return m_finallyDepth != 0; } 506 508 507 void pushFinallyContext( Label* target, RegisterID* returnAddrDst);509 void pushFinallyContext(StatementNode* finallyBlock); 508 510 void popFinallyContext(); 509 511 -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r112555 r113136 2 2 * Copyright (C) 1999-2002 Harri Porten (porten@kde.org) 3 3 * Copyright (C) 2001 Peter Kelly (pmk@post.com) 4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.4 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2012 Apple Inc. All rights reserved. 5 5 * Copyright (C) 2007 Cameron Zwarich (cwzwarich@uwaterloo.ca) 6 6 * Copyright (C) 2007 Maks Orlovich … … 1728 1728 if (generator.scopeDepth()) { 1729 1729 RefPtr<Label> l0 = generator.newLabel(); 1730 if (generator.hasFinaliser() && !r0->isTemporary()) {1730 if (generator.hasFinaliser()) { 1731 1731 returnRegister = generator.emitMove(generator.newTemporary(), r0); 1732 1732 r0 = returnRegister.get(); … … 1958 1958 1959 1959 RefPtr<Label> tryStartLabel = generator.newLabel(); 1960 RefPtr<Label> finallyStart; 1961 RefPtr<RegisterID> finallyReturnAddr; 1962 if (m_finallyBlock) { 1963 finallyStart = generator.newLabel(); 1964 finallyReturnAddr = generator.newTemporary(); 1965 generator.pushFinallyContext(finallyStart.get(), finallyReturnAddr.get()); 1966 } 1960 if (m_finallyBlock) 1961 generator.pushFinallyContext(m_finallyBlock); 1967 1962 1968 1963 generator.emitLabel(tryStartLabel.get()); … … 1986 1981 if (m_finallyBlock) { 1987 1982 generator.popFinallyContext(); 1988 // there may be important registers live at the time we jump 1989 // to a finally block (such as for a return or throw) so we 1990 // ref the highest register ever used as a conservative 1991 // approach to not clobbering anything important 1992 RefPtr<RegisterID> highestUsedRegister = generator.highestUsedRegister(); 1983 1993 1984 RefPtr<Label> finallyEndLabel = generator.newLabel(); 1994 1985 1995 // Normal path: invoke the finally block, then jump over it.1996 generator.emit JumpSubroutine(finallyReturnAddr.get(), finallyStart.get());1986 // Normal path: run the finally code, and jump to the end. 1987 generator.emitNode(dst, m_finallyBlock); 1997 1988 generator.emitJump(finallyEndLabel.get()); 1998 1989 … … 2000 1991 RefPtr<Label> here = generator.emitLabel(generator.newLabel().get()); 2001 1992 RefPtr<RegisterID> tempExceptionRegister = generator.emitCatch(generator.newTemporary(), tryStartLabel.get(), here.get()); 2002 generator.emit JumpSubroutine(finallyReturnAddr.get(), finallyStart.get());1993 generator.emitNode(dst, m_finallyBlock); 2003 1994 generator.emitThrow(tempExceptionRegister.get()); 2004 2005 // The finally block.2006 generator.emitLabel(finallyStart.get());2007 generator.emitNode(dst, m_finallyBlock);2008 generator.emitSubroutineReturn(finallyReturnAddr.get());2009 1995 2010 1996 generator.emitLabel(finallyEndLabel.get()); -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r111739 r113136 5187 5187 NEXT_INSTRUCTION(); 5188 5188 } 5189 DEFINE_OPCODE(op_jsr) {5190 /* jsr retAddrDst(r) target(offset)5191 5192 Places the address of the next instruction into the retAddrDst5193 register and jumps to offset target from the current instruction.5194 */5195 int retAddrDst = vPC[1].u.operand;5196 int target = vPC[2].u.operand;5197 callFrame->r(retAddrDst) = vPC + OPCODE_LENGTH(op_jsr);5198 5199 vPC += target;5200 NEXT_INSTRUCTION();5201 }5202 DEFINE_OPCODE(op_sret) {5203 /* sret retAddrSrc(r)5204 5205 Jumps to the address stored in the retAddrSrc register. This5206 differs from op_jmp because the target address is stored in a5207 register, not as an immediate.5208 */5209 int retAddrSrc = vPC[1].u.operand;5210 vPC = callFrame->r(retAddrSrc).vPC();5211 NEXT_INSTRUCTION();5212 }5213 5189 DEFINE_OPCODE(op_debug) { 5214 5190 /* debug debugHookID(n) firstLine(n) lastLine(n) -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r110122 r113136 284 284 DEFINE_OP(op_jngreater) 285 285 DEFINE_OP(op_jngreatereq) 286 DEFINE_OP(op_jsr)287 286 DEFINE_OP(op_jtrue) 288 287 DEFINE_OP(op_loop) … … 341 340 DEFINE_OP(op_rshift) 342 341 DEFINE_OP(op_urshift) 343 DEFINE_OP(op_sret)344 342 DEFINE_OP(op_strcat) 345 343 DEFINE_OP(op_stricteq) … … 666 664 } 667 665 668 // Link absolute addresses for jsr669 for (Vector<JSRInfo>::iterator iter = m_jsrSites.begin(); iter != m_jsrSites.end(); ++iter)670 patchBuffer.patch(iter->storeLocation, patchBuffer.locationOf(iter->target).executableAddress());671 672 666 m_codeBlock->setNumberOfStructureStubInfos(m_propertyAccessCompilationInfo.size()); 673 667 for (unsigned i = 0; i < m_propertyAccessCompilationInfo.size(); ++i) { -
trunk/Source/JavaScriptCore/jit/JIT.h
r112192 r113136 281 281 282 282 private: 283 struct JSRInfo {284 DataLabelPtr storeLocation;285 Label target;286 287 JSRInfo(DataLabelPtr storeLocation, Label targetLocation)288 : storeLocation(storeLocation)289 , target(targetLocation)290 {291 }292 };293 294 283 JIT(JSGlobalData*, CodeBlock* = 0); 295 284 … … 830 819 void emit_op_jngreater(Instruction*); 831 820 void emit_op_jngreatereq(Instruction*); 832 void emit_op_jsr(Instruction*);833 821 void emit_op_jtrue(Instruction*); 834 822 void emit_op_loop(Instruction*); … … 884 872 void emit_op_ret_object_or_this(Instruction*); 885 873 void emit_op_rshift(Instruction*); 886 void emit_op_sret(Instruction*);887 874 void emit_op_strcat(Instruction*); 888 875 void emit_op_stricteq(Instruction*); … … 1067 1054 1068 1055 unsigned m_bytecodeOffset; 1069 Vector<JSRInfo> m_jsrSites;1070 1056 Vector<SlowCaseEntry> m_slowCases; 1071 1057 Vector<SwitchRecord> m_switches; -
trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp
r110122 r113136 743 743 } 744 744 745 void JIT::emit_op_jsr(Instruction* currentInstruction)746 {747 int retAddrDst = currentInstruction[1].u.operand;748 int target = currentInstruction[2].u.operand;749 DataLabelPtr storeLocation = storePtrWithPatch(TrustedImmPtr(0), Address(callFrameRegister, sizeof(Register) * retAddrDst));750 addJump(jump(), target);751 m_jsrSites.append(JSRInfo(storeLocation, label()));752 killLastResultRegister();753 }754 755 void JIT::emit_op_sret(Instruction* currentInstruction)756 {757 jump(Address(callFrameRegister, sizeof(Register) * currentInstruction[1].u.operand));758 killLastResultRegister();759 }760 761 745 void JIT::emit_op_eq(Instruction* currentInstruction) 762 746 { -
trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp
r111481 r113136 922 922 } 923 923 924 void JIT::emit_op_jsr(Instruction* currentInstruction)925 {926 int retAddrDst = currentInstruction[1].u.operand;927 int target = currentInstruction[2].u.operand;928 DataLabelPtr storeLocation = storePtrWithPatch(TrustedImmPtr(0), Address(callFrameRegister, sizeof(Register) * retAddrDst));929 addJump(jump(), target);930 m_jsrSites.append(JSRInfo(storeLocation, label()));931 }932 933 void JIT::emit_op_sret(Instruction* currentInstruction)934 {935 jump(Address(callFrameRegister, sizeof(Register) * currentInstruction[1].u.operand));936 }937 938 924 void JIT::emit_op_eq(Instruction* currentInstruction) 939 925 { -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter32_64.asm
r110383 r113136 1572 1572 1573 1573 1574 _llint_op_jsr:1575 traceExecution()1576 loadi 4[PC], t01577 addi 3 * 4, PC, t11578 storei t1, [cfr, t0, 8]1579 dispatchBranch(8[PC])1580 1581 1582 _llint_op_sret:1583 traceExecution()1584 loadi 4[PC], t01585 loadp [cfr, t0, 8], PC1586 dispatch(0)1587 1588 1589 1574 _llint_op_end: 1590 1575 traceExecution() -
trunk/Source/JavaScriptCore/llint/LowLevelInterpreter64.asm
r111481 r113136 1430 1430 1431 1431 1432 _llint_op_jsr:1433 traceExecution()1434 loadis 8[PB, PC, 8], t01435 addi 3, PC, t11436 storei t1, [cfr, t0, 8]1437 dispatchInt(16[PB, PC, 8])1438 1439 1440 _llint_op_sret:1441 traceExecution()1442 loadis 8[PB, PC, 8], t01443 loadi [cfr, t0, 8], PC1444 dispatch(0)1445 1446 1447 1432 _llint_op_end: 1448 1433 traceExecution()
Note:
See TracChangeset
for help on using the changeset viewer.