Ignore:
Timestamp:
May 18, 2012, 1:42:14 PM (13 years ago)
Author:
[email protected]
Message:

DFG should have out-of-line slow paths
https://bugs.webkit.org/show_bug.cgi?id=83992

Reviewed by Oliver Hunt.

Merge of r114472 and r114553 from dfgopt.

Introduces the notion of slow path code generation closures in the DFG.
These are defined in DFGSlowPathGenerator.h, though they are fairly
extensible so DFGSpeculativeJIT64.cpp and DFGSpeculativeJIT32_64.cpp
define a couple special-purpose ones. A slow path generation closure
(DFG::SlowPathGenerator) is executed after the main speculative path is
generated. This makes them great for scheduling slow path code out of
the way of the hot paths.

This patch also converts most - but not all - of the DFG to use slow
path generators instead of inline slow paths.

The result is a sub-1% improvement on SunSpider and V8, and a miniscule
regression on Kraken.

  • JavaScriptCore.xcodeproj/project.pbxproj:
  • assembler/AbstractMacroAssembler.h:

(JSC::AbstractMacroAssembler::TrustedImmPtr::TrustedImmPtr):
(TrustedImmPtr):
(JSC::AbstractMacroAssembler::TrustedImm32::TrustedImm32):
(TrustedImm32):

  • bytecode/StructureStubInfo.h:
  • dfg/DFGCommon.h:
  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::link):
(JSC::DFG::JITCompiler::compile):
(JSC::DFG::JITCompiler::compileFunction):

  • dfg/DFGJITCompiler.h:

(DFG):
(JSC::DFG::PropertyAccessRecord::PropertyAccessRecord):
(PropertyAccessRecord):
(JITCompiler):

  • dfg/DFGSilentRegisterSavePlan.h: Added.

(DFG):
(SilentRegisterSavePlan):
(JSC::DFG::SilentRegisterSavePlan::SilentRegisterSavePlan):
(JSC::DFG::SilentRegisterSavePlan::spillAction):
(JSC::DFG::SilentRegisterSavePlan::fillAction):
(JSC::DFG::SilentRegisterSavePlan::nodeIndex):
(JSC::DFG::SilentRegisterSavePlan::gpr):
(JSC::DFG::SilentRegisterSavePlan::fpr):

  • dfg/DFGSlowPathGenerator.h: Added.

(DFG):
(SlowPathGenerator):
(JSC::DFG::SlowPathGenerator::SlowPathGenerator):
(JSC::DFG::SlowPathGenerator::~SlowPathGenerator):
(JSC::DFG::SlowPathGenerator::generate):
(JSC::DFG::SlowPathGenerator::label):
(JSC::DFG::SlowPathGenerator::call):
(JumpingSlowPathGenerator):
(JSC::DFG::JumpingSlowPathGenerator::JumpingSlowPathGenerator):
(JSC::DFG::JumpingSlowPathGenerator::linkFrom):
(JSC::DFG::JumpingSlowPathGenerator::jumpTo):
(CallSlowPathGenerator):
(JSC::DFG::CallSlowPathGenerator::CallSlowPathGenerator):
(JSC::DFG::CallSlowPathGenerator::call):
(JSC::DFG::CallSlowPathGenerator::setUp):
(JSC::DFG::CallSlowPathGenerator::recordCall):
(JSC::DFG::CallSlowPathGenerator::tearDown):
(CallResultAndNoArgumentsSlowPathGenerator):
(JSC::DFG::CallResultAndNoArgumentsSlowPathGenerator::CallResultAndNoArgumentsSlowPathGenerator):
(JSC::DFG::CallResultAndNoArgumentsSlowPathGenerator::generateInternal):
(CallResultAndOneArgumentSlowPathGenerator):
(JSC::DFG::CallResultAndOneArgumentSlowPathGenerator::CallResultAndOneArgumentSlowPathGenerator):
(JSC::DFG::CallResultAndOneArgumentSlowPathGenerator::generateInternal):
(CallResultAndTwoArgumentsSlowPathGenerator):
(JSC::DFG::CallResultAndTwoArgumentsSlowPathGenerator::CallResultAndTwoArgumentsSlowPathGenerator):
(JSC::DFG::CallResultAndTwoArgumentsSlowPathGenerator::generateInternal):
(CallResultAndThreeArgumentsSlowPathGenerator):
(JSC::DFG::CallResultAndThreeArgumentsSlowPathGenerator::CallResultAndThreeArgumentsSlowPathGenerator):
(JSC::DFG::CallResultAndThreeArgumentsSlowPathGenerator::generateInternal):
(CallResultAndFourArgumentsSlowPathGenerator):
(JSC::DFG::CallResultAndFourArgumentsSlowPathGenerator::CallResultAndFourArgumentsSlowPathGenerator):
(JSC::DFG::CallResultAndFourArgumentsSlowPathGenerator::generateInternal):
(CallResultAndFiveArgumentsSlowPathGenerator):
(JSC::DFG::CallResultAndFiveArgumentsSlowPathGenerator::CallResultAndFiveArgumentsSlowPathGenerator):
(JSC::DFG::CallResultAndFiveArgumentsSlowPathGenerator::generateInternal):
(JSC::DFG::slowPathCall):
(AssigningSlowPathGenerator):
(JSC::DFG::AssigningSlowPathGenerator::AssigningSlowPathGenerator):
(JSC::DFG::AssigningSlowPathGenerator::generateInternal):
(JSC::DFG::slowPathMove):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::SpeculativeJIT):
(DFG):
(JSC::DFG::SpeculativeJIT::~SpeculativeJIT):
(JSC::DFG::SpeculativeJIT::addSlowPathGenerator):
(JSC::DFG::SpeculativeJIT::runSlowPathGenerators):
(JSC::DFG::SpeculativeJIT::compileValueToInt32):
(JSC::DFG::SpeculativeJIT::compilePutByValForIntTypedArray):

  • dfg/DFGSpeculativeJIT.h:

(DFG):
(SpeculativeJIT):
(JSC::DFG::SpeculativeJIT::silentSavePlanForGPR):
(JSC::DFG::SpeculativeJIT::silentSavePlanForFPR):
(JSC::DFG::SpeculativeJIT::silentSpill):
(JSC::DFG::SpeculativeJIT::silentFill):
(JSC::DFG::SpeculativeJIT::silentSpillAllRegistersImpl):
(JSC::DFG::SpeculativeJIT::silentSpillAllRegisters):
(JSC::DFG::SpeculativeJIT::pickCanTrample):
(JSC::DFG::SpeculativeJIT::silentFillAllRegisters):
(JSC::DFG::SpeculativeJIT::callOperation):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(ValueToNumberSlowPathGenerator):
(JSC::DFG::ValueToNumberSlowPathGenerator::ValueToNumberSlowPathGenerator):
(JSC::DFG::ValueToNumberSlowPathGenerator::generateInternal):
(DFG):
(JSC::DFG::SpeculativeJIT::nonSpeculativeValueToNumber):
(JSC::DFG::SpeculativeJIT::nonSpeculativeValueToInt32):
(JSC::DFG::SpeculativeJIT::cachedGetById):
(JSC::DFG::SpeculativeJIT::cachedPutById):
(CompareAndBoxBooleanSlowPathGenerator):
(JSC::DFG::CompareAndBoxBooleanSlowPathGenerator::CompareAndBoxBooleanSlowPathGenerator):
(JSC::DFG::CompareAndBoxBooleanSlowPathGenerator::generateInternal):
(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeCompare):
(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq):
(JSC::DFG::SpeculativeJIT::compileLogicalNot):
(JSC::DFG::SpeculativeJIT::compile):

  • dfg/DFGSpeculativeJIT64.cpp:

(ValueToNumberSlowPathGenerator):
(JSC::DFG::ValueToNumberSlowPathGenerator::ValueToNumberSlowPathGenerator):
(JSC::DFG::ValueToNumberSlowPathGenerator::generateInternal):
(DFG):
(JSC::DFG::SpeculativeJIT::nonSpeculativeValueToNumber):
(JSC::DFG::SpeculativeJIT::nonSpeculativeValueToInt32):
(JSC::DFG::SpeculativeJIT::cachedGetById):
(JSC::DFG::SpeculativeJIT::cachedPutById):
(CompareAndBoxBooleanSlowPathGenerator):
(JSC::DFG::CompareAndBoxBooleanSlowPathGenerator::CompareAndBoxBooleanSlowPathGenerator):
(JSC::DFG::CompareAndBoxBooleanSlowPathGenerator::generateInternal):
(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeCompare):
(JSC::DFG::SpeculativeJIT::nonSpeculativeNonPeepholeStrictEq):
(JSC::DFG::SpeculativeJIT::compileLogicalNot):
(JSC::DFG::SpeculativeJIT::compile):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/dfg/DFGJITCompiler.cpp

    r117198 r117620  
    3333#include "DFGOperations.h"
    3434#include "DFGRegisterBank.h"
     35#include "DFGSlowPathGenerator.h"
    3536#include "DFGSpeculativeJIT.h"
    3637#include "DFGThunks.h"
     
    7980    bool compiledSpeculative = speculative.compile();
    8081    ASSERT_UNUSED(compiledSpeculative, compiledSpeculative);
    81 
    82     linkOSRExits();
    83 
     82}
     83
     84void JITCompiler::compileExceptionHandlers()
     85{
    8486    // Iterate over the m_calls vector, checking for jumps to link.
    8587    bool didLinkExceptionCheck = false;
     
    149151    for (unsigned i = 0; i < m_propertyAccesses.size(); ++i) {
    150152        StructureStubInfo& info = m_codeBlock->structureStubInfo(i);
    151         CodeLocationCall callReturnLocation = linkBuffer.locationOf(m_propertyAccesses[i].m_functionCall);
     153        CodeLocationCall callReturnLocation = linkBuffer.locationOf(m_propertyAccesses[i].m_slowPathGenerator->call());
    152154        info.codeOrigin = m_propertyAccesses[i].m_codeOrigin;
    153155        info.callReturnLocation = callReturnLocation;
    154         info.patch.dfg.deltaCheckImmToCall = differenceBetweenCodePtr(linkBuffer.locationOf(m_propertyAccesses[i].m_deltaCheckImmToCall), callReturnLocation);
    155         info.patch.dfg.deltaCallToStructCheck = differenceBetweenCodePtr(callReturnLocation, linkBuffer.locationOf(m_propertyAccesses[i].m_deltaCallToStructCheck));
     156        info.patch.dfg.deltaCheckImmToCall = differenceBetweenCodePtr(linkBuffer.locationOf(m_propertyAccesses[i].m_structureImm), callReturnLocation);
     157        info.patch.dfg.deltaCallToStructCheck = differenceBetweenCodePtr(callReturnLocation, linkBuffer.locationOf(m_propertyAccesses[i].m_structureCheck));
    156158#if USE(JSVALUE64)
    157         info.patch.dfg.deltaCallToLoadOrStore = differenceBetweenCodePtr(callReturnLocation, linkBuffer.locationOf(m_propertyAccesses[i].m_deltaCallToLoadOrStore));
     159        info.patch.dfg.deltaCallToLoadOrStore = differenceBetweenCodePtr(callReturnLocation, linkBuffer.locationOf(m_propertyAccesses[i].m_loadOrStore));
    158160#else
    159         info.patch.dfg.deltaCallToTagLoadOrStore = differenceBetweenCodePtr(callReturnLocation, linkBuffer.locationOf(m_propertyAccesses[i].m_deltaCallToTagLoadOrStore));
    160         info.patch.dfg.deltaCallToPayloadLoadOrStore = differenceBetweenCodePtr(callReturnLocation, linkBuffer.locationOf(m_propertyAccesses[i].m_deltaCallToPayloadLoadOrStore));
    161 #endif
    162         info.patch.dfg.deltaCallToSlowCase = differenceBetweenCodePtr(callReturnLocation, linkBuffer.locationOf(m_propertyAccesses[i].m_deltaCallToSlowCase));
    163         info.patch.dfg.deltaCallToDone = differenceBetweenCodePtr(callReturnLocation, linkBuffer.locationOf(m_propertyAccesses[i].m_deltaCallToDone));
     161        info.patch.dfg.deltaCallToTagLoadOrStore = differenceBetweenCodePtr(callReturnLocation, linkBuffer.locationOf(m_propertyAccesses[i].m_tagLoadOrStore));
     162        info.patch.dfg.deltaCallToPayloadLoadOrStore = differenceBetweenCodePtr(callReturnLocation, linkBuffer.locationOf(m_propertyAccesses[i].m_payloadLoadOrStore));
     163#endif
     164        info.patch.dfg.deltaCallToSlowCase = differenceBetweenCodePtr(callReturnLocation, linkBuffer.locationOf(m_propertyAccesses[i].m_slowPathGenerator->label()));
     165        info.patch.dfg.deltaCallToDone = differenceBetweenCodePtr(callReturnLocation, linkBuffer.locationOf(m_propertyAccesses[i].m_done));
    164166        info.patch.dfg.baseGPR = m_propertyAccesses[i].m_baseGPR;
    165167#if USE(JSVALUE64)
     
    200202    compileBody(speculative);
    201203
     204    // Generate slow path code.
     205    speculative.runSlowPathGenerators();
     206   
     207    compileExceptionHandlers();
     208    linkOSRExits();
     209   
    202210    // Create OSR entry trampolines if necessary.
    203211    speculative.createOSREntries();
     
    269277    jump(fromArityCheck);
    270278   
     279    // Generate slow path code.
     280    speculative.runSlowPathGenerators();
     281   
     282    compileExceptionHandlers();
     283    linkOSRExits();
     284   
    271285    // Create OSR entry trampolines if necessary.
    272286    speculative.createOSREntries();
Note: See TracChangeset for help on using the changeset viewer.