Ignore:
Timestamp:
Nov 24, 2002, 2:37:44 PM (23 years ago)
Author:
darin
Message:

JavaScriptCore:

  • changed ScopeChain to not ref each item in the chain, and use marking instead; gains 1% on JavaScript iBench
  • kjs/context.h: Return chain by reference.
  • kjs/internal.cpp: (ContextImp::mark): Mark the scope chain.
  • kjs/interpreter.cpp: (Context::scopeChain): Return chain by reference.
  • kjs/interpreter.h: Make some Context methods inline.
  • kjs/nodes.cpp: (ThisNode::evaluate): Get at ContextImp directly. (ResolveNode::evaluateReference): Ditto. (VarDeclNode::evaluate): Ditto. (VarDeclNode::processVarDecls): Ditto. (FuncDeclNode::processFuncDecl): Pass ScopeChain directly to avoid copying. (FuncExprNode::evaluate): Ditto.
  • kjs/object.cpp: Make scope and setScope inline.
  • kjs/object.h: Make scope return a chain by reference. Make scope and setScope both be inline. Use a normal ScopeChain instead of NoRefScopeChain since they are now one and the same.
  • kjs/scope_chain.cpp: Remove all the code to ref and deref objects. Merge NoRefScopeChain in with ScopeChain since they both work this way now.
  • kjs/scope_chain.h: Remove NoRefScopeChain and simplify the ref counts. Make more functions inline.

WebCore:

  • force-js-clean-timestamp: Touch for ScopeChain change.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/scope_chain.cpp

    r2824 r2851  
    2626namespace KJS {
    2727
    28 ScopeChainNode::ScopeChainNode(ScopeChainNode *n, ObjectImp *o)
    29     : next(n), object(o), nodeAndObjectRefCount(1), nodeOnlyRefCount(0)
    30 {
    31     o->ref();
    32 }
    33 
    3428inline void ScopeChain::ref() const
    3529{
    3630    for (ScopeChainNode *n = _node; n; n = n->next) {
    37         if (n->nodeAndObjectRefCount++ != 0)
     31        if (n->refCount++ != 0)
    3832            break;
    39         n->object->ref();
    4033    }
    41 }
    42 
    43 ScopeChain::ScopeChain(const NoRefScopeChain &c)
    44     : _node(c._node)
    45 {
    46     ref();
    4734}
    4835
     
    6754    _node = newNode;
    6855   
    69     // Three cases:
    70     //   1) This was not the last reference of the old node.
    71     //      In this case we move our ref from the old to the new node.
    72     //   2) This was the last reference of the old node, but there are garbage collected references.
    73     //      In this case, the new node doesn't get any new ref, and the object is deref'd.
    74     //   3) This was the last reference of the old node.
    75     //      In this case the object is deref'd and the entire node goes.
    76     if (--oldNode->nodeAndObjectRefCount != 0) {
     56    if (--oldNode->refCount != 0) {
    7757        if (newNode)
    78             ++newNode->nodeAndObjectRefCount;
     58            ++newNode->refCount;
    7959    } else {
    80         oldNode->object->deref();
    81         if (oldNode->nodeOnlyRefCount == 0)
    82             delete oldNode;
     60        delete oldNode;
    8361    }
    8462}
     
    8967    do {
    9068        ScopeChainNode *next = n->next;
    91         n->object->deref();
    92         if (n->nodeOnlyRefCount == 0)
    93             delete n;
     69        delete n;
    9470        n = next;
    95     } while (n && --n->nodeAndObjectRefCount == 0);
     71    } while (n && --n->refCount == 0);
    9672}
    9773
    98 inline void NoRefScopeChain::ref() const
    99 {
    100     for (ScopeChainNode *n = _node; n; n = n->next)
    101         if (n->nodeOnlyRefCount++ != 0)
    102             break;
    103 }
    104 
    105 NoRefScopeChain &NoRefScopeChain::operator=(const ScopeChain &c)
    106 {
    107     c.ref();
    108     deref();
    109     _node = c._node;
    110     return *this;
    111 }
    112 
    113 void NoRefScopeChain::mark()
     74void ScopeChain::mark()
    11475{
    11576    for (ScopeChainNode *n = _node; n; n = n->next) {
     
    12081}
    12182
    122 void NoRefScopeChain::release()
    123 {
    124     ScopeChainNode *n = _node;
    125     do {
    126         ScopeChainNode *next = n->next;
    127         if (n->nodeAndObjectRefCount == 0)
    128             delete n;
    129         n = next;
    130     } while (n && --n->nodeOnlyRefCount == 0);
    131 }
    132 
    13383} // namespace KJS
Note: See TracChangeset for help on using the changeset viewer.