+2019-02-14 Yusuke Suzuki <ysuzuki@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 <tzagallo@apple.com>
generateUnlinkedCodeBlockForFunctions shouldn't need to create a FunctionExecutable just to get its source code
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)
#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)