Changeset 209653 in webkit for trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
- Timestamp:
- Dec 9, 2016, 11:32:38 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r209638 r209653 197 197 m_proc.addFastConstant(m_tagMask->key()); 198 198 199 // Store out callee and argument count for possible OSR exit. 200 m_out.store64(m_out.argumentRegister(argumentRegisterForCallee()), addressFor(CallFrameSlot::callee)); 201 m_out.store32(m_out.argumentRegisterInt32(argumentRegisterForArgumentCount()), payloadFor(CallFrameSlot::argumentCount)); 202 199 203 m_out.storePtr(m_out.constIntPtr(codeBlock()), addressFor(CallFrameSlot::codeBlock)); 200 204 … … 248 252 availabilityMap().clear(); 249 253 availabilityMap().m_locals = Operands<Availability>(codeBlock()->numParameters(), 0); 254 255 Vector<Node*, 8> argumentNodes; 256 Vector<LValue, 8> argumentValues; 257 258 argumentNodes.resize(codeBlock()->numParameters()); 259 argumentValues.resize(codeBlock()->numParameters()); 260 261 m_highBlock = m_graph.block(0); 262 250 263 for (unsigned i = codeBlock()->numParameters(); i--;) { 251 availabilityMap().m_locals.argument(i) = 252 Availability(FlushedAt(FlushedJSValue, virtualRegisterForArgument(i))); 253 } 254 m_node = nullptr; 255 m_origin = NodeOrigin(CodeOrigin(0), CodeOrigin(0), true); 256 for (unsigned i = codeBlock()->numParameters(); i--;) { 257 Node* node = m_graph.m_arguments[i]; 264 Node* node = m_graph.m_argumentsForChecking[i]; 258 265 VirtualRegister operand = virtualRegisterForArgument(i); 259 266 260 LValue jsValue = m_out.load64(addressFor(operand));261 267 LValue jsValue = nullptr; 268 262 269 if (node) { 263 DFG_ASSERT(m_graph, node, operand == node->stackAccessData()->machineLocal); 270 if (i < NUMBER_OF_JS_FUNCTION_ARGUMENT_REGISTERS) { 271 availabilityMap().m_locals.argument(i) = Availability(node); 272 jsValue = m_out.argumentRegister(GPRInfo::toArgumentRegister(node->argumentRegisterIndex())); 273 274 setJSValue(node, jsValue); 275 } else { 276 availabilityMap().m_locals.argument(i) = 277 Availability(FlushedAt(FlushedJSValue, operand)); 278 jsValue = m_out.load64(addressFor(virtualRegisterForArgument(i))); 279 } 280 281 DFG_ASSERT(m_graph, node, node->hasArgumentRegisterIndex() || operand == node->stackAccessData()->machineLocal); 264 282 265 283 // This is a hack, but it's an effective one. It allows us to do CSE on the … … 269 287 m_loadedArgumentValues.add(node, jsValue); 270 288 } 271 289 290 argumentNodes[i] = node; 291 argumentValues[i] = jsValue; 292 } 293 294 m_node = nullptr; 295 m_origin = NodeOrigin(CodeOrigin(0), CodeOrigin(0), true); 296 for (unsigned i = codeBlock()->numParameters(); i--;) { 297 Node* node = argumentNodes[i]; 298 299 if (!node) 300 continue; 301 302 LValue jsValue = argumentValues[i]; 303 272 304 switch (m_graph.m_argumentFormats[i]) { 273 305 case FlushedInt32: … … 813 845 case GetArgumentCountIncludingThis: 814 846 compileGetArgumentCountIncludingThis(); 847 break; 848 case GetArgumentRegister: 849 compileGetArgumentRegister(); 815 850 break; 816 851 case GetScope: … … 5403 5438 } 5404 5439 5440 void compileGetArgumentRegister() 5441 { 5442 // We might have already have a value for this node. 5443 if (LValue value = m_loadedArgumentValues.get(m_node)) { 5444 setJSValue(value); 5445 return; 5446 } 5447 setJSValue(m_out.argumentRegister(GPRInfo::toArgumentRegister(m_node->argumentRegisterIndex()))); 5448 } 5449 5405 5450 void compileGetScope() 5406 5451 { … … 5815 5860 Vector<ConstrainedValue> arguments; 5816 5861 5817 // Make sure that the callee goes into GPR0 because that's where the slow path thunks expect the 5818 // callee to be. 5819 arguments.append(ConstrainedValue(jsCallee, ValueRep::reg(GPRInfo::regT0))); 5862 // Make sure that the callee goes into argumentRegisterForCallee() because that's where 5863 // the slow path thunks expect the callee to be. 5864 GPRReg calleeReg = argumentRegisterForCallee(); 5865 arguments.append(ConstrainedValue(jsCallee, ValueRep::reg(calleeReg))); 5820 5866 5821 5867 auto addArgument = [&] (LValue value, VirtualRegister reg, int offset) { … … 5825 5871 }; 5826 5872 5827 addArgument(jsCallee, VirtualRegister(CallFrameSlot::callee), 0); 5828 addArgument(m_out.constInt32(numArgs), VirtualRegister(CallFrameSlot::argumentCount), PayloadOffset); 5829 for (unsigned i = 0; i < numArgs; ++i) 5830 addArgument(lowJSValue(m_graph.varArgChild(node, 1 + i)), virtualRegisterForArgument(i), 0); 5873 ArgumentsLocation argLocation = argumentsLocationFor(numArgs); 5874 arguments.append(ConstrainedValue(jsCallee, ValueRep::reg(calleeReg))); 5875 arguments.append(ConstrainedValue(m_out.constInt32(numArgs), ValueRep::reg(argumentRegisterForArgumentCount()))); 5876 5877 for (unsigned i = 0; i < numArgs; ++i) { 5878 if (i < NUMBER_OF_JS_FUNCTION_ARGUMENT_REGISTERS) 5879 arguments.append(ConstrainedValue(lowJSValue(m_graph.varArgChild(node, 1 + i)), ValueRep::reg(argumentRegisterForFunctionArgument(i)))); 5880 else 5881 addArgument(lowJSValue(m_graph.varArgChild(node, 1 + i)), virtualRegisterForArgument(i), 0); 5882 } 5831 5883 5832 5884 PatchpointValue* patchpoint = m_out.patchpoint(Int64); … … 5857 5909 CallLinkInfo* callLinkInfo = jit.codeBlock()->addCallLinkInfo(); 5858 5910 5911 incrementCounter(&jit, VM::FTLCaller); 5912 5859 5913 CCallHelpers::DataLabelPtr targetToCheck; 5860 5914 CCallHelpers::Jump slowPath = jit.branchPtrWithPatch( 5861 CCallHelpers::NotEqual, GPRInfo::regT0, targetToCheck,5915 CCallHelpers::NotEqual, calleeReg, targetToCheck, 5862 5916 CCallHelpers::TrustedImmPtr(0)); 5863 5917 … … 5867 5921 slowPath.link(&jit); 5868 5922 5869 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo:: regT2);5923 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo::nonArgGPR0); 5870 5924 CCallHelpers::Call slowCall = jit.nearCall(); 5871 5925 done.link(&jit); … … 5873 5927 callLinkInfo->setUpCall( 5874 5928 node->op() == Construct ? CallLinkInfo::Construct : CallLinkInfo::Call, 5875 node->origin.semantic, GPRInfo::regT0);5929 argLocation, node->origin.semantic, argumentRegisterForCallee()); 5876 5930 5877 5931 jit.addPtr( … … 5882 5936 [=] (LinkBuffer& linkBuffer) { 5883 5937 MacroAssemblerCodePtr linkCall = 5884 linkBuffer.vm().get CTIStub(linkCallThunkGenerator).code();5938 linkBuffer.vm().getJITCallThunkEntryStub(linkCallThunkGenerator).entryFor(callLinkInfo->argumentsLocation()); 5885 5939 linkBuffer.link(slowCall, FunctionPtr(linkCall.executableAddress())); 5886 5940 … … 5926 5980 Vector<ConstrainedValue> arguments; 5927 5981 5928 arguments.append(ConstrainedValue(jsCallee, ValueRep::SomeRegister)); 5982 // Make sure that the callee goes into argumentRegisterForCallee() because that's where 5983 // the slow path thunks expect the callee to be. 5984 GPRReg calleeReg = argumentRegisterForCallee(); 5985 arguments.append(ConstrainedValue(jsCallee, ValueRep::reg(calleeReg))); 5929 5986 if (!isTail) { 5930 5987 auto addArgument = [&] (LValue value, VirtualRegister reg, int offset) { … … 5933 5990 arguments.append(ConstrainedValue(value, ValueRep::stackArgument(offsetFromSP))); 5934 5991 }; 5935 5992 5993 arguments.append(ConstrainedValue(jsCallee, ValueRep::reg(calleeReg))); 5994 #if ENABLE(CALLER_SPILLS_CALLEE) 5936 5995 addArgument(jsCallee, VirtualRegister(CallFrameSlot::callee), 0); 5996 #endif 5997 arguments.append(ConstrainedValue(m_out.constInt32(numPassedArgs), ValueRep::reg(argumentRegisterForArgumentCount()))); 5998 #if ENABLE(CALLER_SPILLS_ARGCOUNT) 5937 5999 addArgument(m_out.constInt32(numPassedArgs), VirtualRegister(CallFrameSlot::argumentCount), PayloadOffset); 5938 for (unsigned i = 0; i < numPassedArgs; ++i) 5939 addArgument(lowJSValue(m_graph.varArgChild(node, 1 + i)), virtualRegisterForArgument(i), 0); 5940 for (unsigned i = numPassedArgs; i < numAllocatedArgs; ++i) 5941 addArgument(m_out.constInt64(JSValue::encode(jsUndefined())), virtualRegisterForArgument(i), 0); 6000 #endif 6001 6002 for (unsigned i = 0; i < numPassedArgs; ++i) { 6003 if (i < NUMBER_OF_JS_FUNCTION_ARGUMENT_REGISTERS) 6004 arguments.append(ConstrainedValue(lowJSValue(m_graph.varArgChild(node, 1 + i)), ValueRep::reg(argumentRegisterForFunctionArgument(i)))); 6005 else 6006 addArgument(lowJSValue(m_graph.varArgChild(node, 1 + i)), virtualRegisterForArgument(i), 0); 6007 } 6008 for (unsigned i = numPassedArgs; i < numAllocatedArgs; ++i) { 6009 if (i < NUMBER_OF_JS_FUNCTION_ARGUMENT_REGISTERS) 6010 arguments.append(ConstrainedValue(m_out.constInt64(JSValue::encode(jsUndefined())), ValueRep::reg(argumentRegisterForFunctionArgument(i)))); 6011 else 6012 addArgument(m_out.constInt64(JSValue::encode(jsUndefined())), virtualRegisterForArgument(i), 0); 6013 } 5942 6014 } else { 5943 6015 for (unsigned i = 0; i < numPassedArgs; ++i) … … 5981 6053 5982 6054 RegisterSet toSave = params.unavailableRegisters(); 6055 shuffleData.argumentsInRegisters = true; 5983 6056 shuffleData.callee = ValueRecovery::inGPR(calleeGPR, DataFormatCell); 5984 6057 toSave.set(calleeGPR); … … 5999 6072 CCallHelpers::PatchableJump patchableJump = jit.patchableJump(); 6000 6073 CCallHelpers::Label mainPath = jit.label(); 6001 6074 6075 incrementCounter(&jit, VM::FTLCaller); 6076 incrementCounter(&jit, VM::TailCall); 6077 incrementCounter(&jit, VM::DirectCall); 6078 6002 6079 jit.store32( 6003 6080 CCallHelpers::TrustedImm32(callSiteIndex.bits()), … … 6020 6097 6021 6098 callLinkInfo->setUpCall( 6022 CallLinkInfo::DirectTailCall, node->origin.semantic, InvalidGPRReg);6099 CallLinkInfo::DirectTailCall, argumentsLocationFor(numPassedArgs), node->origin.semantic, InvalidGPRReg); 6023 6100 callLinkInfo->setExecutableDuringCompilation(executable); 6024 6101 if (numAllocatedArgs > numPassedArgs) … … 6043 6120 CCallHelpers::Label mainPath = jit.label(); 6044 6121 6122 incrementCounter(&jit, VM::FTLCaller); 6123 incrementCounter(&jit, VM::DirectCall); 6124 6045 6125 jit.store32( 6046 6126 CCallHelpers::TrustedImm32(callSiteIndex.bits()), … … 6054 6134 callLinkInfo->setUpCall( 6055 6135 isConstruct ? CallLinkInfo::DirectConstruct : CallLinkInfo::DirectCall, 6056 node->origin.semantic, InvalidGPRReg);6136 argumentsLocationFor(numPassedArgs), node->origin.semantic, InvalidGPRReg); 6057 6137 callLinkInfo->setExecutableDuringCompilation(executable); 6058 6138 if (numAllocatedArgs > numPassedArgs) … … 6065 6145 CCallHelpers::Label slowPath = jit.label(); 6066 6146 if (isX86()) 6067 jit.pop(CCallHelpers::selectScratchGPR(calleeGPR)); 6068 6069 callOperation( 6070 *state, params.unavailableRegisters(), jit, 6071 node->origin.semantic, exceptions.get(), operationLinkDirectCall, 6072 InvalidGPRReg, CCallHelpers::TrustedImmPtr(callLinkInfo), 6073 calleeGPR).call(); 6147 jit.pop(GPRInfo::nonArgGPR0); 6148 6149 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo::nonArgGPR0); // Link info needs to be in nonArgGPR0 6150 CCallHelpers::Call slowCall = jit.nearCall(); 6151 exceptions->append(jit.emitExceptionCheck(AssemblyHelpers::NormalExceptionCheck, AssemblyHelpers::FarJumpWidth)); 6074 6152 jit.jump().linkTo(mainPath, &jit); 6075 6153 … … 6080 6158 6081 6159 linkBuffer.link(call, slowPathLocation); 6160 MacroAssemblerCodePtr linkCall = 6161 linkBuffer.vm().getJITCallThunkEntryStub(linkDirectCallThunkGenerator).entryFor(callLinkInfo->argumentsLocation()); 6162 linkBuffer.link(slowCall, FunctionPtr(linkCall.executableAddress())); 6082 6163 6083 6164 callLinkInfo->setCallLocations( … … 6111 6192 Vector<ConstrainedValue> arguments; 6112 6193 6113 arguments.append(ConstrainedValue(jsCallee, ValueRep::reg(GPRInfo::regT0))); 6194 GPRReg calleeReg = argumentRegisterForCallee(); 6195 arguments.append(ConstrainedValue(jsCallee, ValueRep::reg(calleeReg))); 6114 6196 6115 6197 for (unsigned i = 0; i < numArgs; ++i) { … … 6145 6227 CallSiteIndex callSiteIndex = state->jitCode->common.addUniqueCallSiteIndex(codeOrigin); 6146 6228 6229 incrementCounter(&jit, VM::FTLCaller); 6230 incrementCounter(&jit, VM::TailCall); 6231 6147 6232 CallFrameShuffleData shuffleData; 6233 shuffleData.argumentsInRegisters = true; 6148 6234 shuffleData.numLocals = state->jitCode->common.frameRegisterCount; 6149 shuffleData.callee = ValueRecovery::inGPR( GPRInfo::regT0, DataFormatJS);6235 shuffleData.callee = ValueRecovery::inGPR(calleeReg, DataFormatJS); 6150 6236 6151 6237 for (unsigned i = 0; i < numArgs; ++i) … … 6158 6244 CCallHelpers::DataLabelPtr targetToCheck; 6159 6245 CCallHelpers::Jump slowPath = jit.branchPtrWithPatch( 6160 CCallHelpers::NotEqual, GPRInfo::regT0, targetToCheck,6246 CCallHelpers::NotEqual, calleeReg, targetToCheck, 6161 6247 CCallHelpers::TrustedImmPtr(0)); 6162 6248 … … 6176 6262 6177 6263 CallFrameShuffler slowPathShuffler(jit, shuffleData); 6178 slowPathShuffler.setCalleeJSValueRegs(JSValueRegs(GPRInfo::regT0));6179 6264 slowPathShuffler.prepareForSlowPath(); 6180 6265 6181 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo:: regT2);6266 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo::nonArgGPR0); 6182 6267 CCallHelpers::Call slowCall = jit.nearCall(); 6183 6268 6184 6269 jit.abortWithReason(JITDidReturnFromTailCall); 6185 6270 6186 callLinkInfo->setUpCall(CallLinkInfo::TailCall, codeOrigin, GPRInfo::regT0);6271 callLinkInfo->setUpCall(CallLinkInfo::TailCall, argumentsLocationFor(numArgs), codeOrigin, calleeReg); 6187 6272 6188 6273 jit.addLinkTask( 6189 6274 [=] (LinkBuffer& linkBuffer) { 6190 6275 MacroAssemblerCodePtr linkCall = 6191 linkBuffer.vm().get CTIStub(linkCallThunkGenerator).code();6276 linkBuffer.vm().getJITCallThunkEntryStub(linkCallThunkGenerator).entryFor(callLinkInfo->argumentsLocation()); 6192 6277 linkBuffer.link(slowCall, FunctionPtr(linkCall.executableAddress())); 6193 6278 … … 6279 6364 6280 6365 CallLinkInfo* callLinkInfo = jit.codeBlock()->addCallLinkInfo(); 6366 ArgumentsLocation argumentsLocation = StackArgs; 6281 6367 6282 6368 RegisterSet usedRegisters = RegisterSet::allRegisters(); … … 6428 6514 jit.emitRestoreCalleeSaves(); 6429 6515 ASSERT(!usedRegisters.get(GPRInfo::regT2)); 6430 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo:: regT2);6516 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo::nonArgGPR0); 6431 6517 CCallHelpers::Call slowCall = jit.nearCall(); 6432 6518 … … 6436 6522 done.link(&jit); 6437 6523 6438 callLinkInfo->setUpCall(callType, node->origin.semantic, GPRInfo::regT0);6524 callLinkInfo->setUpCall(callType, argumentsLocation, node->origin.semantic, GPRInfo::regT0); 6439 6525 6440 6526 jit.addPtr( … … 6445 6531 [=] (LinkBuffer& linkBuffer) { 6446 6532 MacroAssemblerCodePtr linkCall = 6447 linkBuffer.vm().get CTIStub(linkCallThunkGenerator).code();6533 linkBuffer.vm().getJITCallThunkEntryStub(linkCallThunkGenerator).entryFor(StackArgs); 6448 6534 linkBuffer.link(slowCall, FunctionPtr(linkCall.executableAddress())); 6449 6535 … … 6546 6632 exceptionHandle->scheduleExitCreationForUnwind(params, callSiteIndex); 6547 6633 6634 incrementCounter(&jit, VM::FTLCaller); 6635 incrementCounter(&jit, VM::CallVarargs); 6636 6548 6637 jit.store32( 6549 6638 CCallHelpers::TrustedImm32(callSiteIndex.bits()), … … 6551 6640 6552 6641 CallLinkInfo* callLinkInfo = jit.codeBlock()->addCallLinkInfo(); 6642 ArgumentsLocation argumentsLocation = StackArgs; 6553 6643 CallVarargsData* data = node->callVarargsData(); 6554 6644 … … 6711 6801 if (isTailCall) 6712 6802 jit.emitRestoreCalleeSaves(); 6713 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo:: regT2);6803 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo::nonArgGPR0); 6714 6804 CCallHelpers::Call slowCall = jit.nearCall(); 6715 6805 … … 6719 6809 done.link(&jit); 6720 6810 6721 callLinkInfo->setUpCall(callType, node->origin.semantic, GPRInfo::regT0);6811 callLinkInfo->setUpCall(callType, argumentsLocation, node->origin.semantic, GPRInfo::regT0); 6722 6812 6723 6813 jit.addPtr( … … 6728 6818 [=] (LinkBuffer& linkBuffer) { 6729 6819 MacroAssemblerCodePtr linkCall = 6730 linkBuffer.vm().get CTIStub(linkCallThunkGenerator).code();6820 linkBuffer.vm().getJITCallThunkEntryStub(linkCallThunkGenerator).entryFor(StackArgs); 6731 6821 linkBuffer.link(slowCall, FunctionPtr(linkCall.executableAddress())); 6732 6822 … … 6797 6887 6798 6888 exceptionHandle->scheduleExitCreationForUnwind(params, callSiteIndex); 6799 6889 6890 incrementCounter(&jit, VM::FTLCaller); 6891 incrementCounter(&jit, VM::CallEval); 6892 6800 6893 jit.store32( 6801 6894 CCallHelpers::TrustedImm32(callSiteIndex.bits()), … … 6803 6896 6804 6897 CallLinkInfo* callLinkInfo = jit.codeBlock()->addCallLinkInfo(); 6805 callLinkInfo->setUpCall(CallLinkInfo::Call, node->origin.semantic, GPRInfo::regT0);6898 callLinkInfo->setUpCall(CallLinkInfo::Call, StackArgs, node->origin.semantic, GPRInfo::regT0); 6806 6899 6807 6900 jit.addPtr(CCallHelpers::TrustedImm32(-static_cast<ptrdiff_t>(sizeof(CallerFrameAndPC))), CCallHelpers::stackPointerRegister, GPRInfo::regT1);
Note:
See TracChangeset
for help on using the changeset viewer.