Repatch should plant calls to getters directly rather than through a C helper
authorfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Mar 2014 22:38:52 +0000 (22:38 +0000)
committerfpizlo@apple.com <fpizlo@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Mar 2014 22:38:52 +0000 (22:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=129589

Source/JavaScriptCore:

Reviewed by Mark Hahnenberg.

As the title says. All of the superstructure for this was already in place, so now it
was just a matter of actually emitting the call.

8x speed-up for getter microbenchmarks.

* CMakeLists.txt:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecode/PolymorphicGetByIdList.h:
(JSC::GetByIdAccess::doesCalls):
* jit/AccessorCallJITStubRoutine.cpp: Added.
(JSC::AccessorCallJITStubRoutine::AccessorCallJITStubRoutine):
(JSC::AccessorCallJITStubRoutine::~AccessorCallJITStubRoutine):
(JSC::AccessorCallJITStubRoutine::visitWeak):
* jit/AccessorCallJITStubRoutine.h: Added.
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::storeCell):
* jit/GCAwareJITStubRoutine.h:
* jit/Repatch.cpp:
(JSC::generateGetByIdStub):
* runtime/GetterSetter.h:
(JSC::GetterSetter::offsetOfGetter):
(JSC::GetterSetter::offsetOfSetter):

LayoutTests:

Reviewed by Mark Hahnenberg.

* js/regress/getter-expected.txt: Added.
* js/regress/getter.html: Added.
* js/regress/script-tests/getter.js: Added.
* js/regress/script-tests/string-char-code-at.js: Added.
(foo):
* js/regress/string-char-code-at-expected.txt: Added.
* js/regress/string-char-code-at.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166263 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
LayoutTests/ChangeLog
LayoutTests/js/regress/getter-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/getter.html [new file with mode: 0644]
LayoutTests/js/regress/script-tests/getter.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/string-char-code-at.js [new file with mode: 0644]
LayoutTests/js/regress/string-char-code-at-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/string-char-code-at.html [new file with mode: 0644]
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/bytecode/PolymorphicGetByIdList.h
Source/JavaScriptCore/jit/AccessorCallJITStubRoutine.cpp [new file with mode: 0644]
Source/JavaScriptCore/jit/AccessorCallJITStubRoutine.h [new file with mode: 0644]
Source/JavaScriptCore/jit/AssemblyHelpers.h
Source/JavaScriptCore/jit/GCAwareJITStubRoutine.h
Source/JavaScriptCore/jit/Repatch.cpp
Source/JavaScriptCore/runtime/GetterSetter.h

index 3a54e1e..32fc404 100644 (file)
@@ -1,3 +1,18 @@
+2014-03-25  Filip Pizlo  <fpizlo@apple.com>
+
+        Repatch should plant calls to getters directly rather than through a C helper
+        https://bugs.webkit.org/show_bug.cgi?id=129589
+
+        Reviewed by Mark Hahnenberg.
+
+        * js/regress/getter-expected.txt: Added.
+        * js/regress/getter.html: Added.
+        * js/regress/script-tests/getter.js: Added.
+        * js/regress/script-tests/string-char-code-at.js: Added.
+        (foo):
+        * js/regress/string-char-code-at-expected.txt: Added.
+        * js/regress/string-char-code-at.html: Added.
+
 2014-03-25  Jer Noble  <jer.noble@apple.com>
 
         [Mac] Pause the media element during system sleep.
diff --git a/LayoutTests/js/regress/getter-expected.txt b/LayoutTests/js/regress/getter-expected.txt
new file mode 100644 (file)
index 0000000..9277969
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/getter
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/getter.html b/LayoutTests/js/regress/getter.html
new file mode 100644 (file)
index 0000000..6aad5e0
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="resources/regress-pre.js"></script>
+<script src="script-tests/getter.js"></script>
+<script src="resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/script-tests/getter.js b/LayoutTests/js/regress/script-tests/getter.js
new file mode 100644 (file)
index 0000000..f2f1873
--- /dev/null
@@ -0,0 +1,11 @@
+(function() {
+    var o = {_f:42};
+    o.__defineGetter__("f", function() { return this._f; });
+    var result = 0;
+    var n = 2000000;
+    for (var i = 0; i < n; ++i)
+        result += o.f;
+    if (result != n * 42)
+        throw "Error: bad result: " + result;
+})();
+
diff --git a/LayoutTests/js/regress/script-tests/string-char-code-at.js b/LayoutTests/js/regress/script-tests/string-char-code-at.js
new file mode 100644 (file)
index 0000000..c0227fc
--- /dev/null
@@ -0,0 +1,12 @@
+function foo(s) {
+    var result = 0;
+    for (var i = 0; i < s.length; ++i)
+        result += s.charCodeAt(i);
+    return result;
+}
+
+for (var i = 0; i < 1000000; ++i) {
+    var result = foo("hello");
+    if (result != 532)
+        throw "Error: bad result: " + result;
+}
diff --git a/LayoutTests/js/regress/string-char-code-at-expected.txt b/LayoutTests/js/regress/string-char-code-at-expected.txt
new file mode 100644 (file)
index 0000000..c15b4bd
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/string-char-code-at
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/string-char-code-at.html b/LayoutTests/js/regress/string-char-code-at.html
new file mode 100644 (file)
index 0000000..a89adeb
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="resources/regress-pre.js"></script>
+<script src="script-tests/string-char-code-at.js"></script>
+<script src="resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index b827cc3..ff9559e 100644 (file)
@@ -275,6 +275,7 @@ set(JavaScriptCore_SOURCES
     interpreter/StackVisitor.cpp
     interpreter/VMInspector.cpp
 
+    jit/AccessorCallJITStubRoutine.cpp
     jit/AssemblyHelpers.cpp
     jit/ArityCheckFailReturnThunks.cpp
     jit/ClosureCallStubRoutine.cpp
index 31805b0..1979178 100644 (file)
@@ -1,3 +1,34 @@
+2014-03-25  Filip Pizlo  <fpizlo@apple.com>
+
+        Repatch should plant calls to getters directly rather than through a C helper
+        https://bugs.webkit.org/show_bug.cgi?id=129589
+
+        Reviewed by Mark Hahnenberg.
+        
+        As the title says. All of the superstructure for this was already in place, so now it
+        was just a matter of actually emitting the call.
+        
+        8x speed-up for getter microbenchmarks. 
+
+        * CMakeLists.txt:
+        * JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * bytecode/PolymorphicGetByIdList.h:
+        (JSC::GetByIdAccess::doesCalls):
+        * jit/AccessorCallJITStubRoutine.cpp: Added.
+        (JSC::AccessorCallJITStubRoutine::AccessorCallJITStubRoutine):
+        (JSC::AccessorCallJITStubRoutine::~AccessorCallJITStubRoutine):
+        (JSC::AccessorCallJITStubRoutine::visitWeak):
+        * jit/AccessorCallJITStubRoutine.h: Added.
+        * jit/AssemblyHelpers.h:
+        (JSC::AssemblyHelpers::storeCell):
+        * jit/GCAwareJITStubRoutine.h:
+        * jit/Repatch.cpp:
+        (JSC::generateGetByIdStub):
+        * runtime/GetterSetter.h:
+        (JSC::GetterSetter::offsetOfGetter):
+        (JSC::GetterSetter::offsetOfSetter):
+
 2014-03-25  Michael Saboff  <msaboff@apple.com>
 
         Unreviewed, rolling out r166126.
index b296c28..da1938a 100644 (file)
     <ClCompile Include="..\interpreter\ProtoCallFrame.cpp" />
     <ClCompile Include="..\interpreter\StackVisitor.cpp" />
     <ClCompile Include="..\interpreter\VMInspector.cpp" />
+    <ClCompile Include="..\jit\AccessorCallJITStubRoutine.cpp" />
     <ClCompile Include="..\jit\ArityCheckFailReturnThunks.cpp" />
     <ClCompile Include="..\jit\AssemblyHelpers.cpp" />
     <ClCompile Include="..\jit\ClosureCallStubRoutine.cpp" />
     <ClInclude Include="..\interpreter\Register.h" />
     <ClInclude Include="..\interpreter\StackVisitor.h" />
     <ClInclude Include="..\interpreter\VMInspector.h" />
+    <ClInclude Include="..\jit\AccessorCallJITStubRoutine.h" />
     <ClInclude Include="..\jit\ArityCheckFailReturnThunks.h" />
     <ClInclude Include="..\jit\AssemblyHelpers.h" />
     <ClInclude Include="..\jit\CCallHelpers.h" />
index b521d3e..f18dd82 100644 (file)
                0F73D7AE165A142D00ACAB71 /* ClosureCallStubRoutine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F73D7AB165A142A00ACAB71 /* ClosureCallStubRoutine.cpp */; };
                0F73D7AF165A143000ACAB71 /* ClosureCallStubRoutine.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F73D7AC165A142A00ACAB71 /* ClosureCallStubRoutine.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F743BAA16B88249009F9277 /* ARM64Disassembler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 652A3A201651C66100A80AFE /* ARM64Disassembler.cpp */; };
+               0F7576D218E1FEE9002EF4CD /* AccessorCallJITStubRoutine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F7576D018E1FEE9002EF4CD /* AccessorCallJITStubRoutine.cpp */; };
+               0F7576D318E1FEE9002EF4CD /* AccessorCallJITStubRoutine.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F7576D118E1FEE9002EF4CD /* AccessorCallJITStubRoutine.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F766D2815A8CC1E008F363E /* JITStubRoutine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F766D2615A8CC1B008F363E /* JITStubRoutine.cpp */; };
                0F766D2B15A8CC38008F363E /* JITStubRoutineSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F766D2915A8CC34008F363E /* JITStubRoutineSet.cpp */; };
                0F766D2C15A8CC3A008F363E /* JITStubRoutineSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 0F766D2A15A8CC34008F363E /* JITStubRoutineSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2A68295B1875F80500B6C3E2 /* CopyWriteBarrier.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A68295A1875F80500B6C3E2 /* CopyWriteBarrier.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2A6F462617E959CE00C45C98 /* HeapOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A6F462517E959CE00C45C98 /* HeapOperation.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2A7A58EF1808A4C40020BDF7 /* DeferGC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2A7A58EE1808A4C40020BDF7 /* DeferGC.cpp */; };
-       2A83638518D7D0EE0000EBCC /* EdenGCActivityCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2A83638318D7D0EE0000EBCC /* EdenGCActivityCallback.cpp */; };
-       2A83638618D7D0EE0000EBCC /* EdenGCActivityCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A83638418D7D0EE0000EBCC /* EdenGCActivityCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
-       2A83638918D7D0FE0000EBCC /* FullGCActivityCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2A83638718D7D0FE0000EBCC /* FullGCActivityCallback.cpp */; };
-       2A83638A18D7D0FE0000EBCC /* FullGCActivityCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A83638818D7D0FE0000EBCC /* FullGCActivityCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               2A83638518D7D0EE0000EBCC /* EdenGCActivityCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2A83638318D7D0EE0000EBCC /* EdenGCActivityCallback.cpp */; };
+               2A83638618D7D0EE0000EBCC /* EdenGCActivityCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A83638418D7D0EE0000EBCC /* EdenGCActivityCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               2A83638918D7D0FE0000EBCC /* FullGCActivityCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2A83638718D7D0FE0000EBCC /* FullGCActivityCallback.cpp */; };
+               2A83638A18D7D0FE0000EBCC /* FullGCActivityCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 2A83638818D7D0FE0000EBCC /* FullGCActivityCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2AAAA31218BD49D100394CC8 /* StructureIDBlob.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AAAA31018BD49D100394CC8 /* StructureIDBlob.h */; settings = {ATTRIBUTES = (Private, ); }; };
                2AACE63C18CA5A0300ED0191 /* GCActivityCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AACE63A18CA5A0300ED0191 /* GCActivityCallback.cpp */; };
                2AACE63D18CA5A0300ED0191 /* GCActivityCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 2AACE63B18CA5A0300ED0191 /* GCActivityCallback.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0F714CA216EA92ED00F3EBEB /* DFGBackwardsPropagationPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGBackwardsPropagationPhase.h; path = dfg/DFGBackwardsPropagationPhase.h; sourceTree = "<group>"; };
                0F73D7AB165A142A00ACAB71 /* ClosureCallStubRoutine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClosureCallStubRoutine.cpp; sourceTree = "<group>"; };
                0F73D7AC165A142A00ACAB71 /* ClosureCallStubRoutine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClosureCallStubRoutine.h; sourceTree = "<group>"; };
+               0F7576D018E1FEE9002EF4CD /* AccessorCallJITStubRoutine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessorCallJITStubRoutine.cpp; sourceTree = "<group>"; };
+               0F7576D118E1FEE9002EF4CD /* AccessorCallJITStubRoutine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessorCallJITStubRoutine.h; sourceTree = "<group>"; };
                0F766D1C15A5028D008F363E /* JITStubRoutine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JITStubRoutine.h; sourceTree = "<group>"; };
                0F766D2615A8CC1B008F363E /* JITStubRoutine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITStubRoutine.cpp; sourceTree = "<group>"; };
                0F766D2915A8CC34008F363E /* JITStubRoutineSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITStubRoutineSet.cpp; sourceTree = "<group>"; };
                2A68295A1875F80500B6C3E2 /* CopyWriteBarrier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CopyWriteBarrier.h; sourceTree = "<group>"; };
                2A6F462517E959CE00C45C98 /* HeapOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapOperation.h; sourceTree = "<group>"; };
                2A7A58EE1808A4C40020BDF7 /* DeferGC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeferGC.cpp; sourceTree = "<group>"; };
-       2A83638318D7D0EE0000EBCC /* EdenGCActivityCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EdenGCActivityCallback.cpp; sourceTree = "<group>"; };
-       2A83638418D7D0EE0000EBCC /* EdenGCActivityCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EdenGCActivityCallback.h; sourceTree = "<group>"; };
-       2A83638718D7D0FE0000EBCC /* FullGCActivityCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FullGCActivityCallback.cpp; sourceTree = "<group>"; };
-       2A83638818D7D0FE0000EBCC /* FullGCActivityCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullGCActivityCallback.h; sourceTree = "<group>"; };
+               2A83638318D7D0EE0000EBCC /* EdenGCActivityCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EdenGCActivityCallback.cpp; sourceTree = "<group>"; };
+               2A83638418D7D0EE0000EBCC /* EdenGCActivityCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EdenGCActivityCallback.h; sourceTree = "<group>"; };
+               2A83638718D7D0FE0000EBCC /* FullGCActivityCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FullGCActivityCallback.cpp; sourceTree = "<group>"; };
+               2A83638818D7D0FE0000EBCC /* FullGCActivityCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FullGCActivityCallback.h; sourceTree = "<group>"; };
                2AAAA31018BD49D100394CC8 /* StructureIDBlob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructureIDBlob.h; sourceTree = "<group>"; };
                2AACE63A18CA5A0300ED0191 /* GCActivityCallback.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GCActivityCallback.cpp; sourceTree = "<group>"; };
                2AACE63B18CA5A0300ED0191 /* GCActivityCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCActivityCallback.h; sourceTree = "<group>"; };
                1429D92C0ED22D7000B89619 /* jit */ = {
                        isa = PBXGroup;
                        children = (
+                               0F7576D018E1FEE9002EF4CD /* AccessorCallJITStubRoutine.cpp */,
+                               0F7576D118E1FEE9002EF4CD /* AccessorCallJITStubRoutine.h */,
                                0F6B1CC718641DF800845D97 /* ArityCheckFailReturnThunks.cpp */,
                                0F6B1CC818641DF800845D97 /* ArityCheckFailReturnThunks.h */,
                                0F24E53B17EA9F5900ABB217 /* AssemblyHelpers.cpp */,
                                2A4EC90A1860D6C20094F782 /* WriteBarrierBuffer.h */,
                                0FC8150814043BCA00CFA603 /* WriteBarrierSupport.cpp */,
                                0FC8150914043BD200CFA603 /* WriteBarrierSupport.h */,
-               2A83638318D7D0EE0000EBCC /* EdenGCActivityCallback.cpp */,
-               2A83638418D7D0EE0000EBCC /* EdenGCActivityCallback.h */,
-               2A83638718D7D0FE0000EBCC /* FullGCActivityCallback.cpp */,
-               2A83638818D7D0FE0000EBCC /* FullGCActivityCallback.h */,
+                               2A83638318D7D0EE0000EBCC /* EdenGCActivityCallback.cpp */,
+                               2A83638418D7D0EE0000EBCC /* EdenGCActivityCallback.h */,
+                               2A83638718D7D0FE0000EBCC /* FullGCActivityCallback.cpp */,
+                               2A83638818D7D0FE0000EBCC /* FullGCActivityCallback.h */,
                        );
                        path = heap;
                        sourceTree = "<group>";
                                86D3B2C410156BDE002865E7 /* ARMAssembler.h in Headers */,
                                A584032018BFFBE1005A0811 /* InspectorAgent.h in Headers */,
                                2AACE63D18CA5A0300ED0191 /* GCActivityCallback.h in Headers */,
-               2A83638618D7D0EE0000EBCC /* EdenGCActivityCallback.h in Headers */,
-               2A83638A18D7D0FE0000EBCC /* FullGCActivityCallback.h in Headers */,
+                               2A83638618D7D0EE0000EBCC /* EdenGCActivityCallback.h in Headers */,
+                               2A83638A18D7D0FE0000EBCC /* FullGCActivityCallback.h in Headers */,
                                2AAAA31218BD49D100394CC8 /* StructureIDBlob.h in Headers */,
                                A54E8EB118BFFBBE00556D28 /* GCSegmentedArrayInlines.h in Headers */,
                                86ADD1450FDDEA980006EEC2 /* ARMv7Assembler.h in Headers */,
                                BC18C41E0E16F5CD00B34460 /* JSContextRef.h in Headers */,
                                148CD1D8108CF902008163C6 /* JSContextRefPrivate.h in Headers */,
                                A72028B81797601E0098028C /* JSCTestRunnerUtils.h in Headers */,
+                               0F7576D318E1FEE9002EF4CD /* AccessorCallJITStubRoutine.h in Headers */,
                                0F2B66EC17B6B5AB00A7AE3F /* JSDataView.h in Headers */,
                                0F2B66EE17B6B5AB00A7AE3F /* JSDataViewPrototype.h in Headers */,
                                978801411471AD920041B016 /* JSDateMath.h in Headers */,
                                147F39C2107EC37600427A48 /* Completion.cpp in Sources */,
                                146B16D812EB5B59001BEC1B /* ConservativeRoots.cpp in Sources */,
                                A5FD0079189B051000633231 /* ConsoleMessage.cpp in Sources */,
-               2A83638518D7D0EE0000EBCC /* EdenGCActivityCallback.cpp in Sources */,
+                               2A83638518D7D0EE0000EBCC /* EdenGCActivityCallback.cpp in Sources */,
                                1428082E107EC0570013E7B2 /* ConstructData.cpp in Sources */,
                                A57D23F11891B5B40031C7FA /* ContentSearchUtilities.cpp in Sources */,
                                C240305514B404E60079EB64 /* CopiedSpace.cpp in Sources */,
                                0F919D10157F3329004A4E7D /* JSSegmentedVariableObject.cpp in Sources */,
                                A7299D9D17D12837005F5FF9 /* JSSet.cpp in Sources */,
                                A790DD6F182F499700588807 /* JSSetIterator.cpp in Sources */,
-               2A83638918D7D0FE0000EBCC /* FullGCActivityCallback.cpp in Sources */,
+                               2A83638918D7D0FE0000EBCC /* FullGCActivityCallback.cpp in Sources */,
                                1428083A107EC0750013E7B2 /* JSStack.cpp in Sources */,
                                147F39D5107EC37600427A48 /* JSString.cpp in Sources */,
                                2600B5A6152BAAA70091EE5F /* JSStringJoiner.cpp in Sources */,
                                0FF42732158EBD58004CB9FF /* UDis86Disassembler.cpp in Sources */,
                                A76F279415F13C9600517D67 /* UnlinkedCodeBlock.cpp in Sources */,
                                B59F89391891F29F00D5CCDC /* UnlinkedInstructionStream.cpp in Sources */,
+                               0F7576D218E1FEE9002EF4CD /* AccessorCallJITStubRoutine.cpp in Sources */,
                                0F24E55817F74EDB00ABB217 /* ValueRecovery.cpp in Sources */,
                                E18E3A590DF9278C00D90B34 /* VM.cpp in Sources */,
                                FE5932A7183C5A2600A1ECCC /* VMEntryScope.cpp in Sources */,
index 511745b..945ba4d 100644 (file)
@@ -79,7 +79,7 @@ public:
         return m_stubRoutine.get();
     }
     
-    bool doesCalls() const { return type() == Getter; }
+    bool doesCalls() const { return type() == Getter || type() == CustomGetter; }
     
     bool visitWeak(RepatchBuffer&) const;
 
diff --git a/Source/JavaScriptCore/jit/AccessorCallJITStubRoutine.cpp b/Source/JavaScriptCore/jit/AccessorCallJITStubRoutine.cpp
new file mode 100644 (file)
index 0000000..f4a94b7
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2014 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 "AccessorCallJITStubRoutine.h"
+
+#if ENABLE(JIT)
+
+#include "CallLinkInfo.h"
+
+namespace JSC {
+
+AccessorCallJITStubRoutine::AccessorCallJITStubRoutine(
+    const MacroAssemblerCodeRef& code, VM& vm, std::unique_ptr<CallLinkInfo> info)
+    : GCAwareJITStubRoutine(code, vm)
+    , m_callLinkInfo(std::move(info))
+{
+}
+
+AccessorCallJITStubRoutine::~AccessorCallJITStubRoutine()
+{
+}
+
+bool AccessorCallJITStubRoutine::visitWeak(RepatchBuffer& repatchBuffer)
+{
+    m_callLinkInfo->visitWeak(repatchBuffer);
+    return true;
+}
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
+
diff --git a/Source/JavaScriptCore/jit/AccessorCallJITStubRoutine.h b/Source/JavaScriptCore/jit/AccessorCallJITStubRoutine.h
new file mode 100644 (file)
index 0000000..d5d3855
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2014 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. 
+ */
+
+#ifndef AccessorCallJITStubRoutine_h
+#define AccessorCallJITStubRoutine_h
+
+#if ENABLE(JIT)
+
+#include "GCAwareJITStubRoutine.h"
+
+namespace JSC {
+
+struct CallLinkInfo;
+
+// JIT stub routine for use by JavaScript accessors. These will be making a JS
+// call that requires inline caching. 
+
+class AccessorCallJITStubRoutine : public GCAwareJITStubRoutine {
+public:
+    AccessorCallJITStubRoutine(
+        const MacroAssemblerCodeRef&, VM&, std::unique_ptr<CallLinkInfo>);
+    
+    virtual ~AccessorCallJITStubRoutine();
+    
+    virtual bool visitWeak(RepatchBuffer&) override;
+    
+private:
+    std::unique_ptr<CallLinkInfo> m_callLinkInfo;
+};
+
+} // namespace JSC
+
+#endif // ENABLE(JIT)
+
+#endif // AccessorCallJITStubRoutine_h
+
index ed2bad2..41fb363 100644 (file)
@@ -66,6 +66,17 @@ public:
         stackPointerAligned.link(this);
 #endif
     }
+    
+    template<typename T>
+    void storeCell(T cell, Address address)
+    {
+#if USE(JSVALUE64)
+        store64(cell, address);
+#else
+        store32(cell, address.withOffset(PayloadOffset));
+        store32(TrustedImm32(JSValue::CellTag), address.withOffset(TagOffset));
+#endif
+    }
 
 #if CPU(X86_64) || CPU(X86)
     static size_t prologueStackPointerDelta()
index b08f257..0adc63b 100644 (file)
@@ -110,7 +110,7 @@ private:
 
 PassRefPtr<JITStubRoutine> createJITStubRoutine(
     const MacroAssemblerCodeRef&, VM&, const JSCell* owner, bool makesCalls,
-    JSCell* = 0);
+    JSCell* = nullptr);
 
 // Helper for the creation of simple stub routines that need no help from the GC. Note
 // that codeBlock gets "executed" more than once.
index faff70c..c7ae166 100644 (file)
 
 #if ENABLE(JIT)
 
+#include "AccessorCallJITStubRoutine.h"
 #include "CCallHelpers.h"
 #include "DFGOperations.h"
 #include "DFGSpeculativeJIT.h"
 #include "FTLThunks.h"
 #include "GCAwareJITStubRoutine.h"
+#include "GetterSetter.h"
 #include "JIT.h"
 #include "JITInlines.h"
 #include "LinkBuffer.h"
@@ -301,19 +303,138 @@ static void generateGetByIdStub(
 #if USE(JSVALUE64)
         stubJit.load64(MacroAssembler::Address(storageGPR, offsetRelativeToBase(offset)), loadedValueGPR);
 #else
-        stubJit.load32(MacroAssembler::Address(storageGPR, offsetRelativeToBase(offset) + TagOffset), resultTagGPR);
+        if (slot.isCacheableValue())
+            stubJit.load32(MacroAssembler::Address(storageGPR, offsetRelativeToBase(offset) + TagOffset), resultTagGPR);
         stubJit.load32(MacroAssembler::Address(storageGPR, offsetRelativeToBase(offset) + PayloadOffset), loadedValueGPR);
 #endif
     }
 
+    // Stuff for custom getters.
     MacroAssembler::Call operationCall;
     MacroAssembler::Call handlerCall;
     FunctionPtr operationFunction;
+
+    // Stuff for JS getters.
+    MacroAssembler::DataLabelPtr addressOfLinkFunctionCheck;
+    MacroAssembler::Call fastPathCall;
+    MacroAssembler::Call slowPathCall;
+    std::unique_ptr<CallLinkInfo> callLinkInfo;
+
     MacroAssembler::Jump success, fail;
     if (isAccessor) {
+        // Need to make sure that whenever this call is made in the future, we remember the
+        // place that we made it from. It just so happens to be the place that we are at
+        // right now!
+        stubJit.store32(MacroAssembler::TrustedImm32(exec->locationAsRawBits()),
+            CCallHelpers::tagFor(static_cast<VirtualRegister>(JSStack::ArgumentCount)));
+
         if (slot.isCacheableGetter()) {
-            stubJit.setupArgumentsWithExecState(baseGPR, loadedValueGPR);
-            operationFunction = operationCallGetter;
+            // Create a JS call using a JS call inline cache. Assume that:
+            //
+            // - SP is aligned and represents the extent of the calling compiler's stack usage.
+            //
+            // - FP is set correctly (i.e. it points to the caller's call frame header).
+            //
+            // - SP - FP is an aligned difference.
+            //
+            // - Any byte between FP (exclusive) and SP (inclusive) could be live in the calling
+            //   code.
+            //
+            // Therefore, we temporary grow the stack for the purpose of the call and then
+            // degrow it after.
+            
+            callLinkInfo = std::make_unique<CallLinkInfo>();
+            callLinkInfo->callType = CallLinkInfo::Call;
+            callLinkInfo->codeOrigin = stubInfo.codeOrigin;
+            callLinkInfo->calleeGPR = loadedValueGPR;
+            
+            MacroAssembler::JumpList done;
+            
+            // There is a 'this' argument but nothing else.
+            unsigned numberOfParameters = 1;
+            
+            // Get the getter; if there ain't one then the result is jsUndefined().
+            stubJit.loadPtr(
+                MacroAssembler::Address(loadedValueGPR, GetterSetter::offsetOfGetter()),
+                loadedValueGPR);
+            MacroAssembler::Jump returnUndefined = stubJit.branchTestPtr(
+                MacroAssembler::Zero, loadedValueGPR);
+            
+            unsigned numberOfRegsForCall =
+                JSStack::CallFrameHeaderSize + numberOfParameters;
+            
+            unsigned alignedNumberOfNeededRegs =
+                WTF::roundUpToMultipleOf(stackAlignmentRegisters(), numberOfRegsForCall);
+            
+            unsigned alignedNumberOfNeededBytes =
+                alignedNumberOfNeededRegs * sizeof(Register);
+            
+            stubJit.subPtr(
+                MacroAssembler::TrustedImm32(
+                    alignedNumberOfNeededBytes - sizeof(CallerFrameAndPC)),
+                MacroAssembler::stackPointerRegister);
+            
+            MacroAssembler::Address calleeFrame = MacroAssembler::Address(
+                MacroAssembler::stackPointerRegister,
+                -static_cast<ptrdiff_t>(sizeof(CallerFrameAndPC)));
+            
+            stubJit.store32(
+                MacroAssembler::TrustedImm32(numberOfParameters),
+                calleeFrame.withOffset(
+                    JSStack::ArgumentCount * sizeof(Register) + PayloadOffset));
+            
+            stubJit.storeCell(
+                loadedValueGPR, calleeFrame.withOffset(JSStack::Callee * sizeof(Register)));
+            stubJit.storeCell(
+                baseGPR,
+                calleeFrame.withOffset(
+                    virtualRegisterForArgument(0).offset() * sizeof(Register)));
+            
+            MacroAssembler::Jump slowCase = stubJit.branchPtrWithPatch(
+                MacroAssembler::NotEqual, loadedValueGPR, addressOfLinkFunctionCheck,
+                MacroAssembler::TrustedImmPtr(0));
+            
+            // loadedValueGPR is already burned. We can reuse it. From here on we assume that
+            // any volatile register will be clobbered anyway.
+            stubJit.loadPtr(
+                MacroAssembler::Address(loadedValueGPR, JSFunction::offsetOfScopeChain()),
+                loadedValueGPR);
+            stubJit.storeCell(
+                loadedValueGPR, calleeFrame.withOffset(JSStack::ScopeChain * sizeof(Register)));
+            fastPathCall = stubJit.nearCall();
+            
+            stubJit.addPtr(
+                MacroAssembler::TrustedImm32(
+                    alignedNumberOfNeededBytes - sizeof(CallerFrameAndPC)),
+                MacroAssembler::stackPointerRegister);
+            
+            done.append(stubJit.jump());
+            slowCase.link(&stubJit);
+            
+            stubJit.move(loadedValueGPR, GPRInfo::regT0);
+#if USE(JSVALUE32_64)
+            stubJit.move(MacroAssembler::TrustedImm32(JSValue::CellTag), GPRInfo::regT1);
+#endif
+            stubJit.move(MacroAssembler::TrustedImmPtr(callLinkInfo.get()), GPRInfo::regT2);
+            slowPathCall = stubJit.nearCall();
+            
+            stubJit.addPtr(
+                MacroAssembler::TrustedImm32(
+                    alignedNumberOfNeededBytes - sizeof(CallerFrameAndPC)),
+                MacroAssembler::stackPointerRegister);
+            
+            done.append(stubJit.jump());
+            returnUndefined.link(&stubJit);
+            
+#if USE(JSVALUE64)
+            stubJit.move(
+                MacroAssembler::TrustedImm64(JSValue::encode(jsUndefined())), resultGPR);
+#else
+            stubJit.move(MacroAssembler::TrustedImm32(JSValue::UndefinedTag), resultTagGPR);
+            stubJit.move(MacroAssembler::TrustedImm32(0), resultGPR);
+#endif
+            
+            done.link(&stubJit);
         } else {
             // EncodedJSValue (*GetValueFunc)(ExecState*, JSObject* slotBase, EncodedJSValue thisValue, PropertyName);
 #if USE(JSVALUE64)
@@ -321,44 +442,53 @@ static void generateGetByIdStub(
 #else
             stubJit.setupArgumentsWithExecState(baseForAccessGPR, baseGPR, MacroAssembler::TrustedImm32(JSValue::CellTag), MacroAssembler::TrustedImmPtr(propertyName.impl()));
 #endif
-            operationFunction = FunctionPtr(slot.customGetter());
-        }
+            stubJit.storePtr(GPRInfo::callFrameRegister, &vm->topCallFrame);
 
-        // Need to make sure that whenever this call is made in the future, we remember the
-        // place that we made it from. It just so happens to be the place that we are at
-        // right now!
-        stubJit.store32(MacroAssembler::TrustedImm32(exec->locationAsRawBits()),
-            CCallHelpers::tagFor(static_cast<VirtualRegister>(JSStack::ArgumentCount)));
-        stubJit.storePtr(GPRInfo::callFrameRegister, &vm->topCallFrame);
+            operationFunction = FunctionPtr(slot.customGetter());
 
-        operationCall = stubJit.call();
+            operationCall = stubJit.call();
 #if USE(JSVALUE64)
-        stubJit.move(GPRInfo::returnValueGPR, resultGPR);
+            stubJit.move(GPRInfo::returnValueGPR, resultGPR);
 #else
-        stubJit.setupResults(resultGPR, resultTagGPR);
+            stubJit.setupResults(resultGPR, resultTagGPR);
 #endif
-        MacroAssembler::Jump noException = stubJit.emitExceptionCheck(CCallHelpers::InvertedExceptionCheck);
-
-        stubJit.setupArguments(CCallHelpers::TrustedImmPtr(vm), GPRInfo::callFrameRegister);
-        handlerCall = stubJit.call();
-        stubJit.jumpToExceptionHandler();
-        
-        noException.link(&stubJit);
+            MacroAssembler::Jump noException = stubJit.emitExceptionCheck(CCallHelpers::InvertedExceptionCheck);
+            
+            stubJit.setupArguments(CCallHelpers::TrustedImmPtr(vm), GPRInfo::callFrameRegister);
+            handlerCall = stubJit.call();
+            stubJit.jumpToExceptionHandler();
+            
+            noException.link(&stubJit);
+        }
     }
     emitRestoreScratch(stubJit, needToRestoreScratch, scratchGPR, success, fail, failureCases);
     
     LinkBuffer patchBuffer(*vm, &stubJit, exec->codeBlock());
     
     linkRestoreScratch(patchBuffer, needToRestoreScratch, success, fail, failureCases, successLabel, slowCaseLabel);
-    if (isAccessor) {
+    if (slot.isCacheableCustom()) {
         patchBuffer.link(operationCall, operationFunction);
         patchBuffer.link(handlerCall, lookupExceptionHandler);
+    } else if (slot.isCacheableGetter()) {
+        callLinkInfo->hotPathOther = patchBuffer.locationOfNearCall(fastPathCall);
+        callLinkInfo->hotPathBegin = patchBuffer.locationOf(addressOfLinkFunctionCheck);
+        callLinkInfo->callReturnLocation = patchBuffer.locationOfNearCall(slowPathCall);
+
+        ThunkGenerator generator = linkThunkGeneratorFor(
+            CodeForCall, RegisterPreservationNotRequired);
+        patchBuffer.link(
+            slowPathCall, CodeLocationLabel(vm->getCTIStub(generator).code()));
     }
     
-    stubRoutine = FINALIZE_CODE_FOR_GC_AWARE_STUB(
-        exec->codeBlock(), patchBuffer, true, nullptr,
+    MacroAssemblerCodeRef code = FINALIZE_CODE_FOR(
+        exec->codeBlock(), patchBuffer,
         ("Get access stub for %s, return point %p",
             toCString(*exec->codeBlock()).data(), successLabel.executableAddress()));
+    
+    if (slot.isCacheableGetter())
+        stubRoutine = adoptRef(new AccessorCallJITStubRoutine(code, *vm, std::move(callLinkInfo)));
+    else
+        stubRoutine = createJITStubRoutine(code, *vm, codeBlock->ownerExecutable(), true);
 }
 
 static bool tryCacheGetByID(ExecState* exec, JSValue baseValue, const Identifier& propertyName, const PropertySlot& slot, StructureStubInfo& stubInfo)
@@ -587,10 +717,17 @@ static bool tryBuildGetByIDList(ExecState* exec, JSValue baseValue, const Identi
         stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.deltaCallToDone),
         CodeLocationLabel(list->currentSlowPathTarget(stubInfo)), stubRoutine);
     
+    GetByIdAccess::AccessType accessType;
+    if (slot.isCacheableValue())
+        accessType = GetByIdAccess::SimpleStub;
+    else if (slot.isCacheableGetter())
+        accessType = GetByIdAccess::Getter;
+    else
+        accessType = GetByIdAccess::CustomGetter;
+    
     list->addAccess(GetByIdAccess(
-        *vm, codeBlock->ownerExecutable(),
-        slot.isCacheableValue() ? GetByIdAccess::SimpleStub : GetByIdAccess::Getter,
-        stubRoutine, structure, prototypeChain, count));
+        *vm, codeBlock->ownerExecutable(), accessType, stubRoutine, structure,
+        prototypeChain, count));
     
     patchJumpToGetByIdStub(codeBlock, stubInfo, stubRoutine.get());
     
index 5695bb9..354192b 100644 (file)
@@ -64,6 +64,16 @@ namespace JSC {
             return Structure::create(vm, globalObject, prototype, TypeInfo(GetterSetterType, OverridesVisitChildren), info());
         }
         
+        static ptrdiff_t offsetOfGetter()
+        {
+            return OBJECT_OFFSETOF(GetterSetter, m_getter);
+        }
+        
+        static ptrdiff_t offsetOfSetter()
+        {
+            return OBJECT_OFFSETOF(GetterSetter, m_setter);
+        }
+        
         DECLARE_INFO;
 
     private: