Ignore:
Timestamp:
Feb 14, 2019, 11:10:15 AM (6 years ago)
Author:
[email protected]
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):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/VM.cpp

    r241038 r241557  
    689689}
    690690
     691static Ref<NativeJITCode> jitCodeForCallTrampoline()
     692{
     693    static NativeJITCode* result;
     694    static std::once_flag onceKey;
     695    std::call_once(onceKey, [&] {
     696        result = new NativeJITCode(LLInt::getCodeRef<JSEntryPtrTag>(llint_native_call_trampoline), JITCode::HostCallThunk, NoIntrinsic);
     697    });
     698    return makeRef(*result);
     699}
     700
     701static Ref<NativeJITCode> jitCodeForConstructTrampoline()
     702{
     703    static NativeJITCode* result;
     704    static std::once_flag onceKey;
     705    std::call_once(onceKey, [&] {
     706        result = new NativeJITCode(LLInt::getCodeRef<JSEntryPtrTag>(llint_native_construct_trampoline), JITCode::HostCallThunk, NoIntrinsic);
     707    });
     708    return makeRef(*result);
     709}
     710
    691711NativeExecutable* VM::getHostFunction(NativeFunction function, Intrinsic intrinsic, NativeFunction constructor, const DOMJIT::Signature* signature, const String& name)
    692712{
     
    701721    UNUSED_PARAM(intrinsic);
    702722    UNUSED_PARAM(signature);
    703 
    704     return NativeExecutable::create(*this,
    705         adoptRef(*new NativeJITCode(LLInt::getCodeRef<JSEntryPtrTag>(llint_native_call_trampoline), JITCode::HostCallThunk, NoIntrinsic)), function,
    706         adoptRef(*new NativeJITCode(LLInt::getCodeRef<JSEntryPtrTag>(llint_native_construct_trampoline), JITCode::HostCallThunk, NoIntrinsic)), constructor,
    707         name);
     723    return NativeExecutable::create(*this, jitCodeForCallTrampoline(), function, jitCodeForConstructTrampoline(), constructor, name);
    708724}
    709725
Note: See TracChangeset for help on using the changeset viewer.