Changeset 44838 in webkit for trunk/JavaScriptCore/jit


Ignore:
Timestamp:
Jun 18, 2009, 7:32:29 PM (16 years ago)
Author:
[email protected]
Message:

2009-06-18 Gavin Barraclough <[email protected]>

Rubber Stamped by Mark Rowe (originally reviewed by Sam Weinig).

(Reintroducing patch added in r44492, and reverted in r44796.)

Change the implementation of op_throw so the stub function always modifies its
return address - if it doesn't find a 'catch' it will switch to a trampoline
to force a return from JIT execution. This saves memory, by avoiding the need
for a unique return for every op_throw.

  • jit/JITOpcodes.cpp: (JSC::JIT::emit_op_throw):

JITStubs::cti_op_throw now always changes its return address,
remove return code generated after the stub call (this is now
handled by ctiOpThrowNotCaught).

  • jit/JITStubs.cpp: (JSC::):

Add ctiOpThrowNotCaught definitions.

(JSC::JITStubs::DEFINE_STUB_FUNCTION):

Change cti_op_throw to always change its return address.

  • jit/JITStubs.h:

Add ctiOpThrowNotCaught declaration.

Location:
trunk/JavaScriptCore/jit
Files:
3 edited

Legend:

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

    r44796 r44838  
    623623    stubCall.call();
    624624    ASSERT(regT0 == returnValueRegister);
    625 #if PLATFORM(X86_64)
    626     addPtr(Imm32(0x48), X86::esp);
    627     pop(X86::ebx);
    628     pop(X86::r15);
    629     pop(X86::r14);
    630     pop(X86::r13);
    631     pop(X86::r12);
    632     pop(X86::ebp);
    633     ret();
    634 #else
    635     addPtr(Imm32(0x1c), X86::esp);
    636     pop(X86::ebx);
    637     pop(X86::edi);
    638     pop(X86::esi);
    639     pop(X86::ebp);
    640     ret();
     625#ifndef NDEBUG
     626    // cti_op_throw always changes it's return address,
     627    // this point in the code should never be reached.
     628    breakpoint();
    641629#endif
    642630}
  • trunk/JavaScriptCore/jit/JITStubs.cpp

    r44796 r44838  
    7878COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
    7979
    80 asm(
     80asm volatile (
    8181".globl " SYMBOL_STRING(ctiTrampoline) "\n"
    8282SYMBOL_STRING(ctiTrampoline) ":" "\n"
     
    9898);
    9999
    100 asm(
     100asm volatile (
    101101".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
    102102SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
     
    113113);
    114114   
     115asm volatile (
     116".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
     117SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
     118    "addl $0x1c, %esp" "\n"
     119    "popl %ebx" "\n"
     120    "popl %edi" "\n"
     121    "popl %esi" "\n"
     122    "popl %ebp" "\n"
     123    "ret" "\n"
     124);
     125   
    115126#elif COMPILER(GCC) && PLATFORM(X86_64)
    116127
     
    125136COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x48, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
    126137
    127 asm(
     138asm volatile (
    128139".globl " SYMBOL_STRING(ctiTrampoline) "\n"
    129140SYMBOL_STRING(ctiTrampoline) ":" "\n"
     
    151162);
    152163
    153 asm(
     164asm volatile (
    154165".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
    155166SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
     
    166177);
    167178
     179asm volatile (
     180".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
     181SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
     182    "addq $0x48, %rsp" "\n"
     183    "popq %rbx" "\n"
     184    "popq %r15" "\n"
     185    "popq %r14" "\n"
     186    "popq %r13" "\n"
     187    "popq %r12" "\n"
     188    "popq %rbp" "\n"
     189    "ret" "\n"
     190);
     191
    168192#elif COMPILER(GCC) && PLATFORM(ARM_V7)
    169193
     
    183207COMPILE_ASSERT(offsetof(struct JITStackFrame, enabledProfilerReference) == 0x3c, JITStackFrame_enabledProfilerReference_offset_matches_ctiTrampoline);
    184208
    185 asm volatile  (
     209asm volatile (
    186210".text" "\n"
    187211".align 2" "\n"
     
    290314        }
    291315    }
     316     
     317     __declspec(naked) void ctiOpThrowNotCaught()
     318     {
     319         __asm {
     320             add esp, 0x1c;
     321             pop ebx;
     322             pop edi;
     323             pop esi;
     324             pop ebp;
     325             ret;
     326         }
     327     }
    292328}
    293329
     
    23132349    if (!handler) {
    23142350        *stackFrame.exception = exceptionValue;
     2351        STUB_SET_RETURN_ADDRESS(reinterpret_cast<void*>(ctiOpThrowNotCaught));
    23152352        return JSValue::encode(jsNull());
    23162353    }
  • trunk/JavaScriptCore/jit/JITStubs.h

    r44796 r44838  
    183183
    184184    extern "C" void ctiVMThrowTrampoline();
     185    extern "C" void ctiOpThrowNotCaught();
    185186    extern "C" EncodedJSValue ctiTrampoline(
    186187#if PLATFORM(X86_64)
Note: See TracChangeset for help on using the changeset viewer.