haikuwebkit/Source/WebCore/domjit/DOMJITHelpers.cpp

56 lines
2.0 KiB
C++
Raw Permalink Normal View History

[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. Canonical link: https://commits.webkit.org/181855@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208070 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-10-28 21:33:30 +00:00
/*
* Copyright (C) 2016 Apple Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "DOMJITHelpers.h"
#if ENABLE(JIT)
#include "Document.h"
#include "JSDOMBinding.h"
#include "Node.h"
namespace WebCore { namespace DOMJIT {
using JSC::CCallHelpers;
using JSC::GPRReg;
using JSC::JSValueRegs;
using JSC::MacroAssembler;
void loadDocument(MacroAssembler& jit, GPRReg node, GPRReg output)
{
jit.loadPtr(CCallHelpers::Address(node, Node::treeScopeMemoryOffset()), output);
jit.loadPtr(CCallHelpers::Address(output, TreeScope::documentScopeMemoryOffset()), output);
}
void loadDocumentElement(MacroAssembler& jit, GPRReg document, GPRReg output)
{
jit.loadPtr(CCallHelpers::Address(document, Document::documentElementMemoryOffset()), output);
}
} }
#endif