Changeset 241557 in webkit


Ignore:
Timestamp:
Feb 14, 2019 11:10:15 AM (5 years ago)
Author:
ysuzuki@apple.com
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):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r241552 r241557  
     12019-02-14  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Should have default NativeJITCode
     4        https://bugs.webkit.org/show_bug.cgi?id=194634
     5
     6        Reviewed by Mark Lam.
     7
     8        In JSC_useJIT=false mode, we always create identical NativeJITCode for call and construct when we create NativeExecutable.
     9        This is meaningless since we do not modify NativeJITCode after the creation. This patch adds singleton used as a default one.
     10        Since NativeJITCode (& JITCode) is ThreadSafeRefCounted, we can just share it in a whole process level. This removes 446 NativeJITCode
     11        allocations, which takes 14KB.
     12
     13        * runtime/VM.cpp:
     14        (JSC::jitCodeForCallTrampoline):
     15        (JSC::jitCodeForConstructTrampoline):
     16        (JSC::VM::getHostFunction):
     17
    1182019-02-14  Tadeu Zagallo  <tzagallo@apple.com>
    219
  • 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.