Changeset 230556 in webkit


Ignore:
Timestamp:
Apr 11, 2018 9:27:24 PM (6 years ago)
Author:
Yusuke Suzuki
Message:

[JSC] Add CCallHelpers::CellValue to wrap JSCell GPR to convert it to EncodedJSValue
https://bugs.webkit.org/show_bug.cgi?id=184500

Reviewed by Mark Lam.

Instead of passing JSValue::JSCellTag to callOperation meta-program to convert
JSCell GPR to EncodedJSValue in 32bit code, we add CallHelpers::CellValue.
It is a wrapper for GPRReg, like TrustedImmPtr for pointer value. When poking
CellValue, 32bit code emits JSValue::CellTag automatically. In 64bit, we just
poke held GPR. The benefit from this CellValue is that we can use the same code
for 32bit and 64bit. This patch removes several ifdefs.

  • bytecode/AccessCase.cpp:

(JSC::AccessCase::generateImpl):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileCallDOMGetter):
(JSC::DFG::SpeculativeJIT::compileGetDirectPname):
(JSC::DFG::SpeculativeJIT::cachedPutById):

  • dfg/DFGSpeculativeJIT32_64.cpp:

(JSC::DFG::SpeculativeJIT::cachedGetById):
(JSC::DFG::SpeculativeJIT::cachedGetByIdWithThis):

  • jit/CCallHelpers.h:

(JSC::CCallHelpers::CellValue::CellValue):
(JSC::CCallHelpers::CellValue::gpr const):
(JSC::CCallHelpers::setupArgumentsImpl):

Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r230550 r230556  
     12018-04-11  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [JSC] Add CCallHelpers::CellValue to wrap JSCell GPR to convert it to EncodedJSValue
     4        https://bugs.webkit.org/show_bug.cgi?id=184500
     5
     6        Reviewed by Mark Lam.
     7
     8        Instead of passing JSValue::JSCellTag to callOperation meta-program to convert
     9        JSCell GPR to EncodedJSValue in 32bit code, we add CallHelpers::CellValue.
     10        It is a wrapper for GPRReg, like TrustedImmPtr for pointer value. When poking
     11        CellValue, 32bit code emits JSValue::CellTag automatically. In 64bit, we just
     12        poke held GPR. The benefit from this CellValue is that we can use the same code
     13        for 32bit and 64bit. This patch removes several ifdefs.
     14
     15        * bytecode/AccessCase.cpp:
     16        (JSC::AccessCase::generateImpl):
     17        * dfg/DFGSpeculativeJIT.cpp:
     18        (JSC::DFG::SpeculativeJIT::compileCallDOMGetter):
     19        (JSC::DFG::SpeculativeJIT::compileGetDirectPname):
     20        (JSC::DFG::SpeculativeJIT::cachedPutById):
     21        * dfg/DFGSpeculativeJIT32_64.cpp:
     22        (JSC::DFG::SpeculativeJIT::cachedGetById):
     23        (JSC::DFG::SpeculativeJIT::cachedGetByIdWithThis):
     24        * jit/CCallHelpers.h:
     25        (JSC::CCallHelpers::CellValue::CellValue):
     26        (JSC::CCallHelpers::CellValue::gpr const):
     27        (JSC::CCallHelpers::setupArgumentsImpl):
     28
    1292018-04-11  Mark Lam  <mark.lam@apple.com>
    230
  • trunk/Source/JavaScriptCore/bytecode/AccessCase.cpp

    r230294 r230556  
    845845            // https://bugs.webkit.org/show_bug.cgi?id=158014
    846846            GPRReg baseForCustom = m_type == CustomValueGetter || m_type == CustomValueSetter ? baseForAccessGPR : baseForCustomGetGPR;
    847 #if USE(JSVALUE64)
    848847            if (m_type == CustomValueGetter || m_type == CustomAccessorGetter) {
    849848                jit.setupArguments<PropertySlot::GetValueFunc>(
    850                     baseForCustom,
    851                     CCallHelpers::TrustedImmPtr(ident.impl()));
    852             } else
    853                 jit.setupArguments<PutPropertySlot::PutValueFunc>(baseForCustom, valueRegs.gpr());
    854 #else
    855             if (m_type == CustomValueGetter || m_type == CustomAccessorGetter) {
    856                 jit.setupArguments<PropertySlot::GetValueFunc>(
    857                     JSValue::JSCellType, baseForCustom,
     849                    CCallHelpers::CellValue(baseForCustom),
    858850                    CCallHelpers::TrustedImmPtr(ident.impl()));
    859851            } else {
    860852                jit.setupArguments<PutPropertySlot::PutValueFunc>(
    861                     JSValue::JSCellType, baseForCustom,
     853                    CCallHelpers::CellValue(baseForCustom),
    862854                    valueRegs);
    863855            }
    864 #endif
    865856            jit.storePtr(GPRInfo::callFrameRegister, &vm.topCallFrame);
    866857
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r230543 r230556  
    90329032
    90339033        flushRegisters();
    9034 #if USE(JSVALUE64)
    9035         m_jit.setupArguments<J_JITOperation_EJI>(baseGPR, identifierUID(node->callDOMGetterData()->identifierNumber));
    9036 #else
    9037         m_jit.setupArguments<J_JITOperation_EJI>(JSValue::JSCellType, baseGPR, identifierUID(node->callDOMGetterData()->identifierNumber));
    9038 #endif
     9034        m_jit.setupArguments<J_JITOperation_EJI>(CCallHelpers::CellValue(baseGPR), identifierUID(node->callDOMGetterData()->identifierNumber));
    90399035        m_jit.storePtr(GPRInfo::callFrameRegister, &m_jit.vm()->topCallFrame);
    90409036        m_jit.emitStoreCodeOrigin(m_currentNode->origin.semantic);
     
    1273712733    JSValueRegsFlushedCallResult result(this);
    1273812734    JSValueRegs resultRegs = result.regs();
    12739     callOperation(operationGetByValCell, resultRegs, baseGPR, JSValue::JSCellType, propertyGPR);
     12735    callOperation(operationGetByValCell, resultRegs, baseGPR, CCallHelpers::CellValue(propertyGPR));
    1274012736    m_jit.exceptionCheck();
    1274112737    jsValueResult(resultRegs, node);
     
    1278512781    done.link(&m_jit);
    1278612782
    12787 #if USE(JSVALUE64)
    12788     addSlowPathGenerator(slowPathCall(slowPath, this, operationGetByValCell, GetPropertyPtrTag, resultRegs, baseGPR, propertyGPR));
    12789 #else
    12790     addSlowPathGenerator(slowPathCall(slowPath, this, operationGetByValCell, GetPropertyPtrTag, resultRegs, baseGPR, JSValue::JSCellType, propertyGPR));
    12791 #endif
     12783    addSlowPathGenerator(slowPathCall(slowPath, this, operationGetByValCell, GetPropertyPtrTag, resultRegs, baseGPR, CCallHelpers::CellValue(propertyGPR)));
    1279212784
    1279312785    jsValueResult(resultRegs, node);
     
    1282612818    slowCases.append(gen.slowPathJump());
    1282712819
    12828 #if USE(JSVALUE64)
    1282912820    auto slowPath = slowPathCall(
    1283012821        slowCases, this, gen.slowPathFunction(), PutPropertyPtrTag, NoResult, gen.stubInfo(), valueRegs,
    12831         baseGPR, identifierUID(identifierNumber));
    12832 #else
    12833     auto slowPath = slowPathCall(
    12834         slowCases, this, gen.slowPathFunction(), PutPropertyPtrTag, NoResult, gen.stubInfo(), valueRegs,
    12835         JSValue::JSCellType, baseGPR, identifierUID(identifierNumber));
    12836 #endif
     12822        CCallHelpers::CellValue(baseGPR), identifierUID(identifierNumber));
    1283712823
    1283812824    m_jit.addPutById(gen, slowPath.get());
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT32_64.cpp

    r230517 r230556  
    215215            slowCases, this, appropriateOptimizingGetByIdFunction(type),
    216216            JSValueRegs(resultTagGPR, resultPayloadGPR), gen.stubInfo(),
    217             JSValue::JSCellType, basePayloadGPR,
     217            CCallHelpers::CellValue(basePayloadGPR),
    218218            identifierUID(identifierNumber));
    219219    } else {
     
    250250            slowCases, this, operationGetByIdWithThisOptimize,
    251251            JSValueRegs(resultTagGPR, resultPayloadGPR), gen.stubInfo(),
    252             JSValue::JSCellType, basePayloadGPR,
    253             JSValue::JSCellType, thisPayloadGPR,
     252            CCallHelpers::CellValue(basePayloadGPR),
     253            CCallHelpers::CellValue(thisPayloadGPR),
    254254            identifierUID(identifierNumber));
    255255    } else {
  • trunk/Source/JavaScriptCore/jit/CCallHelpers.h

    r230129 r230556  
    6363    }
    6464
     65    // Wrapper to encode JSCell GPR into JSValue.
     66    class CellValue {
     67    public:
     68        explicit CellValue(GPRReg gpr)
     69            : m_gpr(gpr)
     70        {
     71        }
     72
     73        GPRReg gpr() const { return m_gpr; }
     74
     75    private:
     76        GPRReg m_gpr;
     77    };
     78
    6579    // The most general helper for setting arguments that fit in a GPR, if you can compute each
    6680    // argument without using any argument registers. You usually want one of the setupArguments*()
     
    336350    }
    337351
     352    template<typename OperationType, unsigned numGPRArgs, unsigned numGPRSources, unsigned numFPRArgs, unsigned numFPRSources, unsigned extraPoke, typename... Args>
     353    ALWAYS_INLINE void setupArgumentsImpl(ArgCollection<numGPRArgs, numGPRSources, numFPRArgs, numFPRSources, extraPoke> argSourceRegs, CellValue arg, Args... args)
     354    {
     355        marshallArgumentRegister<OperationType>(argSourceRegs, arg.gpr(), args...);
     356    }
     357
    338358#else // USE(JSVALUE64)
    339359
     
    358378    template<typename OperationType, unsigned numGPRArgs, unsigned numGPRSources, unsigned numFPRArgs, unsigned numFPRSources, unsigned extraPoke, typename... Args>
    359379    ALWAYS_INLINE std::enable_if_t<std::is_same<CURRENT_ARGUMENT_TYPE, EncodedJSValue>::value>
    360     setupArgumentsImpl(ArgCollection<numGPRArgs, numGPRSources, numFPRArgs, numFPRSources, extraPoke> argSourceRegs, JSValue::JSCellTag, GPRReg payload, Args... args)
    361     {
    362         pokeForArgument(payload, numGPRArgs, numFPRArgs, extraPoke);
    363         pokeForArgument(TrustedImm32(JSValue::CellTag), numGPRArgs, numFPRArgs, extraPoke + 1);
    364         setupArgumentsImpl<OperationType>(argSourceRegs.addGPRArg().addPoke(), args...);
    365     }
    366 
    367     template<typename OperationType, unsigned numGPRArgs, unsigned numGPRSources, unsigned numFPRArgs, unsigned numFPRSources, unsigned extraPoke, typename... Args>
    368     ALWAYS_INLINE std::enable_if_t<std::is_same<CURRENT_ARGUMENT_TYPE, EncodedJSValue>::value>
    369     setupArgumentsImpl(ArgCollection<numGPRArgs, numGPRSources, numFPRArgs, numFPRSources, extraPoke> argSourceRegs, JSValue::JSCellTag, TrustedImmPtr payload, Args... args)
    370     {
    371         pokeForArgument(payload, numGPRArgs, numFPRArgs, extraPoke);
    372         pokeForArgument(TrustedImm32(JSValue::CellTag), numGPRArgs, numFPRArgs, extraPoke + 1);
    373         setupArgumentsImpl<OperationType>(argSourceRegs.addGPRArg().addPoke(), args...);
    374     }
    375 
    376     template<typename OperationType, unsigned numGPRArgs, unsigned numGPRSources, unsigned numFPRArgs, unsigned numFPRSources, unsigned extraPoke, typename... Args>
    377     ALWAYS_INLINE std::enable_if_t<std::is_same<CURRENT_ARGUMENT_TYPE, EncodedJSValue>::value>
    378380    setupArgumentsImpl(ArgCollection<numGPRArgs, numGPRSources, numFPRArgs, numFPRSources, extraPoke> argSourceRegs, JSValueRegs arg, Args... args)
    379381    {
    380382        pokeForArgument(arg.payloadGPR(), numGPRArgs, numFPRArgs, extraPoke);
    381383        pokeForArgument(arg.tagGPR(), numGPRArgs, numFPRArgs, extraPoke + 1);
     384        setupArgumentsImpl<OperationType>(argSourceRegs.addGPRArg().addPoke(), args...);
     385    }
     386
     387    template<typename OperationType, unsigned numGPRArgs, unsigned numGPRSources, unsigned numFPRArgs, unsigned numFPRSources, unsigned extraPoke, typename... Args>
     388    ALWAYS_INLINE std::enable_if_t<std::is_same<CURRENT_ARGUMENT_TYPE, EncodedJSValue>::value>
     389    setupArgumentsImpl(ArgCollection<numGPRArgs, numGPRSources, numFPRArgs, numFPRSources, extraPoke> argSourceRegs, CellValue arg, Args... args)
     390    {
     391        pokeForArgument(arg.gpr(), numGPRArgs, numFPRArgs, extraPoke);
     392        pokeForArgument(TrustedImm32(JSValue::CellTag), numGPRArgs, numFPRArgs, extraPoke + 1);
    382393        setupArgumentsImpl<OperationType>(argSourceRegs.addGPRArg().addPoke(), args...);
    383394    }
Note: See TracChangeset for help on using the changeset viewer.