Ignore:
Timestamp:
Feb 18, 2010, 10:23:25 PM (15 years ago)
Author:
[email protected]
Message:

2010-02-18 Oliver Hunt <[email protected]>

Reviewed by Gavin Barraclough.

Improve interpreter getter performance
https://bugs.webkit.org/show_bug.cgi?id=35138

Improve the performance of getter dispatch by making it possible
for the interpreter to cache the GetterSetter object lookup.

To do this we simply need to make PropertySlot aware of getters
as a potentially cacheable property, and record the base and this
objects for a getter access. This allows us to use more-or-less
identical code to that used by the normal get_by_id caching, with
the dispatch being the only actual difference.

I'm holding off of implementing this in the JIT until I do some
cleanup to try and making coding in the JIT not be as horrible
as it is currently.

  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::dump): (JSC::CodeBlock::derefStructures): (JSC::CodeBlock::refStructures):
  • bytecode/Opcode.h:
  • interpreter/Interpreter.cpp: (JSC::Interpreter::resolveGlobal): (JSC::Interpreter::tryCacheGetByID): (JSC::Interpreter::privateExecute):
  • jit/JIT.cpp: (JSC::JIT::privateCompileMainPass):
  • jit/JITStubs.cpp: (JSC::JITThunks::tryCacheGetByID): (JSC::DEFINE_STUB_FUNCTION):
  • runtime/JSObject.cpp: (JSC::JSObject::fillGetterPropertySlot):
  • runtime/PropertySlot.cpp: (JSC::PropertySlot::functionGetter):
  • runtime/PropertySlot.h: (JSC::PropertySlot::isGetter): (JSC::PropertySlot::isCacheable): (JSC::PropertySlot::isCacheableValue): (JSC::PropertySlot::setValueSlot): (JSC::PropertySlot::setGetterSlot): (JSC::PropertySlot::setCacheableGetterSlot): (JSC::PropertySlot::clearOffset): (JSC::PropertySlot::thisValue):
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/PropertySlot.h

    r46598 r55002  
    7272        }
    7373
    74         bool isCacheable() const { return m_offset != WTF::notFound; }
     74        bool isGetter() const { return m_isGetter; }
     75        bool isCacheable() const { return m_isCacheable; }
     76        bool isCacheableValue() const { return m_isCacheable && !m_isGetter; }
    7577        size_t cachedOffset() const
    7678        {
     
    103105            m_data.valueSlot = valueSlot;
    104106            m_offset = offset;
     107            m_isCacheable = true;
     108            m_isGetter = false;
    105109        }
    106110       
     
    140144            m_data.index = index;
    141145        }
    142        
     146
    143147        void setGetterSlot(JSObject* getterFunc)
     148        {
     149            ASSERT(getterFunc);
     150            m_thisValue = m_slotBase;
     151            m_getValue = functionGetter;
     152            m_data.getterFunc = getterFunc;
     153            m_isGetter = true;
     154        }
     155
     156        void setCacheableGetterSlot(JSValue slotBase, JSObject* getterFunc, unsigned offset)
    144157        {
    145158            ASSERT(getterFunc);
    146159            m_getValue = functionGetter;
     160            m_thisValue = m_slotBase;
     161            m_slotBase = slotBase;
    147162            m_data.getterFunc = getterFunc;
    148         }
    149        
     163            m_offset = offset;
     164            m_isCacheable = true;
     165            m_isGetter = true;
     166        }
     167
    150168        void setUndefined()
    151169        {
     
    183201            // Clear offset even in release builds, in case this PropertySlot has been used before.
    184202            // (For other data members, we don't need to clear anything because reuse would meaningfully overwrite them.)
    185             m_offset = WTF::notFound;
     203            m_offset = 0;
     204            m_isCacheable = false;
     205            m_isGetter = false;
    186206        }
    187207
    188208        unsigned index() const { return m_data.index; }
    189209
     210        JSValue thisValue() const { return m_thisValue; }
    190211    private:
    191212        static JSValue functionGetter(ExecState*, const Identifier&, const PropertySlot&);
     
    202223
    203224        JSValue m_value;
     225        JSValue m_thisValue;
    204226
    205227        size_t m_offset;
     228        bool m_isCacheable : 1;
     229        bool m_isGetter : 1;
    206230    };
    207231
Note: See TracChangeset for help on using the changeset viewer.