Changeset 169695 in webkit


Ignore:
Timestamp:
Jun 9, 2014 11:07:37 AM (10 years ago)
Author:
mark.lam@apple.com
Message:

Structure should initialize its previousID in its constructor.
<https://webkit.org/b/133606>

Reviewed by Mark Hahnenberg.

Currently, the Structure constructor that takes a previous structure will
initialize its previousID to point to the previous structure's previousID.
This is incorrect. However, the caller of the Structure::create() factory
method (which instantiated the Structure) will later call setPreviousID()
to set the previousID to the correct previous structure. This makes the
code confusing to read and more error prone in that the structure relies
on client code to fix its invalid previousID.

This patch fixes this by making the Structure constructor initialize
previousID correctly.

  • runtime/Structure.cpp:

(JSC::Structure::Structure):
(JSC::Structure::addPropertyTransition):
(JSC::Structure::nonPropertyTransition):

  • runtime/Structure.h:
  • runtime/StructureInlines.h:

(JSC::Structure::create):

Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r169668 r169695  
     12014-06-07  Mark Lam  <mark.lam@apple.com>
     2
     3        Structure should initialize its previousID in its constructor.
     4        <https://webkit.org/b/133606>
     5
     6        Reviewed by Mark Hahnenberg.
     7
     8        Currently, the Structure constructor that takes a previous structure will
     9        initialize its previousID to point to the previous structure's previousID.
     10        This is incorrect.  However, the caller of the Structure::create() factory
     11        method (which instantiated the Structure) will later call setPreviousID()
     12        to set the previousID to the correct previous structure.  This makes the
     13        code confusing to read and more error prone in that the structure relies
     14        on client code to fix its invalid previousID.
     15
     16        This patch fixes this by making the Structure constructor initialize
     17        previousID correctly.
     18
     19        * runtime/Structure.cpp:
     20        (JSC::Structure::Structure):
     21        (JSC::Structure::addPropertyTransition):
     22        (JSC::Structure::nonPropertyTransition):
     23        * runtime/Structure.h:
     24        * runtime/StructureInlines.h:
     25        (JSC::Structure::create):
     26
    1272014-06-06  Andreas Kling  <akling@apple.com>
    228
  • trunk/Source/JavaScriptCore/runtime/Structure.cpp

    r169121 r169695  
    212212}
    213213
    214 Structure::Structure(VM& vm, const Structure* previous)
     214Structure::Structure(VM& vm, Structure* previous)
    215215    : JSCell(vm, vm.structureStructure.get())
    216216    , m_prototype(vm, this, previous->storedPrototype())
     
    237237    if (previous->typeInfo().structureHasRareData() && previous->rareData()->needsCloning())
    238238        cloneRareDataFrom(vm, previous);
    239     else if (previous->previousID())
    240         m_previousOrRareData.set(vm, this, previous->previousID());
     239    setPreviousID(vm, this, previous);
    241240
    242241    previous->notifyTransitionFromThisStructure();
     
    460459
    461460    transition->m_cachedPrototypeChain.setMayBeNull(vm, transition, structure->m_cachedPrototypeChain.get());
    462     transition->setPreviousID(vm, transition, structure);
    463461    transition->m_nameInPrevious = propertyName.uid();
    464462    transition->m_attributesInPrevious = attributes;
     
    673671   
    674672    Structure* transition = create(vm, structure);
    675     transition->setPreviousID(vm, transition, structure);
    676673    transition->m_attributesInPrevious = attributes;
    677674    transition->m_blob.setIndexingType(indexingType);
  • trunk/Source/JavaScriptCore/runtime/Structure.h

    r169121 r169695  
    390390    JS_EXPORT_PRIVATE Structure(VM&, JSGlobalObject*, JSValue prototype, const TypeInfo&, const ClassInfo*, IndexingType, unsigned inlineCapacity);
    391391    Structure(VM&);
    392     Structure(VM&, const Structure*);
    393 
    394     static Structure* create(VM&, const Structure*);
     392    Structure(VM&, Structure*);
     393
     394    static Structure* create(VM&, Structure*);
    395395   
    396396    static Structure* addPropertyTransitionToExistingStructureImpl(Structure*, StringImpl* uid, unsigned attributes, JSCell* specificValue, PropertyOffset&);
  • trunk/Source/JavaScriptCore/runtime/StructureInlines.h

    r168373 r169695  
    5050}
    5151
    52 inline Structure* Structure::create(VM& vm, const Structure* structure)
     52inline Structure* Structure::create(VM& vm, Structure* structure)
    5353{
    5454    ASSERT(vm.structureStructure);
Note: See TracChangeset for help on using the changeset viewer.