Title: [230556] trunk/Source/_javascript_Core
Revision
230556
Author
utatane....@gmail.com
Date
2018-04-11 21:27:24 -0700 (Wed, 11 Apr 2018)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (230555 => 230556)


--- trunk/Source/_javascript_Core/ChangeLog	2018-04-12 04:19:30 UTC (rev 230555)
+++ trunk/Source/_javascript_Core/ChangeLog	2018-04-12 04:27:24 UTC (rev 230556)
@@ -1,3 +1,31 @@
+2018-04-11  Yusuke Suzuki  <utatane....@gmail.com>
+
+        [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):
+
 2018-04-11  Mark Lam  <mark....@apple.com>
 
         [Build fix] Replace CompactJITCodeMap with JITCodeMap.

Modified: trunk/Source/_javascript_Core/bytecode/AccessCase.cpp (230555 => 230556)


--- trunk/Source/_javascript_Core/bytecode/AccessCase.cpp	2018-04-12 04:19:30 UTC (rev 230555)
+++ trunk/Source/_javascript_Core/bytecode/AccessCase.cpp	2018-04-12 04:27:24 UTC (rev 230556)
@@ -844,24 +844,15 @@
             // FIXME: Remove this differences in custom values and custom accessors.
             // https://bugs.webkit.org/show_bug.cgi?id=158014
             GPRReg baseForCustom = m_type == CustomValueGetter || m_type == CustomValueSetter ? baseForAccessGPR : baseForCustomGetGPR; 
-#if USE(JSVALUE64)
             if (m_type == CustomValueGetter || m_type == CustomAccessorGetter) {
                 jit.setupArguments<PropertySlot::GetValueFunc>(
-                    baseForCustom,
+                    CCallHelpers::CellValue(baseForCustom),
                     CCallHelpers::TrustedImmPtr(ident.impl()));
-            } else
-                jit.setupArguments<PutPropertySlot::PutValueFunc>(baseForCustom, valueRegs.gpr());
-#else
-            if (m_type == CustomValueGetter || m_type == CustomAccessorGetter) {
-                jit.setupArguments<PropertySlot::GetValueFunc>(
-                    JSValue::JSCellType, baseForCustom,
-                    CCallHelpers::TrustedImmPtr(ident.impl()));
             } else {
                 jit.setupArguments<PutPropertySlot::PutValueFunc>(
-                    JSValue::JSCellType, baseForCustom,
+                    CCallHelpers::CellValue(baseForCustom),
                     valueRegs);
             }
-#endif
             jit.storePtr(GPRInfo::callFrameRegister, &vm.topCallFrame);
 
             PtrTag callTag = ptrTag(GetterSetterPtrTag, nextPtrTagID());

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp (230555 => 230556)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2018-04-12 04:19:30 UTC (rev 230555)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT.cpp	2018-04-12 04:27:24 UTC (rev 230556)
@@ -9031,11 +9031,7 @@
         GPRReg baseGPR = base.gpr();
 
         flushRegisters();
-#if USE(JSVALUE64)
-        m_jit.setupArguments<J_JITOperation_EJI>(baseGPR, identifierUID(node->callDOMGetterData()->identifierNumber));
-#else
-        m_jit.setupArguments<J_JITOperation_EJI>(JSValue::JSCellType, baseGPR, identifierUID(node->callDOMGetterData()->identifierNumber));
-#endif
+        m_jit.setupArguments<J_JITOperation_EJI>(CCallHelpers::CellValue(baseGPR), identifierUID(node->callDOMGetterData()->identifierNumber));
         m_jit.storePtr(GPRInfo::callFrameRegister, &m_jit.vm()->topCallFrame);
         m_jit.emitStoreCodeOrigin(m_currentNode->origin.semantic);
         m_jit.appendCall(getter);
@@ -12736,7 +12732,7 @@
     flushRegisters();
     JSValueRegsFlushedCallResult result(this);
     JSValueRegs resultRegs = result.regs();
-    callOperation(operationGetByValCell, resultRegs, baseGPR, JSValue::JSCellType, propertyGPR);
+    callOperation(operationGetByValCell, resultRegs, baseGPR, CCallHelpers::CellValue(propertyGPR));
     m_jit.exceptionCheck();
     jsValueResult(resultRegs, node);
 #else
@@ -12784,11 +12780,7 @@
 
     done.link(&m_jit);
 
-#if USE(JSVALUE64)
-    addSlowPathGenerator(slowPathCall(slowPath, this, operationGetByValCell, GetPropertyPtrTag, resultRegs, baseGPR, propertyGPR));
-#else
-    addSlowPathGenerator(slowPathCall(slowPath, this, operationGetByValCell, GetPropertyPtrTag, resultRegs, baseGPR, JSValue::JSCellType, propertyGPR));
-#endif
+    addSlowPathGenerator(slowPathCall(slowPath, this, operationGetByValCell, GetPropertyPtrTag, resultRegs, baseGPR, CCallHelpers::CellValue(propertyGPR)));
 
     jsValueResult(resultRegs, node);
 #endif
@@ -12825,15 +12817,9 @@
         slowCases.append(slowPathTarget);
     slowCases.append(gen.slowPathJump());
 
-#if USE(JSVALUE64)
     auto slowPath = slowPathCall(
         slowCases, this, gen.slowPathFunction(), PutPropertyPtrTag, NoResult, gen.stubInfo(), valueRegs,
-        baseGPR, identifierUID(identifierNumber));
-#else
-    auto slowPath = slowPathCall(
-        slowCases, this, gen.slowPathFunction(), PutPropertyPtrTag, NoResult, gen.stubInfo(), valueRegs,
-        JSValue::JSCellType, baseGPR, identifierUID(identifierNumber));
-#endif
+        CCallHelpers::CellValue(baseGPR), identifierUID(identifierNumber));
 
     m_jit.addPutById(gen, slowPath.get());
     addSlowPathGenerator(WTFMove(slowPath));

Modified: trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp (230555 => 230556)


--- trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp	2018-04-12 04:19:30 UTC (rev 230555)
+++ trunk/Source/_javascript_Core/dfg/DFGSpeculativeJIT32_64.cpp	2018-04-12 04:27:24 UTC (rev 230556)
@@ -214,7 +214,7 @@
         slowPath = slowPathCall(
             slowCases, this, appropriateOptimizingGetByIdFunction(type),
             JSValueRegs(resultTagGPR, resultPayloadGPR), gen.stubInfo(),
-            JSValue::JSCellType, basePayloadGPR,
+            CCallHelpers::CellValue(basePayloadGPR),
             identifierUID(identifierNumber));
     } else {
         slowPath = slowPathCall(
@@ -249,8 +249,8 @@
         slowPath = slowPathCall(
             slowCases, this, operationGetByIdWithThisOptimize,
             JSValueRegs(resultTagGPR, resultPayloadGPR), gen.stubInfo(),
-            JSValue::JSCellType, basePayloadGPR,
-            JSValue::JSCellType, thisPayloadGPR,
+            CCallHelpers::CellValue(basePayloadGPR),
+            CCallHelpers::CellValue(thisPayloadGPR),
             identifierUID(identifierNumber));
     } else {
         ASSERT(baseTagGPROrNone != InvalidGPRReg);

Modified: trunk/Source/_javascript_Core/jit/CCallHelpers.h (230555 => 230556)


--- trunk/Source/_javascript_Core/jit/CCallHelpers.h	2018-04-12 04:19:30 UTC (rev 230555)
+++ trunk/Source/_javascript_Core/jit/CCallHelpers.h	2018-04-12 04:27:24 UTC (rev 230556)
@@ -62,6 +62,20 @@
     {
     }
 
+    // Wrapper to encode JSCell GPR into JSValue.
+    class CellValue {
+    public:
+        explicit CellValue(GPRReg gpr)
+            : m_gpr(gpr)
+        {
+        }
+
+        GPRReg gpr() const { return m_gpr; }
+
+    private:
+        GPRReg m_gpr;
+    };
+
     // The most general helper for setting arguments that fit in a GPR, if you can compute each
     // argument without using any argument registers. You usually want one of the setupArguments*()
     // methods below instead of this. This thing is most useful if you have *a lot* of arguments.
@@ -335,6 +349,12 @@
         marshallArgumentRegister<OperationType>(argSourceRegs, arg.gpr(), args...);
     }
 
+    template<typename OperationType, unsigned numGPRArgs, unsigned numGPRSources, unsigned numFPRArgs, unsigned numFPRSources, unsigned extraPoke, typename... Args>
+    ALWAYS_INLINE void setupArgumentsImpl(ArgCollection<numGPRArgs, numGPRSources, numFPRArgs, numFPRSources, extraPoke> argSourceRegs, CellValue arg, Args... args)
+    {
+        marshallArgumentRegister<OperationType>(argSourceRegs, arg.gpr(), args...);
+    }
+
 #else // USE(JSVALUE64)
 
     // These functions are a hack for X86 since it has no argument gprs...
@@ -357,31 +377,22 @@
 
     template<typename OperationType, unsigned numGPRArgs, unsigned numGPRSources, unsigned numFPRArgs, unsigned numFPRSources, unsigned extraPoke, typename... Args>
     ALWAYS_INLINE std::enable_if_t<std::is_same<CURRENT_ARGUMENT_TYPE, EncodedJSValue>::value>
-    setupArgumentsImpl(ArgCollection<numGPRArgs, numGPRSources, numFPRArgs, numFPRSources, extraPoke> argSourceRegs, JSValue::JSCellTag, GPRReg payload, Args... args)
+    setupArgumentsImpl(ArgCollection<numGPRArgs, numGPRSources, numFPRArgs, numFPRSources, extraPoke> argSourceRegs, JSValueRegs arg, Args... args)
     {
-        pokeForArgument(payload, numGPRArgs, numFPRArgs, extraPoke);
-        pokeForArgument(TrustedImm32(JSValue::CellTag), numGPRArgs, numFPRArgs, extraPoke + 1);
+        pokeForArgument(arg.payloadGPR(), numGPRArgs, numFPRArgs, extraPoke);
+        pokeForArgument(arg.tagGPR(), numGPRArgs, numFPRArgs, extraPoke + 1);
         setupArgumentsImpl<OperationType>(argSourceRegs.addGPRArg().addPoke(), args...);
     }
 
     template<typename OperationType, unsigned numGPRArgs, unsigned numGPRSources, unsigned numFPRArgs, unsigned numFPRSources, unsigned extraPoke, typename... Args>
     ALWAYS_INLINE std::enable_if_t<std::is_same<CURRENT_ARGUMENT_TYPE, EncodedJSValue>::value>
-    setupArgumentsImpl(ArgCollection<numGPRArgs, numGPRSources, numFPRArgs, numFPRSources, extraPoke> argSourceRegs, JSValue::JSCellTag, TrustedImmPtr payload, Args... args)
+    setupArgumentsImpl(ArgCollection<numGPRArgs, numGPRSources, numFPRArgs, numFPRSources, extraPoke> argSourceRegs, CellValue arg, Args... args)
     {
-        pokeForArgument(payload, numGPRArgs, numFPRArgs, extraPoke);
+        pokeForArgument(arg.gpr(), numGPRArgs, numFPRArgs, extraPoke);
         pokeForArgument(TrustedImm32(JSValue::CellTag), numGPRArgs, numFPRArgs, extraPoke + 1);
         setupArgumentsImpl<OperationType>(argSourceRegs.addGPRArg().addPoke(), args...);
     }
 
-    template<typename OperationType, unsigned numGPRArgs, unsigned numGPRSources, unsigned numFPRArgs, unsigned numFPRSources, unsigned extraPoke, typename... Args>
-    ALWAYS_INLINE std::enable_if_t<std::is_same<CURRENT_ARGUMENT_TYPE, EncodedJSValue>::value>
-    setupArgumentsImpl(ArgCollection<numGPRArgs, numGPRSources, numFPRArgs, numFPRSources, extraPoke> argSourceRegs, JSValueRegs arg, Args... args)
-    {
-        pokeForArgument(arg.payloadGPR(), numGPRArgs, numFPRArgs, extraPoke);
-        pokeForArgument(arg.tagGPR(), numGPRArgs, numFPRArgs, extraPoke + 1);
-        setupArgumentsImpl<OperationType>(argSourceRegs.addGPRArg().addPoke(), args...);
-    }
-
 #endif // USE(JSVALUE64)
 
     template<typename OperationType, unsigned numGPRArgs, unsigned numGPRSources, unsigned numFPRArgs, unsigned numFPRSources, unsigned extraPoke, typename Arg, typename... Args>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to