Changeset 31277 in webkit


Ignore:
Timestamp:
Mar 24, 2008, 10:48:22 PM (17 years ago)
Author:
ggaren@apple.com
Message:

2008-03-24 Geoffrey Garen <ggaren@apple.com>

Reviewed by Oliver Hunt.


Fixed recent 25% regression on simple for loop test. GCC seems to be
very finicky about the code that gets inlined into
Machine::privateExecute.

Everything in this patch is simply the result of experiment.


The resolve and resolve_base opcodes do not seem to have gotten slower
from this change.

  • VM/Machine.cpp: (KJS::resolve): (KJS::resolveBase): (KJS::Machine::privateExecute):
  • kjs/nodes.h:
Location:
branches/squirrelfish/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/squirrelfish/JavaScriptCore/ChangeLog

    r31276 r31277  
     12008-03-24  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4       
     5        Fixed recent 25% regression on simple for loop test. GCC seems to be
     6        very finicky about the code that gets inlined into
     7        Machine::privateExecute.
     8
     9        Everything in this patch is simply the result of experiment.
     10       
     11        The resolve and resolve_base opcodes do not seem to have gotten slower
     12        from this change.
     13
     14        * VM/Machine.cpp:
     15        (KJS::resolve):
     16        (KJS::resolveBase):
     17        (KJS::Machine::privateExecute):
     18        * kjs/nodes.h:
     19
    1202008-03-24  Oliver Hunt  <oliver@apple.com>
    221
  • branches/squirrelfish/JavaScriptCore/VM/Machine.cpp

    r31276 r31277  
    138138}
    139139
     140static void NEVER_INLINE resolve(ExecState* exec, Instruction* vPC, Register* r, ScopeChain* scopeChain, CodeBlock* codeBlock)
     141{
     142    int r0 = (vPC + 1)->u.operand;
     143    int k0 = (vPC + 2)->u.operand;
     144
     145    ScopeChainIterator iter = scopeChain->begin();
     146    ScopeChainIterator end = scopeChain->end();
     147    ASSERT(iter != end);
     148
     149    PropertySlot slot;
     150    Identifier& ident = codeBlock->identifiers[k0];
     151    do {
     152        JSObject* o = *iter;
     153        if (o->getPropertySlot(exec, ident, slot)) {
     154            r[r0].u.jsValue = slot.getValue(exec, o, ident);
     155            return;
     156        }
     157    } while (++iter != end);
     158
     159    ASSERT_NOT_REACHED(); // FIXME: throw an undefined variable exception
     160}
     161
     162static void NEVER_INLINE resolveBase(ExecState* exec, Instruction* vPC, Register* r, ScopeChain* scopeChain, CodeBlock* codeBlock)
     163{
     164    int r0 = (vPC + 1)->u.operand;
     165    int k0 = (vPC + 2)->u.operand;
     166
     167    ScopeChainIterator iter = scopeChain->begin();
     168    ScopeChainIterator end = scopeChain->end();
     169    ASSERT(iter != end);
     170
     171    PropertySlot slot;
     172    Identifier& ident = codeBlock->identifiers[k0];
     173    JSObject* base;
     174    do {
     175        base = *iter;
     176        if (base->getPropertySlot(exec, ident, slot)) {
     177            r[r0].u.jsValue = base;
     178            return;
     179        }
     180    } while (++iter != end);
     181
     182    r[r0].u.jsValue = base;
     183}
     184
    140185void Machine::privateExecute(ExecutionFlag flag, ExecState* exec, ScopeChain* scopeChain, CodeBlock* codeBlock)
    141186{
     
    227272    }
    228273    BEGIN_OPCODE(op_resolve) {
    229         int r0 = (++vPC)->u.operand;
    230         int k0 = (++vPC)->u.operand;
    231 
    232         ScopeChainIterator iter = scopeChain->begin();
    233         ScopeChainIterator end = scopeChain->end();
    234         ASSERT(iter != end);
    235 
    236         PropertySlot slot;
    237         Identifier& ident = codeBlock->identifiers[k0];
    238         do {
    239             JSObject* o = *iter;
    240             if (o->getPropertySlot(exec, ident, slot)) {
    241                 r[r0].u.jsValue = slot.getValue(exec, o, ident);
    242                 ++vPC;
    243                 NEXT_OPCODE;
    244             }
    245         } while (++iter != end);
    246 
    247         ASSERT_NOT_REACHED(); // FIXME: throw an undefined variable exception
     274        resolve(exec, vPC, r, scopeChain, codeBlock);
     275        vPC += 3;
     276       
     277        NEXT_OPCODE;
    248278    }
    249279    BEGIN_OPCODE(op_resolve_base) {
    250         int r0 = (++vPC)->u.operand;
    251         int k0 = (++vPC)->u.operand;
    252 
    253         ScopeChainIterator iter = scopeChain->begin();
    254         ScopeChainIterator end = scopeChain->end();
    255         ASSERT(iter != end);
    256 
    257         PropertySlot slot;
    258         Identifier& ident = codeBlock->identifiers[k0];
    259         JSObject* base;
    260         do {
    261             base = *iter;
    262             if (base->getPropertySlot(exec, ident, slot)) {
    263                 r[r0].u.jsValue = base;
    264 
    265                 ++vPC;
    266                 NEXT_OPCODE;
    267             }
    268         } while (++iter != end);
    269 
    270         r[r0].u.jsValue = base;
    271 
    272         ++vPC;
     280        resolveBase(exec, vPC, r, scopeChain, codeBlock);
     281        vPC += 3;
     282
    273283        NEXT_OPCODE;
    274284    }
  • branches/squirrelfish/JavaScriptCore/kjs/nodes.h

    r31265 r31277  
    29362936        virtual JSValue* execute(ExecState*) KJS_FAST_CALL;
    29372937        virtual void streamTo(SourceStream&) const KJS_FAST_CALL;
    2938         ALWAYS_INLINE FunctionImp* makeFunction(ExecState*) KJS_FAST_CALL;
     2938        FunctionImp* makeFunction(ExecState*) KJS_FAST_CALL;
    29392939
    29402940        Identifier m_ident;
Note: See TracChangeset for help on using the changeset viewer.