Ignore:
Timestamp:
Dec 4, 2015, 4:04:01 PM (9 years ago)
Author:
[email protected]
Message:

OSR exits that are exception handlers should emit less code eagerly in the thunk generator, and instead, should defer as much code generation as possible to be lazily generated in the exit itself
https://bugs.webkit.org/show_bug.cgi?id=151406

Reviewed by Filip Pizlo.

We no longer emit any extra code eagerly for an OSRExit that
is an exception handler. We emit all code lazily in the exit
itself. This has one interesting consequence which is that the
actual C call to compile the exit goes through an OSR exit generation
thunk that must now be aware of resetting the call frame and the stack
pointer to their proper values before making the compileOSRExit C
call. This has one interesting consequence in the FTL because the
FTL will do a pushToSaveImmediateWithoutTouchingRegisters with the
OSR exit index. We must take care to preserve this exit index when
we reset the stack pointer by re-pushing it onto the stack.

  • bytecode/CodeBlock.h:

(JSC::CodeBlock::setJITCode):
(JSC::CodeBlock::jitCode):
(JSC::CodeBlock::jitCodeOffset):
(JSC::CodeBlock::jitType):

  • dfg/DFGCommonData.h:

(JSC::DFG::CommonData::frameRegisterCountOffset):

  • dfg/DFGJITCode.h:

(JSC::DFG::JITCode::setOSREntryBlock):
(JSC::DFG::JITCode::clearOSREntryBlock):
(JSC::DFG::JITCode::commonDataOffset):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::linkOSRExits):

  • dfg/DFGOSRExitCompiler.cpp:
  • dfg/DFGOSRExitCompilerCommon.h:

(JSC::DFG::adjustFrameAndStackInOSRExitCompilerThunk):

  • dfg/DFGThunks.cpp:

(JSC::DFG::osrExitGenerationThunkGenerator):

  • ftl/FTLCompile.cpp:

(JSC::FTL::mmAllocateDataSection):

  • ftl/FTLExitThunkGenerator.cpp:

(JSC::FTL::ExitThunkGenerator::~ExitThunkGenerator):
(JSC::FTL::ExitThunkGenerator::emitThunk):
(JSC::FTL::ExitThunkGenerator::emitThunks):

  • ftl/FTLExitThunkGenerator.h:

(JSC::FTL::ExitThunkGenerator::didThings):

  • ftl/FTLJITCode.h:

(JSC::FTL::JITCode::commonDataOffset):

  • ftl/FTLOSRExitCompiler.cpp:

(JSC::FTL::compileStub):
(JSC::FTL::compileFTLOSRExit):

  • ftl/FTLThunks.cpp:

(JSC::FTL::genericGenerationThunkGenerator):
(JSC::FTL::osrExitGenerationThunkGenerator):
(JSC::FTL::lazySlowPathGenerationThunkGenerator):
(JSC::FTL::registerClobberCheck):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ftl/FTLThunks.cpp

    r190860 r193485  
    3030
    3131#include "AssemblyHelpers.h"
     32#include "DFGOSRExitCompilerCommon.h"
    3233#include "FPRInfo.h"
    3334#include "FTLOSRExitCompiler.h"
     
    4142using namespace DFG;
    4243
     44enum class FrameAndStackAdjustmentRequirement {
     45    Needed,
     46    NotNeeded
     47};
     48
    4349static MacroAssemblerCodeRef genericGenerationThunkGenerator(
    44     VM* vm, FunctionPtr generationFunction, const char* name, unsigned extraPopsToRestore)
     50    VM* vm, FunctionPtr generationFunction, const char* name, unsigned extraPopsToRestore, FrameAndStackAdjustmentRequirement frameAndStackAdjustmentRequirement)
    4551{
    4652    AssemblyHelpers jit(vm, 0);
     53
     54    if (frameAndStackAdjustmentRequirement == FrameAndStackAdjustmentRequirement::Needed) {
     55        // This needs to happen before we use the scratch buffer because this function also uses the scratch buffer.
     56        adjustFrameAndStackInOSRExitCompilerThunk<FTL::JITCode>(jit, vm, JITCode::FTLJIT);
     57    }
    4758   
    4859    // Note that the "return address" will be the ID that we pass to the generation function.
     
    116127    unsigned extraPopsToRestore = 0;
    117128    return genericGenerationThunkGenerator(
    118         vm, compileFTLOSRExit, "FTL OSR exit generation thunk", extraPopsToRestore);
     129        vm, compileFTLOSRExit, "FTL OSR exit generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::Needed);
    119130}
    120131
     
    123134    unsigned extraPopsToRestore = 1;
    124135    return genericGenerationThunkGenerator(
    125         vm, compileFTLLazySlowPath, "FTL lazy slow path generation thunk", extraPopsToRestore);
     136        vm, compileFTLLazySlowPath, "FTL lazy slow path generation thunk", extraPopsToRestore, FrameAndStackAdjustmentRequirement::NotNeeded);
    126137}
    127138
Note: See TracChangeset for help on using the changeset viewer.