Commit b8c4f432 authored by barraclough@apple.com's avatar barraclough@apple.com

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.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@153556 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 3792c256
2013-07-31 Gavin Barraclough <barraclough@apple.com>
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 <max.hong.shen@gmail.com> 2013-07-31 Yi Shen <max.hong.shen@gmail.com>
Reduce JSC API static value setter/getter overhead. Reduce JSC API static value setter/getter overhead.
......
...@@ -349,8 +349,6 @@ static bool tryCacheGetByID(ExecState* exec, JSValue baseValue, const Identifier ...@@ -349,8 +349,6 @@ static bool tryCacheGetByID(ExecState* exec, JSValue baseValue, const Identifier
StructureChain* prototypeChain = structure->prototypeChain(exec); 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); 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); RepatchBuffer repatchBuffer(codeBlock);
...@@ -442,8 +440,6 @@ static bool tryBuildGetByIDList(ExecState* exec, JSValue baseValue, const Identi ...@@ -442,8 +440,6 @@ static bool tryBuildGetByIDList(ExecState* exec, JSValue baseValue, const Identi
return false; return false;
} }
ASSERT(slot.slotBase().isObject());
PolymorphicAccessStructureList* polymorphicStructureList; PolymorphicAccessStructureList* polymorphicStructureList;
int listIndex; int listIndex;
CodeLocationLabel slowCase; CodeLocationLabel slowCase;
...@@ -577,8 +573,6 @@ static bool tryBuildGetByIDList(ExecState* exec, JSValue baseValue, const Identi ...@@ -577,8 +573,6 @@ static bool tryBuildGetByIDList(ExecState* exec, JSValue baseValue, const Identi
if (baseValue.asCell()->structure()->typeInfo().prohibitsPropertyCaching() || !slot.isCacheableValue()) if (baseValue.asCell()->structure()->typeInfo().prohibitsPropertyCaching() || !slot.isCacheableValue())
return false; return false;
ASSERT(slot.slotBase().isObject());
PropertyOffset offset = slot.cachedOffset(); PropertyOffset offset = slot.cachedOffset();
size_t count = normalizePrototypeChainForChainAccess(exec, baseValue, slot.slotBase(), ident, offset); size_t count = normalizePrototypeChainForChainAccess(exec, baseValue, slot.slotBase(), ident, offset);
if (count == InvalidPrototypeChain) if (count == InvalidPrototypeChain)
......
...@@ -236,8 +236,6 @@ NEVER_INLINE static void tryCacheGetByID(CallFrame* callFrame, CodeBlock* codeBl ...@@ -236,8 +236,6 @@ NEVER_INLINE static void tryCacheGetByID(CallFrame* callFrame, CodeBlock* codeBl
} }
if (slot.slotBase() == structure->prototypeForLookup(callFrame)) { if (slot.slotBase() == structure->prototypeForLookup(callFrame)) {
ASSERT(slot.slotBase().isObject());
JSObject* slotBaseObject = asObject(slot.slotBase()); JSObject* slotBaseObject = asObject(slot.slotBase());
size_t offset = slot.cachedOffset(); size_t offset = slot.cachedOffset();
...@@ -653,8 +651,6 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_self_fail) ...@@ -653,8 +651,6 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_self_fail)
&& !baseValue.asCell()->structure()->isUncacheableDictionary() && !baseValue.asCell()->structure()->isUncacheableDictionary()
&& slot.slotBase() == baseValue) { && slot.slotBase() == baseValue) {
ASSERT(slot.slotBase().isObject());
PolymorphicAccessStructureList* polymorphicStructureList; PolymorphicAccessStructureList* polymorphicStructureList;
int listIndex = 1; int listIndex = 1;
...@@ -766,7 +762,6 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_proto_list) ...@@ -766,7 +762,6 @@ DEFINE_STUB_FUNCTION(EncodedJSValue, op_get_by_id_proto_list)
Structure* structure = baseValue.asCell()->structure(); Structure* structure = baseValue.asCell()->structure();
ASSERT(slot.slotBase().isObject());
JSObject* slotBaseObject = asObject(slot.slotBase()); JSObject* slotBaseObject = asObject(slot.slotBase());
PropertyOffset offset = slot.cachedOffset(); PropertyOffset offset = slot.cachedOffset();
......
...@@ -319,7 +319,7 @@ bool JSObject::getOwnPropertySlotByIndex(JSObject* thisObject, ExecState* exec, ...@@ -319,7 +319,7 @@ bool JSObject::getOwnPropertySlotByIndex(JSObject* thisObject, ExecState* exec,
} else if (SparseArrayValueMap* map = storage->m_sparseMap.get()) { } else if (SparseArrayValueMap* map = storage->m_sparseMap.get()) {
SparseArrayValueMap::iterator it = map->find(i); SparseArrayValueMap::iterator it = map->find(i);
if (it != map->notFound()) { if (it != map->notFound()) {
it->value.get(slot); it->value.get(thisObject, slot);
return true; return true;
} }
} }
...@@ -1623,7 +1623,7 @@ bool JSObject::removeDirect(VM& vm, PropertyName propertyName) ...@@ -1623,7 +1623,7 @@ bool JSObject::removeDirect(VM& vm, PropertyName propertyName)
NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue getterSetter, PropertyOffset offset) NEVER_INLINE void JSObject::fillGetterPropertySlot(PropertySlot& slot, JSValue getterSetter, PropertyOffset offset)
{ {
if (structure()->isDictionary()) { if (structure()->isDictionary()) {
slot.setGetterSlot(jsCast<GetterSetter*>(getterSetter)); slot.setGetterSlot(this, jsCast<GetterSetter*>(getterSetter));
return; return;
} }
......
...@@ -1491,6 +1491,28 @@ ALWAYS_INLINE Identifier makeIdentifier(ExecState*, const Identifier& name) ...@@ -1491,6 +1491,28 @@ ALWAYS_INLINE Identifier makeIdentifier(ExecState*, const Identifier& name)
#define JSC_NATIVE_FUNCTION(jsName, cppName, attributes, length) \ #define JSC_NATIVE_FUNCTION(jsName, cppName, attributes, length) \
JSC_NATIVE_INTRINSIC_FUNCTION(jsName, cppName, (attributes), (length), NoIntrinsic) 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 } // namespace JSC
#endif // JSObject_h #endif // JSObject_h
...@@ -28,7 +28,8 @@ namespace JSC { ...@@ -28,7 +28,8 @@ namespace JSC {
JSValue PropertySlot::functionGetter(ExecState* exec) const 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 } // namespace JSC
...@@ -49,37 +49,18 @@ public: ...@@ -49,37 +49,18 @@ public:
{ {
} }
explicit PropertySlot(const JSValue base) explicit PropertySlot(const JSValue thisValue)
: m_slotBase(base) : m_propertyType(TypeUnset)
, m_propertyType(TypeUnset)
, m_offset(invalidOffset) , m_offset(invalidOffset)
, m_thisValue(thisValue)
{ {
} }
typedef JSValue (*GetValueFunc)(ExecState*, JSValue slotBase, PropertyName); typedef JSValue (*GetValueFunc)(ExecState*, JSValue slotBase, PropertyName);
typedef JSValue (*GetIndexValueFunc)(ExecState*, JSValue slotBase, unsigned); typedef JSValue (*GetIndexValueFunc)(ExecState*, JSValue slotBase, unsigned);
JSValue getValue(ExecState* exec, PropertyName propertyName) const JSValue getValue(ExecState*, PropertyName) const;
{ JSValue getValue(ExecState*, 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(), propertyName);
}
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 isCacheable() const { return m_offset != invalidOffset; }
bool isCacheableValue() const { return isCacheable() && m_propertyType == TypeValue; } bool isCacheableValue() const { return isCacheable() && m_propertyType == TypeValue; }
...@@ -98,7 +79,13 @@ public: ...@@ -98,7 +79,13 @@ public:
return m_data.custom.getValue; 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); ASSERT(value);
m_data.value = JSValue::encode(value); m_data.value = JSValue::encode(value);
...@@ -109,7 +96,7 @@ public: ...@@ -109,7 +96,7 @@ public:
m_offset = invalidOffset; m_offset = invalidOffset;
} }
void setValue(JSValue slotBase, JSValue value, PropertyOffset offset) void setValue(JSObject* slotBase, JSValue value, PropertyOffset offset)
{ {
ASSERT(value); ASSERT(value);
m_data.value = JSValue::encode(value); m_data.value = JSValue::encode(value);
...@@ -125,12 +112,12 @@ public: ...@@ -125,12 +112,12 @@ public:
ASSERT(value); ASSERT(value);
m_data.value = JSValue::encode(value); m_data.value = JSValue::encode(value);
m_slotBase = JSValue(); m_slotBase = 0;
m_propertyType = TypeValue; m_propertyType = TypeValue;
m_offset = invalidOffset; m_offset = invalidOffset;
} }
void setCustom(JSValue slotBase, GetValueFunc getValue) void setCustom(JSObject* slotBase, GetValueFunc getValue)
{ {
ASSERT(getValue); ASSERT(getValue);
m_data.custom.getValue = getValue; m_data.custom.getValue = getValue;
...@@ -141,7 +128,7 @@ public: ...@@ -141,7 +128,7 @@ public:
m_offset = invalidOffset; m_offset = invalidOffset;
} }
void setCacheableCustom(JSValue slotBase, GetValueFunc getValue) void setCacheableCustom(JSObject* slotBase, GetValueFunc getValue)
{ {
ASSERT(getValue); ASSERT(getValue);
m_data.custom.getValue = getValue; m_data.custom.getValue = getValue;
...@@ -152,7 +139,7 @@ public: ...@@ -152,7 +139,7 @@ public:
m_offset = !invalidOffset; m_offset = !invalidOffset;
} }
void setCustomIndex(JSValue slotBase, unsigned index, GetIndexValueFunc getIndexValue) void setCustomIndex(JSObject* slotBase, unsigned index, GetIndexValueFunc getIndexValue)
{ {
ASSERT(getIndexValue); ASSERT(getIndexValue);
m_data.customIndex.getIndexValue = getIndexValue; m_data.customIndex.getIndexValue = getIndexValue;
...@@ -164,20 +151,20 @@ public: ...@@ -164,20 +151,20 @@ public:
m_offset = invalidOffset; m_offset = invalidOffset;
} }
void setGetterSlot(GetterSetter* getterSetter) void setGetterSlot(JSObject* slotBase, GetterSetter* getterSetter)
{ {
ASSERT(getterSetter); ASSERT(getterSetter);
m_data.getter.thisValue = JSValue::encode(m_slotBase);
m_data.getter.getterSetter = getterSetter; m_data.getter.getterSetter = getterSetter;
ASSERT(slotBase);
m_slotBase = slotBase;
m_propertyType = TypeGetter; m_propertyType = TypeGetter;
m_offset = invalidOffset; m_offset = invalidOffset;
} }
void setCacheableGetterSlot(JSValue slotBase, GetterSetter* getterSetter, PropertyOffset offset) void setCacheableGetterSlot(JSObject* slotBase, GetterSetter* getterSetter, PropertyOffset offset)
{ {
ASSERT(getterSetter); ASSERT(getterSetter);
m_data.getter.thisValue = JSValue::encode(m_slotBase);
m_data.getter.getterSetter = getterSetter; m_data.getter.getterSetter = getterSetter;
ASSERT(slotBase); ASSERT(slotBase);
...@@ -191,18 +178,12 @@ public: ...@@ -191,18 +178,12 @@ public:
setValue(jsUndefined()); setValue(jsUndefined());
} }
JSValue slotBase() const
{
return m_slotBase;
}
private: private:
JS_EXPORT_PRIVATE JSValue functionGetter(ExecState*) const; JS_EXPORT_PRIVATE JSValue functionGetter(ExecState*) const;
union { union {
EncodedJSValue value; EncodedJSValue value;
struct { struct {
EncodedJSValue thisValue;
GetterSetter* getterSetter; GetterSetter* getterSetter;
} getter; } getter;
struct { struct {
...@@ -214,9 +195,10 @@ private: ...@@ -214,9 +195,10 @@ private:
} customIndex; } customIndex;
} m_data; } m_data;
JSValue m_slotBase;
PropertyType m_propertyType; PropertyType m_propertyType;
PropertyOffset m_offset; PropertyOffset m_offset;
JSValue m_thisValue;
JSObject* m_slotBase;
}; };
} // namespace JSC } // namespace JSC
......
...@@ -122,7 +122,7 @@ bool SparseArrayValueMap::putDirect(ExecState* exec, JSObject* array, unsigned i ...@@ -122,7 +122,7 @@ bool SparseArrayValueMap::putDirect(ExecState* exec, JSObject* array, unsigned i
return true; return true;
} }
void SparseArrayEntry::get(PropertySlot& slot) const void SparseArrayEntry::get(JSObject* thisObject, PropertySlot& slot) const
{ {
JSValue value = Base::get(); JSValue value = Base::get();
ASSERT(value); ASSERT(value);
...@@ -132,7 +132,7 @@ void SparseArrayEntry::get(PropertySlot& slot) const ...@@ -132,7 +132,7 @@ void SparseArrayEntry::get(PropertySlot& slot) const
return; return;
} }
slot.setGetterSlot(jsCast<GetterSetter*>(value)); slot.setGetterSlot(thisObject, jsCast<GetterSetter*>(value));
} }
void SparseArrayEntry::get(PropertyDescriptor& descriptor) const void SparseArrayEntry::get(PropertyDescriptor& descriptor) const
......
...@@ -44,7 +44,7 @@ struct SparseArrayEntry : public WriteBarrier<Unknown> { ...@@ -44,7 +44,7 @@ struct SparseArrayEntry : public WriteBarrier<Unknown> {
SparseArrayEntry() : attributes(0) { } SparseArrayEntry() : attributes(0) { }
JSValue get(ExecState*, JSObject*) const; JSValue get(ExecState*, JSObject*) const;
void get(PropertySlot&) const; void get(JSObject*, PropertySlot&) const;
void get(PropertyDescriptor&) const; void get(PropertyDescriptor&) const;
void put(ExecState*, JSValue thisValue, SparseArrayValueMap*, JSValue, bool shouldThrow); void put(ExecState*, JSValue thisValue, SparseArrayValueMap*, JSValue, bool shouldThrow);
JSValue getNonSparseMode() const; JSValue getNonSparseMode() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment