Changeset 209678 in webkit for trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
- Timestamp:
- Dec 10, 2016, 5:14:37 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r209653 r209678 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 203 199 m_out.storePtr(m_out.constIntPtr(codeBlock()), addressFor(CallFrameSlot::codeBlock)); 204 200 … … 252 248 availabilityMap().clear(); 253 249 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 263 250 for (unsigned i = codeBlock()->numParameters(); i--;) { 264 Node* node = m_graph.m_argumentsForChecking[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]; 265 258 VirtualRegister operand = virtualRegisterForArgument(i); 266 259 267 LValue jsValue = nullptr;268 260 LValue jsValue = m_out.load64(addressFor(operand)); 261 269 262 if (node) { 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); 263 DFG_ASSERT(m_graph, node, operand == node->stackAccessData()->machineLocal); 282 264 283 265 // This is a hack, but it's an effective one. It allows us to do CSE on the … … 287 269 m_loadedArgumentValues.add(node, jsValue); 288 270 } 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 271 304 272 switch (m_graph.m_argumentFormats[i]) { 305 273 case FlushedInt32: … … 845 813 case GetArgumentCountIncludingThis: 846 814 compileGetArgumentCountIncludingThis(); 847 break;848 case GetArgumentRegister:849 compileGetArgumentRegister();850 815 break; 851 816 case GetScope: … … 5438 5403 } 5439 5404 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 5450 5405 void compileGetScope() 5451 5406 { … … 5860 5815 Vector<ConstrainedValue> arguments; 5861 5816 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))); 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))); 5866 5820 5867 5821 auto addArgument = [&] (LValue value, VirtualRegister reg, int offset) { … … 5871 5825 }; 5872 5826 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 } 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); 5883 5831 5884 5832 PatchpointValue* patchpoint = m_out.patchpoint(Int64); … … 5909 5857 CallLinkInfo* callLinkInfo = jit.codeBlock()->addCallLinkInfo(); 5910 5858 5911 incrementCounter(&jit, VM::FTLCaller);5912 5913 5859 CCallHelpers::DataLabelPtr targetToCheck; 5914 5860 CCallHelpers::Jump slowPath = jit.branchPtrWithPatch( 5915 CCallHelpers::NotEqual, calleeReg, targetToCheck,5861 CCallHelpers::NotEqual, GPRInfo::regT0, targetToCheck, 5916 5862 CCallHelpers::TrustedImmPtr(0)); 5917 5863 … … 5921 5867 slowPath.link(&jit); 5922 5868 5923 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo:: nonArgGPR0);5869 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo::regT2); 5924 5870 CCallHelpers::Call slowCall = jit.nearCall(); 5925 5871 done.link(&jit); … … 5927 5873 callLinkInfo->setUpCall( 5928 5874 node->op() == Construct ? CallLinkInfo::Construct : CallLinkInfo::Call, 5929 argLocation, node->origin.semantic, argumentRegisterForCallee());5875 node->origin.semantic, GPRInfo::regT0); 5930 5876 5931 5877 jit.addPtr( … … 5936 5882 [=] (LinkBuffer& linkBuffer) { 5937 5883 MacroAssemblerCodePtr linkCall = 5938 linkBuffer.vm().get JITCallThunkEntryStub(linkCallThunkGenerator).entryFor(callLinkInfo->argumentsLocation());5884 linkBuffer.vm().getCTIStub(linkCallThunkGenerator).code(); 5939 5885 linkBuffer.link(slowCall, FunctionPtr(linkCall.executableAddress())); 5940 5886 … … 5980 5926 Vector<ConstrainedValue> arguments; 5981 5927 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))); 5928 arguments.append(ConstrainedValue(jsCallee, ValueRep::SomeRegister)); 5986 5929 if (!isTail) { 5987 5930 auto addArgument = [&] (LValue value, VirtualRegister reg, int offset) { … … 5990 5933 arguments.append(ConstrainedValue(value, ValueRep::stackArgument(offsetFromSP))); 5991 5934 }; 5992 5993 arguments.append(ConstrainedValue(jsCallee, ValueRep::reg(calleeReg))); 5994 #if ENABLE(CALLER_SPILLS_CALLEE) 5935 5995 5936 addArgument(jsCallee, VirtualRegister(CallFrameSlot::callee), 0); 5996 #endif5997 arguments.append(ConstrainedValue(m_out.constInt32(numPassedArgs), ValueRep::reg(argumentRegisterForArgumentCount())));5998 #if ENABLE(CALLER_SPILLS_ARGCOUNT)5999 5937 addArgument(m_out.constInt32(numPassedArgs), VirtualRegister(CallFrameSlot::argumentCount), PayloadOffset); 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 } 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); 6014 5942 } else { 6015 5943 for (unsigned i = 0; i < numPassedArgs; ++i) … … 6053 5981 6054 5982 RegisterSet toSave = params.unavailableRegisters(); 6055 shuffleData.argumentsInRegisters = true;6056 5983 shuffleData.callee = ValueRecovery::inGPR(calleeGPR, DataFormatCell); 6057 5984 toSave.set(calleeGPR); … … 6072 5999 CCallHelpers::PatchableJump patchableJump = jit.patchableJump(); 6073 6000 CCallHelpers::Label mainPath = jit.label(); 6074 6075 incrementCounter(&jit, VM::FTLCaller); 6076 incrementCounter(&jit, VM::TailCall); 6077 incrementCounter(&jit, VM::DirectCall); 6078 6001 6079 6002 jit.store32( 6080 6003 CCallHelpers::TrustedImm32(callSiteIndex.bits()), … … 6097 6020 6098 6021 callLinkInfo->setUpCall( 6099 CallLinkInfo::DirectTailCall, argumentsLocationFor(numPassedArgs),node->origin.semantic, InvalidGPRReg);6022 CallLinkInfo::DirectTailCall, node->origin.semantic, InvalidGPRReg); 6100 6023 callLinkInfo->setExecutableDuringCompilation(executable); 6101 6024 if (numAllocatedArgs > numPassedArgs) … … 6120 6043 CCallHelpers::Label mainPath = jit.label(); 6121 6044 6122 incrementCounter(&jit, VM::FTLCaller);6123 incrementCounter(&jit, VM::DirectCall);6124 6125 6045 jit.store32( 6126 6046 CCallHelpers::TrustedImm32(callSiteIndex.bits()), … … 6134 6054 callLinkInfo->setUpCall( 6135 6055 isConstruct ? CallLinkInfo::DirectConstruct : CallLinkInfo::DirectCall, 6136 argumentsLocationFor(numPassedArgs),node->origin.semantic, InvalidGPRReg);6056 node->origin.semantic, InvalidGPRReg); 6137 6057 callLinkInfo->setExecutableDuringCompilation(executable); 6138 6058 if (numAllocatedArgs > numPassedArgs) … … 6145 6065 CCallHelpers::Label slowPath = jit.label(); 6146 6066 if (isX86()) 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)); 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(); 6152 6074 jit.jump().linkTo(mainPath, &jit); 6153 6075 … … 6158 6080 6159 6081 linkBuffer.link(call, slowPathLocation); 6160 MacroAssemblerCodePtr linkCall =6161 linkBuffer.vm().getJITCallThunkEntryStub(linkDirectCallThunkGenerator).entryFor(callLinkInfo->argumentsLocation());6162 linkBuffer.link(slowCall, FunctionPtr(linkCall.executableAddress()));6163 6082 6164 6083 callLinkInfo->setCallLocations( … … 6192 6111 Vector<ConstrainedValue> arguments; 6193 6112 6194 GPRReg calleeReg = argumentRegisterForCallee(); 6195 arguments.append(ConstrainedValue(jsCallee, ValueRep::reg(calleeReg))); 6113 arguments.append(ConstrainedValue(jsCallee, ValueRep::reg(GPRInfo::regT0))); 6196 6114 6197 6115 for (unsigned i = 0; i < numArgs; ++i) { … … 6227 6145 CallSiteIndex callSiteIndex = state->jitCode->common.addUniqueCallSiteIndex(codeOrigin); 6228 6146 6229 incrementCounter(&jit, VM::FTLCaller);6230 incrementCounter(&jit, VM::TailCall);6231 6232 6147 CallFrameShuffleData shuffleData; 6233 shuffleData.argumentsInRegisters = true;6234 6148 shuffleData.numLocals = state->jitCode->common.frameRegisterCount; 6235 shuffleData.callee = ValueRecovery::inGPR( calleeReg, DataFormatJS);6149 shuffleData.callee = ValueRecovery::inGPR(GPRInfo::regT0, DataFormatJS); 6236 6150 6237 6151 for (unsigned i = 0; i < numArgs; ++i) … … 6244 6158 CCallHelpers::DataLabelPtr targetToCheck; 6245 6159 CCallHelpers::Jump slowPath = jit.branchPtrWithPatch( 6246 CCallHelpers::NotEqual, calleeReg, targetToCheck,6160 CCallHelpers::NotEqual, GPRInfo::regT0, targetToCheck, 6247 6161 CCallHelpers::TrustedImmPtr(0)); 6248 6162 … … 6262 6176 6263 6177 CallFrameShuffler slowPathShuffler(jit, shuffleData); 6178 slowPathShuffler.setCalleeJSValueRegs(JSValueRegs(GPRInfo::regT0)); 6264 6179 slowPathShuffler.prepareForSlowPath(); 6265 6180 6266 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo:: nonArgGPR0);6181 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo::regT2); 6267 6182 CCallHelpers::Call slowCall = jit.nearCall(); 6268 6183 6269 6184 jit.abortWithReason(JITDidReturnFromTailCall); 6270 6185 6271 callLinkInfo->setUpCall(CallLinkInfo::TailCall, argumentsLocationFor(numArgs), codeOrigin, calleeReg);6186 callLinkInfo->setUpCall(CallLinkInfo::TailCall, codeOrigin, GPRInfo::regT0); 6272 6187 6273 6188 jit.addLinkTask( 6274 6189 [=] (LinkBuffer& linkBuffer) { 6275 6190 MacroAssemblerCodePtr linkCall = 6276 linkBuffer.vm().get JITCallThunkEntryStub(linkCallThunkGenerator).entryFor(callLinkInfo->argumentsLocation());6191 linkBuffer.vm().getCTIStub(linkCallThunkGenerator).code(); 6277 6192 linkBuffer.link(slowCall, FunctionPtr(linkCall.executableAddress())); 6278 6193 … … 6364 6279 6365 6280 CallLinkInfo* callLinkInfo = jit.codeBlock()->addCallLinkInfo(); 6366 ArgumentsLocation argumentsLocation = StackArgs;6367 6281 6368 6282 RegisterSet usedRegisters = RegisterSet::allRegisters(); … … 6514 6428 jit.emitRestoreCalleeSaves(); 6515 6429 ASSERT(!usedRegisters.get(GPRInfo::regT2)); 6516 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo:: nonArgGPR0);6430 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo::regT2); 6517 6431 CCallHelpers::Call slowCall = jit.nearCall(); 6518 6432 … … 6522 6436 done.link(&jit); 6523 6437 6524 callLinkInfo->setUpCall(callType, argumentsLocation,node->origin.semantic, GPRInfo::regT0);6438 callLinkInfo->setUpCall(callType, node->origin.semantic, GPRInfo::regT0); 6525 6439 6526 6440 jit.addPtr( … … 6531 6445 [=] (LinkBuffer& linkBuffer) { 6532 6446 MacroAssemblerCodePtr linkCall = 6533 linkBuffer.vm().get JITCallThunkEntryStub(linkCallThunkGenerator).entryFor(StackArgs);6447 linkBuffer.vm().getCTIStub(linkCallThunkGenerator).code(); 6534 6448 linkBuffer.link(slowCall, FunctionPtr(linkCall.executableAddress())); 6535 6449 … … 6632 6546 exceptionHandle->scheduleExitCreationForUnwind(params, callSiteIndex); 6633 6547 6634 incrementCounter(&jit, VM::FTLCaller);6635 incrementCounter(&jit, VM::CallVarargs);6636 6637 6548 jit.store32( 6638 6549 CCallHelpers::TrustedImm32(callSiteIndex.bits()), … … 6640 6551 6641 6552 CallLinkInfo* callLinkInfo = jit.codeBlock()->addCallLinkInfo(); 6642 ArgumentsLocation argumentsLocation = StackArgs;6643 6553 CallVarargsData* data = node->callVarargsData(); 6644 6554 … … 6801 6711 if (isTailCall) 6802 6712 jit.emitRestoreCalleeSaves(); 6803 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo:: nonArgGPR0);6713 jit.move(CCallHelpers::TrustedImmPtr(callLinkInfo), GPRInfo::regT2); 6804 6714 CCallHelpers::Call slowCall = jit.nearCall(); 6805 6715 … … 6809 6719 done.link(&jit); 6810 6720 6811 callLinkInfo->setUpCall(callType, argumentsLocation,node->origin.semantic, GPRInfo::regT0);6721 callLinkInfo->setUpCall(callType, node->origin.semantic, GPRInfo::regT0); 6812 6722 6813 6723 jit.addPtr( … … 6818 6728 [=] (LinkBuffer& linkBuffer) { 6819 6729 MacroAssemblerCodePtr linkCall = 6820 linkBuffer.vm().get JITCallThunkEntryStub(linkCallThunkGenerator).entryFor(StackArgs);6730 linkBuffer.vm().getCTIStub(linkCallThunkGenerator).code(); 6821 6731 linkBuffer.link(slowCall, FunctionPtr(linkCall.executableAddress())); 6822 6732 … … 6887 6797 6888 6798 exceptionHandle->scheduleExitCreationForUnwind(params, callSiteIndex); 6889 6890 incrementCounter(&jit, VM::FTLCaller); 6891 incrementCounter(&jit, VM::CallEval); 6892 6799 6893 6800 jit.store32( 6894 6801 CCallHelpers::TrustedImm32(callSiteIndex.bits()), … … 6896 6803 6897 6804 CallLinkInfo* callLinkInfo = jit.codeBlock()->addCallLinkInfo(); 6898 callLinkInfo->setUpCall(CallLinkInfo::Call, StackArgs,node->origin.semantic, GPRInfo::regT0);6805 callLinkInfo->setUpCall(CallLinkInfo::Call, node->origin.semantic, GPRInfo::regT0); 6899 6806 6900 6807 jit.addPtr(CCallHelpers::TrustedImm32(-static_cast<ptrdiff_t>(sizeof(CallerFrameAndPC))), CCallHelpers::stackPointerRegister, GPRInfo::regT1);
Note:
See TracChangeset
for help on using the changeset viewer.