Changeset 208070 in webkit


Ignore:
Timestamp:
Oct 28, 2016 2:33:30 PM (7 years ago)
Author:
Yusuke Suzuki
Message:

[DOMJIT] Implement Document::documentElement
https://bugs.webkit.org/show_bug.cgi?id=164113

Reviewed by Sam Weinig.

Source/WebCore:

Test: js/dom/domjit-accessor-document-element.html

This patch implements document.documentElement DOMJIT accessor.
Similar to ownerDocument accessor, the way to access to document.documentElement
from JIT code is already prepared for CSSJIT. DOMJIT just utilizes the existing
functionality: using documentElementMemoryOffset().

document.documentElement is frequently called in jQuery. Especially, every time
we call jQuery.attr(), this is called.

To implement Document accessor, we clean up some code in DOMJITHelpers.
We create the cpp file for DOMJITHelpers and move some helpers to it.
And we also implement DOMJIT::checkDOM<DOMInterface> for convenience.
It returns appropriate CheckDOM patchpoint implementation.

This patch improves Dromaeo jslib-attr-jquery.html 10% (481.64 v.s. 532.54).

  • CMakeLists.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • cssjit/SelectorCompiler.cpp:

(WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsScopeRoot):

  • dom/Document.idl:
  • domjit/DOMJITAbstractHeapRepository.h:
  • domjit/DOMJITCheckDOM.h: Copied from Source/WebCore/domjit/DOMJITAbstractHeapRepository.h.

(WebCore::DOMJIT::TypeChecker<Node>::branchIfFail):
(WebCore::DOMJIT::TypeChecker<Document>::branchIfFail):
(WebCore::DOMJIT::TypeChecker<Event>::branchIfFail):
(WebCore::DOMJIT::TypeChecker<Element>::branchIfFail):
(WebCore::DOMJIT::checkDOM):

  • domjit/DOMJITHelpers.cpp: Copied from Source/WebCore/domjit/DOMJITAbstractHeapRepository.h.

(WebCore::DOMJIT::loadDocument):
(WebCore::DOMJIT::loadDocumentElement):

  • domjit/DOMJITHelpers.h:

(WebCore::DOMJIT::toWrapperSlow):
(WebCore::DOMJIT::loadDocument): Deleted.

  • domjit/JSDocumentDOMJIT.cpp: Added.

(WebCore::DocumentDocumentElementDOMJIT::checkDOM):
(WebCore::DocumentDocumentElementDOMJIT::callDOM):

  • domjit/JSNodeDOMJIT.cpp:

(WebCore::createCallDOMForOffsetAccess):
(WebCore::NodeFirstChildDOMJIT::checkDOM):
(WebCore::NodeLastChildDOMJIT::checkDOM):
(WebCore::NodeNextSiblingDOMJIT::checkDOM):
(WebCore::NodePreviousSiblingDOMJIT::checkDOM):
(WebCore::NodeParentNodeDOMJIT::checkDOM):
(WebCore::NodeNodeTypeDOMJIT::checkDOM):
(WebCore::NodeOwnerDocumentDOMJIT::checkDOM):
(WebCore::NodeOwnerDocumentDOMJIT::callDOM):
(WebCore::toWrapperSlow): Deleted.
(WebCore::checkNode): Deleted.

LayoutTests:

  • js/dom/domjit-accessor-document-element-changed-expected.txt: Added.
  • js/dom/domjit-accessor-document-element-changed.html: Added.
  • js/dom/domjit-accessor-document-element-expected.txt: Added.
  • js/dom/domjit-accessor-document-element.html: Added.
Location:
trunk
Files:
5 added
9 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r208058 r208070  
     12016-10-28  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [DOMJIT] Implement Document::documentElement
     4        https://bugs.webkit.org/show_bug.cgi?id=164113
     5
     6        Reviewed by Sam Weinig.
     7
     8        * js/dom/domjit-accessor-document-element-changed-expected.txt: Added.
     9        * js/dom/domjit-accessor-document-element-changed.html: Added.
     10        * js/dom/domjit-accessor-document-element-expected.txt: Added.
     11        * js/dom/domjit-accessor-document-element.html: Added.
     12
    1132016-10-28  Simon Fraser  <simon.fraser@apple.com>
    214
  • trunk/Source/WebCore/CMakeLists.txt

    r208036 r208070  
    15461546
    15471547    domjit/DOMJITAbstractHeapRepository.cpp
     1548    domjit/DOMJITHelpers.cpp
     1549    domjit/JSDocumentDOMJIT.cpp
    15481550    domjit/JSNodeDOMJIT.cpp
    15491551
  • trunk/Source/WebCore/ChangeLog

    r208069 r208070  
     12016-10-28  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        [DOMJIT] Implement Document::documentElement
     4        https://bugs.webkit.org/show_bug.cgi?id=164113
     5
     6        Reviewed by Sam Weinig.
     7
     8        Test: js/dom/domjit-accessor-document-element.html
     9
     10        This patch implements document.documentElement DOMJIT accessor.
     11        Similar to ownerDocument accessor, the way to access to document.documentElement
     12        from JIT code is already prepared for CSSJIT. DOMJIT just utilizes the existing
     13        functionality: using documentElementMemoryOffset().
     14
     15        document.documentElement is frequently called in jQuery. Especially, every time
     16        we call jQuery.attr(), this is called.
     17
     18        To implement Document accessor, we clean up some code in DOMJITHelpers.
     19        We create the cpp file for DOMJITHelpers and move some helpers to it.
     20        And we also implement DOMJIT::checkDOM<DOMInterface> for convenience.
     21        It returns appropriate CheckDOM patchpoint implementation.
     22
     23        This patch improves Dromaeo jslib-attr-jquery.html 10% (481.64 v.s. 532.54).
     24
     25        * CMakeLists.txt:
     26        * WebCore.xcodeproj/project.pbxproj:
     27        * cssjit/SelectorCompiler.cpp:
     28        (WebCore::SelectorCompiler::SelectorCodeGenerator::generateElementIsScopeRoot):
     29        * dom/Document.idl:
     30        * domjit/DOMJITAbstractHeapRepository.h:
     31        * domjit/DOMJITCheckDOM.h: Copied from Source/WebCore/domjit/DOMJITAbstractHeapRepository.h.
     32        (WebCore::DOMJIT::TypeChecker<Node>::branchIfFail):
     33        (WebCore::DOMJIT::TypeChecker<Document>::branchIfFail):
     34        (WebCore::DOMJIT::TypeChecker<Event>::branchIfFail):
     35        (WebCore::DOMJIT::TypeChecker<Element>::branchIfFail):
     36        (WebCore::DOMJIT::checkDOM):
     37        * domjit/DOMJITHelpers.cpp: Copied from Source/WebCore/domjit/DOMJITAbstractHeapRepository.h.
     38        (WebCore::DOMJIT::loadDocument):
     39        (WebCore::DOMJIT::loadDocumentElement):
     40        * domjit/DOMJITHelpers.h:
     41        (WebCore::DOMJIT::toWrapperSlow):
     42        (WebCore::DOMJIT::loadDocument): Deleted.
     43        * domjit/JSDocumentDOMJIT.cpp: Added.
     44        (WebCore::DocumentDocumentElementDOMJIT::checkDOM):
     45        (WebCore::DocumentDocumentElementDOMJIT::callDOM):
     46        * domjit/JSNodeDOMJIT.cpp:
     47        (WebCore::createCallDOMForOffsetAccess):
     48        (WebCore::NodeFirstChildDOMJIT::checkDOM):
     49        (WebCore::NodeLastChildDOMJIT::checkDOM):
     50        (WebCore::NodeNextSiblingDOMJIT::checkDOM):
     51        (WebCore::NodePreviousSiblingDOMJIT::checkDOM):
     52        (WebCore::NodeParentNodeDOMJIT::checkDOM):
     53        (WebCore::NodeNodeTypeDOMJIT::checkDOM):
     54        (WebCore::NodeOwnerDocumentDOMJIT::checkDOM):
     55        (WebCore::NodeOwnerDocumentDOMJIT::callDOM):
     56        (WebCore::toWrapperSlow): Deleted.
     57        (WebCore::checkNode): Deleted.
     58
    1592016-10-28  Dave Hyatt  <hyatt@apple.com>
    260
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r208042 r208070  
    62086208                E38838981BAD145F00D62EE3 /* ScriptModuleLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38838941BAD145F00D62EE3 /* ScriptModuleLoader.cpp */; };
    62096209                E38838991BAD145F00D62EE3 /* ScriptModuleLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */; };
     6210                E398FC241DC32A20003C4684 /* DOMJITHelpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E398FC231DC32A1B003C4684 /* DOMJITHelpers.cpp */; };
    62106211                E3B2F0EB1D7F4C9D00B0C9D1 /* LoadableClassicScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3B2F0E31D7F35EC00B0C9D1 /* LoadableClassicScript.cpp */; };
    62116212                E3B2F0EC1D7F4CA100B0C9D1 /* LoadableScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3B2F0E91D7F3D3C00B0C9D1 /* LoadableScript.cpp */; };
     
    62136214                E3B2F0EE1D7F4CA900B0C9D1 /* LoadableScriptClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E3B2F0E81D7F35EC00B0C9D1 /* LoadableScriptClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    62146215                E3B2F0F01D7F4CB500B0C9D1 /* LoadableClassicScript.h in Headers */ = {isa = PBXBuildFile; fileRef = E3B2F0E41D7F35EC00B0C9D1 /* LoadableClassicScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
     6216                E3B7C0631DC34160001FB0B8 /* JSDocumentDOMJIT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3B7C0621DC3415A001FB0B8 /* JSDocumentDOMJIT.cpp */; };
     6217                E3C99A091DC3D41C00794AD3 /* DOMJITCheckDOM.h in Headers */ = {isa = PBXBuildFile; fileRef = E3C99A081DC3D41700794AD3 /* DOMJITCheckDOM.h */; };
    62156218                E3FA38641D71812D00AA5950 /* PendingScriptClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E3FA38611D716E7600AA5950 /* PendingScriptClient.h */; };
    62166219                E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    1403914042                E38838941BAD145F00D62EE3 /* ScriptModuleLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptModuleLoader.cpp; sourceTree = "<group>"; };
    1404014043                E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptModuleLoader.h; sourceTree = "<group>"; };
     14044                E398FC231DC32A1B003C4684 /* DOMJITHelpers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMJITHelpers.cpp; sourceTree = "<group>"; };
    1404114045                E3AFA9641DA6E908002861BD /* JSNodeDOMJIT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeDOMJIT.cpp; sourceTree = "<group>"; };
    1404214046                E3B2F0E31D7F35EC00B0C9D1 /* LoadableClassicScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadableClassicScript.cpp; sourceTree = "<group>"; };
     
    1404514049                E3B2F0E81D7F35EC00B0C9D1 /* LoadableScriptClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadableScriptClient.h; sourceTree = "<group>"; };
    1404614050                E3B2F0E91D7F3D3C00B0C9D1 /* LoadableScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadableScript.cpp; sourceTree = "<group>"; };
     14051                E3B7C0621DC3415A001FB0B8 /* JSDocumentDOMJIT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentDOMJIT.cpp; sourceTree = "<group>"; };
     14052                E3C99A081DC3D41700794AD3 /* DOMJITCheckDOM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITCheckDOM.h; sourceTree = "<group>"; };
    1404714053                E3D049931DADC04500718F3C /* NodeConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeConstants.h; sourceTree = "<group>"; };
    1404814054                E3FA38611D716E7600AA5950 /* PendingScriptClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PendingScriptClient.h; sourceTree = "<group>"; };
     
    2282322829                                E35CA14B1DBC3A3C00F83516 /* DOMJITAbstractHeapRepository.cpp */,
    2282422830                                E35CA14C1DBC3A3C00F83516 /* DOMJITAbstractHeapRepository.h */,
     22831                                E3C99A081DC3D41700794AD3 /* DOMJITCheckDOM.h */,
     22832                                E398FC231DC32A1B003C4684 /* DOMJITHelpers.cpp */,
    2282522833                                E3150EA51DA7218D00194012 /* DOMJITHelpers.h */,
     22834                                E3B7C0621DC3415A001FB0B8 /* JSDocumentDOMJIT.cpp */,
    2282622835                                E3AFA9641DA6E908002861BD /* JSNodeDOMJIT.cpp */,
    2282722836                        );
     
    2739827407                                B2227A910D00BF220071B782 /* SVGPolygonElement.h in Headers */,
    2739927408                                B2227A940D00BF220071B782 /* SVGPolylineElement.h in Headers */,
     27409                                E3C99A091DC3D41C00794AD3 /* DOMJITCheckDOM.h in Headers */,
    2740027410                                B2227A970D00BF220071B782 /* SVGPreserveAspectRatio.h in Headers */,
    2740127411                                088A0E0A126EF1DB00978F7A /* SVGProperty.h in Headers */,
     
    2902729037                                A8EA7D310A19385500A8EF5F /* HTMLImageElement.cpp in Sources */,
    2902829038                                A8EA7D300A19385500A8EF5F /* HTMLImageLoader.cpp in Sources */,
     29039                                E3B7C0631DC34160001FB0B8 /* JSDocumentDOMJIT.cpp in Sources */,
    2902929040                                A81369CD097374F600D74463 /* HTMLInputElement.cpp in Sources */,
    2903029041                                93309DE5099E64920056E581 /* HTMLInterchange.cpp in Sources */,
     
    2933529346                                9BE6710B1D5AEB2100345514 /* JSCustomElementRegistry.cpp in Sources */,
    2933629347                                9BC5F9E01D5AAF6B002B749D /* JSCustomElementRegistryCustom.cpp in Sources */,
     29348                                E398FC241DC32A20003C4684 /* DOMJITHelpers.cpp in Sources */,
    2933729349                                E4778B7F115A581A00B5D372 /* JSCustomEvent.cpp in Sources */,
    2933829350                                DEC297611B4F2F8D005F5945 /* JSCustomEventCustom.cpp in Sources */,
  • trunk/Source/WebCore/cssjit/SelectorCompiler.cpp

    r207999 r208070  
    37913791
    37923792    DOMJIT::loadDocument(m_assembler, elementAddressRegister, scope);
    3793     m_assembler.loadPtr(Assembler::Address(scope, Document::documentElementMemoryOffset()), scope);
     3793    DOMJIT::loadDocumentElement(m_assembler, scope, scope);
    37943794
    37953795    scopeIsNotNull.link(&m_assembler);
  • trunk/Source/WebCore/dom/Document.idl

    r207571 r208070  
    3030    readonly attribute DocumentType? doctype;
    3131    readonly attribute DOMImplementation implementation;
    32     readonly attribute Element? documentElement;
     32    [DOMJIT] readonly attribute Element? documentElement;
    3333
    3434    [NewObject, MayThrowLegacyException, ImplementedAs=createElementForBindings] Element createElement(DOMString tagName);
  • trunk/Source/WebCore/domjit/DOMJITAbstractHeapRepository.h

    r207932 r208070  
    4444    V(Node_previousSibling, Node) \
    4545    V(Node_ownerDocument, Node) \
     46    V(Document, DOM) \
     47    V(Document_documentElement, Document) \
    4648
    4749
  • trunk/Source/WebCore/domjit/DOMJITCheckDOM.h

    r208069 r208070  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    2323 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24 *
    2425 */
    2526
    2627#pragma once
    2728
    28 #include <domjit/DOMJITHeapRange.h>
    29 #include <wtf/NeverDestroyed.h>
    30 #include <wtf/Noncopyable.h>
     29#include "DOMJITHelpers.h"
    3130
    3231#if ENABLE(JIT)
    3332
     33#include "Document.h"
     34#include "Element.h"
     35#include "Event.h"
     36#include "Node.h"
     37
    3438namespace WebCore { namespace DOMJIT {
    3539
    36 // Describe your abstract heap hierarchy here.
    37 // V(AbstractHeapName, Parent)
    38 #define DOMJIT_ABSTRACT_HEAP_LIST(V) \
    39     V(Node, DOM) \
    40     V(Node_firstChild, Node) \
    41     V(Node_lastChild, Node) \
    42     V(Node_parentNode, Node) \
    43     V(Node_nextSibling, Node) \
    44     V(Node_previousSibling, Node) \
    45     V(Node_ownerDocument, Node) \
     40template<typename DOMInterface>
     41struct TypeChecker {
     42};
    4643
     44template<>
     45struct TypeChecker<Node> {
     46    static CCallHelpers::Jump branchIfFail(CCallHelpers& jit, GPRReg dom)
     47    {
     48        return DOMJIT::branchIfNotNode(jit, dom);
     49    }
     50};
    4751
    48 class AbstractHeapRepository {
    49     WTF_MAKE_NONCOPYABLE(AbstractHeapRepository);
    50 public:
    51     static const AbstractHeapRepository& shared();
     52template<>
     53struct TypeChecker<Document> {
     54    static CCallHelpers::Jump branchIfFail(CCallHelpers& jit, GPRReg dom)
     55    {
     56        return DOMJIT::branchIfNotDocumentWrapper(jit, dom);
     57    }
     58};
    5259
    53     JSC::DOMJIT::HeapRange DOM;
     60template<>
     61struct TypeChecker<Event> {
     62    static CCallHelpers::Jump branchIfFail(CCallHelpers& jit, GPRReg dom)
     63    {
     64        return DOMJIT::branchIfNotEvent(jit, dom);
     65    }
     66};
    5467
    55 #define DOMJIT_DEFINE_MEMBER(name, parent) JSC::DOMJIT::HeapRange name;
    56     DOMJIT_ABSTRACT_HEAP_LIST(DOMJIT_DEFINE_MEMBER)
    57 #undef DOMJIT_DEFINE_MEMBER
     68template<>
     69struct TypeChecker<Element> {
     70    static CCallHelpers::Jump branchIfFail(CCallHelpers& jit, GPRReg dom)
     71    {
     72        return DOMJIT::branchIfNotElement(jit, dom);
     73    }
     74};
    5875
    59     AbstractHeapRepository();
    60 };
     76template<typename DOMInterface>
     77Ref<JSC::DOMJIT::Patchpoint> checkDOM()
     78{
     79    Ref<JSC::DOMJIT::Patchpoint> patchpoint = JSC::DOMJIT::Patchpoint::create();
     80    patchpoint->setGenerator([=](CCallHelpers& jit, JSC::DOMJIT::PatchpointParams& params) {
     81        return TypeChecker<DOMInterface>::branchIfFail(jit, params[0].gpr());
     82    });
     83    return patchpoint;
     84}
    6185
    6286} }
  • trunk/Source/WebCore/domjit/DOMJITHelpers.cpp

    r208069 r208070  
    11/*
    2  * Copyright (C) 2016 Apple Inc. All rights reserved.
     2 * Copyright (C) 2016 Apple Inc. All Rights Reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #pragma once
    27 
    28 #include <domjit/DOMJITHeapRange.h>
    29 #include <wtf/NeverDestroyed.h>
    30 #include <wtf/Noncopyable.h>
     26#include "config.h"
     27#include "DOMJITHelpers.h"
    3128
    3229#if ENABLE(JIT)
    3330
     31#include "Document.h"
     32#include "JSDOMBinding.h"
     33#include "Node.h"
     34
    3435namespace WebCore { namespace DOMJIT {
    3536
    36 // Describe your abstract heap hierarchy here.
    37 // V(AbstractHeapName, Parent)
    38 #define DOMJIT_ABSTRACT_HEAP_LIST(V) \
    39     V(Node, DOM) \
    40     V(Node_firstChild, Node) \
    41     V(Node_lastChild, Node) \
    42     V(Node_parentNode, Node) \
    43     V(Node_nextSibling, Node) \
    44     V(Node_previousSibling, Node) \
    45     V(Node_ownerDocument, Node) \
     37using JSC::CCallHelpers;
     38using JSC::GPRReg;
     39using JSC::JSValueRegs;
     40using JSC::MacroAssembler;
    4641
     42void loadDocument(MacroAssembler& jit, GPRReg node, GPRReg output)
     43{
     44    jit.loadPtr(CCallHelpers::Address(node, Node::treeScopeMemoryOffset()), output);
     45    jit.loadPtr(CCallHelpers::Address(output, TreeScope::documentScopeMemoryOffset()), output);
     46}
    4747
    48 class AbstractHeapRepository {
    49     WTF_MAKE_NONCOPYABLE(AbstractHeapRepository);
    50 public:
    51     static const AbstractHeapRepository& shared();
    52 
    53     JSC::DOMJIT::HeapRange DOM;
    54 
    55 #define DOMJIT_DEFINE_MEMBER(name, parent) JSC::DOMJIT::HeapRange name;
    56     DOMJIT_ABSTRACT_HEAP_LIST(DOMJIT_DEFINE_MEMBER)
    57 #undef DOMJIT_DEFINE_MEMBER
    58 
    59     AbstractHeapRepository();
    60 };
     48void loadDocumentElement(MacroAssembler& jit, GPRReg document, GPRReg output)
     49{
     50    jit.loadPtr(CCallHelpers::Address(document, Document::documentElementMemoryOffset()), output);
     51}
    6152
    6253} }
  • trunk/Source/WebCore/domjit/DOMJITHelpers.h

    r208028 r208070  
    2828
    2929#include "JSDOMWrapper.h"
     30#include "ScriptWrappable.h"
    3031#include <domjit/DOMJITPatchpoint.h>
    3132#include <domjit/DOMJITPatchpointParams.h>
     33#include <interpreter/FrameTracers.h>
    3234
    3335#if ENABLE(JIT)
     
    5052{
    5153    return jit.branchTestPtr(CCallHelpers::NonZero, CCallHelpers::Address(weakImpl, JSC::WeakImpl::offsetOfWeakHandleOwner()), CCallHelpers::TrustedImm32(JSC::WeakImpl::StateMask));
     54}
     55
     56template<typename WrappedNode>
     57JSC::EncodedJSValue JIT_OPERATION toWrapperSlow(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject, void* result)
     58{
     59    ASSERT(exec);
     60    ASSERT(result);
     61    ASSERT(globalObject);
     62    JSC::NativeCallFrameTracer tracer(&exec->vm(), exec);
     63    return JSC::JSValue::encode(toJS(exec, static_cast<JSDOMGlobalObject*>(globalObject), *static_cast<WrappedNode*>(result)));
    5264}
    5365
     
    151163}
    152164
    153 inline void loadDocument(MacroAssembler& jit, GPRReg node, GPRReg output)
    154 {
    155     jit.loadPtr(CCallHelpers::Address(node, Node::treeScopeMemoryOffset()), output);
    156     jit.loadPtr(CCallHelpers::Address(output, TreeScope::documentScopeMemoryOffset()), output);
    157 }
     165void loadDocument(MacroAssembler&, GPRReg node, GPRReg output);
     166void loadDocumentElement(MacroAssembler&, GPRReg document, GPRReg output);
    158167
    159168} }
  • trunk/Source/WebCore/domjit/JSNodeDOMJIT.cpp

    r207999 r208070  
    3030
    3131#include "DOMJITAbstractHeapRepository.h"
     32#include "DOMJITCheckDOM.h"
    3233#include "DOMJITHelpers.h"
    3334#include "JSDOMWrapper.h"
     
    4243
    4344enum class IsContainerGuardRequirement { Required, NotRequired };
    44 
    45 template<typename WrappedNode>
    46 EncodedJSValue JIT_OPERATION toWrapperSlow(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject, void* result)
    47 {
    48     ASSERT(exec);
    49     ASSERT(result);
    50     ASSERT(globalObject);
    51     JSC::NativeCallFrameTracer tracer(&exec->vm(), exec);
    52     return JSValue::encode(toJS(exec, static_cast<JSDOMGlobalObject*>(globalObject), *static_cast<WrappedNode*>(result)));
    53 }
    5445
    5546template<typename WrappedNode>
     
    7566        nullCases.append(jit.branchTestPtr(CCallHelpers::Zero, scratch));
    7667
    77         DOMJIT::toWrapper<WrappedNode>(jit, params, scratch, globalObject, result, toWrapperSlow<WrappedNode>, globalObjectValue);
     68        DOMJIT::toWrapper<WrappedNode>(jit, params, scratch, globalObject, result, DOMJIT::toWrapperSlow<WrappedNode>, globalObjectValue);
    7869        CCallHelpers::Jump done = jit.jump();
    7970
     
    8677}
    8778
    88 static Ref<JSC::DOMJIT::Patchpoint> checkNode()
    89 {
    90     Ref<JSC::DOMJIT::Patchpoint> patchpoint = JSC::DOMJIT::Patchpoint::create();
    91     patchpoint->setGenerator([=](CCallHelpers& jit, JSC::DOMJIT::PatchpointParams& params) {
    92         CCallHelpers::JumpList failureCases;
    93         failureCases.append(DOMJIT::branchIfNotNode(jit, params[0].gpr()));
    94         return failureCases;
    95     });
    96     return patchpoint;
    97 }
    98 
    9979Ref<JSC::DOMJIT::Patchpoint> NodeFirstChildDOMJIT::checkDOM()
    10080{
    101     return checkNode();
     81    return DOMJIT::checkDOM<Node>();
    10282}
    10383
     
    11292Ref<JSC::DOMJIT::Patchpoint> NodeLastChildDOMJIT::checkDOM()
    11393{
    114     return checkNode();
     94    return DOMJIT::checkDOM<Node>();
    11595}
    11696
     
    125105Ref<JSC::DOMJIT::Patchpoint> NodeNextSiblingDOMJIT::checkDOM()
    126106{
    127     return checkNode();
     107    return DOMJIT::checkDOM<Node>();
    128108}
    129109
     
    138118Ref<JSC::DOMJIT::Patchpoint> NodePreviousSiblingDOMJIT::checkDOM()
    139119{
    140     return checkNode();
     120    return DOMJIT::checkDOM<Node>();
    141121}
    142122
     
    151131Ref<JSC::DOMJIT::Patchpoint> NodeParentNodeDOMJIT::checkDOM()
    152132{
    153     return checkNode();
     133    return DOMJIT::checkDOM<Node>();
    154134}
    155135
     
    164144Ref<JSC::DOMJIT::Patchpoint> NodeNodeTypeDOMJIT::checkDOM()
    165145{
    166     return checkNode();
     146    return DOMJIT::checkDOM<Node>();
    167147}
    168148
     
    185165Ref<JSC::DOMJIT::Patchpoint> NodeOwnerDocumentDOMJIT::checkDOM()
    186166{
    187     return checkNode();
     167    return DOMJIT::checkDOM<Node>();
    188168}
    189169
     
    208188        jit.loadPtr(CCallHelpers::Address(node, JSNode::offsetOfWrapped()), scratch);
    209189        DOMJIT::loadDocument(jit, scratch, scratch);
    210         DOMJIT::toWrapper<Document>(jit, params, scratch, globalObject, result, toWrapperSlow<Document>, globalObjectValue);
     190        DOMJIT::toWrapper<Document>(jit, params, scratch, globalObject, result, DOMJIT::toWrapperSlow<Document>, globalObjectValue);
    211191        done.link(&jit);
    212192        return CCallHelpers::JumpList();
Note: See TracChangeset for help on using the changeset viewer.