Changeset 38286 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Nov 10, 2008, 9:09:46 PM (17 years ago)
Author:
[email protected]
Message:

2008-11-10 Gavin Barraclough <[email protected]>

Reviewed by Camron Zwarich.

Batch compile the set of static trampolines at the point Machine is constructed, using a single allocation.
Refactor out m_callFrame from CTI, since this is only needed to access the global data (instead store a
pointer to the global data directly, since this is available at the point the Machine is constructed).
Add a method to align the code buffer, to allow JIT generation for multiple trampolines in one block.

  • VM/CTI.cpp: (JSC::CTI::getConstant): (JSC::CTI::emitGetArg): (JSC::CTI::emitGetPutArg): (JSC::CTI::getConstantImmediateNumericArg): (JSC::CTI::printOpcodeOperandTypes): (JSC::CTI::CTI): (JSC::CTI::compileBinaryArithOp): (JSC::CTI::privateCompileMainPass): (JSC::CTI::privateCompileGetByIdProto): (JSC::CTI::privateCompileGetByIdChain): (JSC::CTI::privateCompileCTIMachineTrampolines): (JSC::CTI::freeCTIMachineTrampolines):
  • VM/CTI.h: (JSC::CTI::compile): (JSC::CTI::compileGetByIdSelf): (JSC::CTI::compileGetByIdProto): (JSC::CTI::compileGetByIdChain): (JSC::CTI::compilePutByIdReplace): (JSC::CTI::compilePutByIdTransition): (JSC::CTI::compileCTIMachineTrampolines): (JSC::CTI::compilePatchGetArrayLength):
  • VM/Machine.cpp: (JSC::Machine::initialize): (JSC::Machine::~Machine): (JSC::Machine::execute): (JSC::Machine::tryCTICachePutByID): (JSC::Machine::tryCTICacheGetByID): (JSC::Machine::cti_op_call_JSFunction): (JSC::Machine::cti_vm_lazyLinkCall):
  • VM/Machine.h:
  • masm/X86Assembler.h: (JSC::JITCodeBuffer::isAligned): (JSC::X86Assembler::): (JSC::X86Assembler::align):
  • runtime/JSGlobalData.cpp: (JSC::JSGlobalData::JSGlobalData):
Location:
trunk/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r38285 r38286  
     12008-11-10  Gavin Barraclough  <[email protected]>
     2
     3        Reviewed by Camron Zwarich.
     4
     5        Batch compile the set of static trampolines at the point Machine is constructed, using a single allocation.
     6        Refactor out m_callFrame from CTI, since this is only needed to access the global data (instead store a
     7        pointer to the global data directly, since this is available at the point the Machine is constructed).
     8        Add a method to align the code buffer, to allow JIT generation for multiple trampolines in one block.
     9
     10        * VM/CTI.cpp:
     11        (JSC::CTI::getConstant):
     12        (JSC::CTI::emitGetArg):
     13        (JSC::CTI::emitGetPutArg):
     14        (JSC::CTI::getConstantImmediateNumericArg):
     15        (JSC::CTI::printOpcodeOperandTypes):
     16        (JSC::CTI::CTI):
     17        (JSC::CTI::compileBinaryArithOp):
     18        (JSC::CTI::privateCompileMainPass):
     19        (JSC::CTI::privateCompileGetByIdProto):
     20        (JSC::CTI::privateCompileGetByIdChain):
     21        (JSC::CTI::privateCompileCTIMachineTrampolines):
     22        (JSC::CTI::freeCTIMachineTrampolines):
     23        * VM/CTI.h:
     24        (JSC::CTI::compile):
     25        (JSC::CTI::compileGetByIdSelf):
     26        (JSC::CTI::compileGetByIdProto):
     27        (JSC::CTI::compileGetByIdChain):
     28        (JSC::CTI::compilePutByIdReplace):
     29        (JSC::CTI::compilePutByIdTransition):
     30        (JSC::CTI::compileCTIMachineTrampolines):
     31        (JSC::CTI::compilePatchGetArrayLength):
     32        * VM/Machine.cpp:
     33        (JSC::Machine::initialize):
     34        (JSC::Machine::~Machine):
     35        (JSC::Machine::execute):
     36        (JSC::Machine::tryCTICachePutByID):
     37        (JSC::Machine::tryCTICacheGetByID):
     38        (JSC::Machine::cti_op_call_JSFunction):
     39        (JSC::Machine::cti_vm_lazyLinkCall):
     40        * VM/Machine.h:
     41        * masm/X86Assembler.h:
     42        (JSC::JITCodeBuffer::isAligned):
     43        (JSC::X86Assembler::):
     44        (JSC::X86Assembler::align):
     45        * runtime/JSGlobalData.cpp:
     46        (JSC::JSGlobalData::JSGlobalData):
     47
    1482008-11-10  Maciej Stachowiak  <[email protected]>
    249
  • trunk/JavaScriptCore/VM/CTI.cpp

    r38284 r38286  
    169169#endif
    170170
    171 ALWAYS_INLINE JSValue* CTI::getConstant(CallFrame* callFrame, int src)
    172 {
    173     return m_codeBlock->constantRegisters[src - m_codeBlock->numVars].jsValue(callFrame);
     171ALWAYS_INLINE JSValue* CTI::getConstant(int src)
     172{
     173    return m_codeBlock->constantRegisters[src - m_codeBlock->numVars].getJSValue();
    174174}
    175175
     
    184184    // TODO: we want to reuse values that are already in registers if we can - add a register allocator!
    185185    if (m_codeBlock->isConstant(src)) {
    186         JSValue* js = getConstant(m_callFrame, src);
     186        JSValue* js = getConstant(src);
    187187        m_jit.movl_i32r(asInteger(js), dst);
    188188    } else
     
    194194{
    195195    if (m_codeBlock->isConstant(src)) {
    196         JSValue* js = getConstant(m_callFrame, src);
     196        JSValue* js = getConstant(src);
    197197        m_jit.movl_i32m(asInteger(js), offset + sizeof(void*), X86::esp);
    198198    } else {
     
    216216{
    217217    if (m_codeBlock->isConstant(src)) {
    218         JSValue* js = getConstant(m_callFrame, src);
     218        JSValue* js = getConstant(src);
    219219        return JSImmediate::isNumber(js) ? js : noValue();
    220220    }
     
    275275    char which1 = '*';
    276276    if (m_codeBlock->isConstant(src1)) {
    277         JSValue* js = getConstant(m_callFrame, src1);
     277        JSValue* js = getConstant(src1);
    278278        which1 =
    279279            JSImmediate::isImmediate(js) ?
     
    289289    char which2 = '*';
    290290    if (m_codeBlock->isConstant(src2)) {
    291         JSValue* js = getConstant(m_callFrame, src2);
     291        JSValue* js = getConstant(src2);
    292292        which2 =
    293293            JSImmediate::isImmediate(js) ?
     
    547547}
    548548
    549 CTI::CTI(Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock)
    550     : m_jit(machine->jitCodeBuffer())
    551     , m_machine(machine)
    552     , m_callFrame(callFrame)
     549CTI::CTI(JSGlobalData* globalData, CodeBlock* codeBlock)
     550    : m_jit(globalData->machine->jitCodeBuffer())
     551    , m_machine(globalData->machine)
     552    , m_globalData(globalData)
    553553    , m_codeBlock(codeBlock)
    554554    , m_labels(codeBlock ? codeBlock->instructions.size() : 0)
     
    792792void CTI::compileBinaryArithOp(OpcodeID opcodeID, unsigned dst, unsigned src1, unsigned src2, OperandTypes types, unsigned i)
    793793{
    794     StructureID* numberStructureID = m_callFrame->globalData().numberStructureID.get();
     794    StructureID* numberStructureID = m_globalData->numberStructureID.get();
    795795    X86Assembler::JmpSrc wasJSNumberCell1;
    796796    X86Assembler::JmpSrc wasJSNumberCell1b;
     
    10061006            unsigned src = instruction[i + 2].u.operand;
    10071007            if (m_codeBlock->isConstant(src))
    1008                 m_jit.movl_i32r(asInteger(getConstant(m_callFrame, src)), X86::eax);
     1008                m_jit.movl_i32r(asInteger(getConstant(src)), X86::eax);
    10091009            else
    10101010                emitGetArg(src, X86::eax);
     
    15311531                if (!resultType.definitelyIsNumber()) {
    15321532                    emitJumpSlowCaseIfNotJSCell(X86::eax, i);
    1533                     StructureID* numberStructureID = m_callFrame->globalData().numberStructureID.get();
     1533                    StructureID* numberStructureID = m_globalData->numberStructureID.get();
    15341534                    m_jit.cmpl_i32m(reinterpret_cast<unsigned>(numberStructureID), OBJECT_OFFSET(JSCell, m_structureID), X86::eax);
    15351535                    m_slowCases.append(SlowCaseEntry(m_jit.emitUnlinkedJne(), i));
     
    15411541                X86Assembler::JmpSrc wasCell;
    15421542                if (!resultType.isReusableNumber())
    1543                     emitAllocateNumber(&m_callFrame->globalData(), i);
     1543                    emitAllocateNumber(m_globalData, i);
    15441544
    15451545                putDoubleResultToJSNumberCellOrJSImmediate(X86::xmm0, X86::eax, instruction[i + 1].u.operand, &wasCell,
     
    30513051}
    30523052
    3053 void CTI::privateCompileGetByIdProto(StructureID* structureID, StructureID* prototypeStructureID, size_t cachedOffset, void* returnAddress)
     3053void CTI::privateCompileGetByIdProto(StructureID* structureID, StructureID* prototypeStructureID, size_t cachedOffset, void* returnAddress, CallFrame* callFrame)
    30543054{
    30553055#if USE(CTI_REPATCH_PIC)
     
    30613061    // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a StructureID that is
    30623062    // referencing the prototype object - let's speculatively load it's table nice and early!)
    3063     JSObject* protoObject = asObject(structureID->prototypeForLookup(m_callFrame));
     3063    JSObject* protoObject = asObject(structureID->prototypeForLookup(callFrame));
    30643064    PropertyStorage* protoPropertyStorage = &protoObject->m_propertyStorage;
    30653065    m_jit.movl_mr(static_cast<void*>(protoPropertyStorage), X86::edx);
     
    31043104    // The prototype object definitely exists (if this stub exists the CodeBlock is referencing a StructureID that is
    31053105    // referencing the prototype object - let's speculatively load it's table nice and early!)
    3106     JSObject* protoObject = asObject(structureID->prototypeForLookup(m_callFrame));
     3106    JSObject* protoObject = asObject(structureID->prototypeForLookup(callFrame));
    31073107    PropertyStorage* protoPropertyStorage = &protoObject->m_propertyStorage;
    31083108    m_jit.movl_mr(static_cast<void*>(protoPropertyStorage), X86::edx);
     
    31373137}
    31383138
    3139 void CTI::privateCompileGetByIdChain(StructureID* structureID, StructureIDChain* chain, size_t count, size_t cachedOffset, void* returnAddress)
     3139void CTI::privateCompileGetByIdChain(StructureID* structureID, StructureIDChain* chain, size_t count, size_t cachedOffset, void* returnAddress, CallFrame* callFrame)
    31403140{
    31413141    ASSERT(count);
     
    31533153    JSObject* protoObject = 0;
    31543154    for (unsigned i = 0; i<count; ++i) {
    3155         protoObject = asObject(currStructureID->prototypeForLookup(m_callFrame));
     3155        protoObject = asObject(currStructureID->prototypeForLookup(callFrame));
    31563156        currStructureID = chainEntries[i].get();
    31573157
     
    33293329}
    33303330
    3331 void* CTI::privateCompileArrayLengthTrampoline()
    3332 {
     3331void CTI::privateCompileCTIMachineTrampolines()
     3332{
     3333    // (1) The first function provides fast property access for array length
     3334   
    33333335    // Check eax is an array
    33343336    m_jit.testl_i32r(JSImmediate::TagMask, X86::eax);
    3335     X86Assembler::JmpSrc failureCases1 = m_jit.emitUnlinkedJne();
     3337    X86Assembler::JmpSrc array_failureCases1 = m_jit.emitUnlinkedJne();
    33363338    m_jit.cmpl_i32m(reinterpret_cast<unsigned>(m_machine->m_jsArrayVptr), X86::eax);
    3337     X86Assembler::JmpSrc failureCases2 = m_jit.emitUnlinkedJne();
     3339    X86Assembler::JmpSrc array_failureCases2 = m_jit.emitUnlinkedJne();
    33383340
    33393341    // Checks out okay! - get the length from the storage
     
    33423344
    33433345    m_jit.addl_rr(X86::eax, X86::eax);
    3344     X86Assembler::JmpSrc failureCases3 = m_jit.emitUnlinkedJo();
     3346    X86Assembler::JmpSrc array_failureCases3 = m_jit.emitUnlinkedJo();
    33453347    m_jit.addl_i8r(1, X86::eax);
    33463348   
    33473349    m_jit.ret();
    33483350
    3349     void* code = m_jit.copy();
    3350     ASSERT(code);
    3351 
    3352     X86Assembler::link(code, failureCases1, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail));
    3353     X86Assembler::link(code, failureCases2, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail));
    3354     X86Assembler::link(code, failureCases3, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail));
     3351    // (2) The second function provides fast property access for string length
    33553352   
    3356     return code;
    3357 }
    3358 
    3359 void* CTI::privateCompileStringLengthTrampoline()
    3360 {
     3353    X86Assembler::JmpDst stringLengthBegin = m_jit.align(16);
     3354
    33613355    // Check eax is a string
    33623356    m_jit.testl_i32r(JSImmediate::TagMask, X86::eax);
    3363     X86Assembler::JmpSrc failureCases1 = m_jit.emitUnlinkedJne();
     3357    X86Assembler::JmpSrc string_failureCases1 = m_jit.emitUnlinkedJne();
    33643358    m_jit.cmpl_i32m(reinterpret_cast<unsigned>(m_machine->m_jsStringVptr), X86::eax);
    3365     X86Assembler::JmpSrc failureCases2 = m_jit.emitUnlinkedJne();
     3359    X86Assembler::JmpSrc string_failureCases2 = m_jit.emitUnlinkedJne();
    33663360
    33673361    // Checks out okay! - get the length from the Ustring.
     
    33703364
    33713365    m_jit.addl_rr(X86::eax, X86::eax);
    3372     X86Assembler::JmpSrc failureCases3 = m_jit.emitUnlinkedJo();
     3366    X86Assembler::JmpSrc string_failureCases3 = m_jit.emitUnlinkedJo();
    33733367    m_jit.addl_i8r(1, X86::eax);
    33743368   
    33753369    m_jit.ret();
    33763370
     3371    // All trampolines constructed! copy the code, link up calls, and set the pointers on the Machine object.
     3372
    33773373    void* code = m_jit.copy();
    33783374    ASSERT(code);
    33793375
    3380     X86Assembler::link(code, failureCases1, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail));
    3381     X86Assembler::link(code, failureCases2, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail));
    3382     X86Assembler::link(code, failureCases3, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail));
    3383 
    3384     return code;
     3376    X86Assembler::link(code, array_failureCases1, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail));
     3377    X86Assembler::link(code, array_failureCases2, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail));
     3378    X86Assembler::link(code, array_failureCases3, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail));
     3379    X86Assembler::link(code, string_failureCases1, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail));
     3380    X86Assembler::link(code, string_failureCases2, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail));
     3381    X86Assembler::link(code, string_failureCases3, reinterpret_cast<void*>(Machine::cti_op_get_by_id_fail));
     3382
     3383    m_machine->m_ctiArrayLengthTrampoline = code;
     3384    m_machine->m_ctiStringLengthTrampoline = X86Assembler::getRelocatedAddress(code, stringLengthBegin);
     3385}
     3386
     3387void CTI::freeCTIMachineTrampolines(Machine* machine)
     3388{
     3389    WTF::fastFreeExecutable(machine->m_ctiArrayLengthTrampoline);
    33853390}
    33863391
  • trunk/JavaScriptCore/VM/CTI.h

    r38229 r38286  
    284284
    285285    public:
    286         static void compile(Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock)
    287         {
    288             CTI cti(machine, callFrame, codeBlock);
     286        static void compile(JSGlobalData* globalData, CodeBlock* codeBlock)
     287        {
     288            CTI cti(globalData, codeBlock);
    289289            cti.privateCompile();
    290290        }
     
    294294#endif
    295295
    296         static void compileGetByIdSelf(Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock, StructureID* structureID, size_t cachedOffset, void* returnAddress)
    297         {
    298             CTI cti(machine, callFrame, codeBlock);
     296        static void compileGetByIdSelf(JSGlobalData* globalData, CodeBlock* codeBlock, StructureID* structureID, size_t cachedOffset, void* returnAddress)
     297        {
     298            CTI cti(globalData, codeBlock);
    299299            cti.privateCompileGetByIdSelf(structureID, cachedOffset, returnAddress);
    300300        }
    301301
    302         static void compileGetByIdProto(Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock, StructureID* structureID, StructureID* prototypeStructureID, size_t cachedOffset, void* returnAddress)
    303         {
    304             CTI cti(machine, callFrame, codeBlock);
    305             cti.privateCompileGetByIdProto(structureID, prototypeStructureID, cachedOffset, returnAddress);
    306         }
    307 
    308         static void compileGetByIdChain(Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock, StructureID* structureID, StructureIDChain* chain, size_t count, size_t cachedOffset, void* returnAddress)
    309         {
    310             CTI cti(machine, callFrame, codeBlock);
    311             cti.privateCompileGetByIdChain(structureID, chain, count, cachedOffset, returnAddress);
    312         }
    313 
    314         static void compilePutByIdReplace(Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock, StructureID* structureID, size_t cachedOffset, void* returnAddress)
    315         {
    316             CTI cti(machine, callFrame, codeBlock);
     302        static void compileGetByIdProto(JSGlobalData* globalData, CallFrame* callFrame, CodeBlock* codeBlock, StructureID* structureID, StructureID* prototypeStructureID, size_t cachedOffset, void* returnAddress)
     303        {
     304            CTI cti(globalData, codeBlock);
     305            cti.privateCompileGetByIdProto(structureID, prototypeStructureID, cachedOffset, returnAddress, callFrame);
     306        }
     307
     308        static void compileGetByIdChain(JSGlobalData* globalData, CallFrame* callFrame, CodeBlock* codeBlock, StructureID* structureID, StructureIDChain* chain, size_t count, size_t cachedOffset, void* returnAddress)
     309        {
     310            CTI cti(globalData, codeBlock);
     311            cti.privateCompileGetByIdChain(structureID, chain, count, cachedOffset, returnAddress, callFrame);
     312        }
     313
     314        static void compilePutByIdReplace(JSGlobalData* globalData, CodeBlock* codeBlock, StructureID* structureID, size_t cachedOffset, void* returnAddress)
     315        {
     316            CTI cti(globalData, codeBlock);
    317317            cti.privateCompilePutByIdReplace(structureID, cachedOffset, returnAddress);
    318318        }
    319319       
    320         static void compilePutByIdTransition(Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock, StructureID* oldStructureID, StructureID* newStructureID, size_t cachedOffset, StructureIDChain* sIDC, void* returnAddress)
    321         {
    322             CTI cti(machine, callFrame, codeBlock);
     320        static void compilePutByIdTransition(JSGlobalData* globalData, CodeBlock* codeBlock, StructureID* oldStructureID, StructureID* newStructureID, size_t cachedOffset, StructureIDChain* sIDC, void* returnAddress)
     321        {
     322            CTI cti(globalData, codeBlock);
    323323            cti.privateCompilePutByIdTransition(oldStructureID, newStructureID, cachedOffset, sIDC, returnAddress);
    324324        }
    325325
    326         static void* compileArrayLengthTrampoline(Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock)
    327         {
    328             CTI cti(machine, callFrame, codeBlock);
    329             return cti.privateCompileArrayLengthTrampoline();
    330         }
    331 
    332         static void* compileStringLengthTrampoline(Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock)
    333         {
    334             CTI cti(machine, callFrame, codeBlock);
    335             return cti.privateCompileStringLengthTrampoline();
    336         }
     326        static void compileCTIMachineTrampolines(JSGlobalData* globalData)
     327        {
     328            CTI cti(globalData);
     329            cti.privateCompileCTIMachineTrampolines();
     330        }
     331        static void freeCTIMachineTrampolines(Machine*);
    337332
    338333        static void patchGetByIdSelf(CodeBlock* codeBlock, StructureID* structureID, size_t cachedOffset, void* returnAddress);
    339334        static void patchPutByIdReplace(CodeBlock* codeBlock, StructureID* structureID, size_t cachedOffset, void* returnAddress);
    340335
    341         static void compilePatchGetArrayLength(Machine* machine, CallFrame* callFrame, CodeBlock* codeBlock, void* returnAddress)
    342         {
    343             CTI cti(machine, callFrame, codeBlock);
     336        static void compilePatchGetArrayLength(JSGlobalData* globalData, CodeBlock* codeBlock, void* returnAddress)
     337        {
     338            CTI cti(globalData, codeBlock);
    344339            return cti.privateCompilePatchGetArrayLength(returnAddress);
    345340        }
     
    354349
    355350    private:
    356         CTI(Machine*, CallFrame*, CodeBlock*);
     351        CTI(JSGlobalData*, CodeBlock* = 0);
    357352
    358353        static uintptr_t asInteger(JSValue*);
    359354
    360         JSValue* getConstant(CallFrame*, int src);
     355        JSValue* getConstant(int src);
    361356
    362357        void privateCompileMainPass();
     
    365360        void privateCompile();
    366361        void privateCompileGetByIdSelf(StructureID*, size_t cachedOffset, void* returnAddress);
    367         void privateCompileGetByIdProto(StructureID*, StructureID* prototypeStructureID, size_t cachedOffset, void* returnAddress);
    368         void privateCompileGetByIdChain(StructureID*, StructureIDChain*, size_t count, size_t cachedOffset, void* returnAddress);
     362        void privateCompileGetByIdProto(StructureID*, StructureID* prototypeStructureID, size_t cachedOffset, void* returnAddress, CallFrame* callFrame);
     363        void privateCompileGetByIdChain(StructureID*, StructureIDChain*, size_t count, size_t cachedOffset, void* returnAddress, CallFrame* callFrame);
    369364        void privateCompilePutByIdReplace(StructureID*, size_t cachedOffset, void* returnAddress);
    370365        void privateCompilePutByIdTransition(StructureID*, StructureID*, size_t cachedOffset, StructureIDChain*, void* returnAddress);
    371366
    372         void* privateCompileArrayLengthTrampoline();
    373         void* privateCompileStringLengthTrampoline();
     367        void privateCompileCTIMachineTrampolines();
    374368        void privateCompilePatchGetArrayLength(void* returnAddress);
    375369
     
    441435        X86Assembler m_jit;
    442436        Machine* m_machine;
     437        JSGlobalData* m_globalData;
    443438        CallFrame* m_callFrame;
    444439        CodeBlock* m_codeBlock;
  • trunk/JavaScriptCore/VM/Machine.cpp

    r38249 r38286  
    637637}
    638638
     639void Machine::initialize(JSGlobalData* globalData)
     640{
     641    CTI::compileCTIMachineTrampolines(globalData);
     642}
     643
    639644Machine::~Machine()
    640645{
    641646#if ENABLE(CTI)
    642     if (m_ctiArrayLengthTrampoline)
    643         fastFree(m_ctiArrayLengthTrampoline);
    644     if (m_ctiStringLengthTrampoline)
    645         fastFree(m_ctiStringLengthTrampoline);
     647    CTI::freeCTIMachineTrampolines(this);
    646648#endif
    647649}
     
    931933#if ENABLE(CTI)
    932934        if (!codeBlock->ctiCode)
    933             CTI::compile(this, newCallFrame, codeBlock);
     935            CTI::compile(scopeChain->globalData, codeBlock);
    934936        result = CTI::execute(codeBlock->ctiCode, &m_registerFile, newCallFrame, scopeChain->globalData, exception);
    935937#else
     
    997999#if ENABLE(CTI)
    9981000        if (!codeBlock->ctiCode)
    999             CTI::compile(this, newCallFrame, codeBlock);
     1001            CTI::compile(scopeChain->globalData, codeBlock);
    10001002        result = CTI::execute(codeBlock->ctiCode, &m_registerFile, newCallFrame, scopeChain->globalData, exception);
    10011003#else
     
    10891091#if ENABLE(CTI)
    10901092        if (!codeBlock->ctiCode)
    1091             CTI::compile(this, newCallFrame, codeBlock);
     1093            CTI::compile(scopeChain->globalData, codeBlock);
    10921094        result = CTI::execute(codeBlock->ctiCode, &m_registerFile, newCallFrame, scopeChain->globalData, exception);
    10931095#else
     
    41304132        vPC[7] = slot.cachedOffset();
    41314133        codeBlock->refStructureIDs(vPC);
    4132         CTI::compilePutByIdTransition(this, callFrame, codeBlock, structureID->previousID(), structureID, slot.cachedOffset(), chain, returnAddress);
     4134        CTI::compilePutByIdTransition(callFrame->scopeChain()->globalData, codeBlock, structureID->previousID(), structureID, slot.cachedOffset(), chain, returnAddress);
    41334135        return;
    41344136    }
     
    41434145    CTI::patchPutByIdReplace(codeBlock, structureID, slot.cachedOffset(), returnAddress);
    41444146#else
    4145     CTI::compilePutByIdReplace(this, callFrame, codeBlock, structureID, slot.cachedOffset(), returnAddress);
     4147    CTI::compilePutByIdReplace(callFrame->scopeChain()->globalData, callFrame, codeBlock, structureID, slot.cachedOffset(), returnAddress);
    41464148#endif
    4147 }
    4148 
    4149 void* Machine::getCTIArrayLengthTrampoline(CallFrame* callFrame, CodeBlock* codeBlock)
    4150 {
    4151     if (!m_ctiArrayLengthTrampoline)
    4152         m_ctiArrayLengthTrampoline = CTI::compileArrayLengthTrampoline(this, callFrame, codeBlock);
    4153        
    4154     return m_ctiArrayLengthTrampoline;
    4155 }
    4156 
    4157 void* Machine::getCTIStringLengthTrampoline(CallFrame* callFrame, CodeBlock* codeBlock)
    4158 {
    4159     if (!m_ctiStringLengthTrampoline)
    4160         m_ctiStringLengthTrampoline = CTI::compileStringLengthTrampoline(this, callFrame, codeBlock);
    4161        
    4162     return m_ctiStringLengthTrampoline;
    41634149}
    41644150
     
    41764162    if (isJSArray(baseValue) && propertyName == callFrame->propertyNames().length) {
    41774163#if USE(CTI_REPATCH_PIC)
    4178         CTI::compilePatchGetArrayLength(this, callFrame, codeBlock, returnAddress);
     4164        CTI::compilePatchGetArrayLength(callFrame->scopeChain()->globalData, codeBlock, returnAddress);
    41794165#else
    4180         ctiRepatchCallByReturnAddress(returnAddress, getCTIArrayLengthTrampoline(callFrame, codeBlock));
     4166        ctiRepatchCallByReturnAddress(returnAddress, m_ctiArrayLengthTrampoline);
    41814167#endif
    41824168        return;
     
    41854171        // The tradeoff of compiling an repatched inline string length access routine does not seem
    41864172        // to pay off, so we currently only do this for arrays.
    4187         ctiRepatchCallByReturnAddress(returnAddress, getCTIStringLengthTrampoline(callFrame, codeBlock));
     4173        ctiRepatchCallByReturnAddress(returnAddress, m_ctiStringLengthTrampoline);
    41884174        return;
    41894175    }
     
    42214207        CTI::patchGetByIdSelf(codeBlock, structureID, slot.cachedOffset(), returnAddress);
    42224208#else
    4223         CTI::compileGetByIdSelf(this, callFrame, codeBlock, structureID, slot.cachedOffset(), returnAddress);
     4209        CTI::compileGetByIdSelf(callFrame->scopeChain()->globalData, callFrame, codeBlock, structureID, slot.cachedOffset(), returnAddress);
    42244210#endif
    42254211        return;
     
    42454231        codeBlock->refStructureIDs(vPC);
    42464232
    4247         CTI::compileGetByIdProto(this, callFrame, codeBlock, structureID, slotBaseObject->structureID(), slot.cachedOffset(), returnAddress);
     4233        CTI::compileGetByIdProto(callFrame->scopeChain()->globalData, callFrame, codeBlock, structureID, slotBaseObject->structureID(), slot.cachedOffset(), returnAddress);
    42484234        return;
    42494235    }
     
    42874273    codeBlock->refStructureIDs(vPC);
    42884274
    4289     CTI::compileGetByIdChain(this, callFrame, codeBlock, structureID, chain, count, slot.cachedOffset(), returnAddress);
     4275    CTI::compileGetByIdChain(callFrame->scopeChain()->globalData, callFrame, codeBlock, structureID, chain, count, slot.cachedOffset(), returnAddress);
    42904276}
    42914277
     
    47224708
    47234709    if (!newCodeBlock->ctiCode)
    4724         CTI::compile(ARG_globalData->machine, ARG_callFrame, newCodeBlock);
     4710        CTI::compile(ARG_globalData, newCodeBlock);
    47254711
    47264712    return newCodeBlock;
     
    47744760    CTI_STACK_HACK();
    47754761
    4776     Machine* machine = ARG_globalData->machine;
    4777     CallFrame* callFrame = CallFrame::create(ARG_callFrame);
    4778 
    47794762    JSFunction* callee = asFunction(ARG_src1);
    47804763    CodeBlock* codeBlock = &callee->m_body->byteCode(callee->m_scopeChain.node());
    47814764    if (!codeBlock->ctiCode)
    4782         CTI::compile(machine, callFrame, codeBlock);
     4765        CTI::compile(ARG_globalData, codeBlock);
    47834766
    47844767    CTI::linkCall(callee, codeBlock, codeBlock->ctiCode, ARG_linkInfo2, ARG_int3);
  • trunk/JavaScriptCore/VM/Machine.h

    r38209 r38286  
    107107        Machine();
    108108        ~Machine();
     109
     110        void initialize(JSGlobalData*);
    109111       
    110112        RegisterFile& registerFile() { return m_registerFile; }
     
    324326        void tryCTICachePutByID(CallFrame*, CodeBlock*, void* returnAddress, JSValue* baseValue, const PutPropertySlot&);
    325327
    326         void* getCTIArrayLengthTrampoline(CallFrame*, CodeBlock*);
    327         void* getCTIStringLengthTrampoline(CallFrame*, CodeBlock*);
    328 
    329328        JITCodeBuffer* jitCodeBuffer() const { return m_jitCodeBuffer.get(); }
    330329#endif
  • trunk/JavaScriptCore/masm/X86Assembler.h

    r37991 r38286  
    6161    }
    6262
     63    bool isAligned(int alignment)
     64    {
     65        return !(m_index & (alignment - 1));
     66    }
     67   
    6368    void putByteUnchecked(int value)
    6469    {
     
    220225        OP_JMP_rel32                    = 0xE9,
    221226        PRE_SSE_F2                      = 0xF2,
     227        OP_HLT                          = 0xF4,
    222228        OP_GROUP3_Ev                    = 0xF7,
    223229        OP_GROUP3_EvIz                  = 0xF7, // OP_GROUP3_Ev has an immediate, when instruction is a test.
     
    911917    }
    912918   
     919    JmpDst align(int alignment)
     920    {
     921        while (!m_buffer->isAligned(alignment))
     922            m_buffer->putByte(OP_HLT);
     923
     924        return label();
     925    }
     926
    913927    JmpSrc emitUnlinkedJmp()
    914928    {
  • trunk/JavaScriptCore/runtime/JSGlobalData.cpp

    r38205 r38286  
    9797    startProfilerServerIfNeeded();
    9898#endif
     99    machine->initialize(this);
    99100}
    100101
Note: See TracChangeset for help on using the changeset viewer.