Ignore:
Timestamp:
Dec 16, 2009, 7:50:37 PM (15 years ago)
Author:
[email protected]
Message:

Fixed <rdar://problem/7355025> Interpreter::privateExecute macro generates
bloated code

Reviewed by Oliver Hunt.

This patch cuts Interpreter stack use by about a third.

  • bytecode/Opcode.h: Changed Opcode to const void* to work with the

const static initiliazation we want to do in Interpreter::privateExecute.

  • interpreter/Interpreter.cpp:

(JSC::Interpreter::Interpreter): Moved hashtable initialization here to
avoid polluting Interpreter::privateExecute's stack, and changed it from a
series of add() calls to one add() call in a loop, to cut down on code size.

(JSC::Interpreter::privateExecute): Changed a series of label computations
to a copy of a compile-time constant array to cut down on code size.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/interpreter/Interpreter.cpp

    r51964 r52231  
    322322    , m_reentryDepth(0)
    323323{
     324#if HAVE(COMPUTED_GOTO)
    324325    privateExecute(InitializeAndReturn, 0, 0, 0);
     326
     327    for (int i = 0; i < numOpcodeIDs; ++i)
     328        m_opcodeIDTable.add(m_opcodeTable[i], static_cast<OpcodeID>(i));
     329#endif // HAVE(COMPUTED_GOTO)
     330
    325331#if ENABLE(OPCODE_SAMPLING)
    326332    enableSampler();
     
    10821088    // One-time initialization of our address tables. We have to put this code
    10831089    // here because our labels are only in scope inside this function.
    1084     if (flag == InitializeAndReturn) {
     1090    if (UNLIKELY(flag == InitializeAndReturn)) {
    10851091        #if HAVE(COMPUTED_GOTO)
    1086             #define ADD_BYTECODE(id, length) m_opcodeTable[id] = &&id;
    1087                 FOR_EACH_OPCODE_ID(ADD_BYTECODE);
    1088             #undef ADD_BYTECODE
    1089 
    1090             #define ADD_OPCODE_ID(id, length) m_opcodeIDTable.add(&&id, id);
    1091                 FOR_EACH_OPCODE_ID(ADD_OPCODE_ID);
    1092             #undef ADD_OPCODE_ID
    1093             ASSERT(m_opcodeIDTable.size() == numOpcodeIDs);
     1092            #define LIST_OPCODE_LABEL(id, length) &&id,
     1093                static Opcode labels[] = { FOR_EACH_OPCODE_ID(LIST_OPCODE_LABEL) };
     1094                for (size_t i = 0; i < sizeof(labels) / sizeof(Opcode); ++i)
     1095                    m_opcodeTable[i] = labels[i];
     1096            #undef LIST_OPCODE_LABEL
    10941097        #endif // HAVE(COMPUTED_GOTO)
    10951098        return JSValue();
Note: See TracChangeset for help on using the changeset viewer.