Ignore:
Timestamp:
Sep 15, 2009, 4:17:19 PM (16 years ago)
Author:
[email protected]
Message:

Allow anonymous storage inside JSObject
https://bugs.webkit.org/show_bug.cgi?id=29168

Reviewed by Geoff Garen

Add the concept of anonymous slots to Structures so that it is
possible to store references to values that need marking in the
standard JSObject storage buffer. This allows us to reduce the
malloc overhead of some objects (by allowing them to store JS
values in the inline storage of the object) and reduce the
dependence of custom mark functions (if all an objects children
are in the standard object property storage there's no need to
mark them manually).

File:
1 edited

Legend:

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

    r48336 r48403  
    210210        }
    211211
     212    protected:
     213        void addAnonymousSlots(unsigned count);
     214        void putAnonymousValue(unsigned index, JSValue value)
     215        {
     216            *locationForOffset(index) = value;
     217        }
     218        JSValue getAnonymousValue(unsigned index)
     219        {
     220            return *locationForOffset(index);
     221        }
     222
    212223    private:
    213224        // Nobody should ever ask any of these questions on something already known to be a JSObject.
     
    514525}
    515526
     527inline void JSObject::addAnonymousSlots(unsigned count)
     528{
     529    size_t currentCapacity = m_structure->propertyStorageCapacity();
     530    RefPtr<Structure> structure = Structure::addAnonymousSlotsTransition(m_structure, count);
     531
     532    if (currentCapacity != structure->propertyStorageCapacity())
     533        allocatePropertyStorage(currentCapacity, structure->propertyStorageCapacity());
     534
     535    setStructure(structure.release());
     536}
     537
    516538inline void JSObject::putDirect(const Identifier& propertyName, JSValue value, unsigned attributes, bool checkReadOnly, PutPropertySlot& slot)
    517539{
Note: See TracChangeset for help on using the changeset viewer.