Ignore:
Timestamp:
Sep 15, 2008, 10:53:15 PM (17 years ago)
Author:
[email protected]
Message:

Bug 20874: op_resolve does not do any form of caching
<https://bugs.webkit.org/show_bug.cgi?id=20874>

Reviewed by Cameron Zwarich

This patch adds an op_resolve_global opcode to handle (and cache)
property lookup we can statically determine must occur on the global
object (if at all).

3% progression on sunspider, 3.2x improvement to bitops-bitwise-and, and
10% in math-partial-sums

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/VM/CodeGenerator.cpp

    r36463 r36480  
    760760bool CodeGenerator::findScopedProperty(const Identifier& property, int& index, size_t& stackDepth, bool forWriting, JSValue*& globalObject)
    761761{
    762     // Cases where we cannot optimise the lookup
     762    // Cases where we cannot statically optimise the lookup
    763763    if (property == propertyNames().arguments || !canOptimizeNonLocals()) {
    764764        stackDepth = 0;
    765765        index = missingSymbolMarker();
     766
     767        if (shouldOptimizeLocals() && m_codeType == GlobalCode) {
     768            ScopeChainIterator iter = m_scopeChain->begin();
     769            globalObject = *iter;
     770            ASSERT((++iter) == m_scopeChain->end());
     771        }
    766772        return false;
    767773    }
    768774
     775    size_t depth = 0;
     776   
    769777    ScopeChainIterator iter = m_scopeChain->begin();
    770778    ScopeChainIterator end = m_scopeChain->end();
    771     size_t depth = 0;
    772 
    773779    for (; iter != end; ++iter, ++depth) {
    774780        JSObject* currentScope = *iter;
     
    821827    int index = 0;
    822828    JSValue* globalObject = 0;
    823     if (!findScopedProperty(property, index, depth, false, globalObject)) {
     829    if (!findScopedProperty(property, index, depth, false, globalObject) && !globalObject) {
    824830        // We can't optimise at all :-(
    825831        emitOpcode(op_resolve);
     
    829835    }
    830836
    831     if (index == missingSymbolMarker()) {
    832         // In this case we are at least able to drop a few scope chains from the
    833         // lookup chain, although we still need to hash from then on.
    834         emitOpcode(op_resolve_skip);
     837    if (index != missingSymbolMarker()) {
     838        // Directly index the property lookup across multiple scopes.  Yay!
     839        return emitGetScopedVar(dst, depth, index, globalObject);
     840    }
     841
     842    if (globalObject) {
     843        m_codeBlock->structureIDInstructions.append(instructions().size());
     844        emitOpcode(op_resolve_global);
    835845        instructions().append(dst->index());
     846        instructions().append(static_cast<JSCell*>(globalObject));
    836847        instructions().append(addConstant(property));
    837         instructions().append(depth);
     848        instructions().append(0);
     849        instructions().append(0);
    838850        return dst;
    839851    }
    840852
    841     // Directly index the property lookup across multiple scopes.  Yay!
    842     return emitGetScopedVar(dst, depth, index, globalObject);
     853    // In this case we are at least able to drop a few scope chains from the
     854    // lookup chain, although we still need to hash from then on.
     855    emitOpcode(op_resolve_skip);
     856    instructions().append(dst->index());
     857    instructions().append(addConstant(property));
     858    instructions().append(depth);
     859    return dst;
    843860}
    844861
Note: See TracChangeset for help on using the changeset viewer.