Ignore:
Timestamp:
Jul 30, 2009, 1:57:44 PM (16 years ago)
Author:
[email protected]
Message:

Merged nitro-extreme branch into trunk.

File:
1 edited

Legend:

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

    r46247 r46598  
    6363namespace JSC {
    6464
    65 
    6665#if PLATFORM(DARWIN) || PLATFORM(WIN_OS)
    6766#define SYMBOL_STRING(name) "_" #name
     
    7069#endif
    7170
     71#if USE(JSVALUE32_64)
     72
    7273#if COMPILER(GCC) && PLATFORM(X86)
    7374
    7475// These ASSERTs remind you that, if you change the layout of JITStackFrame, you
    7576// need to change the assembly trampolines below to match.
    76 COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x38, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
    77 COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_offset_matches_ctiTrampoline);
    78 COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
     77COMPILE_ASSERT(offsetof(struct JITStackFrame, code) % 16 == 0x0, JITStackFrame_maintains_16byte_stack_alignment);
     78COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x3c, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
     79COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
     80COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_offset_matches_ctiTrampoline);
    7981
    8082asm volatile (
     
    8688    "pushl %edi" "\n"
    8789    "pushl %ebx" "\n"
    88     "subl $0x1c, %esp" "\n"
     90    "subl $0x3c, %esp" "\n"
    8991    "movl $512, %esi" "\n"
    90     "movl 0x38(%esp), %edi" "\n"
    91     "call *0x30(%esp)" "\n"
    92     "addl $0x1c, %esp" "\n"
     92    "movl 0x58(%esp), %edi" "\n"
     93    "call *0x50(%esp)" "\n"
     94    "addl $0x3c, %esp" "\n"
    9395    "popl %ebx" "\n"
    9496    "popl %edi" "\n"
     
    105107#endif
    106108    "call " SYMBOL_STRING(cti_vm_throw) "\n"
    107     "addl $0x1c, %esp" "\n"
     109    "addl $0x3c, %esp" "\n"
    108110    "popl %ebx" "\n"
    109111    "popl %edi" "\n"
     
    116118".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
    117119SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
    118     "addl $0x1c, %esp" "\n"
     120    "addl $0x3c, %esp" "\n"
    119121    "popl %ebx" "\n"
    120122    "popl %edi" "\n"
     
    132134// These ASSERTs remind you that, if you change the layout of JITStackFrame, you
    133135// need to change the assembly trampolines below to match.
     136COMPILE_ASSERT(offsetof(struct JITStackFrame, code) % 32 == 0x0, JITStackFrame_maintains_32byte_stack_alignment);
     137COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x48, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
    134138COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x90, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
    135139COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x80, JITStackFrame_code_offset_matches_ctiTrampoline);
    136 COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x48, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
    137140
    138141asm volatile (
     
    262265// These ASSERTs remind you that, if you change the layout of JITStackFrame, you
    263266// need to change the assembly trampolines below to match.
     267COMPILE_ASSERT(offsetof(struct JITStackFrame, code) % 16 == 0x0, JITStackFrame_maintains_16byte_stack_alignment);
     268COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x3c, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
     269COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x58, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
     270COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x50, JITStackFrame_code_offset_matches_ctiTrampoline);
     271
     272extern "C" {
     273
     274    __declspec(naked) EncodedJSValue ctiTrampoline(void* code, RegisterFile*, CallFrame*, JSValue* exception, Profiler**, JSGlobalData*)
     275    {
     276        __asm {
     277            push ebp;
     278            mov ebp, esp;
     279            push esi;
     280            push edi;
     281            push ebx;
     282            sub esp, 0x3c;
     283            mov esi, 512;
     284            mov ecx, esp;
     285            mov edi, [esp + 0x58];
     286            call [esp + 0x50];
     287            add esp, 0x3c;
     288            pop ebx;
     289            pop edi;
     290            pop esi;
     291            pop ebp;
     292            ret;
     293        }
     294    }
     295
     296    __declspec(naked) void ctiVMThrowTrampoline()
     297    {
     298        __asm {
     299            mov ecx, esp;
     300            call cti_vm_throw;
     301            add esp, 0x3c;
     302            pop ebx;
     303            pop edi;
     304            pop esi;
     305            pop ebp;
     306            ret;
     307        }
     308    }
     309
     310    __declspec(naked) void ctiOpThrowNotCaught()
     311    {
     312        __asm {
     313            add esp, 0x3c;
     314            pop ebx;
     315            pop edi;
     316            pop esi;
     317            pop ebp;
     318            ret;
     319        }
     320    }
     321}
     322
     323#endif // COMPILER(GCC) && PLATFORM(X86)
     324
     325#else // USE(JSVALUE32_64)
     326
     327#if COMPILER(GCC) && PLATFORM(X86)
     328
     329// These ASSERTs remind you that, if you change the layout of JITStackFrame, you
     330// need to change the assembly trampolines below to match.
     331COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x38, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
     332COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_offset_matches_ctiTrampoline);
     333COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
     334
     335asm volatile (
     336".globl " SYMBOL_STRING(ctiTrampoline) "\n"
     337SYMBOL_STRING(ctiTrampoline) ":" "\n"
     338    "pushl %ebp" "\n"
     339    "movl %esp, %ebp" "\n"
     340    "pushl %esi" "\n"
     341    "pushl %edi" "\n"
     342    "pushl %ebx" "\n"
     343    "subl $0x1c, %esp" "\n"
     344    "movl $512, %esi" "\n"
     345    "movl 0x38(%esp), %edi" "\n"
     346    "call *0x30(%esp)" "\n"
     347    "addl $0x1c, %esp" "\n"
     348    "popl %ebx" "\n"
     349    "popl %edi" "\n"
     350    "popl %esi" "\n"
     351    "popl %ebp" "\n"
     352    "ret" "\n"
     353);
     354
     355asm volatile (
     356".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
     357SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
     358#if !USE(JIT_STUB_ARGUMENT_VA_LIST)
     359    "movl %esp, %ecx" "\n"
     360#endif
     361    "call " SYMBOL_STRING(cti_vm_throw) "\n"
     362    "addl $0x1c, %esp" "\n"
     363    "popl %ebx" "\n"
     364    "popl %edi" "\n"
     365    "popl %esi" "\n"
     366    "popl %ebp" "\n"
     367    "ret" "\n"
     368);
     369   
     370asm volatile (
     371".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
     372SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
     373    "addl $0x1c, %esp" "\n"
     374    "popl %ebx" "\n"
     375    "popl %edi" "\n"
     376    "popl %esi" "\n"
     377    "popl %ebp" "\n"
     378    "ret" "\n"
     379);
     380   
     381#elif COMPILER(GCC) && PLATFORM(X86_64)
     382
     383#if USE(JIT_STUB_ARGUMENT_VA_LIST)
     384#error "JIT_STUB_ARGUMENT_VA_LIST not supported on x86-64."
     385#endif
     386
     387// These ASSERTs remind you that, if you change the layout of JITStackFrame, you
     388// need to change the assembly trampolines below to match.
     389COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x90, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
     390COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x80, JITStackFrame_code_offset_matches_ctiTrampoline);
     391COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x48, JITStackFrame_stub_argument_space_matches_ctiTrampoline);
     392
     393asm volatile (
     394".globl " SYMBOL_STRING(ctiTrampoline) "\n"
     395SYMBOL_STRING(ctiTrampoline) ":" "\n"
     396    "pushq %rbp" "\n"
     397    "movq %rsp, %rbp" "\n"
     398    "pushq %r12" "\n"
     399    "pushq %r13" "\n"
     400    "pushq %r14" "\n"
     401    "pushq %r15" "\n"
     402    "pushq %rbx" "\n"
     403    "subq $0x48, %rsp" "\n"
     404    "movq $512, %r12" "\n"
     405    "movq $0xFFFF000000000000, %r14" "\n"
     406    "movq $0xFFFF000000000002, %r15" "\n"
     407    "movq 0x90(%rsp), %r13" "\n"
     408    "call *0x80(%rsp)" "\n"
     409    "addq $0x48, %rsp" "\n"
     410    "popq %rbx" "\n"
     411    "popq %r15" "\n"
     412    "popq %r14" "\n"
     413    "popq %r13" "\n"
     414    "popq %r12" "\n"
     415    "popq %rbp" "\n"
     416    "ret" "\n"
     417);
     418
     419asm volatile (
     420".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
     421SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
     422    "movq %rsp, %rdi" "\n"
     423    "call " SYMBOL_STRING(cti_vm_throw) "\n"
     424    "addq $0x48, %rsp" "\n"
     425    "popq %rbx" "\n"
     426    "popq %r15" "\n"
     427    "popq %r14" "\n"
     428    "popq %r13" "\n"
     429    "popq %r12" "\n"
     430    "popq %rbp" "\n"
     431    "ret" "\n"
     432);
     433
     434asm volatile (
     435".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
     436SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
     437    "addq $0x48, %rsp" "\n"
     438    "popq %rbx" "\n"
     439    "popq %r15" "\n"
     440    "popq %r14" "\n"
     441    "popq %r13" "\n"
     442    "popq %r12" "\n"
     443    "popq %rbp" "\n"
     444    "ret" "\n"
     445);
     446
     447#elif COMPILER(GCC) && PLATFORM_ARM_ARCH(7)
     448
     449#if USE(JIT_STUB_ARGUMENT_VA_LIST)
     450#error "JIT_STUB_ARGUMENT_VA_LIST not supported on ARMv7."
     451#endif
     452
     453asm volatile (
     454".text" "\n"
     455".align 2" "\n"
     456".globl " SYMBOL_STRING(ctiTrampoline) "\n"
     457".thumb" "\n"
     458".thumb_func " SYMBOL_STRING(ctiTrampoline) "\n"
     459SYMBOL_STRING(ctiTrampoline) ":" "\n"
     460    "sub sp, sp, #0x3c" "\n"
     461    "str lr, [sp, #0x20]" "\n"
     462    "str r4, [sp, #0x24]" "\n"
     463    "str r5, [sp, #0x28]" "\n"
     464    "str r6, [sp, #0x2c]" "\n"
     465    "str r1, [sp, #0x30]" "\n"
     466    "str r2, [sp, #0x34]" "\n"
     467    "str r3, [sp, #0x38]" "\n"
     468    "cpy r5, r2" "\n"
     469    "mov r6, #512" "\n"
     470    "blx r0" "\n"
     471    "ldr r6, [sp, #0x2c]" "\n"
     472    "ldr r5, [sp, #0x28]" "\n"
     473    "ldr r4, [sp, #0x24]" "\n"
     474    "ldr lr, [sp, #0x20]" "\n"
     475    "add sp, sp, #0x3c" "\n"
     476    "bx lr" "\n"
     477);
     478
     479asm volatile (
     480".text" "\n"
     481".align 2" "\n"
     482".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
     483".thumb" "\n"
     484".thumb_func " SYMBOL_STRING(ctiVMThrowTrampoline) "\n"
     485SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n"
     486    "cpy r0, sp" "\n"
     487    "bl " SYMBOL_STRING(cti_vm_throw) "\n"
     488    "ldr r6, [sp, #0x2c]" "\n"
     489    "ldr r5, [sp, #0x28]" "\n"
     490    "ldr r4, [sp, #0x24]" "\n"
     491    "ldr lr, [sp, #0x20]" "\n"
     492    "add sp, sp, #0x3c" "\n"
     493    "bx lr" "\n"
     494);
     495
     496asm volatile (
     497".text" "\n"
     498".align 2" "\n"
     499".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
     500".thumb" "\n"
     501".thumb_func " SYMBOL_STRING(ctiOpThrowNotCaught) "\n"
     502SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n"
     503    "ldr r6, [sp, #0x2c]" "\n"
     504    "ldr r5, [sp, #0x28]" "\n"
     505    "ldr r4, [sp, #0x24]" "\n"
     506    "ldr lr, [sp, #0x20]" "\n"
     507    "add sp, sp, #0x3c" "\n"
     508    "bx lr" "\n"
     509);
     510
     511#elif COMPILER(MSVC)
     512
     513#if USE(JIT_STUB_ARGUMENT_VA_LIST)
     514#error "JIT_STUB_ARGUMENT_VA_LIST configuration not supported on MSVC."
     515#endif
     516
     517// These ASSERTs remind you that, if you change the layout of JITStackFrame, you
     518// need to change the assembly trampolines below to match.
    264519COMPILE_ASSERT(offsetof(struct JITStackFrame, callFrame) == 0x38, JITStackFrame_callFrame_offset_matches_ctiTrampoline);
    265520COMPILE_ASSERT(offsetof(struct JITStackFrame, code) == 0x30, JITStackFrame_code_offset_matches_ctiTrampoline);
     
    294549        __asm {
    295550            mov ecx, esp;
    296             call JITStubs::cti_vm_throw;
     551            call cti_vm_throw;
    297552            add esp, 0x1c;
    298553            pop ebx;
     
    317572}
    318573
    319 #endif
     574#endif // COMPILER(GCC) && PLATFORM(X86)
     575
     576#endif // USE(JSVALUE32_64)
    320577
    321578#if ENABLE(OPCODE_SAMPLING)
     
    327584JITThunks::JITThunks(JSGlobalData* globalData)
    328585{
    329     JIT::compileCTIMachineTrampolines(globalData, &m_executablePool, &m_ctiArrayLengthTrampoline, &m_ctiStringLengthTrampoline, &m_ctiVirtualCallPreLink, &m_ctiVirtualCallLink, &m_ctiVirtualCall, &m_ctiNativeCallThunk);
     586    JIT::compileCTIMachineTrampolines(globalData, &m_executablePool, &m_ctiStringLengthTrampoline, &m_ctiVirtualCallPreLink, &m_ctiVirtualCallLink, &m_ctiVirtualCall, &m_ctiNativeCallThunk);
    330587
    331588#if PLATFORM_ARM_ARCH(7)
     
    359616    // Uncacheable: give up.
    360617    if (!slot.isCacheable()) {
    361         ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(JITStubs::cti_op_put_by_id_generic));
     618        ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_put_by_id_generic));
    362619        return;
    363620    }
     
    367624
    368625    if (structure->isDictionary()) {
    369         ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(JITStubs::cti_op_put_by_id_generic));
     626        ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_put_by_id_generic));
    370627        return;
    371628    }
     
    373630    // If baseCell != base, then baseCell must be a proxy for another object.
    374631    if (baseCell != slot.base()) {
    375         ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(JITStubs::cti_op_put_by_id_generic));
     632        ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_put_by_id_generic));
    376633        return;
    377634    }
     
    385642        StructureChain* prototypeChain = structure->prototypeChain(callFrame);
    386643        if (!prototypeChain->isCacheable()) {
    387             ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(JITStubs::cti_op_put_by_id_generic));
     644            ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_put_by_id_generic));
    388645            return;
    389646        }
     
    405662    // FIXME: Cache property access for immediates.
    406663    if (!baseValue.isCell()) {
    407         ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(JITStubs::cti_op_get_by_id_generic));
     664        ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_get_by_id_generic));
    408665        return;
    409666    }
     
    425682    // Uncacheable: give up.
    426683    if (!slot.isCacheable()) {
    427         ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(JITStubs::cti_op_get_by_id_generic));
     684        ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_get_by_id_generic));
    428685        return;
    429686    }
     
    433690
    434691    if (structure->isDictionary()) {
    435         ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(JITStubs::cti_op_get_by_id_generic));
     692        ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_get_by_id_generic));
    436693        return;
    437694    }
     
    476733    StructureChain* prototypeChain = structure->prototypeChain(callFrame);
    477734    if (!prototypeChain->isCacheable()) {
    478         ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(JITStubs::cti_op_get_by_id_generic));
     735        ctiPatchCallByReturnAddress(codeBlock, returnAddress, FunctionPtr(cti_op_get_by_id_generic));
    479736        return;
    480737    }
     
    483740}
    484741
    485 #endif
     742#endif // ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
    486743
    487744#if USE(JIT_STUB_ARGUMENT_VA_LIST)
     
    560817#define CHECK_FOR_EXCEPTION() \
    561818    do { \
    562         if (UNLIKELY(stackFrame.globalData->exception != JSValue())) \
     819        if (UNLIKELY(stackFrame.globalData->exception)) \
    563820            VM_THROW_EXCEPTION(); \
    564821    } while (0)
    565822#define CHECK_FOR_EXCEPTION_AT_END() \
    566823    do { \
    567         if (UNLIKELY(stackFrame.globalData->exception != JSValue())) \
     824        if (UNLIKELY(stackFrame.globalData->exception)) \
    568825            VM_THROW_EXCEPTION_AT_END(); \
    569826    } while (0)
    570827#define CHECK_FOR_EXCEPTION_VOID() \
    571828    do { \
    572         if (UNLIKELY(stackFrame.globalData->exception != JSValue())) { \
     829        if (UNLIKELY(stackFrame.globalData->exception)) { \
    573830            VM_THROW_EXCEPTION_AT_END(); \
    574831            return; \
    575832        } \
    576833    } while (0)
    577 
    578 namespace JITStubs {
    579834
    580835#if PLATFORM_ARM_ARCH(7)
     
    602857#endif
    603858
    604 DEFINE_STUB_FUNCTION(JSObject*, op_convert_this)
     859DEFINE_STUB_FUNCTION(EncodedJSValue, op_convert_this)
    605860{
    606861    STUB_INIT_STACK_FRAME(stackFrame);
     
    611866    JSObject* result = v1.toThisObject(callFrame);
    612867    CHECK_FOR_EXCEPTION_AT_END();
    613     return result;
     868    return JSValue::encode(result);
    614869}
    615870
     
    651906
    652907    if (rightIsNumber & leftIsString) {
    653         RefPtr<UString::Rep> value = v2.isInt32Fast() ?
    654             concatenate(asString(v1)->value().rep(), v2.getInt32Fast()) :
     908        RefPtr<UString::Rep> value = v2.isInt32() ?
     909            concatenate(asString(v1)->value().rep(), v2.asInt32()) :
    655910            concatenate(asString(v1)->value().rep(), right);
    656911
     
    8061061}
    8071062
    808 
    809 DEFINE_STUB_FUNCTION(EncodedJSValue, op_put_by_id_transition_realloc)
     1063DEFINE_STUB_FUNCTION(JSObject*, op_put_by_id_transition_realloc)
    8101064{
    8111065    STUB_INIT_STACK_FRAME(stackFrame);
    8121066
    8131067    JSValue baseValue = stackFrame.args[0].jsValue();
    814     int32_t oldSize = stackFrame.args[1].int32();
    815     int32_t newSize = stackFrame.args[2].int32();
     1068    int32_t oldSize = stackFrame.args[3].int32();
     1069    int32_t newSize = stackFrame.args[4].int32();
    8161070
    8171071    ASSERT(baseValue.isObject());
    818     asObject(baseValue)->allocatePropertyStorage(oldSize, newSize);
    819 
    820     return JSValue::encode(baseValue);
     1072    JSObject* base = asObject(baseValue);
     1073    base->allocatePropertyStorage(oldSize, newSize);
     1074
     1075    return base;
    8211076}
    8221077
     
    11171372}
    11181373
    1119 #endif
     1374#endif // ENABLE(JIT_OPTIMIZE_PROPERTY_ACCESS)
    11201375
    11211376DEFINE_STUB_FUNCTION(EncodedJSValue, op_instanceof)
     
    12641519}
    12651520
     1521#if ENABLE(JIT_OPTIMIZE_CALL)
    12661522DEFINE_STUB_FUNCTION(void*, vm_dontLazyLinkCall)
    12671523{
     
    12941550    return jitCode.addressForCall().executableAddress();
    12951551}
     1552#endif // !ENABLE(JIT_OPTIMIZE_CALL)
    12961553
    12971554DEFINE_STUB_FUNCTION(JSObject*, op_push_activation)
     
    13591616    Arguments* arguments = new (stackFrame.globalData) Arguments(stackFrame.callFrame);
    13601617    stackFrame.callFrame->setCalleeArguments(arguments);
    1361     stackFrame.callFrame[RegisterFile::ArgumentsRegister] = arguments;
     1618    stackFrame.callFrame[RegisterFile::ArgumentsRegister] = JSValue(arguments);
    13621619}
    13631620
     
    13681625    Arguments* arguments = new (stackFrame.globalData) Arguments(stackFrame.callFrame, Arguments::NoParameters);
    13691626    stackFrame.callFrame->setCalleeArguments(arguments);
    1370     stackFrame.callFrame[RegisterFile::ArgumentsRegister] = arguments;
     1627    stackFrame.callFrame[RegisterFile::ArgumentsRegister] = JSValue(arguments);
    13711628}
    13721629
     
    15201777    JSValue result;
    15211778
    1522     if (LIKELY(subscript.isUInt32Fast())) {
    1523         uint32_t i = subscript.getUInt32Fast();
     1779    if (LIKELY(subscript.isUInt32())) {
     1780        uint32_t i = subscript.asUInt32();
    15241781        if (isJSArray(globalData, baseValue)) {
    15251782            JSArray* jsArray = asArray(baseValue);
     
    15591816    JSValue result;
    15601817   
    1561     if (LIKELY(subscript.isUInt32Fast())) {
    1562         uint32_t i = subscript.getUInt32Fast();
     1818    if (LIKELY(subscript.isUInt32())) {
     1819        uint32_t i = subscript.asUInt32();
    15631820        if (isJSString(globalData, baseValue) && asString(baseValue)->canGetIndex(i))
    15641821            result = asString(baseValue)->getIndex(stackFrame.globalData, i);
     
    15771834}
    15781835   
    1579 
    15801836DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_val_byte_array)
    15811837{
     
    15901846    JSValue result;
    15911847
    1592     if (LIKELY(subscript.isUInt32Fast())) {
    1593         uint32_t i = subscript.getUInt32Fast();
     1848    if (LIKELY(subscript.isUInt32())) {
     1849        uint32_t i = subscript.asUInt32();
    15941850        if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
    15951851            // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
     
    16091865}
    16101866
    1611 DEFINE_STUB_FUNCTION(EncodedJSValue, op_resolve_func)
    1612 {
    1613     STUB_INIT_STACK_FRAME(stackFrame);
    1614 
    1615     CallFrame* callFrame = stackFrame.callFrame;
    1616     ScopeChainNode* scopeChain = callFrame->scopeChain();
    1617 
    1618     ScopeChainIterator iter = scopeChain->begin();
    1619     ScopeChainIterator end = scopeChain->end();
    1620 
    1621     // FIXME: add scopeDepthIsZero optimization
    1622 
    1623     ASSERT(iter != end);
    1624 
    1625     Identifier& ident = stackFrame.args[0].identifier();
    1626     JSObject* base;
    1627     do {
    1628         base = *iter;
    1629         PropertySlot slot(base);
    1630         if (base->getPropertySlot(callFrame, ident, slot)) {           
    1631             // ECMA 11.2.3 says that if we hit an activation the this value should be null.
    1632             // However, section 10.2.3 says that in the case where the value provided
    1633             // by the caller is null, the global object should be used. It also says
    1634             // that the section does not apply to internal functions, but for simplicity
    1635             // of implementation we use the global object anyway here. This guarantees
    1636             // that in host objects you always get a valid object for this.
    1637             // We also handle wrapper substitution for the global object at the same time.
    1638             JSObject* thisObj = base->toThisObject(callFrame);
    1639             JSValue result = slot.getValue(callFrame, ident);
    1640             CHECK_FOR_EXCEPTION_AT_END();
    1641 
    1642             callFrame->registers()[stackFrame.args[1].int32()] = JSValue(thisObj);
    1643             return JSValue::encode(result);
    1644         }
    1645         ++iter;
    1646     } while (iter != end);
    1647 
    1648     CodeBlock* codeBlock = callFrame->codeBlock();
    1649     unsigned vPCIndex = codeBlock->getBytecodeIndex(callFrame, STUB_RETURN_ADDRESS);
    1650     stackFrame.globalData->exception = createUndefinedVariableError(callFrame, ident, vPCIndex, codeBlock);
    1651     VM_THROW_EXCEPTION_AT_END();
    1652     return JSValue::encode(JSValue());
    1653 }
    1654 
    16551867DEFINE_STUB_FUNCTION(EncodedJSValue, op_sub)
    16561868{
     
    16821894    JSValue value = stackFrame.args[2].jsValue();
    16831895
    1684     if (LIKELY(subscript.isUInt32Fast())) {
    1685         uint32_t i = subscript.getUInt32Fast();
     1896    if (LIKELY(subscript.isUInt32())) {
     1897        uint32_t i = subscript.asUInt32();
    16861898        if (isJSArray(globalData, baseValue)) {
    16871899            JSArray* jsArray = asArray(baseValue);
     
    16941906            ctiPatchCallByReturnAddress(callFrame->codeBlock(), STUB_RETURN_ADDRESS, FunctionPtr(cti_op_put_by_val_byte_array));
    16951907            // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
    1696             if (value.isInt32Fast()) {
    1697                 jsByteArray->setIndex(i, value.getInt32Fast());
     1908            if (value.isInt32()) {
     1909                jsByteArray->setIndex(i, value.asInt32());
    16981910                return;
    16991911            } else {
     
    17331945        asArray(baseValue)->JSArray::put(callFrame, i, value);
    17341946    else {
    1735         // This should work since we're re-boxing an immediate unboxed in JIT code.
    1736         ASSERT(JSValue::makeInt32Fast(i));
    1737         Identifier property(callFrame, JSValue::makeInt32Fast(i).toString(callFrame));
    1738         // FIXME: can toString throw an exception here?
    1739         if (!stackFrame.globalData->exception) { // Don't put to an object if toString threw an exception.
    1740             PutPropertySlot slot;
    1741             baseValue.put(callFrame, property, value, slot);
    1742         }
     1947        Identifier property(callFrame, UString::from(i));
     1948        PutPropertySlot slot;
     1949        baseValue.put(callFrame, property, value, slot);
    17431950    }
    17441951
     
    17571964    JSValue value = stackFrame.args[2].jsValue();
    17581965   
    1759     if (LIKELY(subscript.isUInt32Fast())) {
    1760         uint32_t i = subscript.getUInt32Fast();
     1966    if (LIKELY(subscript.isUInt32())) {
     1967        uint32_t i = subscript.asUInt32();
    17611968        if (isJSByteArray(globalData, baseValue) && asByteArray(baseValue)->canAccessIndex(i)) {
    17621969            JSByteArray* jsByteArray = asByteArray(baseValue);
    17631970           
    17641971            // All fast byte array accesses are safe from exceptions so return immediately to avoid exception checks.
    1765             if (value.isInt32Fast()) {
    1766                 jsByteArray->setIndex(i, value.getInt32Fast());
     1972            if (value.isInt32()) {
     1973                jsByteArray->setIndex(i, value.asInt32());
    17671974                return;
    17681975            } else {
     
    18152022{
    18162023    STUB_INIT_STACK_FRAME(stackFrame);
     2024
    18172025    CallFrame* callFrame = stackFrame.callFrame;
    18182026    RegisterFile* registerFile = stackFrame.registerFile;
     
    18292037            VM_THROW_EXCEPTION();
    18302038        }
    1831         int32_t expectedParams = asFunction(callFrame->registers()[RegisterFile::Callee].jsValue())->body()->parameterCount();
     2039        int32_t expectedParams = callFrame->callee()->body()->parameterCount();
    18322040        int32_t inplaceArgs = min(providedParams, expectedParams);
    18332041       
     
    19612169
    19622170    CallFrame* callFrame = stackFrame.callFrame;
    1963     JSGlobalObject* globalObject = asGlobalObject(stackFrame.args[0].jsValue());
     2171    JSGlobalObject* globalObject = stackFrame.args[0].globalObject();
    19642172    Identifier& ident = stackFrame.args[1].identifier();
    19652173    unsigned globalResolveInfoIndex = stackFrame.args[2].int32();
     
    20852293}
    20862294
    2087 DEFINE_STUB_FUNCTION(EncodedJSValue, op_eq)
     2295#if USE(JSVALUE32_64)
     2296
     2297DEFINE_STUB_FUNCTION(bool, op_eq)
    20882298{
    20892299    STUB_INIT_STACK_FRAME(stackFrame);
     
    20922302    JSValue src2 = stackFrame.args[1].jsValue();
    20932303
    2094     CallFrame* callFrame = stackFrame.callFrame;
    2095 
    2096     ASSERT(!JSValue::areBothInt32Fast(src1, src2));
    2097     JSValue result = jsBoolean(JSValue::equalSlowCaseInline(callFrame, src1, src2));
    2098     CHECK_FOR_EXCEPTION_AT_END();
    2099     return JSValue::encode(result);
    2100 }
     2304    start:
     2305    if (src2.isUndefined()) {
     2306        return src1.isNull() ||
     2307               (src1.isCell() && asCell(src1)->structure()->typeInfo().masqueradesAsUndefined()) ||
     2308               src1.isUndefined();
     2309    }
     2310   
     2311    if (src2.isNull()) {
     2312        return src1.isUndefined() ||
     2313               (src1.isCell() && asCell(src1)->structure()->typeInfo().masqueradesAsUndefined()) ||
     2314               src1.isNull();
     2315    }
     2316
     2317    if (src1.isInt32()) {
     2318        if (src2.isDouble())
     2319            return src1.asInt32() == src2.asDouble();
     2320        double d = src2.toNumber(stackFrame.callFrame);
     2321        CHECK_FOR_EXCEPTION();
     2322        return src1.asInt32() == d;
     2323    }
     2324
     2325    if (src1.isDouble()) {
     2326        if (src2.isInt32())
     2327            return src1.asDouble() == src2.asInt32();
     2328        double d = src2.toNumber(stackFrame.callFrame);
     2329        CHECK_FOR_EXCEPTION();
     2330        return src1.asDouble() == d;
     2331    }
     2332
     2333    if (src1.isTrue()) {
     2334        if (src2.isFalse())
     2335            return false;
     2336        double d = src2.toNumber(stackFrame.callFrame);
     2337        CHECK_FOR_EXCEPTION();
     2338        return d == 1.0;
     2339    }
     2340
     2341    if (src1.isFalse()) {
     2342        if (src2.isTrue())
     2343            return false;
     2344        double d = src2.toNumber(stackFrame.callFrame);
     2345        CHECK_FOR_EXCEPTION();
     2346        return d == 0.0;
     2347    }
     2348   
     2349    if (src1.isUndefined())
     2350        return src2.isCell() && asCell(src2)->structure()->typeInfo().masqueradesAsUndefined();
     2351   
     2352    if (src1.isNull())
     2353        return src2.isCell() && asCell(src2)->structure()->typeInfo().masqueradesAsUndefined();
     2354
     2355    ASSERT(src1.isCell());
     2356
     2357    JSCell* cell1 = asCell(src1);
     2358
     2359    if (cell1->isString()) {
     2360        if (src2.isInt32())
     2361            return static_cast<JSString*>(cell1)->value().toDouble() == src2.asInt32();
     2362           
     2363        if (src2.isDouble())
     2364            return static_cast<JSString*>(cell1)->value().toDouble() == src2.asDouble();
     2365
     2366        if (src2.isTrue())
     2367            return static_cast<JSString*>(cell1)->value().toDouble() == 1.0;
     2368
     2369        if (src2.isFalse())
     2370            return static_cast<JSString*>(cell1)->value().toDouble() == 0.0;
     2371
     2372        ASSERT(src2.isCell());
     2373        JSCell* cell2 = asCell(src2);
     2374        if (cell2->isString())
     2375            return static_cast<JSString*>(cell1)->value() == static_cast<JSString*>(cell2)->value();
     2376
     2377        ASSERT(cell2->isObject());
     2378        src2 = static_cast<JSObject*>(cell2)->toPrimitive(stackFrame.callFrame);
     2379        CHECK_FOR_EXCEPTION();
     2380        goto start;
     2381    }
     2382
     2383    ASSERT(cell1->isObject());
     2384    if (src2.isObject())
     2385        return static_cast<JSObject*>(cell1) == asObject(src2);
     2386    src1 = static_cast<JSObject*>(cell1)->toPrimitive(stackFrame.callFrame);
     2387    CHECK_FOR_EXCEPTION();
     2388    goto start;
     2389}
     2390
     2391DEFINE_STUB_FUNCTION(bool, op_eq_strings)
     2392{
     2393    STUB_INIT_STACK_FRAME(stackFrame);
     2394
     2395    JSString* string1 = stackFrame.args[0].jsString();
     2396    JSString* string2 = stackFrame.args[1].jsString();
     2397
     2398    ASSERT(string1->isString());
     2399    ASSERT(string2->isString());
     2400    return string1->value() == string2->value();
     2401}
     2402
     2403#else // USE(JSVALUE32_64)
     2404
     2405DEFINE_STUB_FUNCTION(bool, op_eq)
     2406{
     2407    STUB_INIT_STACK_FRAME(stackFrame);
     2408
     2409    JSValue src1 = stackFrame.args[0].jsValue();
     2410    JSValue src2 = stackFrame.args[1].jsValue();
     2411
     2412    CallFrame* callFrame = stackFrame.callFrame;
     2413
     2414    bool result = JSValue::equalSlowCaseInline(callFrame, src1, src2);
     2415    CHECK_FOR_EXCEPTION_AT_END();
     2416    return result;
     2417}
     2418
     2419#endif // USE(JSVALUE32_64)
    21012420
    21022421DEFINE_STUB_FUNCTION(EncodedJSValue, op_lshift)
     
    21072426    JSValue shift = stackFrame.args[1].jsValue();
    21082427
    2109     int32_t left;
    2110     uint32_t right;
    2111     if (JSValue::areBothInt32Fast(val, shift))
    2112         return JSValue::encode(jsNumber(stackFrame.globalData, val.getInt32Fast() << (shift.getInt32Fast() & 0x1f)));
    2113     if (val.numberToInt32(left) && shift.numberToUInt32(right))
    2114         return JSValue::encode(jsNumber(stackFrame.globalData, left << (right & 0x1f)));
    2115 
    21162428    CallFrame* callFrame = stackFrame.callFrame;
    21172429    JSValue result = jsNumber(stackFrame.globalData, (val.toInt32(callFrame)) << (shift.toUInt32(callFrame) & 0x1f));
     
    21272439    JSValue src2 = stackFrame.args[1].jsValue();
    21282440
    2129     int32_t left;
    2130     int32_t right;
    2131     if (src1.numberToInt32(left) && src2.numberToInt32(right))
    2132         return JSValue::encode(jsNumber(stackFrame.globalData, left & right));
    2133 
     2441    ASSERT(!src1.isInt32() || !src2.isInt32());
    21342442    CallFrame* callFrame = stackFrame.callFrame;
    21352443    JSValue result = jsNumber(stackFrame.globalData, src1.toInt32(callFrame) & src2.toInt32(callFrame));
     
    21452453    JSValue shift = stackFrame.args[1].jsValue();
    21462454
    2147     int32_t left;
    2148     uint32_t right;
    2149     if (JSFastMath::canDoFastRshift(val, shift))
    2150         return JSValue::encode(JSFastMath::rightShiftImmediateNumbers(val, shift));
    2151     if (val.numberToInt32(left) && shift.numberToUInt32(right))
    2152         return JSValue::encode(jsNumber(stackFrame.globalData, left >> (right & 0x1f)));
    2153 
    21542455    CallFrame* callFrame = stackFrame.callFrame;
    21552456    JSValue result = jsNumber(stackFrame.globalData, (val.toInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f));
     2457
    21562458    CHECK_FOR_EXCEPTION_AT_END();
    21572459    return JSValue::encode(result);
     
    21642466    JSValue src = stackFrame.args[0].jsValue();
    21652467
    2166     int value;
    2167     if (src.numberToInt32(value))
    2168         return JSValue::encode(jsNumber(stackFrame.globalData, ~value));
    2169 
     2468    ASSERT(!src.isInt32());
    21702469    CallFrame* callFrame = stackFrame.callFrame;
    21712470    JSValue result = jsNumber(stackFrame.globalData, ~src.toInt32(callFrame));
     
    22412540}
    22422541
    2243 DEFINE_STUB_FUNCTION(EncodedJSValue, op_neq)
    2244 {
    2245     STUB_INIT_STACK_FRAME(stackFrame);
    2246 
    2247     JSValue src1 = stackFrame.args[0].jsValue();
    2248     JSValue src2 = stackFrame.args[1].jsValue();
    2249 
    2250     ASSERT(!JSValue::areBothInt32Fast(src1, src2));
    2251 
    2252     CallFrame* callFrame = stackFrame.callFrame;
    2253     JSValue result = jsBoolean(!JSValue::equalSlowCaseInline(callFrame, src1, src2));
    2254     CHECK_FOR_EXCEPTION_AT_END();
    2255     return JSValue::encode(result);
    2256 }
    2257 
    22582542DEFINE_STUB_FUNCTION(EncodedJSValue, op_post_dec)
    22592543{
     
    22792563
    22802564    CallFrame* callFrame = stackFrame.callFrame;
    2281 
    2282     if (JSFastMath::canDoFastUrshift(val, shift))
    2283         return JSValue::encode(JSFastMath::rightShiftImmediateNumbers(val, shift));
    2284     else {
    2285         JSValue result = jsNumber(stackFrame.globalData, (val.toUInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f));
    2286         CHECK_FOR_EXCEPTION_AT_END();
    2287         return JSValue::encode(result);
    2288     }
     2565    JSValue result = jsNumber(stackFrame.globalData, (val.toUInt32(callFrame)) >> (shift.toUInt32(callFrame) & 0x1f));
     2566    CHECK_FOR_EXCEPTION_AT_END();
     2567    return JSValue::encode(result);
    22892568}
    22902569
     
    23452624        JSValue exceptionValue;
    23462625        JSValue result = interpreter->callEval(callFrame, registerFile, argv, argCount, registerOffset, exceptionValue);
    2347         if (UNLIKELY(exceptionValue != JSValue())) {
     2626        if (UNLIKELY(exceptionValue)) {
    23482627            stackFrame.globalData->exception = exceptionValue;
    23492628            VM_THROW_EXCEPTION_AT_END();
     
    25832862    CodeBlock* codeBlock = callFrame->codeBlock();
    25842863
    2585     if (scrutinee.isInt32Fast())
    2586         return codeBlock->immediateSwitchJumpTable(tableIndex).ctiForValue(scrutinee.getInt32Fast()).executableAddress();
     2864    if (scrutinee.isInt32())
     2865        return codeBlock->immediateSwitchJumpTable(tableIndex).ctiForValue(scrutinee.asInt32()).executableAddress();
    25872866    else {
    25882867        double value;
     
    27383017}
    27393018
    2740 } // namespace JITStubs
    2741 
    27423019} // namespace JSC
    27433020
Note: See TracChangeset for help on using the changeset viewer.