Changeset 52231 in webkit


Ignore:
Timestamp:
Dec 16, 2009 7:50:37 PM (14 years ago)
Author:
ggaren@apple.com
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.

Location:
trunk/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r52222 r52231  
     12009-12-16  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Fixed <rdar://problem/7355025> Interpreter::privateExecute macro generates
     6        bloated code
     7       
     8        This patch cuts Interpreter stack use by about a third.
     9
     10        * bytecode/Opcode.h: Changed Opcode to const void* to work with the
     11        const static initiliazation we want to do in Interpreter::privateExecute.
     12
     13        * interpreter/Interpreter.cpp:
     14        (JSC::Interpreter::Interpreter): Moved hashtable initialization here to
     15        avoid polluting Interpreter::privateExecute's stack, and changed it from a
     16        series of add() calls to one add() call in a loop, to cut down on code size.
     17
     18        (JSC::Interpreter::privateExecute): Changed a series of label computations
     19        to a copy of a compile-time constant array to cut down on code size.
     20
    1212009-12-16  Mark Rowe  <mrowe@apple.com>
    222
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r52222 r52231  
    25672567                        baseConfigurationReference = 1C9051430BA9E8A70081E9D0 /* JavaScriptCore.xcconfig */;
    25682568                        buildSettings = {
    2569                                 BUILD_VARIANTS = (
    2570                                         normal,
    2571                                 );
     2569                                BUILD_VARIANTS = normal;
    25722570                        };
    25732571                        name = Production;
  • trunk/JavaScriptCore/bytecode/Opcode.h

    r51735 r52231  
    197197
    198198#if HAVE(COMPUTED_GOTO)
    199     typedef void* Opcode;
     199    typedef const void* Opcode;
    200200#else
    201201    typedef OpcodeID Opcode;
  • 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.