diff options
Diffstat (limited to 'Source/JavaScriptCore/jit/JITStubs.cpp')
-rw-r--r-- | Source/JavaScriptCore/jit/JITStubs.cpp | 198 |
1 files changed, 23 insertions, 175 deletions
diff --git a/Source/JavaScriptCore/jit/JITStubs.cpp b/Source/JavaScriptCore/jit/JITStubs.cpp index ded3428..74f505f 100644 --- a/Source/JavaScriptCore/jit/JITStubs.cpp +++ b/Source/JavaScriptCore/jit/JITStubs.cpp @@ -79,7 +79,7 @@ namespace JSC { #define THUMB_FUNC_PARAM(name) #endif -#if OS(LINUX) && CPU(X86_64) +#if (OS(LINUX) || OS(FREEBSD)) && CPU(X86_64) #define SYMBOL_STRING_RELOCATION(name) #name "@plt" #elif OS(DARWIN) #define SYMBOL_STRING_RELOCATION(name) "_" #name @@ -221,7 +221,7 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "ret" "\n" ); -#elif COMPILER(GCC) && CPU(ARM_THUMB2) +#elif (COMPILER(GCC) || COMPILER(RVCT)) && CPU(ARM_THUMB2) #define THUNK_RETURN_ADDRESS_OFFSET 0x38 #define PRESERVED_RETURN_ADDRESS_OFFSET 0x3C @@ -233,8 +233,10 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" #define EXCEPTION_OFFSET 0x54 #define ENABLE_PROFILER_REFERENCE_OFFSET 0x58 -#elif (COMPILER(GCC) || COMPILER(RVCT)) && CPU(ARM_TRADITIONAL) +#elif (COMPILER(GCC) || COMPILER(MSVC) || COMPILER(RVCT)) && CPU(ARM_TRADITIONAL) +// Also update the MSVC section (defined at DEFINE_STUB_FUNCTION) +// when changing one of the following values. #define THUNK_RETURN_ADDRESS_OFFSET 64 #define PRESERVEDR4_OFFSET 68 @@ -298,12 +300,6 @@ extern "C" { } } -#elif COMPILER(MSVC) && CPU(ARM_TRADITIONAL) - -#define THUNK_RETURN_ADDRESS_OFFSET 64 -#define PRESERVEDR4_OFFSET 68 -// See DEFINE_STUB_FUNCTION for more information. - #elif CPU(MIPS) #define PRESERVED_GP_OFFSET 60 @@ -325,58 +321,7 @@ extern "C" { #else // USE(JSVALUE32_64) -#if COMPILER(GCC) && CPU(X86) - -// These ASSERTs remind you that, if you change the layout of JITStackFrame, you -// need to change the assembly trampolines below to match. -COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x38, JITStackFrame_callFrame_offset_matches_ctiTrampoline); -COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_offset_matches_ctiTrampoline); -COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline); - -asm ( -".text\n" -".globl " SYMBOL_STRING(ctiTrampoline) "\n" -HIDE_SYMBOL(ctiTrampoline) "\n" -SYMBOL_STRING(ctiTrampoline) ":" "\n" - "pushl %ebp" "\n" - "movl %esp, %ebp" "\n" - "pushl %esi" "\n" - "pushl %edi" "\n" - "pushl %ebx" "\n" - "subl $0x1c, %esp" "\n" - "movl $512, %esi" "\n" - "movl 0x38(%esp), %edi" "\n" - "call *0x30(%esp)" "\n" - "addl $0x1c, %esp" "\n" - "popl %ebx" "\n" - "popl %edi" "\n" - "popl %esi" "\n" - "popl %ebp" "\n" - "ret" "\n" -); - -asm ( -".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" -HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" -SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" - "movl %esp, %ecx" "\n" - "call " SYMBOL_STRING_RELOCATION(cti_vm_throw) "\n" - "int3" "\n" -); - -asm ( -".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" -HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" -SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" - "addl $0x1c, %esp" "\n" - "popl %ebx" "\n" - "popl %edi" "\n" - "popl %esi" "\n" - "popl %ebp" "\n" - "ret" "\n" -); - -#elif COMPILER(GCC) && CPU(X86_64) +#if COMPILER(GCC) && CPU(X86_64) // These ASSERTs remind you that, if you change the layout of JITStackFrame, you // need to change the assembly trampolines below to match. @@ -442,103 +387,6 @@ SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "ret" "\n" ); -#elif COMPILER(GCC) && CPU(ARM_THUMB2) - -#define THUNK_RETURN_ADDRESS_OFFSET 0x20 -#define PRESERVED_RETURN_ADDRESS_OFFSET 0x24 -#define PRESERVED_R4_OFFSET 0x28 -#define PRESERVED_R5_OFFSET 0x2C -#define PRESERVED_R6_OFFSET 0x30 -#define REGISTER_FILE_OFFSET 0x34 -#define CALLFRAME_OFFSET 0x38 -#define EXCEPTION_OFFSET 0x3C -#define ENABLE_PROFILER_REFERENCE_OFFSET 0x40 - -#elif (COMPILER(GCC) || COMPILER(RVCT)) && CPU(ARM_TRADITIONAL) - -#define THUNK_RETURN_ADDRESS_OFFSET 32 -#define PRESERVEDR4_OFFSET 36 - -#elif CPU(MIPS) - -#define PRESERVED_GP_OFFSET 28 -#define PRESERVED_S0_OFFSET 32 -#define PRESERVED_S1_OFFSET 36 -#define PRESERVED_S2_OFFSET 40 -#define PRESERVED_RETURN_ADDRESS_OFFSET 44 -#define THUNK_RETURN_ADDRESS_OFFSET 48 -#define REGISTER_FILE_OFFSET 52 -#define CALLFRAME_OFFSET 56 -#define EXCEPTION_OFFSET 60 -#define ENABLE_PROFILER_REFERENCE_OFFSET 64 -#define GLOBAL_DATA_OFFSET 68 -#define STACK_LENGTH 72 - -#elif COMPILER(MSVC) && CPU(X86) - -// These ASSERTs remind you that, if you change the layout of JITStackFrame, you -// need to change the assembly trampolines below to match. -COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x38, JITStackFrame_callFrame_offset_matches_ctiTrampoline); -COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_offset_matches_ctiTrampoline); -COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline); - -extern "C" { - - __declspec(naked) EncodedJSValue ctiTrampoline(void* code, RegisterFile*, CallFrame*, void* /*unused1*/, Profiler**, JSGlobalData*) - { - __asm { - push ebp; - mov ebp, esp; - push esi; - push edi; - push ebx; - sub esp, 0x1c; - mov esi, 512; - mov ecx, esp; - mov edi, [esp + 0x38]; - call [esp + 0x30]; - add esp, 0x1c; - pop ebx; - pop edi; - pop esi; - pop ebp; - ret; - } - } - - __declspec(naked) void ctiVMThrowTrampoline() - { - __asm { - mov ecx, esp; - call cti_vm_throw; - add esp, 0x1c; - pop ebx; - pop edi; - pop esi; - pop ebp; - ret; - } - } - - __declspec(naked) void ctiOpThrowNotCaught() - { - __asm { - add esp, 0x1c; - pop ebx; - pop edi; - pop esi; - pop ebp; - ret; - } - } -} - -#elif COMPILER(MSVC) && CPU(ARM_TRADITIONAL) - -#define THUNK_RETURN_ADDRESS_OFFSET 32 -#define PRESERVEDR4_OFFSET 36 -// See DEFINE_STUB_FUNCTION for more information. - #else #error "JIT not supported on this platform." #endif @@ -997,7 +845,7 @@ NEVER_INLINE void JITThunks::tryCacheGetByID(CallFrame* callFrame, CodeBlock* co // Since we're accessing a prototype in a loop, it's a good bet that it // should not be treated as a dictionary. if (slotBaseObject->structure()->isDictionary()) { - slotBaseObject->flattenDictionaryObject(); + slotBaseObject->flattenDictionaryObject(callFrame->globalData()); offset = slotBaseObject->structure()->get(propertyName); } @@ -1094,17 +942,17 @@ static NEVER_INLINE void throwStackOverflowError(CallFrame* callFrame, JSGlobalD #define CHECK_FOR_EXCEPTION() \ do { \ - if (UNLIKELY(stackFrame.globalData->exception)) \ + if (UNLIKELY(stackFrame.globalData->exception.get())) \ VM_THROW_EXCEPTION(); \ } while (0) #define CHECK_FOR_EXCEPTION_AT_END() \ do { \ - if (UNLIKELY(stackFrame.globalData->exception)) \ + if (UNLIKELY(stackFrame.globalData->exception.get())) \ VM_THROW_EXCEPTION_AT_END(); \ } while (0) #define CHECK_FOR_EXCEPTION_VOID() \ do { \ - if (UNLIKELY(stackFrame.globalData->exception)) { \ + if (UNLIKELY(stackFrame.globalData->exception.get())) { \ VM_THROW_EXCEPTION_AT_END(); \ return; \ } \ @@ -1270,13 +1118,13 @@ MSVC_BEGIN() MSVC_BEGIN(ctiTrampoline PROC) MSVC_BEGIN( stmdb sp!, {r1-r3}) MSVC_BEGIN( stmdb sp!, {r4-r8, lr}) -MSVC_BEGIN( sub sp, sp, # THUNK_RETURN_ADDRESS_OFFSET + 4) +MSVC_BEGIN( sub sp, sp, #68 ; sync with PRESERVEDR4_OFFSET) MSVC_BEGIN( mov r4, r2) MSVC_BEGIN( mov r5, #512) MSVC_BEGIN( ; r0 contains the code) MSVC_BEGIN( mov lr, pc) MSVC_BEGIN( bx r0) -MSVC_BEGIN( add sp, sp, # THUNK_RETURN_ADDRESS_OFFSET + 4) +MSVC_BEGIN( add sp, sp, #68 ; sync with PRESERVEDR4_OFFSET) MSVC_BEGIN( ldmia sp!, {r4-r8, lr}) MSVC_BEGIN( add sp, sp, #12) MSVC_BEGIN( bx lr) @@ -1287,7 +1135,7 @@ MSVC_BEGIN( mov r0, sp) MSVC_BEGIN( mov lr, pc) MSVC_BEGIN( bl cti_vm_throw) MSVC_BEGIN(ctiOpThrowNotCaught) -MSVC_BEGIN( add sp, sp, # THUNK_RETURN_ADDRESS_OFFSET + 4) +MSVC_BEGIN( add sp, sp, #68 ; sync with PRESERVEDR4_OFFSET) MSVC_BEGIN( ldmia sp!, {r4-r8, lr}) MSVC_BEGIN( add sp, sp, #12) MSVC_BEGIN( bx lr) @@ -1297,9 +1145,9 @@ MSVC_BEGIN() MSVC( EXPORT cti_#op#) MSVC( IMPORT JITStubThunked_#op#) MSVC(cti_#op# PROC) -MSVC( str lr, [sp, # THUNK_RETURN_ADDRESS_OFFSET]) +MSVC( str lr, [sp, #64] ; sync with THUNK_RETURN_ADDRESS_OFFSET) MSVC( bl JITStubThunked_#op#) -MSVC( ldr lr, [sp, # THUNK_RETURN_ADDRESS_OFFSET]) +MSVC( ldr lr, [sp, #64] ; sync with THUNK_RETURN_ADDRESS_OFFSET) MSVC( bx lr) MSVC(cti_#op# ENDP) MSVC() @@ -1618,7 +1466,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_method_check) // Since we're accessing a prototype in a loop, it's a good bet that it // should not be treated as a dictionary. if (slotBaseObject->structure()->isDictionary()) - slotBaseObject->flattenDictionaryObject(); + slotBaseObject->flattenDictionaryObject(callFrame->globalData()); // The result fetched should always be the callee! ASSERT(result == JSValue(callee)); @@ -1808,7 +1656,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_proto_list) // Since we're accessing a prototype in a loop, it's a good bet that it // should not be treated as a dictionary. if (slotBaseObject->structure()->isDictionary()) { - slotBaseObject->flattenDictionaryObject(); + slotBaseObject->flattenDictionaryObject(callFrame->globalData()); offset = slotBaseObject->structure()->get(propertyName); } @@ -2299,7 +2147,7 @@ DEFINE_STUB_FUNCTION(void, op_tear_off_activation) activation->copyRegisters(); if (JSValue v = stackFrame.args[1].jsValue()) { if (!stackFrame.callFrame->codeBlock()->isStrictMode()) - asArguments(v)->setActivation(activation); + asArguments(v)->setActivation(*stackFrame.globalData, activation); } } @@ -2356,7 +2204,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve) Identifier& ident = stackFrame.args[0].identifier(); do { - JSObject* o = *iter; + JSObject* o = iter->get(); PropertySlot slot(o); if (o->getPropertySlot(callFrame, ident, slot)) { JSValue result = slot.getValue(callFrame, ident); @@ -2549,7 +2397,7 @@ DEFINE_STUB_FUNCTION(void, op_put_by_val) if (isJSArray(globalData, baseValue)) { JSArray* jsArray = asArray(baseValue); if (jsArray->canSetIndex(i)) - jsArray->setIndex(i, value); + jsArray->setIndex(*globalData, i, value); else jsArray->JSArray::put(callFrame, i, value); } else if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) { @@ -2797,7 +2645,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_skip) } Identifier& ident = stackFrame.args[0].identifier(); do { - JSObject* o = *iter; + JSObject* o = iter->get(); PropertySlot slot(o); if (o->getPropertySlot(callFrame, ident, slot)) { JSValue result = slot.getValue(callFrame, ident); @@ -3126,7 +2974,7 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_with_base) Identifier& ident = stackFrame.args[0].identifier(); JSObject* base; do { - base = *iter; + base = iter->get(); PropertySlot slot(base); if (base->getPropertySlot(callFrame, ident, slot)) { JSValue result = slot.getValue(callFrame, ident); @@ -3632,7 +3480,7 @@ DEFINE_STUB_FUNCTION(void*, vm_throw) { STUB_INIT_STACK_FRAME(stackFrame); JSGlobalData* globalData = stackFrame.globalData; - ExceptionHandler handler = jitThrow(globalData, stackFrame.callFrame, globalData->exception, globalData->exceptionLocation); + ExceptionHandler handler = jitThrow(globalData, stackFrame.callFrame, globalData->exception.get(), globalData->exceptionLocation); STUB_SET_RETURN_ADDRESS(handler.catchRoutine); return handler.callFrame; } |