diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/ftl/FTLThunks.cpp | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/ftl/FTLThunks.cpp')
-rw-r--r-- | Source/JavaScriptCore/ftl/FTLThunks.cpp | 125 |
1 files changed, 25 insertions, 100 deletions
diff --git a/Source/JavaScriptCore/ftl/FTLThunks.cpp b/Source/JavaScriptCore/ftl/FTLThunks.cpp index cfbc75b7c..bf04af02a 100644 --- a/Source/JavaScriptCore/ftl/FTLThunks.cpp +++ b/Source/JavaScriptCore/ftl/FTLThunks.cpp @@ -29,10 +29,8 @@ #if ENABLE(FTL_JIT) #include "AssemblyHelpers.h" -#include "DFGOSRExitCompilerCommon.h" #include "FPRInfo.h" #include "FTLOSRExitCompiler.h" -#include "FTLOperations.h" #include "FTLSaveRestore.h" #include "GPRInfo.h" #include "LinkBuffer.h" @@ -41,51 +39,29 @@ namespace JSC { namespace FTL { using namespace DFG; -enum class FrameAndStackAdjustmentRequirement { - Needed, - NotNeeded -}; - -static MacroAssemblerCodeRef genericGenerationThunkGenerator( - VM* vm, FunctionPtr generationFunction, const char* name, unsigned extraPopsToRestore, FrameAndStackAdjustmentRequirement frameAndStackAdjustmentRequirement) +MacroAssemblerCodeRef osrExitGenerationThunkGenerator(VM& vm, const Location& location) { - AssemblyHelpers jit(vm, 0); - - if (frameAndStackAdjustmentRequirement == FrameAndStackAdjustmentRequirement::Needed) { - // This needs to happen before we use the scratch buffer because this function also uses the scratch buffer. - adjustFrameAndStackInOSRExitCompilerThunk<FTL::JITCode>(jit, vm, JITCode::FTLJIT); - } - - // Note that the "return address" will be the ID that we pass to the generation function. + AssemblyHelpers jit(&vm, 0); - ptrdiff_t stackMisalignment = MacroAssembler::pushToSaveByteOffset(); + // Note that the "return address" will be the OSR exit ID. // Pretend that we're a C call frame. - jit.pushToSave(MacroAssembler::framePointerRegister); + jit.push(MacroAssembler::framePointerRegister); jit.move(MacroAssembler::stackPointerRegister, MacroAssembler::framePointerRegister); - stackMisalignment += MacroAssembler::pushToSaveByteOffset(); - - // Now create ourselves enough stack space to give saveAllRegisters() a scratch slot. - unsigned numberOfRequiredPops = 0; - do { - jit.pushToSave(GPRInfo::regT0); - stackMisalignment += MacroAssembler::pushToSaveByteOffset(); - numberOfRequiredPops++; - } while (stackMisalignment % stackAlignmentBytes()); + jit.push(GPRInfo::regT0); + jit.push(GPRInfo::regT0); - ScratchBuffer* scratchBuffer = vm->scratchBufferForSize(requiredScratchMemorySizeInBytes()); + ScratchBuffer* scratchBuffer = vm.scratchBufferForSize(requiredScratchMemorySizeInBytes()); char* buffer = static_cast<char*>(scratchBuffer->dataBuffer()); saveAllRegisters(jit, buffer); // Tell GC mark phase how much of the scratch buffer is active during call. - jit.move(MacroAssembler::TrustedImmPtr(scratchBuffer->activeLengthPtr()), GPRInfo::nonArgGPR0); - jit.storePtr(MacroAssembler::TrustedImmPtr(requiredScratchMemorySizeInBytes()), GPRInfo::nonArgGPR0); + jit.move(MacroAssembler::TrustedImmPtr(scratchBuffer->activeLengthPtr()), GPRInfo::nonArgGPR1); + jit.storePtr(MacroAssembler::TrustedImmPtr(requiredScratchMemorySizeInBytes()), GPRInfo::nonArgGPR1); - jit.loadPtr(GPRInfo::callFrameRegister, GPRInfo::argumentGPR0); - jit.peek( - GPRInfo::argumentGPR1, - (stackMisalignment - MacroAssembler::pushToSaveByteOffset()) / sizeof(void*)); + location.restoreInto(jit, buffer, GPRInfo::argumentGPR0, 1); + jit.peek(GPRInfo::argumentGPR1, 3); MacroAssembler::Call functionCall = jit.call(); // At this point we want to make a tail call to what was returned to us in the @@ -95,73 +71,24 @@ static MacroAssemblerCodeRef genericGenerationThunkGenerator( jit.move(GPRInfo::returnValueGPR, GPRInfo::regT0); - // Make sure we tell the GC that we're not using the scratch buffer anymore. - jit.move(MacroAssembler::TrustedImmPtr(scratchBuffer->activeLengthPtr()), GPRInfo::regT1); - jit.storePtr(MacroAssembler::TrustedImmPtr(0), GPRInfo::regT1); - // Prepare for tail call. - while (numberOfRequiredPops--) - jit.popToRestore(GPRInfo::regT1); - jit.popToRestore(MacroAssembler::framePointerRegister); - - // When we came in here, there was an additional thing pushed to the stack. Some clients want it - // popped before proceeding. - while (extraPopsToRestore--) - jit.popToRestore(GPRInfo::regT1); - - // Put the return address wherever the return instruction wants it. On all platforms, this - // ensures that the return address is out of the way of register restoration. + jit.pop(GPRInfo::regT1); + jit.pop(GPRInfo::regT1); + jit.pop(MacroAssembler::framePointerRegister); + + // At this point we're sitting on the return address - so if we did a jump right now, the + // tail-callee would be happy. Instead we'll stash the callee in the return address and then + // restore all registers. + jit.restoreReturnAddressBeforeReturn(GPRInfo::regT0); - + restoreAllRegisters(jit, buffer); jit.ret(); - LinkBuffer patchBuffer(*vm, jit, GLOBAL_THUNK_ID); - patchBuffer.link(functionCall, generationFunction); - return FINALIZE_CODE(patchBuffer, ("%s", name)); -} - -MacroAssemblerCodeRef osrExitGenerationThunkGenerator(VM* vm) -{ - unsigned extraPopsToRestore = 0; - return genericGenerationThunkGenerator( - vm, compileFTLOSRExit, "FTL OSR exit generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::Needed); -} - -MacroAssemblerCodeRef lazySlowPathGenerationThunkGenerator(VM* vm) -{ - unsigned extraPopsToRestore = 1; - return genericGenerationThunkGenerator( - vm, compileFTLLazySlowPath, "FTL lazy slow path generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::NotNeeded); -} - -static void registerClobberCheck(AssemblyHelpers& jit, RegisterSet dontClobber) -{ - if (!Options::clobberAllRegsInFTLICSlowPath()) - return; - - RegisterSet clobber = RegisterSet::allRegisters(); - clobber.exclude(RegisterSet::reservedHardwareRegisters()); - clobber.exclude(RegisterSet::stackRegisters()); - clobber.exclude(RegisterSet::calleeSaveRegisters()); - clobber.exclude(dontClobber); - - GPRReg someGPR; - for (Reg reg = Reg::first(); reg <= Reg::last(); reg = reg.next()) { - if (!clobber.get(reg) || !reg.isGPR()) - continue; - - jit.move(AssemblyHelpers::TrustedImm32(0x1337beef), reg.gpr()); - someGPR = reg.gpr(); - } - - for (Reg reg = Reg::first(); reg <= Reg::last(); reg = reg.next()) { - if (!clobber.get(reg) || !reg.isFPR()) - continue; - - jit.move64ToDouble(someGPR, reg.fpr()); - } + LinkBuffer patchBuffer(vm, &jit, GLOBAL_THUNK_ID); + patchBuffer.link(functionCall, compileFTLOSRExit); + return FINALIZE_CODE(patchBuffer, ("FTL OSR exit generation thunk for callFrame at %s", toCString(location).data())); } MacroAssemblerCodeRef slowPathCallThunkGenerator(VM& vm, const SlowPathCallKey& key) @@ -195,10 +122,8 @@ MacroAssemblerCodeRef slowPathCallThunkGenerator(VM& vm, const SlowPathCallKey& jit.preserveReturnAddressAfterCall(GPRInfo::nonArgGPR0); jit.storePtr(GPRInfo::nonArgGPR0, AssemblyHelpers::Address(MacroAssembler::stackPointerRegister, key.offset())); - registerClobberCheck(jit, key.argumentRegisters()); + JITCompiler::Call call = jit.call(); - AssemblyHelpers::Call call = jit.call(); - jit.loadPtr(AssemblyHelpers::Address(MacroAssembler::stackPointerRegister, key.offset()), GPRInfo::nonPreservedNonReturnGPR); jit.restoreReturnAddressBeforeReturn(GPRInfo::nonPreservedNonReturnGPR); @@ -222,7 +147,7 @@ MacroAssemblerCodeRef slowPathCallThunkGenerator(VM& vm, const SlowPathCallKey& jit.ret(); - LinkBuffer patchBuffer(vm, jit, GLOBAL_THUNK_ID); + LinkBuffer patchBuffer(vm, &jit, GLOBAL_THUNK_ID); patchBuffer.link(call, FunctionPtr(key.callTarget())); return FINALIZE_CODE(patchBuffer, ("FTL slow path call thunk for %s", toCString(key).data())); } |