Ignore:
Timestamp:
Oct 6, 2016, 10:07:13 PM (9 years ago)
Author:
Yusuke Suzuki
Message:

[DOMJIT] Support slow path call
https://bugs.webkit.org/show_bug.cgi?id=162978

Reviewed by Saam Barati.

One of the most important features required in DOMJIT::Patchpoint is slow path calls.
DOM operation typically returns DOMWrapper object. At that time, if wrapper cache hits, we can go
to the fast path. However, if we cannot use the cache, we need to go to the slow path to call toJS function.
At that time, slow path call functionality is necessary.

This patch expose DOMJIT::PatchpointParams::addSlowPathCall. We can request slow path call code generation
through this interface. DOMJIT::PatchpointParams automatically leverages appropriate slow path call systems
in each tier. In DFG, we use slow path call system. In FTL, we implement slow path call by using addLatePath
to construct slow path call. But these details are completely hidden by DOMJIT::PatchpointParams. Users can
just use addSlowPathCall.

Since DFG and FTL slow path call systems are implemented in variadic templates, directly using this means
that we need to expose core part of DFG and FTL. For example, DFG::SpeculativeJIT need to be exposed in
such a design. That is too bad. Instead, we use magical macro in DOMJITSlowPathCalls.h. We can list up the
call signatures in DOMJIT_SLOW_PATH_CALLS. DOMJIT uses these signatures to generate an interface to request
slow path calls inside DFG and FTL instead of exposing everything.

  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • dfg/DFGCommon.h:
  • dfg/DFGDOMJITPatchpointParams.cpp: Copied from Source/JavaScriptCore/domjit/DOMJITPatchpointParams.h.

(JSC::DFG::dispatch):

  • dfg/DFGDOMJITPatchpointParams.h: Copied from Source/JavaScriptCore/domjit/DOMJITPatchpointParams.h.

(JSC::DFG::DOMJITPatchpointParams::DOMJITPatchpointParams):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileCallDOM):
(JSC::DFG::SpeculativeJIT::compileCheckDOM):

  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::extractResult): Deleted.

  • domjit/DOMJITPatchpointParams.h:

(JSC::DOMJIT::PatchpointParams::addSlowPathCall):

  • domjit/DOMJITSlowPathCalls.h: Copied from Source/JavaScriptCore/domjit/DOMJITPatchpointParams.h.
  • ftl/FTLDOMJITPatchpointParams.cpp: Added.

(JSC::FTL::dispatch):

  • ftl/FTLDOMJITPatchpointParams.h: Copied from Source/JavaScriptCore/domjit/DOMJITPatchpointParams.h.

(JSC::FTL::DOMJITPatchpointParams::DOMJITPatchpointParams):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileCheckDOM):
(JSC::FTL::DFG::LowerDFGToB3::compileCallDOM):

  • jit/GPRInfo.h:

(JSC::extractResult):

  • jsc.cpp:
File:
1 copied

Legend:

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

    r206898 r206899  
    2424 */
    2525
    26 #pragma once
     26#include "config.h"
     27#include "DFGDOMJITPatchpointParams.h"
    2728
    28 #if ENABLE(JIT)
     29#if ENABLE(DFG_JIT)
    2930
    30 #include "CCallHelpers.h"
    31 #include "DOMJITReg.h"
    32 #include "RegisterSet.h"
     31#include "DFGSlowPathGenerator.h"
     32#include "DFGSpeculativeJIT.h"
    3333
    34 namespace JSC { namespace DOMJIT {
     34namespace JSC { namespace DFG {
    3535
    36 class PatchpointParams {
    37 WTF_MAKE_NONCOPYABLE(PatchpointParams);
    38 public:
    39     virtual ~PatchpointParams() { }
     36template<typename OperationType, typename ResultType, typename Arguments, size_t... ArgumentsIndex>
     37static void dispatch(SpeculativeJIT* jit, CCallHelpers::JumpList from, OperationType operation, ResultType result, Arguments arguments, std::index_sequence<ArgumentsIndex...>)
     38{
     39    jit->addSlowPathGenerator(slowPathCall(from, jit, operation, result, std::get<ArgumentsIndex>(arguments)...));
     40}
    4041
    41     unsigned size() const { return m_regs.size(); }
    42     const Reg& at(unsigned index) const { return m_regs[index]; }
    43     const Reg& operator[](unsigned index) const { return at(index); }
     42#define JSC_DEFINE_CALL_OPERATIONS(OperationType, ResultType, ...) \
     43    void DOMJITPatchpointParams::addSlowPathCallImpl(CCallHelpers::JumpList from, CCallHelpers&, OperationType operation, ResultType result, std::tuple<__VA_ARGS__> args) const \
     44    { \
     45        dispatch(m_jit, from, operation, result, args, std::make_index_sequence<std::tuple_size<decltype(args)>::value>()); \
     46    } \
    4447
    45     GPRReg gpScratch(unsigned index) const { return m_gpScratch[index]; }
    46     FPRReg fpScratch(unsigned index) const { return m_fpScratch[index]; }
    47 
    48     PatchpointParams(Vector<Reg>&& regs, Vector<GPRReg>&& gpScratch, Vector<FPRReg>&& fpScratch)
    49         : m_regs(WTFMove(regs))
    50         , m_gpScratch(WTFMove(gpScratch))
    51         , m_fpScratch(WTFMove(fpScratch))
    52     {
    53     }
    54 
    55 private:
    56 
    57     Vector<Reg> m_regs;
    58     Vector<GPRReg> m_gpScratch;
    59     Vector<FPRReg> m_fpScratch;
    60 };
     48DOMJIT_SLOW_PATH_CALLS(JSC_DEFINE_CALL_OPERATIONS)
     49#undef JSC_DEFINE_CALL_OPERATIONS
    6150
    6251} }
Note: See TracChangeset for help on using the changeset viewer.