⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 271422 in webkit


Ignore:
Timestamp:
Jan 12, 2021, 4:09:16 PM (6 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Bypass OperationPtrTagging for JITCage verification for CallDOMGetter
https://bugs.webkit.org/show_bug.cgi?id=220564

Reviewed by Saam Barati.

JSTests:

  • stress/domjit-getter2.js: Added.

(shouldBe):
(access):

Source/JavaScriptCore:

CustomAccessorPtrTag functions are not registered ones for JITCage since we are using C++ trampoline to invoke them.
However, we do not want to use this trampoline in x64 due to performance issue. So we would like to call these
functions directly from JIT while they are not registered (And this is OK in JITCage since they are called from trampoline).
In this patch we bypass OperationPtrTagging by using WTF::tagNativeCodePtrImpl directly for non JITCage case.

  • dfg/DFGJITCompiler.h:

(JSC::DFG::JITCompiler::appendOperationCall):

  • dfg/DFGSpeculativeJIT.cpp:

(JSC::DFG::SpeculativeJIT::compileCallDOMGetter):

  • dfg/DFGSpeculativeJIT.h:

(JSC::DFG::SpeculativeJIT::appendOperationCall):

  • ftl/FTLLowerDFGToB3.cpp:

(JSC::FTL::DFG::LowerDFGToB3::compileCallDOMGetter):
(JSC::FTL::DFG::LowerDFGToB3::vmCall):

  • ftl/FTLOutput.h:

(JSC::FTL::Output::operation):

  • tools/JSDollarVM.cpp:
Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r271420 r271422  
     12021-01-12  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Bypass OperationPtrTagging for JITCage verification for CallDOMGetter
     4        https://bugs.webkit.org/show_bug.cgi?id=220564
     5
     6        Reviewed by Saam Barati.
     7
     8        * stress/domjit-getter2.js: Added.
     9        (shouldBe):
     10        (access):
     11
    1122021-01-12  Caio Lima  <ticaiolima@gmail.com>
    213
  • trunk/Source/JavaScriptCore/ChangeLog

    r271420 r271422  
     12021-01-12  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Bypass OperationPtrTagging for JITCage verification for CallDOMGetter
     4        https://bugs.webkit.org/show_bug.cgi?id=220564
     5
     6        Reviewed by Saam Barati.
     7
     8        CustomAccessorPtrTag functions are not registered ones for JITCage since we are using C++ trampoline to invoke them.
     9        However, we do not want to use this trampoline in x64 due to performance issue. So we would like to call these
     10        functions directly from JIT while they are not registered (And this is OK in JITCage since they are called from trampoline).
     11        In this patch we bypass OperationPtrTagging by using WTF::tagNativeCodePtrImpl directly for non JITCage case.
     12
     13        * dfg/DFGJITCompiler.h:
     14        (JSC::DFG::JITCompiler::appendOperationCall):
     15        * dfg/DFGSpeculativeJIT.cpp:
     16        (JSC::DFG::SpeculativeJIT::compileCallDOMGetter):
     17        * dfg/DFGSpeculativeJIT.h:
     18        (JSC::DFG::SpeculativeJIT::appendOperationCall):
     19        * ftl/FTLLowerDFGToB3.cpp:
     20        (JSC::FTL::DFG::LowerDFGToB3::compileCallDOMGetter):
     21        (JSC::FTL::DFG::LowerDFGToB3::vmCall):
     22        * ftl/FTLOutput.h:
     23        (JSC::FTL::Output::operation):
     24        * tools/JSDollarVM.cpp:
     25
    1262021-01-12  Caio Lima  <ticaiolima@gmail.com>
    227
  • trunk/Source/JavaScriptCore/dfg/DFGJITCompiler.h

    r262920 r271422  
    146146        return functionCall;
    147147    }
     148
     149    Call appendOperationCall(const FunctionPtr<OperationPtrTag> function)
     150    {
     151        Call functionCall = call(OperationPtrTag);
     152        m_calls.append(CallLinkRecord(functionCall, function));
     153        return functionCall;
     154    }
    148155   
    149156    void exceptionCheck();
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.cpp

    r270874 r271422  
    1012310123        if (Options::useJITCage())
    1012410124            m_jit.appendCall(vmEntryCustomAccessor);
    10125         else
    10126             m_jit.appendCall(getter.retagged<CFunctionPtrTag>());
     10125        else {
     10126            FunctionPtr<OperationPtrTag> bypassedFunction = FunctionPtr<OperationPtrTag>(MacroAssemblerCodePtr<OperationPtrTag>(WTF::tagNativeCodePtrImpl<OperationPtrTag>(WTF::untagNativeCodePtrImpl<CustomAccessorPtrTag>(getter.executableAddress()))));
     10127            m_jit.appendOperationCall(bypassedFunction);
     10128        }
    1012710129        m_jit.setupResults(resultRegs);
    1012810130
  • trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT.h

    r270874 r271422  
    985985        m_jit.emitStoreCodeOrigin(m_currentNode->origin.semantic);
    986986        return m_jit.appendCall(function);
     987    }
     988
     989    JITCompiler::Call appendOperationCall(const FunctionPtr<OperationPtrTag> function)
     990    {
     991        prepareForExternalCall();
     992        m_jit.emitStoreCodeOrigin(m_currentNode->origin.semantic);
     993        return m_jit.appendOperationCall(function);
    987994    }
    988995
  • trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp

    r271226 r271422  
    1450714507                    vmCall(Int64, vmEntryCustomAccessor, weakPointer(globalObject), lowCell(m_node->child1()), m_out.constIntPtr(m_graph.identifiers()[m_node->callDOMGetterData()->identifierNumber]), m_out.constIntPtr(m_node->callDOMGetterData()->customAccessorGetter.executableAddress())));
    1450814508            } else {
    14509                 setJSValue(
    14510                     vmCall(Int64, bitwise_cast<CustomGetterSetter::CustomGetter>(m_node->callDOMGetterData()->customAccessorGetter.retaggedExecutableAddress<CFunctionPtrTag>()),
    14511                         weakPointer(globalObject), lowCell(m_node->child1()), m_out.constIntPtr(m_graph.identifiers()[m_node->callDOMGetterData()->identifierNumber])));
     14509                FunctionPtr<CustomAccessorPtrTag> getter = m_node->callDOMGetterData()->customAccessorGetter;
     14510                FunctionPtr<OperationPtrTag> bypassedFunction = FunctionPtr<OperationPtrTag>(MacroAssemblerCodePtr<OperationPtrTag>(WTF::tagNativeCodePtrImpl<OperationPtrTag>(WTF::untagNativeCodePtrImpl<CustomAccessorPtrTag>(getter.executableAddress()))));
     14511                setJSValue(vmCall(Int64, bypassedFunction, weakPointer(globalObject), lowCell(m_node->child1()), m_out.constIntPtr(m_graph.identifiers()[m_node->callDOMGetterData()->identifierNumber])));
    1451214512            }
    1451314513            return;
     
    1910419104    {
    1910519105        static_assert(!std::is_same<OperationType, LValue>::value);
    19106         static_assert(FunctionTraits<OperationType>::cCallArity() == sizeof...(Args), "Sanity check");
     19106        if constexpr (!std::is_same_v<FunctionPtr<OperationPtrTag>, OperationType>)
     19107            static_assert(FunctionTraits<OperationType>::cCallArity() == sizeof...(Args), "Sanity check");
    1910719108        callPreflight();
    1910819109        LValue result = m_out.call(type, m_out.operation(function), std::forward<Args>(args)...);
  • trunk/Source/JavaScriptCore/ftl/FTLOutput.h

    r268247 r271422  
    403403    template<typename FunctionType>
    404404    LValue operation(FunctionType function) { return constIntPtr(tagCFunctionPtr<void*, OperationPtrTag>(function)); }
     405    LValue operation(FunctionPtr<OperationPtrTag> function) { return constIntPtr(function.executableAddress()); }
    405406
    406407    void jump(LBasicBlock);
  • trunk/Source/JavaScriptCore/tools/JSDollarVM.cpp

    r271269 r271422  
    988988    DollarVMAssertScope assertScope;
    989989    Base::finishCreation(vm);
    990     const DOMJIT::GetterSetter* domJIT = &DOMJITGetterDOMJIT;
    991     auto* customGetterSetter = DOMAttributeGetterSetter::create(vm, domJIT->getter(), nullptr, DOMAttributeAnnotation { DOMJITNode::info(), domJIT });
    992     putDirectCustomAccessor(vm, Identifier::fromString(vm, "customGetter"), customGetterSetter, PropertyAttribute::ReadOnly | PropertyAttribute::CustomAccessor);
     990    {
     991        const DOMJIT::GetterSetter* domJIT = &DOMJITGetterDOMJIT;
     992        auto* customGetterSetter = DOMAttributeGetterSetter::create(vm, domJIT->getter(), nullptr, DOMAttributeAnnotation { DOMJITNode::info(), domJIT });
     993        putDirectCustomAccessor(vm, Identifier::fromString(vm, "customGetter"), customGetterSetter, PropertyAttribute::ReadOnly | PropertyAttribute::CustomAccessor);
     994    }
     995    {
     996        auto* customGetterSetter = DOMAttributeGetterSetter::create(vm, domJITGetterCustomGetter, nullptr, DOMAttributeAnnotation { DOMJITNode::info(), nullptr });
     997        putDirectCustomAccessor(vm, Identifier::fromString(vm, "customGetter2"), customGetterSetter, PropertyAttribute::ReadOnly | PropertyAttribute::CustomAccessor);
     998    }
    993999}
    9941000
Note: See TracChangeset for help on using the changeset viewer.