Ignore:
Timestamp:
Jul 31, 2013, 6:09:25 PM (12 years ago)
Author:
[email protected]
Message:

More cleanup in PropertySlot
https://bugs.webkit.org/show_bug.cgi?id=119359

Reviewed by Geoff Garen.

m_slotBase is overloaded to store the (receiver) thisValue and the object that contains the property,
This is confusing, and means that slotBase cannot be typed correctly (can only be a JSObject).

  • dfg/DFGRepatch.cpp:

(JSC::DFG::tryCacheGetByID):
(JSC::DFG::tryBuildGetByIDList):

  • No need to ASSERT slotBase is an object.
  • jit/JITStubs.cpp:

(JSC::tryCacheGetByID):
(JSC::DEFINE_STUB_FUNCTION):

  • No need to ASSERT slotBase is an object.
  • runtime/JSObject.cpp:

(JSC::JSObject::getOwnPropertySlotByIndex):
(JSC::JSObject::fillGetterPropertySlot):

  • Pass an object through to setGetterSlot.
  • runtime/JSObject.h:

(JSC::PropertySlot::getValue):

  • Moved from PropertySlot (need to know anout JSObject).
  • runtime/PropertySlot.cpp:

(JSC::PropertySlot::functionGetter):

  • update per member name changes
  • runtime/PropertySlot.h:

(JSC::PropertySlot::PropertySlot):

  • Argument to constructor set to 'thisValue'.

(JSC::PropertySlot::slotBase):

  • This returns a JSObject*.

(JSC::PropertySlot::setValue):
(JSC::PropertySlot::setCustom):
(JSC::PropertySlot::setCacheableCustom):
(JSC::PropertySlot::setCustomIndex):
(JSC::PropertySlot::setGetterSlot):
(JSC::PropertySlot::setCacheableGetterSlot):

  • slotBase is a JSObject*, make setGetterSlot set slotBase for consistency.
  • runtime/SparseArrayValueMap.cpp:

(JSC::SparseArrayEntry::get):

  • Pass an object through to setGetterSlot.
  • runtime/SparseArrayValueMap.h:
    • Pass an object through to setGetterSlot.
File:
1 edited

Legend:

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

    r153532 r153556  
    5050    }
    5151
    52     explicit PropertySlot(const JSValue base)
    53         : m_slotBase(base)
    54         , m_propertyType(TypeUnset)
     52    explicit PropertySlot(const JSValue thisValue)
     53        : m_propertyType(TypeUnset)
    5554        , m_offset(invalidOffset)
     55        , m_thisValue(thisValue)
    5656    {
    5757    }
     
    6060    typedef JSValue (*GetIndexValueFunc)(ExecState*, JSValue slotBase, unsigned);
    6161
    62     JSValue getValue(ExecState* exec, PropertyName propertyName) const
    63     {
    64         if (m_propertyType == TypeValue)
    65             return JSValue::decode(m_data.value);
    66         if (m_propertyType == TypeCustomIndex)
    67             return m_data.customIndex.getIndexValue(exec, slotBase(), m_data.customIndex.index);
    68         if (m_propertyType == TypeGetter)
    69             return functionGetter(exec);
    70         return m_data.custom.getValue(exec, slotBase(), propertyName);
    71     }
    72 
    73     JSValue getValue(ExecState* exec, unsigned propertyName) const
    74     {
    75         if (m_propertyType == TypeValue)
    76             return JSValue::decode(m_data.value);
    77         if (m_propertyType == TypeCustomIndex)
    78             return m_data.customIndex.getIndexValue(exec, slotBase(), m_data.customIndex.index);
    79         if (m_propertyType == TypeGetter)
    80             return functionGetter(exec);
    81         return m_data.custom.getValue(exec, slotBase(), Identifier::from(exec, propertyName));
    82     }
     62    JSValue getValue(ExecState*, PropertyName) const;
     63    JSValue getValue(ExecState*, unsigned propertyName) const;
    8364
    8465    bool isCacheable() const { return m_offset != invalidOffset; }
     
    9980    }
    10081
    101     void setValue(JSValue slotBase, JSValue value)
     82    JSObject* slotBase() const
     83    {
     84        ASSERT(m_propertyType != TypeUnset);
     85        return m_slotBase;
     86    }
     87
     88    void setValue(JSObject* slotBase, JSValue value)
    10289    {
    10390        ASSERT(value);
     
    11097    }
    11198   
    112     void setValue(JSValue slotBase, JSValue value, PropertyOffset offset)
     99    void setValue(JSObject* slotBase, JSValue value, PropertyOffset offset)
    113100    {
    114101        ASSERT(value);
     
    126113        m_data.value = JSValue::encode(value);
    127114
    128         m_slotBase = JSValue();
     115        m_slotBase = 0;
    129116        m_propertyType = TypeValue;
    130117        m_offset = invalidOffset;
    131118    }
    132119
    133     void setCustom(JSValue slotBase, GetValueFunc getValue)
     120    void setCustom(JSObject* slotBase, GetValueFunc getValue)
    134121    {
    135122        ASSERT(getValue);
     
    142129    }
    143130   
    144     void setCacheableCustom(JSValue slotBase, GetValueFunc getValue)
     131    void setCacheableCustom(JSObject* slotBase, GetValueFunc getValue)
    145132    {
    146133        ASSERT(getValue);
     
    153140    }
    154141
    155     void setCustomIndex(JSValue slotBase, unsigned index, GetIndexValueFunc getIndexValue)
     142    void setCustomIndex(JSObject* slotBase, unsigned index, GetIndexValueFunc getIndexValue)
    156143    {
    157144        ASSERT(getIndexValue);
     
    165152    }
    166153
    167     void setGetterSlot(GetterSetter* getterSetter)
     154    void setGetterSlot(JSObject* slotBase, GetterSetter* getterSetter)
    168155    {
    169156        ASSERT(getterSetter);
    170         m_data.getter.thisValue = JSValue::encode(m_slotBase);
    171157        m_data.getter.getterSetter = getterSetter;
    172158
     159        ASSERT(slotBase);
     160        m_slotBase = slotBase;
    173161        m_propertyType = TypeGetter;
    174162        m_offset = invalidOffset;
    175163    }
    176164
    177     void setCacheableGetterSlot(JSValue slotBase, GetterSetter* getterSetter, PropertyOffset offset)
     165    void setCacheableGetterSlot(JSObject* slotBase, GetterSetter* getterSetter, PropertyOffset offset)
    178166    {
    179167        ASSERT(getterSetter);
    180         m_data.getter.thisValue = JSValue::encode(m_slotBase);
    181168        m_data.getter.getterSetter = getterSetter;
    182169
     
    190177    {
    191178        setValue(jsUndefined());
    192     }
    193 
    194     JSValue slotBase() const
    195     {
    196         return m_slotBase;
    197179    }
    198180
     
    203185        EncodedJSValue value;
    204186        struct {
    205             EncodedJSValue thisValue;
    206187            GetterSetter* getterSetter;
    207188        } getter;
     
    215196    } m_data;
    216197
    217     JSValue m_slotBase;
    218198    PropertyType m_propertyType;
    219199    PropertyOffset m_offset;
     200    JSValue m_thisValue;
     201    JSObject* m_slotBase;
    220202};
    221203
Note: See TracChangeset for help on using the changeset viewer.