Commit 904726e7 authored by barraclough@apple.com's avatar barraclough@apple.com

https://bugs.webkit.org/show_bug.cgi?id=120067

Remove getPropertyDescriptor

Reviewed by Oliver Hunt.

This is used by lookupGetter/lookupSetter - this can easily bee replaced by getPropertySlot.
Since we'll be getting the GetterSetter from the slot in the setter case, rename isGetter() to isAccessor().

* runtime/JSObject.cpp:
* runtime/JSObject.h:
    - remove getPropertyDescriptor
* runtime/ObjectPrototype.cpp:
(JSC::objectProtoFuncLookupGetter):
(JSC::objectProtoFuncLookupSetter):
    - replace call to getPropertyDescriptor with getPropertySlot
* runtime/PropertyDescriptor.h:
* runtime/PropertySlot.h:
(JSC::PropertySlot::isAccessor):
(JSC::PropertySlot::isCacheableGetter):
(JSC::PropertySlot::getterSetter):
    - rename isGetter() to isAccessor()



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154337 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e25699e6
2013-08-20 Gavin Barraclough <barraclough@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=120067
Remove getPropertyDescriptor
Reviewed by Oliver Hunt.
This is used by lookupGetter/lookupSetter - this can easily bee replaced by getPropertySlot.
Since we'll be getting the GetterSetter from the slot in the setter case, rename isGetter() to isAccessor().
* runtime/JSObject.cpp:
* runtime/JSObject.h:
- remove getPropertyDescriptor
* runtime/ObjectPrototype.cpp:
(JSC::objectProtoFuncLookupGetter):
(JSC::objectProtoFuncLookupSetter):
- replace call to getPropertyDescriptor with getPropertySlot
* runtime/PropertyDescriptor.h:
* runtime/PropertySlot.h:
(JSC::PropertySlot::isAccessor):
(JSC::PropertySlot::isCacheableGetter):
(JSC::PropertySlot::getterSetter):
- rename isGetter() to isAccessor()
2013-08-20 Gavin Barraclough <barraclough@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=120054
......
......@@ -2383,19 +2383,6 @@ Butterfly* JSObject::growOutOfLineStorage(VM& vm, size_t oldSize, size_t newSize
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSObject)
bool JSObject::getPropertyDescriptor(ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSObject* object = this;
while (true) {
if (object->methodTable()->getOwnPropertyDescriptor(object, exec, propertyName, descriptor))
return true;
JSValue prototype = object->prototype();
if (!prototype.isObject())
return false;
object = asObject(prototype);
}
}
static bool putDescriptor(ExecState* exec, JSObject* target, PropertyName propertyName, PropertyDescriptor& descriptor, unsigned attributes, const PropertyDescriptor& oldDescriptor)
{
if (descriptor.isGenericDescriptor() || descriptor.isDataDescriptor()) {
......
......@@ -123,7 +123,6 @@ public:
bool fastGetOwnPropertySlot(ExecState*, PropertyName, PropertySlot&);
bool getPropertySlot(ExecState*, PropertyName, PropertySlot&);
bool getPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
JS_EXPORT_PRIVATE bool getPropertyDescriptor(ExecState*, PropertyName, PropertyDescriptor&);
static bool getOwnPropertySlot(JSObject*, ExecState*, PropertyName, PropertySlot&);
JS_EXPORT_PRIVATE static bool getOwnPropertySlotByIndex(JSObject*, ExecState*, unsigned propertyName, PropertySlot&);
......
......@@ -22,6 +22,7 @@
#include "ObjectPrototype.h"
#include "Error.h"
#include "GetterSetter.h"
#include "JSFunction.h"
#include "JSString.h"
#include "JSStringBuilder.h"
......@@ -155,10 +156,10 @@ EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupGetter(ExecState* exec)
if (exec->hadException())
return JSValue::encode(jsUndefined());
PropertyDescriptor descriptor;
if (thisObject->getPropertyDescriptor(exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)), descriptor)
&& descriptor.getterPresent())
return JSValue::encode(descriptor.getter());
PropertySlot slot(thisObject);
if (thisObject->getPropertySlot(exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)), slot)
&& slot.isAccessor())
return JSValue::encode(slot.getterSetter()->getter());
return JSValue::encode(jsUndefined());
}
......@@ -169,10 +170,10 @@ EncodedJSValue JSC_HOST_CALL objectProtoFuncLookupSetter(ExecState* exec)
if (exec->hadException())
return JSValue::encode(jsUndefined());
PropertyDescriptor descriptor;
if (thisObject->getPropertyDescriptor(exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)), descriptor)
&& descriptor.setterPresent())
return JSValue::encode(descriptor.setter());
PropertySlot slot(thisObject);
if (thisObject->getPropertySlot(exec, Identifier(exec, exec->argument(0).toString(exec)->value(exec)), slot)
&& slot.isAccessor())
return JSValue::encode(slot.getterSetter()->setter());
return JSValue::encode(jsUndefined());
}
......
......@@ -94,7 +94,7 @@ bool ClassName::getOwnPropertyDescriptor(JSC::JSObject* object, JSC::ExecState*
/* Workaround, JSDOMWindow::getOwnPropertySlot searches the prototype chain. :-( */ \
if (slot.slotBase() != object && slot.slotBase() && slot.slotBase()->methodTable()->toThis(slot.slotBase(), exec, NotStrictMode) != object) \
return false; \
if (slot.isGetter()) \
if (slot.isAccessor()) \
descriptor.setAccessorDescriptor(slot.getterSetter(), slot.attributes()); \
else \
descriptor.setDescriptor(slot.getValue(exec, propertyName), slot.attributes()); \
......
......@@ -69,10 +69,10 @@ public:
bool isCacheable() const { return m_offset != invalidOffset; }
bool isValue() const { return m_propertyType == TypeValue; }
bool isGetter() const { return m_propertyType == TypeGetter; }
bool isAccessor() const { return m_propertyType == TypeGetter; }
bool isCustom() const { return m_propertyType == TypeCustom; }
bool isCacheableValue() const { return isCacheable() && isValue(); }
bool isCacheableGetter() const { return isCacheable() && isGetter(); }
bool isCacheableGetter() const { return isCacheable() && isAccessor(); }
bool isCacheableCustom() const { return isCacheable() && isCustom(); }
unsigned attributes() const { return m_attributes; }
......@@ -85,7 +85,7 @@ public:
GetterSetter* getterSetter() const
{
ASSERT(isGetter());
ASSERT(isAccessor());
return m_data.getter.getterSetter;
}
......
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