Ignore:
Timestamp:
May 5, 2009, 8:20:10 PM (16 years ago)
Author:
[email protected]
Message:

2009-05-05 Geoffrey Garen <[email protected]>

Reviewed by Cameron Zwarich.


Moved all the JIT stub related code into one place.

  • jit/JIT.cpp:
  • jit/JIT.h:
  • jit/JITCode.h:
  • jit/JITStubs.cpp: (JSC::):
  • jit/JITStubs.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/jit/JITStubs.cpp

    r43220 r43273  
    6262
    6363namespace JSC {
     64
     65
     66#if COMPILER(GCC) && PLATFORM(X86)
     67
     68COMPILE_ASSERT(STUB_ARGS_code == 0x0C, STUB_ARGS_code_is_0x0C);
     69COMPILE_ASSERT(STUB_ARGS_callFrame == 0x0E, STUB_ARGS_callFrame_is_0x0E);
     70
     71#if PLATFORM(DARWIN)
     72#define SYMBOL_STRING(name) "_" #name
     73#else
     74#define SYMBOL_STRING(name) #name
     75#endif
     76
     77asm(
     78".globl " SYMBOL_STRING(ctiTrampoline) "\n"
     79SYMBOL_STRING(ctiTrampoline) ":" "\n"
     80    "pushl %ebp" "\n"
     81    "movl %esp, %ebp" "\n"
     82    "pushl %esi" "\n"
     83    "pushl %edi" "\n"
     84    "pushl %ebx" "\n"
     85    "subl $0x1c, %esp" "\n"
     86    "movl $512, %esi" "\n"
     87    "movl 0x38(%esp), %edi" "\n" // Ox38 = 0x0E * 4, 0x0E = STUB_ARGS_callFrame (see assertion above)
     88    "call *0x30(%esp)" "\n" // Ox30 = 0x0C * 4, 0x0C = STUB_ARGS_code (see assertion above)
     89    "addl $0x1c, %esp" "\n"
     90    "popl %ebx" "\n"
     91    "popl %edi" "\n"
     92    "popl %esi" "\n"
     93    "popl %ebp" "\n"
     94    "ret" "\n"
     95);
     96
     97asm(
     98".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
     99SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
     100#if USE(JIT_STUB_ARGUMENT_VA_LIST)
     101    "call " SYMBOL_STRING(_ZN3JSC8JITStubs12cti_vm_throwEPvz) "\n"
     102#else
     103#if USE(JIT_STUB_ARGUMENT_REGISTER)
     104    "movl %esp, %ecx" "\n"
     105#else // JIT_STUB_ARGUMENT_STACK
     106    "movl %esp, 0(%esp)" "\n"
     107#endif
     108    "call " SYMBOL_STRING(_ZN3JSC8JITStubs12cti_vm_throwEPPv) "\n"
     109#endif
     110    "addl $0x1c, %esp" "\n"
     111    "popl %ebx" "\n"
     112    "popl %edi" "\n"
     113    "popl %esi" "\n"
     114    "popl %ebp" "\n"
     115    "ret" "\n"
     116);
     117   
     118#elif COMPILER(GCC) && PLATFORM(X86_64)
     119
     120COMPILE_ASSERT(STUB_ARGS_code == 0x10, STUB_ARGS_code_is_0x10);
     121COMPILE_ASSERT(STUB_ARGS_callFrame == 0x12, STUB_ARGS_callFrame_is_0x12);
     122
     123#if PLATFORM(DARWIN)
     124#define SYMBOL_STRING(name) "_" #name
     125#else
     126#define SYMBOL_STRING(name) #name
     127#endif
     128
     129asm(
     130".globl " SYMBOL_STRING(ctiTrampoline) "\n"
     131SYMBOL_STRING(ctiTrampoline) ":" "\n"
     132    "pushq %rbp" "\n"
     133    "movq %rsp, %rbp" "\n"
     134    "pushq %r12" "\n"
     135    "pushq %r13" "\n"
     136    "pushq %r14" "\n"
     137    "pushq %r15" "\n"
     138    "pushq %rbx" "\n"
     139    "subq $0x48, %rsp" "\n"
     140    "movq $512, %r12" "\n"
     141    "movq $0xFFFF000000000000, %r14" "\n"
     142    "movq $0xFFFF000000000002, %r15" "\n"
     143    "movq 0x90(%rsp), %r13" "\n" // Ox90 = 0x12 * 8, 0x12 = STUB_ARGS_callFrame (see assertion above)
     144    "call *0x80(%rsp)" "\n" // Ox80 = 0x10 * 8, 0x10 = STUB_ARGS_code (see assertion above)
     145    "addq $0x48, %rsp" "\n"
     146    "popq %rbx" "\n"
     147    "popq %r15" "\n"
     148    "popq %r14" "\n"
     149    "popq %r13" "\n"
     150    "popq %r12" "\n"
     151    "popq %rbp" "\n"
     152    "ret" "\n"
     153);
     154
     155asm(
     156".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
     157SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
     158#if USE(JIT_STUB_ARGUMENT_REGISTER)
     159    "movq %rsp, %rdi" "\n"
     160    "call " SYMBOL_STRING(_ZN3JSC8JITStubs12cti_vm_throwEPPv) "\n"
     161#else // JIT_STUB_ARGUMENT_VA_LIST or JIT_STUB_ARGUMENT_STACK
     162#error "JIT_STUB_ARGUMENT configuration not supported."
     163#endif
     164    "addq $0x48, %rsp" "\n"
     165    "popq %rbx" "\n"
     166    "popq %r15" "\n"
     167    "popq %r14" "\n"
     168    "popq %r13" "\n"
     169    "popq %r12" "\n"
     170    "popq %rbp" "\n"
     171    "ret" "\n"
     172);
     173   
     174#elif COMPILER(MSVC)
     175
     176extern "C" {
     177   
     178    __declspec(naked) EncodedJSValue ctiTrampoline(void* code, RegisterFile*, CallFrame*, JSValue* exception, Profiler**, JSGlobalData*)
     179    {
     180        __asm {
     181            push ebp;
     182            mov ebp, esp;
     183            push esi;
     184            push edi;
     185            push ebx;
     186            sub esp, 0x1c;
     187            mov esi, 512;
     188            mov ecx, esp;
     189            mov edi, [esp + 0x38];
     190            call [esp + 0x30]; // Ox30 = 0x0C * 4, 0x0C = STUB_ARGS_code (see assertion above)
     191            add esp, 0x1c;
     192            pop ebx;
     193            pop edi;
     194            pop esi;
     195            pop ebp;
     196            ret;
     197        }
     198    }
     199   
     200    __declspec(naked) void ctiVMThrowTrampoline()
     201    {
     202        __asm {
     203#if USE(JIT_STUB_ARGUMENT_REGISTER)
     204            mov ecx, esp;
     205#else // JIT_STUB_ARGUMENT_VA_LIST or JIT_STUB_ARGUMENT_STACK
     206#error "JIT_STUB_ARGUMENT configuration not supported."
     207#endif
     208            call JSC::JITStubs::cti_vm_throw;
     209            add esp, 0x1c;
     210            pop ebx;
     211            pop edi;
     212            pop esi;
     213            pop ebp;
     214            ret;
     215        }
     216    }
     217   
     218}
     219
     220#endif
    64221
    65222#if ENABLE(OPCODE_SAMPLING)
     
    22862443}
    22872444
    2288 #undef STUB_RETURN_ADDRESS
    2289 #undef STUB_SET_RETURN_ADDRESS
    2290 #undef BEGIN_STUB_FUNCTION
    2291 #undef CHECK_FOR_EXCEPTION
    2292 #undef CHECK_FOR_EXCEPTION_AT_END
    2293 #undef CHECK_FOR_EXCEPTION_VOID
    2294 #undef VM_THROW_EXCEPTION
    2295 #undef VM_THROW_EXCEPTION_2
    2296 #undef VM_THROW_EXCEPTION_AT_END
    2297 
    22982445} // namespace JSC
    22992446
Note: See TracChangeset for help on using the changeset viewer.