Title: [153556] trunk/Source/_javascript_Core
Revision
153556
Author
[email protected]
Date
2013-07-31 18:09:25 -0700 (Wed, 31 Jul 2013)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (153555 => 153556)


--- trunk/Source/_javascript_Core/ChangeLog	2013-08-01 01:08:47 UTC (rev 153555)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-08-01 01:09:25 UTC (rev 153556)
@@ -1,3 +1,49 @@
+2013-07-31  Gavin Barraclough  <[email protected]>
+
+        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.
+
 2013-07-31  Yi Shen  <[email protected]>
 
         Reduce JSC API static value setter/getter overhead.

Modified: trunk/Source/_javascript_Core/dfg/DFGRepatch.cpp (153555 => 153556)


--- trunk/Source/_javascript_Core/dfg/DFGRepatch.cpp	2013-08-01 01:08:47 UTC (rev 153555)
+++ trunk/Source/_javascript_Core/dfg/DFGRepatch.cpp	2013-08-01 01:09:25 UTC (rev 153556)
@@ -349,8 +349,6 @@
 
     StructureChain* prototypeChain = structure->prototypeChain(exec);
     
-    ASSERT(slot.slotBase().isObject());
-    
     generateProtoChainAccessStub(exec, stubInfo, prototypeChain, count, offset, structure, stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.dfg.deltaCallToDone), stubInfo.callReturnLocation.labelAtOffset(stubInfo.patch.dfg.deltaCallToSlowCase), stubInfo.stubRoutine);
     
     RepatchBuffer repatchBuffer(codeBlock);
@@ -442,8 +440,6 @@
                 return false;
         }
     
-        ASSERT(slot.slotBase().isObject());
-    
         PolymorphicAccessStructureList* polymorphicStructureList;
         int listIndex;
         CodeLocationLabel slowCase;
@@ -577,8 +573,6 @@
     if (baseValue.asCell()->structure()->typeInfo().prohibitsPropertyCaching() || !slot.isCacheableValue())
         return false;
 
-    ASSERT(slot.slotBase().isObject());
-    
     PropertyOffset offset = slot.cachedOffset();
     size_t count = normalizePrototypeChainForChainAccess(exec, baseValue, slot.slotBase(), ident, offset);
     if (count == InvalidPrototypeChain)

Modified: trunk/Source/_javascript_Core/jit/JITStubs.cpp (153555 => 153556)


--- trunk/Source/_javascript_Core/jit/JITStubs.cpp	2013-08-01 01:08:47 UTC (rev 153555)
+++ trunk/Source/_javascript_Core/jit/JITStubs.cpp	2013-08-01 01:09:25 UTC (rev 153556)
@@ -236,8 +236,6 @@
     }
 
     if (slot.slotBase() == structure->prototypeForLookup(callFrame)) {
-        ASSERT(slot.slotBase().isObject());
-        
         JSObject* slotBaseObject = asObject(slot.slotBase());
         size_t offset = slot.cachedOffset();
 
@@ -653,8 +651,6 @@
         && !baseValue.asCell()->structure()->isUncacheableDictionary()
         && slot.slotBase() == baseValue) {
 
-        ASSERT(slot.slotBase().isObject());
-
         PolymorphicAccessStructureList* polymorphicStructureList;
         int listIndex = 1;
 
@@ -766,7 +762,6 @@
     
     Structure* structure = baseValue.asCell()->structure();
 
-    ASSERT(slot.slotBase().isObject());
     JSObject* slotBaseObject = asObject(slot.slotBase());
     
     PropertyOffset offset = slot.cachedOffset();

Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (153555 => 153556)


--- trunk/Source/_javascript_Core/runtime/JSObject.cpp	2013-08-01 01:08:47 UTC (rev 153555)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp	2013-08-01 01:09:25 UTC (rev 153556)
@@ -319,7 +319,7 @@
         } else if (SparseArrayValueMap* map = storage->m_sparseMap.get()) {
             SparseArrayValueMap::iterator it = map->find(i);
             if (it != map->notFound()) {
-                it->value.get(slot);
+                it->value.get(thisObject, slot);
                 return true;
             }
         }
@@ -1623,7 +1623,7 @@
 NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue getterSetter, PropertyOffset offset)
 {
     if (structure()->isDictionary()) {
-        slot.setGetterSlot(jsCast<GetterSetter*>(getterSetter));
+        slot.setGetterSlot(this, jsCast<GetterSetter*>(getterSetter));
         return;
     }
 

Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (153555 => 153556)


--- trunk/Source/_javascript_Core/runtime/JSObject.h	2013-08-01 01:08:47 UTC (rev 153555)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h	2013-08-01 01:09:25 UTC (rev 153556)
@@ -1491,6 +1491,28 @@
 #define JSC_NATIVE_FUNCTION(jsName, cppName, attributes, length) \
     JSC_NATIVE_INTRINSIC_FUNCTION(jsName, cppName, (attributes), (length), NoIntrinsic)
 
+ALWAYS_INLINE JSValue PropertySlot::getValue(ExecState* exec, PropertyName propertyName) const
+{
+    if (m_propertyType == TypeValue)
+        return JSValue::decode(m_data.value);
+    if (m_propertyType == TypeCustomIndex)
+        return m_data.customIndex.getIndexValue(exec, slotBase(), m_data.customIndex.index);
+    if (m_propertyType == TypeGetter)
+        return functionGetter(exec);
+    return m_data.custom.getValue(exec, slotBase(), propertyName);
+}
+
+ALWAYS_INLINE JSValue PropertySlot::getValue(ExecState* exec, unsigned propertyName) const
+{
+    if (m_propertyType == TypeValue)
+        return JSValue::decode(m_data.value);
+    if (m_propertyType == TypeCustomIndex)
+        return m_data.customIndex.getIndexValue(exec, slotBase(), m_data.customIndex.index);
+    if (m_propertyType == TypeGetter)
+        return functionGetter(exec);
+    return m_data.custom.getValue(exec, slotBase(), Identifier::from(exec, propertyName));
+}
+
 } // namespace JSC
 
 #endif // JSObject_h

Modified: trunk/Source/_javascript_Core/runtime/PropertySlot.cpp (153555 => 153556)


--- trunk/Source/_javascript_Core/runtime/PropertySlot.cpp	2013-08-01 01:08:47 UTC (rev 153555)
+++ trunk/Source/_javascript_Core/runtime/PropertySlot.cpp	2013-08-01 01:09:25 UTC (rev 153556)
@@ -28,7 +28,8 @@
 
 JSValue PropertySlot::functionGetter(ExecState* exec) const
 {
-    return callGetter(exec, JSValue::decode(m_data.getter.thisValue), m_data.getter.getterSetter);
+    ASSERT(m_thisValue);
+    return callGetter(exec, m_thisValue, m_data.getter.getterSetter);
 }
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/PropertySlot.h (153555 => 153556)


--- trunk/Source/_javascript_Core/runtime/PropertySlot.h	2013-08-01 01:08:47 UTC (rev 153555)
+++ trunk/Source/_javascript_Core/runtime/PropertySlot.h	2013-08-01 01:09:25 UTC (rev 153556)
@@ -49,38 +49,19 @@
     {
     }
 
-    explicit PropertySlot(const JSValue base)
-        : m_slotBase(base)
-        , m_propertyType(TypeUnset)
+    explicit PropertySlot(const JSValue thisValue)
+        : m_propertyType(TypeUnset)
         , m_offset(invalidOffset)
+        , m_thisValue(thisValue)
     {
     }
 
     typedef JSValue (*GetValueFunc)(ExecState*, JSValue slotBase, PropertyName);
     typedef JSValue (*GetIndexValueFunc)(ExecState*, JSValue slotBase, unsigned);
 
-    JSValue getValue(ExecState* exec, PropertyName propertyName) const
-    {
-        if (m_propertyType == TypeValue)
-            return JSValue::decode(m_data.value);
-        if (m_propertyType == TypeCustomIndex)
-            return m_data.customIndex.getIndexValue(exec, slotBase(), m_data.customIndex.index);
-        if (m_propertyType == TypeGetter)
-            return functionGetter(exec);
-        return m_data.custom.getValue(exec, slotBase(), propertyName);
-    }
+    JSValue getValue(ExecState*, PropertyName) const;
+    JSValue getValue(ExecState*, unsigned propertyName) const;
 
-    JSValue getValue(ExecState* exec, unsigned propertyName) const
-    {
-        if (m_propertyType == TypeValue)
-            return JSValue::decode(m_data.value);
-        if (m_propertyType == TypeCustomIndex)
-            return m_data.customIndex.getIndexValue(exec, slotBase(), m_data.customIndex.index);
-        if (m_propertyType == TypeGetter)
-            return functionGetter(exec);
-        return m_data.custom.getValue(exec, slotBase(), Identifier::from(exec, propertyName));
-    }
-
     bool isCacheable() const { return m_offset != invalidOffset; }
     bool isCacheableValue() const { return isCacheable() && m_propertyType == TypeValue; }
     bool isCacheableGetter() const { return isCacheable() && m_propertyType == TypeGetter; }
@@ -98,8 +79,14 @@
         return m_data.custom.getValue;
     }
 
-    void setValue(JSValue slotBase, JSValue value)
+    JSObject* slotBase() const
     {
+        ASSERT(m_propertyType != TypeUnset);
+        return m_slotBase;
+    }
+
+    void setValue(JSObject* slotBase, JSValue value)
+    {
         ASSERT(value);
         m_data.value = JSValue::encode(value);
 
@@ -109,7 +96,7 @@
         m_offset = invalidOffset;
     }
     
-    void setValue(JSValue slotBase, JSValue value, PropertyOffset offset)
+    void setValue(JSObject* slotBase, JSValue value, PropertyOffset offset)
     {
         ASSERT(value);
         m_data.value = JSValue::encode(value);
@@ -125,12 +112,12 @@
         ASSERT(value);
         m_data.value = JSValue::encode(value);
 
-        m_slotBase = JSValue();
+        m_slotBase = 0;
         m_propertyType = TypeValue;
         m_offset = invalidOffset;
     }
 
-    void setCustom(JSValue slotBase, GetValueFunc getValue)
+    void setCustom(JSObject* slotBase, GetValueFunc getValue)
     {
         ASSERT(getValue);
         m_data.custom.getValue = getValue;
@@ -141,7 +128,7 @@
         m_offset = invalidOffset;
     }
     
-    void setCacheableCustom(JSValue slotBase, GetValueFunc getValue)
+    void setCacheableCustom(JSObject* slotBase, GetValueFunc getValue)
     {
         ASSERT(getValue);
         m_data.custom.getValue = getValue;
@@ -152,7 +139,7 @@
         m_offset = !invalidOffset;
     }
 
-    void setCustomIndex(JSValue slotBase, unsigned index, GetIndexValueFunc getIndexValue)
+    void setCustomIndex(JSObject* slotBase, unsigned index, GetIndexValueFunc getIndexValue)
     {
         ASSERT(getIndexValue);
         m_data.customIndex.getIndexValue = getIndexValue;
@@ -164,20 +151,20 @@
         m_offset = invalidOffset;
     }
 
-    void setGetterSlot(GetterSetter* getterSetter)
+    void setGetterSlot(JSObject* slotBase, GetterSetter* getterSetter)
     {
         ASSERT(getterSetter);
-        m_data.getter.thisValue = JSValue::encode(m_slotBase);
         m_data.getter.getterSetter = getterSetter;
 
+        ASSERT(slotBase);
+        m_slotBase = slotBase;
         m_propertyType = TypeGetter;
         m_offset = invalidOffset;
     }
 
-    void setCacheableGetterSlot(JSValue slotBase, GetterSetter* getterSetter, PropertyOffset offset)
+    void setCacheableGetterSlot(JSObject* slotBase, GetterSetter* getterSetter, PropertyOffset offset)
     {
         ASSERT(getterSetter);
-        m_data.getter.thisValue = JSValue::encode(m_slotBase);
         m_data.getter.getterSetter = getterSetter;
 
         ASSERT(slotBase);
@@ -191,18 +178,12 @@
         setValue(jsUndefined());
     }
 
-    JSValue slotBase() const
-    {
-        return m_slotBase;
-    }
-
 private:
     JS_EXPORT_PRIVATE JSValue functionGetter(ExecState*) const;
 
     union {
         EncodedJSValue value;
         struct {
-            EncodedJSValue thisValue;
             GetterSetter* getterSetter;
         } getter;
         struct {
@@ -214,9 +195,10 @@
         } customIndex;
     } m_data;
 
-    JSValue m_slotBase;
     PropertyType m_propertyType;
     PropertyOffset m_offset;
+    JSValue m_thisValue;
+    JSObject* m_slotBase;
 };
 
 } // namespace JSC

Modified: trunk/Source/_javascript_Core/runtime/SparseArrayValueMap.cpp (153555 => 153556)


--- trunk/Source/_javascript_Core/runtime/SparseArrayValueMap.cpp	2013-08-01 01:08:47 UTC (rev 153555)
+++ trunk/Source/_javascript_Core/runtime/SparseArrayValueMap.cpp	2013-08-01 01:09:25 UTC (rev 153556)
@@ -122,7 +122,7 @@
     return true;
 }
 
-void SparseArrayEntry::get(PropertySlot& slot) const
+void SparseArrayEntry::get(JSObject* thisObject, PropertySlot& slot) const
 {
     JSValue value = Base::get();
     ASSERT(value);
@@ -132,7 +132,7 @@
         return;
     }
 
-    slot.setGetterSlot(jsCast<GetterSetter*>(value));
+    slot.setGetterSlot(thisObject, jsCast<GetterSetter*>(value));
 }
 
 void SparseArrayEntry::get(PropertyDescriptor& descriptor) const

Modified: trunk/Source/_javascript_Core/runtime/SparseArrayValueMap.h (153555 => 153556)


--- trunk/Source/_javascript_Core/runtime/SparseArrayValueMap.h	2013-08-01 01:08:47 UTC (rev 153555)
+++ trunk/Source/_javascript_Core/runtime/SparseArrayValueMap.h	2013-08-01 01:09:25 UTC (rev 153556)
@@ -44,7 +44,7 @@
     SparseArrayEntry() : attributes(0) { }
 
     JSValue get(ExecState*, JSObject*) const;
-    void get(PropertySlot&) const;
+    void get(JSObject*, PropertySlot&) const;
     void get(PropertyDescriptor&) const;
     void put(ExecState*, JSValue thisValue, SparseArrayValueMap*, JSValue, bool shouldThrow);
     JSValue getNonSparseMode() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to