Changeset 36427 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Sep 14, 2008, 11:26:15 PM (17 years ago)
Author:
[email protected]
Message:

2008-09-14 Maciej Stachowiak <[email protected]>

Reviewed by Cameron Zwarich.


  • speed up JS construction by extracting "prototype" lookup so PIC applies.


~0.5% speedup on SunSpider
Speeds up some of the V8 tests as well, most notably earley-boyer.

  • VM/CTI.cpp: (JSC::CTI::compileOpCall): Account for extra arg for prototype. (JSC::CTI::privateCompileMainPass): Account for increased size of op_construct.
  • VM/CodeGenerator.cpp: (JSC::CodeGenerator::emitConstruct): Emit separate lookup to get prototype property.
  • VM/Machine.cpp: (JSC::Machine::privateExecute): Expect prototype arg in op_construct. (JSC::Machine::cti_op_construct_JSConstruct): ditto (JSC::Machine::cti_op_construct_NotJSConstruct): ditto
Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r36425 r36427  
     12008-09-14  Maciej Stachowiak  <[email protected]>
     2
     3        Reviewed by Cameron Zwarich.
     4       
     5        - speed up JS construction by extracting "prototype" lookup so PIC applies.
     6       
     7        ~0.5% speedup on SunSpider
     8        Speeds up some of the V8 tests as well, most notably earley-boyer.
     9
     10        * VM/CTI.cpp:
     11        (JSC::CTI::compileOpCall): Account for extra arg for prototype.
     12        (JSC::CTI::privateCompileMainPass): Account for increased size of op_construct.
     13        * VM/CodeGenerator.cpp:
     14        (JSC::CodeGenerator::emitConstruct): Emit separate lookup to get prototype property.
     15        * VM/Machine.cpp:
     16        (JSC::Machine::privateExecute): Expect prototype arg in op_construct.
     17        (JSC::Machine::cti_op_construct_JSConstruct): ditto
     18        (JSC::Machine::cti_op_construct_NotJSConstruct): ditto
     19
    1202008-09-10  Alexey Proskuryakov  <[email protected]>
    221
  • trunk/JavaScriptCore/VM/CTI.cpp

    r36418 r36427  
    413413{
    414414    if (type == OpConstruct) {
    415         emitPutArgConstant(reinterpret_cast<unsigned>(instruction + i), 12);
     415        emitPutArgConstant(reinterpret_cast<unsigned>(instruction + i), 16);
     416        emitPutArgConstant(instruction[i + 5].u.operand, 12);
    416417        emitPutArgConstant(instruction[i + 4].u.operand, 8);
    417         emitPutArgConstant(instruction[i + 3].u.operand, 4);
     418        emitGetPutArg(instruction[i + 3].u.operand, 4, X86::ecx);
    418419    } else {
    419420        emitPutArgConstant(reinterpret_cast<unsigned>(instruction + i), 16);
     
    434435        m_jit.emitRestoreArgumentReference();
    435436
    436        emitGetCTIParam(CTI_ARGS_r, X86::edi); // edi := r
     437        emitGetCTIParam(CTI_ARGS_r, X86::edi); // edi := r
    437438
    438439        m_jit.cmpl_i32r(reinterpret_cast<unsigned>(JSImmediate::impossibleValue()), X86::eax);
     
    825826        case op_construct: {
    826827            compileOpCall(instruction, i, OpConstruct);
    827             i += 5;
     828            i += 6;
    828829            break;
    829830        }
  • trunk/JavaScriptCore/VM/CodeGenerator.cpp

    r36417 r36427  
    11011101    // is safe.
    11021102
     1103    RefPtr<RegisterID> protectFunc = func;
     1104
     1105    // Reserve space for prototype
     1106    RefPtr<RegisterID> funcProto = newTemporary();
     1107
    11031108    // Reserve space for call frame.
    11041109    Vector<RefPtr<RegisterID>, RegisterFile::CallFrameHeaderSize> callFrame;
     
    11141119    }
    11151120
     1121    emitGetById(funcProto.get(), func, globalExec()->propertyNames().prototype);
     1122
    11161123    emitOpcode(op_construct);
    11171124    instructions().append(dst->index());
    11181125    instructions().append(func->index());
     1126    instructions().append(funcProto->index());
    11191127    instructions().append(argv.size() ? argv[0]->index() : m_temporaries.size()); // argv
    11201128    instructions().append(argv.size()); // argc
  • trunk/JavaScriptCore/VM/Machine.cpp

    r36418 r36427  
    32803280    }
    32813281    BEGIN_OPCODE(op_construct) {
    3282         /* construct dst(r) constr(r) firstArg(r) argCount(n)
     3282        /* construct dst(r) constr(r) constrProto(r) firstArg(r) argCount(n)
    32833283
    32843284           Invoke register "constr" as a constructor. For JS
     
    32883288           value is passed. In either case, the firstArg and argCount
    32893289           registers are interpreted as for the "call" opcode.
     3290
     3291           Register constrProto must contain the prototype property of
     3292           register constsr. This is to enable polymorphic inline
     3293           caching of this lookup.
    32903294        */
    32913295
    32923296        int dst = (++vPC)->u.operand;
    32933297        int constr = (++vPC)->u.operand;
     3298        int constrProto = (++vPC)->u.operand;
    32943299        int firstArg = (++vPC)->u.operand;
    32953300        int argCount = (++vPC)->u.operand;
     
    33083313
    33093314            JSObject* prototype;
    3310             JSValue* p = constructor->get(exec, exec->propertyNames().prototype);
     3315            JSValue* p = r[constrProto].jsValue(exec);
    33113316            if (p->isObject())
    33123317                prototype = static_cast<JSObject*>(p);
     
    44304435   
    44314436    JSValue* constrVal = ARG_src1;
    4432     int firstArg = ARG_int2;
    4433     int argCount = ARG_int3;
     4437    JSValue* constrProtoVal = ARG_src2;
     4438    int firstArg = ARG_int3;
     4439    int argCount = ARG_int4;
    44344440
    44354441    ConstructData constructData;
     
    44394445        constrVal->getConstructData(constructData);
    44404446
    4441     // Removing this line of code causes a measurable regression on squirrelfish.
     4447    // Removing this line of code causes a measurable regression on sunspider.
    44424448    JSObject* constructor = static_cast<JSObject*>(constrVal);
    44434449
     
    44484454
    44494455    JSObject* prototype;
    4450     JSValue* p = constructor->get(exec, exec->propertyNames().prototype);
     4456    JSValue* p = constrProtoVal;
    44514457    if (p->isObject())
    44524458        prototype = static_cast<JSObject*>(p);
     
    44864492
    44874493    JSValue* constrVal = ARG_src1;
    4488     int firstArg = ARG_int2;
    4489     int argCount = ARG_int3;
     4494    int firstArg = ARG_int3;
     4495    int argCount = ARG_int4;
    44904496
    44914497    ConstructData constructData;
Note: See TracChangeset for help on using the changeset viewer.