Changeset 209678 in webkit for trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
- Timestamp:
- Dec 10, 2016, 5:14:37 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
r209653 r209678 81 81 } 82 82 83 GPRReg SpeculativeJIT::fillJSValue(Edge edge , GPRReg gprToUse)83 GPRReg SpeculativeJIT::fillJSValue(Edge edge) 84 84 { 85 85 VirtualRegister virtualRegister = edge->virtualRegister(); … … 88 88 switch (info.registerFormat()) { 89 89 case DataFormatNone: { 90 GPRReg gpr = allocate( gprToUse);90 GPRReg gpr = allocate(); 91 91 92 92 if (edge->hasConstant()) { … … 121 121 // If not, we'll zero extend in place, so mark on the info that this is now type DataFormatInt32, not DataFormatJSInt32. 122 122 if (m_gprs.isLocked(gpr)) { 123 GPRReg result = allocate(gprToUse); 124 m_jit.or64(GPRInfo::tagTypeNumberRegister, gpr, result); 125 return result; 126 } 127 if (gprToUse != InvalidGPRReg && gpr != gprToUse) { 128 GPRReg result = allocate(gprToUse); 123 GPRReg result = allocate(); 129 124 m_jit.or64(GPRInfo::tagTypeNumberRegister, gpr, result); 130 125 return result; … … 144 139 case DataFormatJSBoolean: { 145 140 GPRReg gpr = info.gpr(); 146 if (gprToUse != InvalidGPRReg && gpr != gprToUse) {147 GPRReg result = allocate(gprToUse);148 m_jit.move(gpr, result);149 return result;150 }151 141 m_gprs.lock(gpr); 152 142 return gpr; … … 643 633 { 644 634 CallLinkInfo::CallType callType; 645 ArgumentsLocation argumentsLocation = StackArgs;646 635 bool isVarargs = false; 647 636 bool isForwardVarargs = false; … … 726 715 GPRReg calleeGPR = InvalidGPRReg; 727 716 CallFrameShuffleData shuffleData; 728 std::optional<JSValueOperand> tailCallee; 729 std::optional<GPRTemporary> calleeGPRTemporary; 730 731 incrementCounter(&m_jit, VM::DFGCaller); 732 717 733 718 ExecutableBase* executable = nullptr; 734 719 FunctionExecutable* functionExecutable = nullptr; … … 749 734 unsigned numUsedStackSlots = m_jit.graph().m_nextMachineLocal; 750 735 751 incrementCounter(&m_jit, VM::CallVarargs);752 736 if (isForwardVarargs) { 753 737 flushRegisters(); … … 858 842 859 843 if (isTail) { 860 incrementCounter(&m_jit, VM::TailCall);861 844 Edge calleeEdge = m_jit.graph().child(node, 0); 862 // We can't get the a specific register for the callee, since that will just move 863 // from any current register. When we silent fill in the slow path we'll fill 864 // the original register and won't have the callee in the right register. 865 // Therefore we allocate a temp register for the callee and move ourselves. 866 tailCallee.emplace(this, calleeEdge); 867 GPRReg tailCalleeGPR = tailCallee->gpr(); 868 calleeGPR = argumentRegisterForCallee(); 869 if (tailCalleeGPR != calleeGPR) 870 calleeGPRTemporary = GPRTemporary(this, calleeGPR); 845 JSValueOperand callee(this, calleeEdge); 846 calleeGPR = callee.gpr(); 871 847 if (!isDirect) 872 tailCallee->use(); 873 874 argumentsLocation = argumentsLocationFor(numAllocatedArgs); 875 shuffleData.argumentsInRegisters = argumentsLocation != StackArgs; 848 callee.use(); 849 876 850 shuffleData.tagTypeNumber = GPRInfo::tagTypeNumberRegister; 877 851 shuffleData.numLocals = m_jit.graph().frameRegisterCount(); 878 shuffleData.callee = ValueRecovery::inGPR( tailCalleeGPR, DataFormatJS);852 shuffleData.callee = ValueRecovery::inGPR(calleeGPR, DataFormatJS); 879 853 shuffleData.args.resize(numAllocatedArgs); 880 854 … … 891 865 892 866 shuffleData.setupCalleeSaveRegisters(m_jit.codeBlock()); 893 } else if (node->op() == CallEval) { 894 // CallEval is handled with the arguments in the stack 867 } else { 895 868 m_jit.store32(MacroAssembler::TrustedImm32(numPassedArgs), JITCompiler::calleeFramePayloadSlot(CallFrameSlot::argumentCount)); 896 869 … … 906 879 for (unsigned i = numPassedArgs; i < numAllocatedArgs; ++i) 907 880 m_jit.storeTrustedValue(jsUndefined(), JITCompiler::calleeArgumentSlot(i)); 908 909 incrementCounter(&m_jit, VM::CallEval);910 } else {911 for (unsigned i = numPassedArgs; i-- > 0;) {912 GPRReg platformArgGPR = argumentRegisterForFunctionArgument(i);913 Edge argEdge = m_jit.graph().m_varArgChildren[node->firstChild() + 1 + i];914 JSValueOperand arg(this, argEdge, platformArgGPR);915 GPRReg argGPR = arg.gpr();916 ASSERT(argGPR == platformArgGPR || platformArgGPR == InvalidGPRReg);917 918 // Only free the non-argument registers at this point.919 if (platformArgGPR == InvalidGPRReg) {920 use(argEdge);921 m_jit.store64(argGPR, JITCompiler::calleeArgumentSlot(i));922 }923 }924 925 // Use the argument edges for arguments passed in registers.926 for (unsigned i = numPassedArgs; i-- > 0;) {927 GPRReg argGPR = argumentRegisterForFunctionArgument(i);928 if (argGPR != InvalidGPRReg) {929 Edge argEdge = m_jit.graph().m_varArgChildren[node->firstChild() + 1 + i];930 use(argEdge);931 }932 }933 934 GPRTemporary argCount(this, argumentRegisterForArgumentCount());935 GPRReg argCountGPR = argCount.gpr();936 m_jit.move(TrustedImm32(numPassedArgs), argCountGPR);937 argumentsLocation = argumentsLocationFor(numAllocatedArgs);938 939 for (unsigned i = numPassedArgs; i < numAllocatedArgs; ++i) {940 GPRReg platformArgGPR = argumentRegisterForFunctionArgument(i);941 942 if (platformArgGPR == InvalidGPRReg)943 m_jit.storeTrustedValue(jsUndefined(), JITCompiler::calleeArgumentSlot(i));944 else {945 GPRTemporary argumentTemp(this, platformArgGPR);946 m_jit.move(TrustedImm64(JSValue::encode(jsUndefined())), argumentTemp.gpr());947 }948 }949 881 } 950 882 } … … 952 884 if (!isTail || isVarargs || isForwardVarargs) { 953 885 Edge calleeEdge = m_jit.graph().child(node, 0); 954 JSValueOperand callee(this, calleeEdge , argumentRegisterForCallee());886 JSValueOperand callee(this, calleeEdge); 955 887 calleeGPR = callee.gpr(); 956 888 callee.use(); 957 if (argumentsLocation == StackArgs) 958 m_jit.store64(calleeGPR, JITCompiler::calleeFrameSlot(CallFrameSlot::callee)); 889 m_jit.store64(calleeGPR, JITCompiler::calleeFrameSlot(CallFrameSlot::callee)); 959 890 960 891 flushRegisters(); … … 983 914 984 915 CallLinkInfo* callLinkInfo = m_jit.codeBlock()->addCallLinkInfo(); 985 callLinkInfo->setUpCall(callType, argumentsLocation,m_currentNode->origin.semantic, calleeGPR);916 callLinkInfo->setUpCall(callType, m_currentNode->origin.semantic, calleeGPR); 986 917 987 918 if (node->op() == CallEval) { … … 1024 955 RELEASE_ASSERT(node->op() == DirectTailCall); 1025 956 1026 if (calleeGPRTemporary != std::nullopt)1027 m_jit.move(tailCallee->gpr(), calleeGPRTemporary->gpr());1028 1029 957 JITCompiler::PatchableJump patchableJump = m_jit.patchableJump(); 1030 958 JITCompiler::Label mainPath = m_jit.label(); 1031 1032 incrementCounter(&m_jit, VM::TailCall);1033 incrementCounter(&m_jit, VM::DirectCall);1034 959 1035 960 m_jit.emitStoreCallSiteIndex(callSite); … … 1047 972 silentFillAllRegisters(InvalidGPRReg); 1048 973 m_jit.exceptionCheck(); 1049 if (calleeGPRTemporary != std::nullopt)1050 m_jit.move(tailCallee->gpr(), calleeGPRTemporary->gpr());1051 974 m_jit.jump().linkTo(mainPath, &m_jit); 1052 975 … … 1059 982 JITCompiler::Label mainPath = m_jit.label(); 1060 983 1061 incrementCounter(&m_jit, VM::DirectCall);1062 1063 984 m_jit.emitStoreCallSiteIndex(callSite); 1064 985 … … 1068 989 JITCompiler::Label slowPath = m_jit.label(); 1069 990 if (isX86()) 1070 m_jit.pop(GPRInfo::nonArgGPR0); 1071 1072 m_jit.move(MacroAssembler::TrustedImmPtr(callLinkInfo), GPRInfo::nonArgGPR0); // Link info needs to be in nonArgGPR0 1073 JITCompiler::Call slowCall = m_jit.nearCall(); 1074 991 m_jit.pop(JITCompiler::selectScratchGPR(calleeGPR)); 992 993 callOperation(operationLinkDirectCall, callLinkInfo, calleeGPR); 1075 994 m_jit.exceptionCheck(); 1076 995 m_jit.jump().linkTo(mainPath, &m_jit); … … 1079 998 1080 999 setResultAndResetStack(); 1081 1082 m_jit.addJSDirectCall(call, slow Call, slowPath, callLinkInfo);1000 1001 m_jit.addJSDirectCall(call, slowPath, callLinkInfo); 1083 1002 return; 1084 1003 } 1085 1086 if (isTail && calleeGPRTemporary != std::nullopt) 1087 m_jit.move(tailCallee->gpr(), calleeGPRTemporary->gpr()); 1088 1004 1089 1005 m_jit.emitStoreCallSiteIndex(callSite); 1090 1006 … … 1110 1026 if (node->op() == TailCall) { 1111 1027 CallFrameShuffler callFrameShuffler(m_jit, shuffleData); 1112 if (argumentsLocation == StackArgs) 1113 callFrameShuffler.setCalleeJSValueRegs(JSValueRegs(argumentRegisterForCallee())); 1028 callFrameShuffler.setCalleeJSValueRegs(JSValueRegs(GPRInfo::regT0)); 1114 1029 callFrameShuffler.prepareForSlowPath(); 1115 } else if (isTail) 1116 m_jit.emitRestoreCalleeSaves(); 1117 1118 m_jit.move(MacroAssembler::TrustedImmPtr(callLinkInfo), GPRInfo::nonArgGPR0); // Link info needs to be in nonArgGPR0 1030 } else { 1031 m_jit.move(calleeGPR, GPRInfo::regT0); // Callee needs to be in regT0 1032 1033 if (isTail) 1034 m_jit.emitRestoreCalleeSaves(); // This needs to happen after we moved calleeGPR to regT0 1035 } 1036 1037 m_jit.move(MacroAssembler::TrustedImmPtr(callLinkInfo), GPRInfo::regT2); // Link info needs to be in regT2 1119 1038 JITCompiler::Call slowCall = m_jit.nearCall(); 1120 1039 1121 1040 done.link(&m_jit); 1122 1041 1123 if (isTail) { 1124 tailCallee = std::nullopt; 1125 calleeGPRTemporary = std::nullopt; 1042 if (isTail) 1126 1043 m_jit.abortWithReason(JITDidReturnFromTailCall); 1127 }else1044 else 1128 1045 setResultAndResetStack(); 1129 1046 … … 4250 4167 } 4251 4168 4252 case GetArgumentRegister:4253 break;4254 4255 4169 case GetRestLength: { 4256 4170 compileGetRestLength(node);
Note:
See TracChangeset
for help on using the changeset viewer.