Title: [241557] trunk/Source/_javascript_Core
Revision
241557
Author
ysuz...@apple.com
Date
2019-02-14 11:10:15 -0800 (Thu, 14 Feb 2019)

Log Message

[JSC] Should have default NativeJITCode
https://bugs.webkit.org/show_bug.cgi?id=194634

Reviewed by Mark Lam.

In JSC_useJIT=false mode, we always create identical NativeJITCode for call and construct when we create NativeExecutable.
This is meaningless since we do not modify NativeJITCode after the creation. This patch adds singleton used as a default one.
Since NativeJITCode (& JITCode) is ThreadSafeRefCounted, we can just share it in a whole process level. This removes 446 NativeJITCode
allocations, which takes 14KB.

* runtime/VM.cpp:
(JSC::jitCodeForCallTrampoline):
(JSC::jitCodeForConstructTrampoline):
(JSC::VM::getHostFunction):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (241556 => 241557)


--- trunk/Source/_javascript_Core/ChangeLog	2019-02-14 19:06:12 UTC (rev 241556)
+++ trunk/Source/_javascript_Core/ChangeLog	2019-02-14 19:10:15 UTC (rev 241557)
@@ -1,3 +1,20 @@
+2019-02-14  Yusuke Suzuki  <ysuz...@apple.com>
+
+        [JSC] Should have default NativeJITCode
+        https://bugs.webkit.org/show_bug.cgi?id=194634
+
+        Reviewed by Mark Lam.
+
+        In JSC_useJIT=false mode, we always create identical NativeJITCode for call and construct when we create NativeExecutable.
+        This is meaningless since we do not modify NativeJITCode after the creation. This patch adds singleton used as a default one.
+        Since NativeJITCode (& JITCode) is ThreadSafeRefCounted, we can just share it in a whole process level. This removes 446 NativeJITCode
+        allocations, which takes 14KB.
+
+        * runtime/VM.cpp:
+        (JSC::jitCodeForCallTrampoline):
+        (JSC::jitCodeForConstructTrampoline):
+        (JSC::VM::getHostFunction):
+
 2019-02-14  Tadeu Zagallo  <tzaga...@apple.com>
 
         generateUnlinkedCodeBlockForFunctions shouldn't need to create a FunctionExecutable just to get its source code

Modified: trunk/Source/_javascript_Core/runtime/VM.cpp (241556 => 241557)


--- trunk/Source/_javascript_Core/runtime/VM.cpp	2019-02-14 19:06:12 UTC (rev 241556)
+++ trunk/Source/_javascript_Core/runtime/VM.cpp	2019-02-14 19:10:15 UTC (rev 241557)
@@ -688,6 +688,26 @@
     return getHostFunction(function, NoIntrinsic, constructor, nullptr, name);
 }
 
+static Ref<NativeJITCode> jitCodeForCallTrampoline()
+{
+    static NativeJITCode* result;
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        result = new NativeJITCode(LLInt::getCodeRef<JSEntryPtrTag>(llint_native_call_trampoline), JITCode::HostCallThunk, NoIntrinsic);
+    });
+    return makeRef(*result);
+}
+
+static Ref<NativeJITCode> jitCodeForConstructTrampoline()
+{
+    static NativeJITCode* result;
+    static std::once_flag onceKey;
+    std::call_once(onceKey, [&] {
+        result = new NativeJITCode(LLInt::getCodeRef<JSEntryPtrTag>(llint_native_construct_trampoline), JITCode::HostCallThunk, NoIntrinsic);
+    });
+    return makeRef(*result);
+}
+
 NativeExecutable* VM::getHostFunction(NativeFunction function, Intrinsic intrinsic, NativeFunction constructor, const DOMJIT::Signature* signature, const String& name)
 {
 #if ENABLE(JIT)
@@ -700,11 +720,7 @@
 #endif // ENABLE(JIT)
     UNUSED_PARAM(intrinsic);
     UNUSED_PARAM(signature);
-
-    return NativeExecutable::create(*this,
-        adoptRef(*new NativeJITCode(LLInt::getCodeRef<JSEntryPtrTag>(llint_native_call_trampoline), JITCode::HostCallThunk, NoIntrinsic)), function,
-        adoptRef(*new NativeJITCode(LLInt::getCodeRef<JSEntryPtrTag>(llint_native_construct_trampoline), JITCode::HostCallThunk, NoIntrinsic)), constructor,
-        name);
+    return NativeExecutable::create(*this, jitCodeForCallTrampoline(), function, jitCodeForConstructTrampoline(), constructor, name);
 }
 
 MacroAssemblerCodePtr<JSEntryPtrTag> VM::getCTIInternalFunctionTrampolineFor(CodeSpecializationKind kind)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to