Diff
Modified: trunk/LayoutTests/ChangeLog (208069 => 208070)
--- trunk/LayoutTests/ChangeLog 2016-10-28 21:12:41 UTC (rev 208069)
+++ trunk/LayoutTests/ChangeLog 2016-10-28 21:33:30 UTC (rev 208070)
@@ -1,3 +1,15 @@
+2016-10-28 Yusuke Suzuki <utatane....@gmail.com>
+
+ [DOMJIT] Implement Document::documentElement
+ https://bugs.webkit.org/show_bug.cgi?id=164113
+
+ Reviewed by Sam Weinig.
+
+ * 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.
+
2016-10-28 Simon Fraser <simon.fra...@apple.com>
Wrong blur radius for filter: drop-shadow()
Added: trunk/LayoutTests/js/dom/domjit-accessor-document-element-changed-expected.txt (0 => 208070)
--- trunk/LayoutTests/js/dom/domjit-accessor-document-element-changed-expected.txt (rev 0)
+++ trunk/LayoutTests/js/dom/domjit-accessor-document-element-changed-expected.txt 2016-10-28 21:33:30 UTC (rev 208070)
@@ -0,0 +1,11 @@
+Test DOMJIT documentElement accessor works after the documentElement is changed.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testNull(target, result) is false
+PASS testNull(target, result) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/js/dom/domjit-accessor-document-element-changed.html (0 => 208070)
--- trunk/LayoutTests/js/dom/domjit-accessor-document-element-changed.html (rev 0)
+++ trunk/LayoutTests/js/dom/domjit-accessor-document-element-changed.html 2016-10-28 21:33:30 UTC (rev 208070)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+description('Test DOMJIT documentElement accessor works after the documentElement is changed.');
+
+var target = null;
+var result = null;
+
+function testNull(element, result)
+{
+ return element.documentElement === result;
+}
+
+function runTest()
+{
+ target = document.implementation.createDocument('', null, null);
+ var element = target.createElement('html');
+ result = null;
+ for (var i = 0; i < 1e4; ++i)
+ shouldBeTrueQuiet(`testNull(target, result)`);
+
+ target.appendChild(element);
+ shouldBeFalse(`testNull(target, result)`);
+ result = element;
+ shouldBeTrue(`testNull(target, result)`);
+
+}
+runTest();
+</script>
+<script src=""
+</body>
+</html>
Added: trunk/LayoutTests/js/dom/domjit-accessor-document-element-expected.txt (0 => 208070)
--- trunk/LayoutTests/js/dom/domjit-accessor-document-element-expected.txt (rev 0)
+++ trunk/LayoutTests/js/dom/domjit-accessor-document-element-expected.txt 2016-10-28 21:33:30 UTC (rev 208070)
@@ -0,0 +1,39 @@
+Test DOMJIT documentElement accessor works.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+PASS (
+ function testHTMLDocument(element, result)
+ {
+ for (var i = 0; i < 1e4; ++i) {
+ if (element.documentElement !== result)
+ return false;
+ }
+ return true;
+ }
+ )(target, result) is true
+PASS (
+ function testXMLDocument(element, result)
+ {
+ for (var i = 0; i < 1e4; ++i) {
+ if (element.documentElement !== result)
+ return false;
+ }
+ return true;
+ }
+ )(target, result) is true
+PASS (
+ function testNull(element, result)
+ {
+ for (var i = 0; i < 1e4; ++i) {
+ if (element.documentElement !== result)
+ return false;
+ }
+ return true;
+ }
+ )(target, result) is true
+
Added: trunk/LayoutTests/js/dom/domjit-accessor-document-element.html (0 => 208070)
--- trunk/LayoutTests/js/dom/domjit-accessor-document-element.html (rev 0)
+++ trunk/LayoutTests/js/dom/domjit-accessor-document-element.html 2016-10-28 21:33:30 UTC (rev 208070)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<iframe id="xmlframe" _onload_="frameLoaded()" style="height:0px" src="" version='1.0' encoding='UTF-8'?><body/>"></iframe>
+<script>
+description('Test DOMJIT documentElement accessor works.');
+
+if (window.testRunner)
+ testRunner.waitUntilDone();
+
+var target = null;
+var result = null;
+function runTest()
+{
+ var xmlDocument = document.getElementById('xmlframe').contentDocument;
+ var targets = [
+ ['HTMLDocument', document, document.firstElementChild],
+ ['XMLDocument', xmlDocument, xmlDocument.firstElementChild],
+ ['Null', document.implementation.createDocument('', null, null), null],
+ ];
+
+ for ([name, target, result] of targets) {
+ var text = `
+ function test${name}(element, result)
+ {
+ for (var i = 0; i < 1e4; ++i) {
+ if (element.documentElement !== result)
+ return false;
+ }
+ return true;
+ }
+ `;
+ shouldBeTrue(`(${text})(target, result)`);
+ }
+
+ if (window.testRunner)
+ testRunner.notifyDone();
+}
+function frameLoaded()
+{
+ runTest();
+}
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/CMakeLists.txt (208069 => 208070)
--- trunk/Source/WebCore/CMakeLists.txt 2016-10-28 21:12:41 UTC (rev 208069)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-10-28 21:33:30 UTC (rev 208070)
@@ -1545,6 +1545,8 @@
dom/default/PlatformMessagePortChannel.cpp
domjit/DOMJITAbstractHeapRepository.cpp
+ domjit/DOMJITHelpers.cpp
+ domjit/JSDocumentDOMJIT.cpp
domjit/JSNodeDOMJIT.cpp
editing/AlternativeTextController.cpp
Modified: trunk/Source/WebCore/ChangeLog (208069 => 208070)
--- trunk/Source/WebCore/ChangeLog 2016-10-28 21:12:41 UTC (rev 208069)
+++ trunk/Source/WebCore/ChangeLog 2016-10-28 21:33:30 UTC (rev 208070)
@@ -1,3 +1,61 @@
+2016-10-28 Yusuke Suzuki <utatane....@gmail.com>
+
+ [DOMJIT] Implement Document::documentElement
+ https://bugs.webkit.org/show_bug.cgi?id=164113
+
+ Reviewed by Sam Weinig.
+
+ 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.
+
2016-10-28 Dave Hyatt <hy...@apple.com>
[CSS Parser] Support initial-letter
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (208069 => 208070)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-10-28 21:12:41 UTC (rev 208069)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-10-28 21:33:30 UTC (rev 208070)
@@ -6207,11 +6207,14 @@
E377FE4D1DADE16500CDD025 /* NodeConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = E3D049931DADC04500718F3C /* NodeConstants.h */; settings = {ATTRIBUTES = (Private, ); }; };
E38838981BAD145F00D62EE3 /* ScriptModuleLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E38838941BAD145F00D62EE3 /* ScriptModuleLoader.cpp */; };
E38838991BAD145F00D62EE3 /* ScriptModuleLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */; };
+ E398FC241DC32A20003C4684 /* DOMJITHelpers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E398FC231DC32A1B003C4684 /* DOMJITHelpers.cpp */; };
E3B2F0EB1D7F4C9D00B0C9D1 /* LoadableClassicScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3B2F0E31D7F35EC00B0C9D1 /* LoadableClassicScript.cpp */; };
E3B2F0EC1D7F4CA100B0C9D1 /* LoadableScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3B2F0E91D7F3D3C00B0C9D1 /* LoadableScript.cpp */; };
E3B2F0ED1D7F4CA300B0C9D1 /* LoadableScript.h in Headers */ = {isa = PBXBuildFile; fileRef = E3B2F0E71D7F35EC00B0C9D1 /* LoadableScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
E3B2F0EE1D7F4CA900B0C9D1 /* LoadableScriptClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E3B2F0E81D7F35EC00B0C9D1 /* LoadableScriptClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
E3B2F0F01D7F4CB500B0C9D1 /* LoadableClassicScript.h in Headers */ = {isa = PBXBuildFile; fileRef = E3B2F0E41D7F35EC00B0C9D1 /* LoadableClassicScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ E3B7C0631DC34160001FB0B8 /* JSDocumentDOMJIT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E3B7C0621DC3415A001FB0B8 /* JSDocumentDOMJIT.cpp */; };
+ E3C99A091DC3D41C00794AD3 /* DOMJITCheckDOM.h in Headers */ = {isa = PBXBuildFile; fileRef = E3C99A081DC3D41700794AD3 /* DOMJITCheckDOM.h */; };
E3FA38641D71812D00AA5950 /* PendingScriptClient.h in Headers */ = {isa = PBXBuildFile; fileRef = E3FA38611D716E7600AA5950 /* PendingScriptClient.h */; };
E401C27517CE53EC00C41A35 /* ElementIteratorAssertions.h in Headers */ = {isa = PBXBuildFile; fileRef = E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */; settings = {ATTRIBUTES = (Private, ); }; };
E401E0A41C3C0B8300F34D10 /* StyleChange.h in Headers */ = {isa = PBXBuildFile; fileRef = E401E0A31C3C0B8300F34D10 /* StyleChange.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -14038,6 +14041,7 @@
E35CA14C1DBC3A3C00F83516 /* DOMJITAbstractHeapRepository.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITAbstractHeapRepository.h; sourceTree = "<group>"; };
E38838941BAD145F00D62EE3 /* ScriptModuleLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptModuleLoader.cpp; sourceTree = "<group>"; };
E38838951BAD145F00D62EE3 /* ScriptModuleLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptModuleLoader.h; sourceTree = "<group>"; };
+ E398FC231DC32A1B003C4684 /* DOMJITHelpers.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMJITHelpers.cpp; sourceTree = "<group>"; };
E3AFA9641DA6E908002861BD /* JSNodeDOMJIT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNodeDOMJIT.cpp; sourceTree = "<group>"; };
E3B2F0E31D7F35EC00B0C9D1 /* LoadableClassicScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadableClassicScript.cpp; sourceTree = "<group>"; };
E3B2F0E41D7F35EC00B0C9D1 /* LoadableClassicScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadableClassicScript.h; sourceTree = "<group>"; };
@@ -14044,6 +14048,8 @@
E3B2F0E71D7F35EC00B0C9D1 /* LoadableScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadableScript.h; sourceTree = "<group>"; };
E3B2F0E81D7F35EC00B0C9D1 /* LoadableScriptClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadableScriptClient.h; sourceTree = "<group>"; };
E3B2F0E91D7F3D3C00B0C9D1 /* LoadableScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadableScript.cpp; sourceTree = "<group>"; };
+ E3B7C0621DC3415A001FB0B8 /* JSDocumentDOMJIT.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDocumentDOMJIT.cpp; sourceTree = "<group>"; };
+ E3C99A081DC3D41700794AD3 /* DOMJITCheckDOM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMJITCheckDOM.h; sourceTree = "<group>"; };
E3D049931DADC04500718F3C /* NodeConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NodeConstants.h; sourceTree = "<group>"; };
E3FA38611D716E7600AA5950 /* PendingScriptClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PendingScriptClient.h; sourceTree = "<group>"; };
E401C27417CE53EC00C41A35 /* ElementIteratorAssertions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementIteratorAssertions.h; sourceTree = "<group>"; };
@@ -22822,7 +22828,10 @@
children = (
E35CA14B1DBC3A3C00F83516 /* DOMJITAbstractHeapRepository.cpp */,
E35CA14C1DBC3A3C00F83516 /* DOMJITAbstractHeapRepository.h */,
+ E3C99A081DC3D41700794AD3 /* DOMJITCheckDOM.h */,
+ E398FC231DC32A1B003C4684 /* DOMJITHelpers.cpp */,
E3150EA51DA7218D00194012 /* DOMJITHelpers.h */,
+ E3B7C0621DC3415A001FB0B8 /* JSDocumentDOMJIT.cpp */,
E3AFA9641DA6E908002861BD /* JSNodeDOMJIT.cpp */,
);
path = domjit;
@@ -27397,6 +27406,7 @@
B2227A8F0D00BF220071B782 /* SVGPolyElement.h in Headers */,
B2227A910D00BF220071B782 /* SVGPolygonElement.h in Headers */,
B2227A940D00BF220071B782 /* SVGPolylineElement.h in Headers */,
+ E3C99A091DC3D41C00794AD3 /* DOMJITCheckDOM.h in Headers */,
B2227A970D00BF220071B782 /* SVGPreserveAspectRatio.h in Headers */,
088A0E0A126EF1DB00978F7A /* SVGProperty.h in Headers */,
081DD49C13BA1A6000DC7627 /* SVGPropertyInfo.h in Headers */,
@@ -29026,6 +29036,7 @@
A871DE240A152AC800B12A68 /* HTMLIFrameElement.cpp in Sources */,
A8EA7D310A19385500A8EF5F /* HTMLImageElement.cpp in Sources */,
A8EA7D300A19385500A8EF5F /* HTMLImageLoader.cpp in Sources */,
+ E3B7C0631DC34160001FB0B8 /* JSDocumentDOMJIT.cpp in Sources */,
A81369CD097374F600D74463 /* HTMLInputElement.cpp in Sources */,
93309DE5099E64920056E581 /* HTMLInterchange.cpp in Sources */,
A81369E5097374F600D74463 /* HTMLKeygenElement.cpp in Sources */,
@@ -29334,6 +29345,7 @@
9BD4E9161C462872005065BC /* JSCustomElementInterface.cpp in Sources */,
9BE6710B1D5AEB2100345514 /* JSCustomElementRegistry.cpp in Sources */,
9BC5F9E01D5AAF6B002B749D /* JSCustomElementRegistryCustom.cpp in Sources */,
+ E398FC241DC32A20003C4684 /* DOMJITHelpers.cpp in Sources */,
E4778B7F115A581A00B5D372 /* JSCustomEvent.cpp in Sources */,
DEC297611B4F2F8D005F5945 /* JSCustomEventCustom.cpp in Sources */,
51EC92650CE90DD400F90308 /* JSCustomSQLStatementErrorCallback.cpp in Sources */,
Modified: trunk/Source/WebCore/cssjit/SelectorCompiler.cpp (208069 => 208070)
--- trunk/Source/WebCore/cssjit/SelectorCompiler.cpp 2016-10-28 21:12:41 UTC (rev 208069)
+++ trunk/Source/WebCore/cssjit/SelectorCompiler.cpp 2016-10-28 21:33:30 UTC (rev 208070)
@@ -3790,7 +3790,7 @@
Assembler::Jump scopeIsNotNull = m_assembler.branchTestPtr(Assembler::NonZero, scope);
DOMJIT::loadDocument(m_assembler, elementAddressRegister, scope);
- m_assembler.loadPtr(Assembler::Address(scope, Document::documentElementMemoryOffset()), scope);
+ DOMJIT::loadDocumentElement(m_assembler, scope, scope);
scopeIsNotNull.link(&m_assembler);
failureCases.append(m_assembler.branchPtr(Assembler::NotEqual, scope, elementAddressRegister));
Modified: trunk/Source/WebCore/dom/Document.idl (208069 => 208070)
--- trunk/Source/WebCore/dom/Document.idl 2016-10-28 21:12:41 UTC (rev 208069)
+++ trunk/Source/WebCore/dom/Document.idl 2016-10-28 21:33:30 UTC (rev 208070)
@@ -29,7 +29,7 @@
] interface Document : Node {
readonly attribute DocumentType? doctype;
readonly attribute DOMImplementation implementation;
- readonly attribute Element? documentElement;
+ [DOMJIT] readonly attribute Element? documentElement;
[NewObject, MayThrowLegacyException, ImplementedAs=createElementForBindings] Element createElement(DOMString tagName);
[NewObject] DocumentFragment createDocumentFragment();
Modified: trunk/Source/WebCore/domjit/DOMJITAbstractHeapRepository.h (208069 => 208070)
--- trunk/Source/WebCore/domjit/DOMJITAbstractHeapRepository.h 2016-10-28 21:12:41 UTC (rev 208069)
+++ trunk/Source/WebCore/domjit/DOMJITAbstractHeapRepository.h 2016-10-28 21:33:30 UTC (rev 208070)
@@ -43,6 +43,8 @@
V(Node_nextSibling, Node) \
V(Node_previousSibling, Node) \
V(Node_ownerDocument, Node) \
+ V(Document, DOM) \
+ V(Document_documentElement, Document) \
class AbstractHeapRepository {
Copied: trunk/Source/WebCore/domjit/DOMJITCheckDOM.h (from rev 208069, trunk/Source/WebCore/domjit/DOMJITAbstractHeapRepository.h) (0 => 208070)
--- trunk/Source/WebCore/domjit/DOMJITCheckDOM.h (rev 0)
+++ trunk/Source/WebCore/domjit/DOMJITCheckDOM.h 2016-10-28 21:33:30 UTC (rev 208070)
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ *
+ */
+
+#pragma once
+
+#include "DOMJITHelpers.h"
+
+#if ENABLE(JIT)
+
+#include "Document.h"
+#include "Element.h"
+#include "Event.h"
+#include "Node.h"
+
+namespace WebCore { namespace DOMJIT {
+
+template<typename DOMInterface>
+struct TypeChecker {
+};
+
+template<>
+struct TypeChecker<Node> {
+ static CCallHelpers::Jump branchIfFail(CCallHelpers& jit, GPRReg dom)
+ {
+ return DOMJIT::branchIfNotNode(jit, dom);
+ }
+};
+
+template<>
+struct TypeChecker<Document> {
+ static CCallHelpers::Jump branchIfFail(CCallHelpers& jit, GPRReg dom)
+ {
+ return DOMJIT::branchIfNotDocumentWrapper(jit, dom);
+ }
+};
+
+template<>
+struct TypeChecker<Event> {
+ static CCallHelpers::Jump branchIfFail(CCallHelpers& jit, GPRReg dom)
+ {
+ return DOMJIT::branchIfNotEvent(jit, dom);
+ }
+};
+
+template<>
+struct TypeChecker<Element> {
+ static CCallHelpers::Jump branchIfFail(CCallHelpers& jit, GPRReg dom)
+ {
+ return DOMJIT::branchIfNotElement(jit, dom);
+ }
+};
+
+template<typename DOMInterface>
+Ref<JSC::DOMJIT::Patchpoint> checkDOM()
+{
+ Ref<JSC::DOMJIT::Patchpoint> patchpoint = JSC::DOMJIT::Patchpoint::create();
+ patchpoint->setGenerator([=](CCallHelpers& jit, JSC::DOMJIT::PatchpointParams& params) {
+ return TypeChecker<DOMInterface>::branchIfFail(jit, params[0].gpr());
+ });
+ return patchpoint;
+}
+
+} }
+
+#endif
Copied: trunk/Source/WebCore/domjit/DOMJITHelpers.cpp (from rev 208069, trunk/Source/WebCore/domjit/DOMJITAbstractHeapRepository.h) (0 => 208070)
--- trunk/Source/WebCore/domjit/DOMJITHelpers.cpp (rev 0)
+++ trunk/Source/WebCore/domjit/DOMJITHelpers.cpp 2016-10-28 21:33:30 UTC (rev 208070)
@@ -0,0 +1,55 @@
+/*
+ * 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
Modified: trunk/Source/WebCore/domjit/DOMJITHelpers.h (208069 => 208070)
--- trunk/Source/WebCore/domjit/DOMJITHelpers.h 2016-10-28 21:12:41 UTC (rev 208069)
+++ trunk/Source/WebCore/domjit/DOMJITHelpers.h 2016-10-28 21:33:30 UTC (rev 208070)
@@ -27,8 +27,10 @@
#pragma once
#include "JSDOMWrapper.h"
+#include "ScriptWrappable.h"
#include <domjit/DOMJITPatchpoint.h>
#include <domjit/DOMJITPatchpointParams.h>
+#include <interpreter/FrameTracers.h>
#if ENABLE(JIT)
@@ -51,6 +53,16 @@
return jit.branchTestPtr(CCallHelpers::NonZero, CCallHelpers::Address(weakImpl, JSC::WeakImpl::offsetOfWeakHandleOwner()), CCallHelpers::TrustedImm32(JSC::WeakImpl::StateMask));
}
+template<typename WrappedNode>
+JSC::EncodedJSValue JIT_OPERATION toWrapperSlow(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject, void* result)
+{
+ ASSERT(exec);
+ ASSERT(result);
+ ASSERT(globalObject);
+ JSC::NativeCallFrameTracer tracer(&exec->vm(), exec);
+ return JSC::JSValue::encode(toJS(exec, static_cast<JSDOMGlobalObject*>(globalObject), *static_cast<WrappedNode*>(result)));
+}
+
template<typename WrappedType>
void tryLookUpWrapperCache(CCallHelpers& jit, CCallHelpers::JumpList& failureCases, GPRReg wrapped, GPRReg resultGPR)
{
@@ -150,11 +162,8 @@
return jit.branchIfNotType(target, JSC::JSType(JSDocumentWrapperType));
}
-inline 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 loadDocument(MacroAssembler&, GPRReg node, GPRReg output);
+void loadDocumentElement(MacroAssembler&, GPRReg document, GPRReg output);
} }
Added: trunk/Source/WebCore/domjit/JSDocumentDOMJIT.cpp (0 => 208070)
--- trunk/Source/WebCore/domjit/JSDocumentDOMJIT.cpp (rev 0)
+++ trunk/Source/WebCore/domjit/JSDocumentDOMJIT.cpp 2016-10-28 21:33:30 UTC (rev 208070)
@@ -0,0 +1,79 @@
+/*
+ * 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 "JSDocument.h"
+
+#if ENABLE(JIT)
+
+#include "DOMJITAbstractHeapRepository.h"
+#include "DOMJITCheckDOM.h"
+#include "DOMJITHelpers.h"
+#include "Document.h"
+#include "JSDOMWrapper.h"
+#include "JSElement.h"
+#include <domjit/DOMJITPatchpoint.h>
+#include <domjit/DOMJITPatchpointParams.h>
+
+using namespace JSC;
+
+namespace WebCore {
+
+Ref<JSC::DOMJIT::Patchpoint> DocumentDocumentElementDOMJIT::checkDOM()
+{
+ return DOMJIT::checkDOM<Document>();
+}
+
+Ref<JSC::DOMJIT::CallDOMPatchpoint> DocumentDocumentElementDOMJIT::callDOM()
+{
+ const auto& heap = DOMJIT::AbstractHeapRepository::shared();
+ Ref<JSC::DOMJIT::CallDOMPatchpoint> patchpoint = JSC::DOMJIT::CallDOMPatchpoint::create();
+ patchpoint->numGPScratchRegisters = 1;
+ patchpoint->setGenerator([=](CCallHelpers& jit, JSC::DOMJIT::PatchpointParams& params) {
+ JSValueRegs result = params[0].jsValueRegs();
+ GPRReg document = params[1].gpr();
+ GPRReg globalObject = params[2].gpr();
+ JSValue globalObjectValue = params[2].value();
+ GPRReg scratch = params.gpScratch(0);
+
+ jit.loadPtr(CCallHelpers::Address(document, JSDocument::offsetOfWrapped()), scratch);
+ DOMJIT::loadDocumentElement(jit, scratch, scratch);
+ auto nullCase = jit.branchTestPtr(CCallHelpers::Zero, scratch);
+ DOMJIT::toWrapper<Element>(jit, params, scratch, globalObject, result, DOMJIT::toWrapperSlow<Element>, globalObjectValue);
+ auto done = jit.jump();
+
+ nullCase.link(&jit);
+ jit.moveValue(jsNull(), result);
+ done.link(&jit);
+
+ return CCallHelpers::JumpList();
+ });
+ patchpoint->effect = JSC::DOMJIT::Effect::forDef(heap.Document_documentElement);
+ return patchpoint;
+}
+
+}
+
+#endif
Modified: trunk/Source/WebCore/domjit/JSNodeDOMJIT.cpp (208069 => 208070)
--- trunk/Source/WebCore/domjit/JSNodeDOMJIT.cpp 2016-10-28 21:12:41 UTC (rev 208069)
+++ trunk/Source/WebCore/domjit/JSNodeDOMJIT.cpp 2016-10-28 21:33:30 UTC (rev 208070)
@@ -29,6 +29,7 @@
#if ENABLE(JIT)
#include "DOMJITAbstractHeapRepository.h"
+#include "DOMJITCheckDOM.h"
#include "DOMJITHelpers.h"
#include "JSDOMWrapper.h"
#include "Node.h"
@@ -43,16 +44,6 @@
enum class IsContainerGuardRequirement { Required, NotRequired };
template<typename WrappedNode>
-EncodedJSValue JIT_OPERATION toWrapperSlow(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject, void* result)
-{
- ASSERT(exec);
- ASSERT(result);
- ASSERT(globalObject);
- JSC::NativeCallFrameTracer tracer(&exec->vm(), exec);
- return JSValue::encode(toJS(exec, static_cast<JSDOMGlobalObject*>(globalObject), *static_cast<WrappedNode*>(result)));
-}
-
-template<typename WrappedNode>
static Ref<JSC::DOMJIT::CallDOMPatchpoint> createCallDOMForOffsetAccess(ptrdiff_t offset, IsContainerGuardRequirement isContainerGuardRequirement)
{
Ref<JSC::DOMJIT::CallDOMPatchpoint> patchpoint = JSC::DOMJIT::CallDOMPatchpoint::create();
@@ -74,7 +65,7 @@
jit.loadPtr(CCallHelpers::Address(scratch, offset), scratch);
nullCases.append(jit.branchTestPtr(CCallHelpers::Zero, scratch));
- DOMJIT::toWrapper<WrappedNode>(jit, params, scratch, globalObject, result, toWrapperSlow<WrappedNode>, globalObjectValue);
+ DOMJIT::toWrapper<WrappedNode>(jit, params, scratch, globalObject, result, DOMJIT::toWrapperSlow<WrappedNode>, globalObjectValue);
CCallHelpers::Jump done = jit.jump();
nullCases.link(&jit);
@@ -85,20 +76,9 @@
return patchpoint;
}
-static Ref<JSC::DOMJIT::Patchpoint> checkNode()
-{
- Ref<JSC::DOMJIT::Patchpoint> patchpoint = JSC::DOMJIT::Patchpoint::create();
- patchpoint->setGenerator([=](CCallHelpers& jit, JSC::DOMJIT::PatchpointParams& params) {
- CCallHelpers::JumpList failureCases;
- failureCases.append(DOMJIT::branchIfNotNode(jit, params[0].gpr()));
- return failureCases;
- });
- return patchpoint;
-}
-
Ref<JSC::DOMJIT::Patchpoint> NodeFirstChildDOMJIT::checkDOM()
{
- return checkNode();
+ return DOMJIT::checkDOM<Node>();
}
Ref<JSC::DOMJIT::CallDOMPatchpoint> NodeFirstChildDOMJIT::callDOM()
@@ -111,7 +91,7 @@
Ref<JSC::DOMJIT::Patchpoint> NodeLastChildDOMJIT::checkDOM()
{
- return checkNode();
+ return DOMJIT::checkDOM<Node>();
}
Ref<JSC::DOMJIT::CallDOMPatchpoint> NodeLastChildDOMJIT::callDOM()
@@ -124,7 +104,7 @@
Ref<JSC::DOMJIT::Patchpoint> NodeNextSiblingDOMJIT::checkDOM()
{
- return checkNode();
+ return DOMJIT::checkDOM<Node>();
}
Ref<JSC::DOMJIT::CallDOMPatchpoint> NodeNextSiblingDOMJIT::callDOM()
@@ -137,7 +117,7 @@
Ref<JSC::DOMJIT::Patchpoint> NodePreviousSiblingDOMJIT::checkDOM()
{
- return checkNode();
+ return DOMJIT::checkDOM<Node>();
}
Ref<JSC::DOMJIT::CallDOMPatchpoint> NodePreviousSiblingDOMJIT::callDOM()
@@ -150,7 +130,7 @@
Ref<JSC::DOMJIT::Patchpoint> NodeParentNodeDOMJIT::checkDOM()
{
- return checkNode();
+ return DOMJIT::checkDOM<Node>();
}
Ref<JSC::DOMJIT::CallDOMPatchpoint> NodeParentNodeDOMJIT::callDOM()
@@ -163,7 +143,7 @@
Ref<JSC::DOMJIT::Patchpoint> NodeNodeTypeDOMJIT::checkDOM()
{
- return checkNode();
+ return DOMJIT::checkDOM<Node>();
}
Ref<JSC::DOMJIT::CallDOMPatchpoint> NodeNodeTypeDOMJIT::callDOM()
@@ -184,7 +164,7 @@
Ref<JSC::DOMJIT::Patchpoint> NodeOwnerDocumentDOMJIT::checkDOM()
{
- return checkNode();
+ return DOMJIT::checkDOM<Node>();
}
Ref<JSC::DOMJIT::CallDOMPatchpoint> NodeOwnerDocumentDOMJIT::callDOM()
@@ -207,7 +187,7 @@
notDocument.link(&jit);
jit.loadPtr(CCallHelpers::Address(node, JSNode::offsetOfWrapped()), scratch);
DOMJIT::loadDocument(jit, scratch, scratch);
- DOMJIT::toWrapper<Document>(jit, params, scratch, globalObject, result, toWrapperSlow<Document>, globalObjectValue);
+ DOMJIT::toWrapper<Document>(jit, params, scratch, globalObject, result, DOMJIT::toWrapperSlow<Document>, globalObjectValue);
done.link(&jit);
return CCallHelpers::JumpList();
});