Ignore:
Timestamp:
Jul 24, 2013, 9:00:13 PM (12 years ago)
Author:
[email protected]
Message:

fourthTier: DFG should separate link phase into things that must be done concurrently and things that must be done synchronously, and have a way of passing data from one to the other
https://bugs.webkit.org/show_bug.cgi?id=116060

Reviewed by Gavin Barraclough.

This introduces the concept of a DFG::Plan, which corresponds to:

  • The data that the concurrent DFG or FTL need to start compiling a CodeBlock. This mostly includes basic things like CodeBlock*, but also a list of must-handle values for OSR entry.
  • The data that the synchronous linker need to link in code compiled by a concurrent compilation thread. This is further encapsulated by DFG::Finalizer, since the data, and the actions that need to be taken, are different in DFG versus FTL. This patch also institutes the policy that the concurrent compilation thread shall not use LinkBuffer::performFinalization(), since that code assumes that it's running on the same thread that will actually run the code.
  • The actions that need to be taken to compile code. In other words, most of the code that previously lived in DFGDriver.cpp now lives in DFG::Plan::compileInThread().
  • The actions that need to be taken when synchronously linking the code. This includes "really" adding watchpoints and identifiers, checking watchpoint and chain validity, and running the DFG::Finalizer.

Currently, DFGDriver just creates a Plan and runs it synchronously. But in the
future, we will be able to malloc some Plans and enqueue them, and have the
concurrent thread dequeue them and call Plan::compileInThread().

For now, this has no behavior or performance change.

(JSC::LinkBuffer::performFinalization):

  • assembler/LinkBuffer.h:

(LinkBuffer):
(JSC::LinkBuffer::LinkBuffer):
(JSC::LinkBuffer::~LinkBuffer):

  • dfg/DFGAbstractState.cpp:

(JSC::DFG::AbstractState::initialize):
(JSC::DFG::AbstractState::executeEffects):

  • dfg/DFGAbstractValue.cpp:

(JSC::DFG::AbstractValue::setFuturePossibleStructure):
(JSC::DFG::AbstractValue::filterFuturePossibleStructure):

  • dfg/DFGByteCodeParser.cpp:

(JSC::DFG::ByteCodeParser::addStructureTransitionCheck):
(JSC::DFG::ByteCodeParser::handleGetById):
(JSC::DFG::ByteCodeParser::parseResolveOperations):
(JSC::DFG::ByteCodeParser::parseBlock):
(JSC::DFG::ByteCodeParser::InlineStackEntry::InlineStackEntry):
(JSC::DFG::ByteCodeParser::parseCodeBlock):

  • dfg/DFGConstantFoldingPhase.cpp:

(JSC::DFG::ConstantFoldingPhase::foldConstants):
(JSC::DFG::ConstantFoldingPhase::addStructureTransitionCheck):

  • dfg/DFGDriver.cpp:

(DFG):
(JSC::DFG::compile):

  • dfg/DFGFailedFinalizer.cpp: Added.

(DFG):
(JSC::DFG::FailedFinalizer::FailedFinalizer):
(JSC::DFG::FailedFinalizer::~FailedFinalizer):
(JSC::DFG::FailedFinalizer::finalize):
(JSC::DFG::FailedFinalizer::finalizeFunction):

  • dfg/DFGFailedFinalizer.h: Added.

(DFG):
(FailedFinalizer):

  • dfg/DFGFinalizer.cpp: Added.

(DFG):
(JSC::DFG::Finalizer::Finalizer):
(JSC::DFG::Finalizer::~Finalizer):

  • dfg/DFGFinalizer.h: Added.

(DFG):
(Finalizer):

  • dfg/DFGFixupPhase.cpp:

(JSC::DFG::FixupPhase::fixupNode):
(JSC::DFG::FixupPhase::canOptimizeStringObjectAccess):

  • dfg/DFGGraph.cpp:

(JSC::DFG::Graph::Graph):
(JSC::DFG::Graph::dump):
(DFG):

  • dfg/DFGGraph.h:

(Graph):
(JSC::DFG::Graph::masqueradesAsUndefinedWatchpointIsStillValid):
(JSC::DFG::Graph::compilation):
(JSC::DFG::Graph::identifiers):
(JSC::DFG::Graph::watchpoints):
(JSC::DFG::Graph::chains):

  • dfg/DFGJITCompiler.cpp:

(JSC::DFG::JITCompiler::linkOSRExits):
(JSC::DFG::JITCompiler::link):
(JSC::DFG::JITCompiler::compile):
(JSC::DFG::JITCompiler::compileFunction):
(JSC::DFG::JITCompiler::linkFunction):
(DFG):
(JSC::DFG::JITCompiler::disassemble):

  • dfg/DFGJITCompiler.h:

(JITCompiler):
(JSC::DFG::JITCompiler::addLazily):

  • dfg/DFGJITFinalizer.cpp: Added.

(DFG):
(JSC::DFG::JITFinalizer::JITFinalizer):
(JSC::DFG::JITFinalizer::~JITFinalizer):
(JSC::DFG::JITFinalizer::finalize):
(JSC::DFG::JITFinalizer::finalizeFunction):
(JSC::DFG::JITFinalizer::finalizeCommon):

  • dfg/DFGJITFinalizer.h: Added.

(DFG):
(JITFinalizer):

  • dfg/DFGPlan.cpp: Added.

(DFG):
(JSC::DFG::dumpAndVerifyGraph):
(JSC::DFG::Plan::Plan):
(JSC::DFG::Plan::~Plan):
(JSC::DFG::Plan::compileInThread):
(JSC::DFG::Plan::isStillValid):
(JSC::DFG::Plan::reallyAdd):
(JSC::DFG::Plan::finalize):

  • dfg/DFGPlan.h: Added.

(DFG):
(Plan):
(JSC::DFG::Plan::vm):

  • dfg/DFGPredictionInjectionPhase.cpp:

(JSC::DFG::PredictionInjectionPhase::run):

  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::SpeculativeJIT::identifierUID):
(JSC::DFG::SpeculativeJIT::speculateStringObjectForStructure):

  • dfg/DFGTypeCheckHoistingPhase.cpp:

(JSC::DFG::TypeCheckHoistingPhase::run):

  • ftl/FTLGeneratedFunction.h: Added.

(FTL):

  • ftl/FTLJITFinalizer.cpp: Added.

(FTL):
(JSC::FTL::JITFinalizer::JITFinalizer):
(JSC::FTL::JITFinalizer::~JITFinalizer):
(JSC::FTL::JITFinalizer::finalize):
(JSC::FTL::JITFinalizer::finalizeFunction):

  • ftl/FTLJITFinalizer.h: Added.

(FTL):
(JITFinalizer):
(JSC::FTL::JITFinalizer::initializeExitThunksLinkBuffer):
(JSC::FTL::JITFinalizer::initializeEntrypointLinkBuffer):
(JSC::FTL::JITFinalizer::initializeCode):
(JSC::FTL::JITFinalizer::initializeFunction):
(JSC::FTL::JITFinalizer::initializeArityCheck):
(JSC::FTL::JITFinalizer::initializeJITCode):

  • ftl/FTLLink.cpp:

(JSC::FTL::link):

  • ftl/FTLLink.h:

(FTL):

  • ftl/FTLLowerDFGToLLVM.cpp:

(JSC::FTL::LowerDFGToLLVM::linkOSRExitsAndCompleteInitializationBlocks):

  • ftl/FTLState.cpp:

(JSC::FTL::State::State):

  • ftl/FTLState.h:

(FTL):
(State):

File:
1 copied

Legend:

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

    r153160 r153161  
    2525
    2626#include "config.h"
    27 #include "FTLState.h"
     27#include "DFGJITFinalizer.h"
    2828
    29 #if ENABLE(FTL_JIT)
     29#if ENABLE(DFG_JIT)
    3030
    31 #include "CodeBlockWithJITType.h"
     31#include "DFGCommon.h"
     32#include "DFGPlan.h"
    3233
    33 namespace JSC { namespace FTL {
     34namespace JSC { namespace DFG {
    3435
    35 using namespace DFG;
    36 
    37 State::State(Graph& graph)
    38     : graph(graph)
    39     , module(0)
    40     , function(0)
    41     , jitCode(adoptRef(new JITCode()))
    42     , engine(0)
    43     , generatedFunction(0)
     36JITFinalizer::JITFinalizer(Plan& plan, PassRefPtr<JITCode> jitCode, PassOwnPtr<LinkBuffer> linkBuffer, MacroAssembler::Label arityCheck)
     37    : Finalizer(plan)
     38    , m_jitCode(jitCode)
     39    , m_linkBuffer(linkBuffer)
     40    , m_arityCheck(arityCheck)
    4441{
    4542}
    4643
    47 void State::dumpState(const char* when)
     44JITFinalizer::~JITFinalizer()
    4845{
    49     dataLog("LLVM IR for ", CodeBlockWithJITType(graph.m_codeBlock, FTL::JITCode::FTLJIT), " ", when, ":\n");
    50     dumpModule(module);
    5146}
    5247
    53 } } // namespace JSC::FTL
     48bool JITFinalizer::finalize(RefPtr<JSC::JITCode>& entry)
     49{
     50    finalizeCommon();
     51   
     52    m_jitCode->initializeCodeRef(m_linkBuffer->finalizeCodeWithoutDisassembly());
     53    entry = m_jitCode;
     54   
     55    return true;
     56}
    5457
    55 #endif // ENABLE(FTL_JIT)
     58bool JITFinalizer::finalizeFunction(RefPtr<JSC::JITCode>& entry, MacroAssemblerCodePtr& withArityCheck)
     59{
     60    finalizeCommon();
     61   
     62    withArityCheck = m_linkBuffer->locationOf(m_arityCheck);
     63    m_jitCode->initializeCodeRef(m_linkBuffer->finalizeCodeWithoutDisassembly());
     64    entry = m_jitCode;
     65   
     66    return true;
     67}
    5668
     69void JITFinalizer::finalizeCommon()
     70{
     71    if (m_plan.compilation)
     72        m_plan.vm().m_perBytecodeProfiler->addCompilation(m_plan.compilation);
     73}
     74
     75} } // namespace JSC::DFG
     76
     77#endif // ENABLE(DFG_JIT)
     78
Note: See TracChangeset for help on using the changeset viewer.