Changeset 250810 in webkit


Ignore:
Timestamp:
Oct 7, 2019 6:10:24 PM (4 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Clean up ThunkGenerator's nativeCallTrampoline generator code
https://bugs.webkit.org/show_bug.cgi?id=202657

Reviewed by Saam Barati.

ThunkGenerator has per-architecture JIT code for nativeForGenerator, but this is unnecessary.
This patch cleans up it and unifies the implementations.

  • jit/ThunkGenerators.cpp:

(JSC::nativeForGenerator):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r250806 r250810  
     12019-10-07  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Clean up ThunkGenerator's nativeCallTrampoline generator code
     4        https://bugs.webkit.org/show_bug.cgi?id=202657
     5
     6        Reviewed by Saam Barati.
     7
     8        ThunkGenerator has per-architecture JIT code for nativeForGenerator, but this is unnecessary.
     9        This patch cleans up it and unifies the implementations.
     10
     11        * jit/ThunkGenerators.cpp:
     12        (JSC::nativeForGenerator):
     13
    1142019-10-07  Saam Barati  <sbarati@apple.com>
    215
  • trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp

    r250803 r250810  
    246246    // https://bugs.webkit.org/show_bug.cgi?id=155689
    247247
    248     // FIXME: We should clean up by removing per-architecture code.
    249     // https://bugs.webkit.org/show_bug.cgi?id=202657
    250    
    251248    int executableOffsetToFunction = NativeExecutable::offsetOfNativeFunctionFor(kind);
    252249   
     
    270267
    271268    jit.emitPutToCallFrameHeader(0, CallFrameSlot::codeBlock);
    272     jit.storePtr(JSInterfaceJIT::callFrameRegister, &vm.topCallFrame);
    273 
    274 #if CPU(X86_64)
    275 #if !OS(WINDOWS)
    276     // Calling convention:      f(edi, esi, edx, ecx, ...);
     269    jit.storePtr(GPRInfo::callFrameRegister, &vm.topCallFrame);
     270
    277271    // Host function signature: f(JSGlobalObject*, CallFrame*);
    278     jit.move(JSInterfaceJIT::callFrameRegister, X86Registers::esi);
    279 
    280     jit.emitGetFromCallFrameHeaderPtr(CallFrameSlot::callee, X86Registers::edi);
    281     if (thunkFunctionType == ThunkFunctionType::JSFunction) {
    282         jit.loadPtr(JSInterfaceJIT::Address(X86Registers::edi, JSFunction::offsetOfExecutable()), X86Registers::r9);
    283         jit.loadPtr(JSInterfaceJIT::Address(X86Registers::edi, JSFunction::offsetOfGlobalObject()), X86Registers::edi);
    284         jit.loadPtr(JSInterfaceJIT::Address(X86Registers::r9, executableOffsetToFunction), X86Registers::r9);
    285     } else {
    286         jit.loadPtr(JSInterfaceJIT::Address(X86Registers::edi, InternalFunction::offsetOfNativeFunctionFor(kind)), X86Registers::r9);
    287         jit.loadPtr(JSInterfaceJIT::Address(X86Registers::edi, InternalFunction::offsetOfGlobalObject()), X86Registers::edi);
    288     }
    289     jit.call(X86Registers::r9, JSEntryPtrTag);
    290 
    291 #else
    292     // Calling convention:      f(ecx, edx, r8, r9, ...);
    293     // Host function signature: f(JSGlobalObject*, CallFrame*);
    294     jit.move(JSInterfaceJIT::callFrameRegister, X86Registers::edx);
    295 
     272#if CPU(X86_64) && OS(WINDOWS)
    296273    // Leave space for the callee parameter home addresses.
    297274    // At this point the stack is aligned to 16 bytes, but if this changes at some point, we need to emit code to align it.
    298     jit.subPtr(JSInterfaceJIT::TrustedImm32(4 * sizeof(int64_t)), JSInterfaceJIT::stackPointerRegister);
    299 
    300     jit.emitGetFromCallFrameHeaderPtr(CallFrameSlot::callee, X86Registers::ecx);
     275    jit.subPtr(CCallHelpers::TrustedImm32(4 * sizeof(int64_t)), CCallHelpers::stackPointerRegister);
     276#elif CPU(MIPS)
     277    // Allocate stack space for (unused) 16 bytes (8-byte aligned) for 4 arguments.
     278    jit.subPtr(CCallHelpers::TrustedImm32(16), CCallHelpers::stackPointerRegister);
     279#endif
     280
     281    jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR1);
     282    jit.emitGetFromCallFrameHeaderPtr(CallFrameSlot::callee, GPRInfo::argumentGPR2);
     283
    301284    if (thunkFunctionType == ThunkFunctionType::JSFunction) {
    302         jit.loadPtr(JSInterfaceJIT::Address(X86Registers::ecx, JSFunction::offsetOfExecutable()), X86Registers::r9);
    303         jit.loadPtr(JSInterfaceJIT::Address(X86Registers::ecx, JSFunction::offsetOfGlobalObject()), X86Registers::ecx);
    304         jit.loadPtr(JSInterfaceJIT::Address(X86Registers::r9, executableOffsetToFunction), X86Registers::r9);
     285        jit.loadPtr(CCallHelpers::Address(GPRInfo::argumentGPR2, JSFunction::offsetOfGlobalObject()), GPRInfo::argumentGPR0);
     286        jit.loadPtr(CCallHelpers::Address(GPRInfo::argumentGPR2, JSFunction::offsetOfExecutable()), GPRInfo::argumentGPR2);
     287        jit.call(CCallHelpers::Address(GPRInfo::argumentGPR2, executableOffsetToFunction), JSEntryPtrTag);
    305288    } else {
    306         jit.loadPtr(JSInterfaceJIT::Address(X86Registers::ecx, InternalFunction::offsetOfNativeFunctionFor(kind)), X86Registers::r9);
    307         jit.loadPtr(JSInterfaceJIT::Address(X86Registers::ecx, InternalFunction::offsetOfGlobalObject()), X86Registers::ecx);
     289        ASSERT(thunkFunctionType == ThunkFunctionType::InternalFunction);
     290        jit.loadPtr(CCallHelpers::Address(GPRInfo::argumentGPR2, InternalFunction::offsetOfGlobalObject()), GPRInfo::argumentGPR0);
     291        jit.call(CCallHelpers::Address(GPRInfo::argumentGPR2, InternalFunction::offsetOfNativeFunctionFor(kind)), JSEntryPtrTag);
    308292    }
    309     jit.call(X86Registers::r9, JSEntryPtrTag);
    310 
    311     jit.addPtr(JSInterfaceJIT::TrustedImm32(4 * sizeof(int64_t)), JSInterfaceJIT::stackPointerRegister);
    312 #endif
    313 
    314 #elif CPU(ARM64)
    315     COMPILE_ASSERT(ARM64Registers::x0 != JSInterfaceJIT::regT3, T3_not_trampled_by_arg_0);
    316     COMPILE_ASSERT(ARM64Registers::x1 != JSInterfaceJIT::regT3, T3_not_trampled_by_arg_1);
    317     COMPILE_ASSERT(ARM64Registers::x2 != JSInterfaceJIT::regT3, T3_not_trampled_by_arg_2);
    318 
    319     // Host function signature: f(JSGlobalObject*, CallFrame*);
    320     jit.move(JSInterfaceJIT::callFrameRegister, ARM64Registers::x1);
    321 
    322     jit.emitGetFromCallFrameHeaderPtr(CallFrameSlot::callee, ARM64Registers::x0);
    323     if (thunkFunctionType == ThunkFunctionType::JSFunction) {
    324         jit.loadPtr(JSInterfaceJIT::Address(ARM64Registers::x0, JSFunction::offsetOfExecutable()), ARM64Registers::x2);
    325         jit.loadPtr(JSInterfaceJIT::Address(ARM64Registers::x0, JSFunction::offsetOfGlobalObject()), ARM64Registers::x0);
    326         jit.loadPtr(JSInterfaceJIT::Address(ARM64Registers::x2, executableOffsetToFunction), ARM64Registers::x2);
    327     } else {
    328         jit.loadPtr(JSInterfaceJIT::Address(ARM64Registers::x0, InternalFunction::offsetOfNativeFunctionFor(kind)), ARM64Registers::x2);
    329         jit.loadPtr(JSInterfaceJIT::Address(ARM64Registers::x0, InternalFunction::offsetOfGlobalObject()), ARM64Registers::x0);
    330     }
    331     jit.call(ARM64Registers::x2, JSEntryPtrTag);
    332 
    333 #elif CPU(ARM_THUMB2) || CPU(MIPS)
    334 #if CPU(MIPS)
    335     // Allocate stack space for (unused) 16 bytes (8-byte aligned) for 4 arguments.
    336     jit.subPtr(JSInterfaceJIT::TrustedImm32(16), JSInterfaceJIT::stackPointerRegister);
    337 #endif
    338 
    339     static_assert(GPRInfo::regT2 != GPRInfo::argumentGPR0);
    340     static_assert(GPRInfo::regT2 != GPRInfo::argumentGPR1);
    341 
    342     // Calling convention is f(argumentGPR0, argumentGPR1, ...).
    343     // Host function signature: f(JSGlobalObject*, CallFrame*);
    344     jit.move(JSInterfaceJIT::callFrameRegister, JSInterfaceJIT::argumentGPR1);
    345 
    346     jit.emitGetFromCallFrameHeaderPtr(CallFrameSlot::callee, JSInterfaceJIT::argumentGPR0);
    347     if (thunkFunctionType == ThunkFunctionType::JSFunction) {
    348         jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::argumentGPR0, JSFunction::offsetOfExecutable()), JSInterfaceJIT::regT2);
    349         jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::argumentGPR0, JSFunction::offsetOfGlobalObject()), JSInterfaceJIT::argumentGPR0);
    350         jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::regT2, executableOffsetToFunction), JSInterfaceJIT::regT2);
    351     } else {
    352         jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::argumentGPR0, InternalFunction::offsetOfNativeFunctionFor(kind)), JSInterfaceJIT::regT2);
    353         jit.loadPtr(JSInterfaceJIT::Address(JSInterfaceJIT::argumentGPR0, InternalFunction::offsetOfGlobalObject()), JSInterfaceJIT::argumentGPR0);
    354     }
    355 
    356     jit.call(JSInterfaceJIT::regT2, JSEntryPtrTag);
    357 
    358 #if CPU(MIPS)
    359     // Restore stack space
    360     jit.addPtr(JSInterfaceJIT::TrustedImm32(16), JSInterfaceJIT::stackPointerRegister);
    361 #endif
    362 #else
    363 #error "JIT not supported on this platform."
    364     UNUSED_PARAM(executableOffsetToFunction);
    365     abortWithReason(TGNotSupported);
     293
     294#if CPU(X86_64) && OS(WINDOWS)
     295    jit.addPtr(CCallHelpers::TrustedImm32(4 * sizeof(int64_t)), CCallHelpers::stackPointerRegister);
     296#elif CPU(MIPS)
     297    jit.addPtr(CCallHelpers::TrustedImm32(16), CCallHelpers::stackPointerRegister);
    366298#endif
    367299
Note: See TracChangeset for help on using the changeset viewer.