Changeset 209653 in webkit for trunk/Source/JavaScriptCore/jit/Repatch.cpp
- Timestamp:
- Dec 9, 2016, 11:32:38 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jit/Repatch.cpp
r209597 r209653 541 541 } 542 542 543 static void linkSlowFor(VM*, CallLinkInfo& callLinkInfo, MacroAssemblerCodeRef codeRef)544 { 545 MacroAssembler::repatchNearCall(callLinkInfo.callReturnLocation(), CodeLocationLabel( codeRef.code()));546 } 547 548 static void linkSlowFor(VM* vm, CallLinkInfo& callLinkInfo, ThunkGenerator generator)549 { 550 linkSlowFor(vm, callLinkInfo, vm->get CTIStub(generator));543 static void linkSlowFor(VM*, CallLinkInfo& callLinkInfo, JITJSCallThunkEntryPointsWithRef thunkEntryPoints) 544 { 545 MacroAssembler::repatchNearCall(callLinkInfo.callReturnLocation(), CodeLocationLabel(thunkEntryPoints.entryFor(callLinkInfo.argumentsLocation()))); 546 } 547 548 static void linkSlowFor(VM* vm, CallLinkInfo& callLinkInfo, JITCallThunkEntryGenerator generator) 549 { 550 linkSlowFor(vm, callLinkInfo, vm->getJITCallThunkEntryStub(generator)); 551 551 } 552 552 553 553 static void linkSlowFor(VM* vm, CallLinkInfo& callLinkInfo) 554 554 { 555 MacroAssemblerCodeRef virtualThunk = virtualThunkFor(vm, callLinkInfo);555 JITJSCallThunkEntryPointsWithRef virtualThunk = virtualThunkFor(vm, callLinkInfo); 556 556 linkSlowFor(vm, callLinkInfo, virtualThunk); 557 callLinkInfo.setSlowStub(createJITStubRoutine(virtualThunk , *vm, nullptr, true));557 callLinkInfo.setSlowStub(createJITStubRoutine(virtualThunk.codeRef(), *vm, nullptr, true)); 558 558 } 559 559 … … 645 645 } 646 646 647 static void revertCall(VM* vm, CallLinkInfo& callLinkInfo, MacroAssemblerCodeRef codeRef)647 static void revertCall(VM* vm, CallLinkInfo& callLinkInfo, JITJSCallThunkEntryPointsWithRef codeRef) 648 648 { 649 649 if (callLinkInfo.isDirect()) { … … 672 672 dataLog("Unlinking call at ", callLinkInfo.hotPathOther(), "\n"); 673 673 674 revertCall(&vm, callLinkInfo, vm.get CTIStub(linkCallThunkGenerator));674 revertCall(&vm, callLinkInfo, vm.getJITCallThunkEntryStub(linkCallThunkGenerator)); 675 675 } 676 676 … … 684 684 dataLog("Linking virtual call at ", *callerCodeBlock, " ", callerFrame->codeOrigin(), "\n"); 685 685 686 MacroAssemblerCodeRef virtualThunk = virtualThunkFor(&vm, callLinkInfo);686 JITJSCallThunkEntryPointsWithRef virtualThunk = virtualThunkFor(&vm, callLinkInfo); 687 687 revertCall(&vm, callLinkInfo, virtualThunk); 688 callLinkInfo.setSlowStub(createJITStubRoutine(virtualThunk , vm, nullptr, true));688 callLinkInfo.setSlowStub(createJITStubRoutine(virtualThunk.codeRef(), vm, nullptr, true)); 689 689 } 690 690 … … 741 741 742 742 Vector<PolymorphicCallCase> callCases; 743 size_t callerArgumentCount = exec->argumentCountIncludingThis(); 743 744 744 745 // Figure out what our cases are. … … 752 753 // If we cannot handle a callee, either because we don't have a CodeBlock or because arity mismatch, 753 754 // assume that it's better for this whole thing to be a virtual call. 754 if (!codeBlock || exec->argumentCountIncludingThis()< static_cast<size_t>(codeBlock->numParameters()) || callLinkInfo.isVarargs()) {755 if (!codeBlock || callerArgumentCount < static_cast<size_t>(codeBlock->numParameters()) || callLinkInfo.isVarargs()) { 755 756 linkVirtualFor(exec, callLinkInfo); 756 757 return; … … 776 777 777 778 GPRReg calleeGPR = static_cast<GPRReg>(callLinkInfo.calleeGPR()); 778 779 780 if (callLinkInfo.argumentsInRegisters()) 781 ASSERT(calleeGPR == argumentRegisterForCallee()); 782 779 783 CCallHelpers stubJit(&vm, callerCodeBlock); 780 784 … … 798 802 if (frameShuffler) 799 803 scratchGPR = frameShuffler->acquireGPR(); 804 else if (callLinkInfo.argumentsInRegisters()) 805 scratchGPR = GPRInfo::nonArgGPR0; 800 806 else 801 807 scratchGPR = AssemblyHelpers::selectScratchGPR(calleeGPR); … … 863 869 if (frameShuffler) 864 870 fastCountsBaseGPR = frameShuffler->acquireGPR(); 871 else if (callLinkInfo.argumentsInRegisters()) 872 #if CPU(ARM64) 873 fastCountsBaseGPR = GPRInfo::nonArgGPR1; 874 #else 875 fastCountsBaseGPR = GPRInfo::regT0; 876 #endif 865 877 else { 866 878 fastCountsBaseGPR = 867 879 AssemblyHelpers::selectScratchGPR(calleeGPR, comparisonValueGPR, GPRInfo::regT3); 868 880 } 869 stubJit.move(CCallHelpers::TrustedImmPtr(fastCounts.get()), fastCountsBaseGPR); 881 if (fastCounts) 882 stubJit.move(CCallHelpers::TrustedImmPtr(fastCounts.get()), fastCountsBaseGPR); 870 883 if (!frameShuffler && callLinkInfo.isTailCall()) 871 884 stubJit.emitRestoreCalleeSaves(); 885 886 incrementCounter(&stubJit, VM::PolymorphicCall); 887 872 888 BinarySwitch binarySwitch(comparisonValueGPR, caseValues, BinarySwitch::IntPtr); 873 889 CCallHelpers::JumpList done; … … 878 894 879 895 ASSERT(variant.executable()->hasJITCodeForCall()); 896 897 EntryPointType entryType = StackArgsArityCheckNotRequired; 898 #if NUMBER_OF_JS_FUNCTION_ARGUMENT_REGISTERS 899 if (callLinkInfo.argumentsInRegisters()) { 900 CodeBlock* codeBlock = callCases[caseIndex].codeBlock(); 901 if (codeBlock) { 902 size_t calleeArgumentCount = static_cast<size_t>(codeBlock->numParameters()); 903 if (calleeArgumentCount == callerArgumentCount || calleeArgumentCount >= NUMBER_OF_JS_FUNCTION_ARGUMENT_REGISTERS) 904 entryType = RegisterArgsArityCheckNotRequired; 905 else { 906 EntryPointType entryForArgCount = JITEntryPoints::registerEntryTypeForArgumentCount(callerArgumentCount); 907 MacroAssemblerCodePtr codePtr = 908 variant.executable()->generatedJITCodeForCall()->addressForCall(entryForArgCount); 909 if (codePtr) 910 entryType = entryForArgCount; 911 else 912 entryType = RegisterArgsPossibleExtraArgs; 913 } 914 } else 915 entryType = RegisterArgsPossibleExtraArgs; 916 } 917 #endif 918 880 919 MacroAssemblerCodePtr codePtr = 881 variant.executable()->generatedJITCodeForCall()->addressForCall(ArityCheckNotRequired); 920 variant.executable()->generatedJITCodeForCall()->addressForCall(entryType); 921 ASSERT(codePtr); 882 922 883 923 if (fastCounts) { … … 887 927 } 888 928 if (frameShuffler) { 889 CallFrameShuffler(stubJit, frameShuffler->snapshot( )).prepareForTailCall();929 CallFrameShuffler(stubJit, frameShuffler->snapshot(callLinkInfo.argumentsLocation())).prepareForTailCall(); 890 930 calls[caseIndex].call = stubJit.nearTailCall(); 891 931 } else if (callLinkInfo.isTailCall()) { … … 908 948 frameShuffler->setCalleeJSValueRegs(JSValueRegs(GPRInfo::regT1, GPRInfo::regT0)); 909 949 #else 910 frameShuffler->setCalleeJSValueRegs(JSValueRegs(GPRInfo::regT0)); 950 if (callLinkInfo.argumentsLocation() == StackArgs) 951 frameShuffler->setCalleeJSValueRegs(JSValueRegs(argumentRegisterForCallee())); 911 952 #endif 912 953 frameShuffler->prepareForSlowPath(); 913 954 } else { 914 stubJit.move(calleeGPR, GPRInfo::regT0);915 955 #if USE(JSVALUE32_64) 916 956 stubJit.move(CCallHelpers::TrustedImm32(JSValue::CellTag), GPRInfo::regT1); 917 957 #endif 918 958 } 919 stubJit.move(CCallHelpers::TrustedImmPtr( &callLinkInfo), GPRInfo::regT2);920 stubJit. move(CCallHelpers::TrustedImmPtr(callLinkInfo.callReturnLocation().executableAddress()), GPRInfo::regT4);921 922 stubJit. restoreReturnAddressBeforeReturn(GPRInfo::regT4);959 stubJit.move(CCallHelpers::TrustedImmPtr(callLinkInfo.callReturnLocation().executableAddress()), GPRInfo::nonArgGPR1); 960 stubJit.restoreReturnAddressBeforeReturn(GPRInfo::nonArgGPR1); 961 962 stubJit.move(CCallHelpers::TrustedImmPtr(&callLinkInfo), GPRInfo::nonArgGPR0); 923 963 AssemblyHelpers::Jump slow = stubJit.jump(); 924 964 … … 941 981 else 942 982 patchBuffer.link(done, callLinkInfo.hotPathOther().labelAtOffset(0)); 943 patchBuffer.link(slow, CodeLocationLabel(vm.get CTIStub(linkPolymorphicCallThunkGenerator).code()));983 patchBuffer.link(slow, CodeLocationLabel(vm.getJITCallThunkEntryStub(linkPolymorphicCallThunkGenerator).entryFor(callLinkInfo.argumentsLocation()))); 944 984 945 985 auto stubRoutine = adoptRef(*new PolymorphicCallStubRoutine(
Note:
See TracChangeset
for help on using the changeset viewer.