Commit 47d7ba89 authored by barraclough@apple.com's avatar barraclough@apple.com

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

Start removing custom implementations of getOwnPropertyDescriptor

Reviewed by Sam Weinig.

This can now typically implemented in terms of getOwnPropertySlot.
Add a macro to PropertyDescriptor to define an implementation of GOPD in terms of GOPS.
Switch over most classes in JSC & the WebCore bindings generator to use this.

Source/JavaScriptCore: 

* API/JSCallbackObjectFunctions.h:
* debugger/DebuggerActivation.cpp:
* runtime/Arguments.cpp:
* runtime/ArrayConstructor.cpp:
* runtime/ArrayPrototype.cpp:
* runtime/BooleanPrototype.cpp:
* runtime/DateConstructor.cpp:
* runtime/DatePrototype.cpp:
* runtime/ErrorPrototype.cpp:
* runtime/JSActivation.cpp:
* runtime/JSArray.cpp:
* runtime/JSArrayBuffer.cpp:
* runtime/JSArrayBufferView.cpp:
* runtime/JSCell.cpp:
* runtime/JSDataView.cpp:
* runtime/JSDataViewPrototype.cpp:
* runtime/JSFunction.cpp:
* runtime/JSGenericTypedArrayViewInlines.h:
* runtime/JSNotAnObject.cpp:
* runtime/JSONObject.cpp:
* runtime/JSObject.cpp:
* runtime/NamePrototype.cpp:
* runtime/NumberConstructor.cpp:
* runtime/NumberPrototype.cpp:
* runtime/ObjectConstructor.cpp:
    - Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL.
* runtime/PropertyDescriptor.h:
    - Added GET_OWN_PROPERTY_DESCRIPTOR_IMPL macro.
* runtime/PropertySlot.h:
(JSC::PropertySlot::isValue):
(JSC::PropertySlot::isGetter):
(JSC::PropertySlot::isCustom):
(JSC::PropertySlot::isCacheableValue):
(JSC::PropertySlot::isCacheableGetter):
(JSC::PropertySlot::isCacheableCustom):
(JSC::PropertySlot::attributes):
(JSC::PropertySlot::getterSetter):
    - Add accessors necessary to convert PropertySlot to descriptor.
* runtime/RegExpConstructor.cpp:
* runtime/RegExpMatchesArray.cpp:
* runtime/RegExpMatchesArray.h:
* runtime/RegExpObject.cpp:
* runtime/RegExpPrototype.cpp:
* runtime/StringConstructor.cpp:
* runtime/StringObject.cpp:
    - Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL.

Source/WebCore: 

* bindings/js/JSCSSStyleDeclarationCustom.cpp:
* bindings/js/JSHTMLAppletElementCustom.cpp:
* bindings/js/JSHTMLEmbedElementCustom.cpp:
* bindings/js/JSHTMLObjectElementCustom.cpp:
* bindings/js/JSHistoryCustom.cpp:
(WebCore::JSHistory::getOwnPropertySlotDelegate):
* bindings/js/JSLocationCustom.cpp:
(WebCore::JSLocation::getOwnPropertySlotDelegate):
* bindings/js/JSWorkerGlobalScopeCustom.cpp:
    - Remove getOwnPropertyDescriptorDelegate methods,
      Change attributes of cross-frame access properties in JSHistory/JSLocation to prevent properties from being redefined.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader):
(GenerateImplementation):
(GenerateConstructorHelperMethods):
    - Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL.
* bindings/scripts/test/JS/JSTestActiveDOMObject.cpp:
* bindings/scripts/test/JS/JSTestCustomNamedGetter.cpp:
* bindings/scripts/test/JS/JSTestEventConstructor.cpp:
* bindings/scripts/test/JS/JSTestEventTarget.cpp:
* bindings/scripts/test/JS/JSTestException.cpp:
* bindings/scripts/test/JS/JSTestInterface.cpp:
* bindings/scripts/test/JS/JSTestMediaQueryListListener.cpp:
* bindings/scripts/test/JS/JSTestNamedConstructor.cpp:
* bindings/scripts/test/JS/JSTestNode.cpp:
* bindings/scripts/test/JS/JSTestObj.cpp:
* bindings/scripts/test/JS/JSTestOverloadedConstructors.cpp:
* bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.cpp:
* bindings/scripts/test/JS/JSTestTypedefs.cpp:
    - Update test expectations.

LayoutTests: 

* http/tests/security/xss-DENIED-defineProperty-expected.txt:
    - Remove erroneous error messages - cross frame access to reload is allowed - it's just read-only, non-configurable.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@154300 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 26d54a61
2013-08-19 Gavin Barraclough <barraclough@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=119995
Start removing custom implementations of getOwnPropertyDescriptor
Reviewed by Sam Weinig.
This can now typically implemented in terms of getOwnPropertySlot.
Add a macro to PropertyDescriptor to define an implementation of GOPD in terms of GOPS.
Switch over most classes in JSC & the WebCore bindings generator to use this.
* http/tests/security/xss-DENIED-defineProperty-expected.txt:
- Remove erroneous error messages - cross frame access to reload is allowed - it's just read-only, non-configurable.
2013-08-19 Jer Noble <jer.noble@apple.com>
<https://bugs.webkit.org/show_bug.cgi?id=120025> REGRESSION (r154254): fast/frames/frameset-frameborder-inheritance.html failing on Apple MountainLion Debug WK1 (Tests)
......@@ -58,12 +58,6 @@ CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from access
CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.
CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.
CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.
CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.
CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.
CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.
CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.
CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.
CONSOLE MESSAGE: Blocked a frame with origin "http://localhost:8000" from accessing a frame with origin "http://127.0.0.1:8000". Protocols, domains, and ports must match.
PASS: cross-site assignment of Object constructor not allowed
PASS: cross-site assignment of new property not allowed
......
......@@ -213,24 +213,7 @@ JSValue JSCallbackObject<Parent>::defaultValue(const JSObject* object, ExecState
}
template <class Parent>
bool JSCallbackObject<Parent>::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSCallbackObject* thisObject = jsCast<JSCallbackObject*>(object);
PropertySlot slot(thisObject);
if (thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, propertyName, slot)) {
// Ideally we should return an access descriptor, but returning a value descriptor is better than nothing.
JSValue value = slot.getValue(exec, propertyName);
if (!exec->hadException())
descriptor.setValue(value);
// We don't know whether the property is configurable, but assume it is.
descriptor.setConfigurable(true);
// We don't know whether the property is enumerable (we could call getOwnPropertyNames() to find out), but assume it isn't.
descriptor.setEnumerable(false);
return true;
}
return Parent::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSCallbackObject<Parent>)
template <class Parent>
void JSCallbackObject<Parent>::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
......
2013-08-18 Gavin Barraclough <barraclough@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=119995
Start removing custom implementations of getOwnPropertyDescriptor
Reviewed by Sam Weinig.
This can now typically implemented in terms of getOwnPropertySlot.
Add a macro to PropertyDescriptor to define an implementation of GOPD in terms of GOPS.
Switch over most classes in JSC & the WebCore bindings generator to use this.
* API/JSCallbackObjectFunctions.h:
* debugger/DebuggerActivation.cpp:
* runtime/Arguments.cpp:
* runtime/ArrayConstructor.cpp:
* runtime/ArrayPrototype.cpp:
* runtime/BooleanPrototype.cpp:
* runtime/DateConstructor.cpp:
* runtime/DatePrototype.cpp:
* runtime/ErrorPrototype.cpp:
* runtime/JSActivation.cpp:
* runtime/JSArray.cpp:
* runtime/JSArrayBuffer.cpp:
* runtime/JSArrayBufferView.cpp:
* runtime/JSCell.cpp:
* runtime/JSDataView.cpp:
* runtime/JSDataViewPrototype.cpp:
* runtime/JSFunction.cpp:
* runtime/JSGenericTypedArrayViewInlines.h:
* runtime/JSNotAnObject.cpp:
* runtime/JSONObject.cpp:
* runtime/JSObject.cpp:
* runtime/NamePrototype.cpp:
* runtime/NumberConstructor.cpp:
* runtime/NumberPrototype.cpp:
* runtime/ObjectConstructor.cpp:
- Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL.
* runtime/PropertyDescriptor.h:
- Added GET_OWN_PROPERTY_DESCRIPTOR_IMPL macro.
* runtime/PropertySlot.h:
(JSC::PropertySlot::isValue):
(JSC::PropertySlot::isGetter):
(JSC::PropertySlot::isCustom):
(JSC::PropertySlot::isCacheableValue):
(JSC::PropertySlot::isCacheableGetter):
(JSC::PropertySlot::isCacheableCustom):
(JSC::PropertySlot::attributes):
(JSC::PropertySlot::getterSetter):
- Add accessors necessary to convert PropertySlot to descriptor.
* runtime/RegExpConstructor.cpp:
* runtime/RegExpMatchesArray.cpp:
* runtime/RegExpMatchesArray.h:
* runtime/RegExpObject.cpp:
* runtime/RegExpPrototype.cpp:
* runtime/StringConstructor.cpp:
* runtime/StringObject.cpp:
- Implement getOwnPropertySlot in terms of GET_OWN_PROPERTY_DESCRIPTOR_IMPL.
2013-08-19 Michael Saboff <msaboff@apple.com>
https://bugs.webkit.org/show_bug.cgi?id=120020 Change Set 154207 causes wrong register to be used for 32 bit tests
......
......@@ -95,11 +95,7 @@ void DebuggerActivation::getOwnPropertyNames(JSObject* object, ExecState* exec,
thisObject->m_activation->methodTable()->getPropertyNames(thisObject->m_activation.get(), exec, propertyNames, mode);
}
bool DebuggerActivation::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
DebuggerActivation* thisObject = jsCast<DebuggerActivation*>(object);
return thisObject->m_activation->methodTable()->getOwnPropertyDescriptor(thisObject->m_activation.get(), exec, propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(DebuggerActivation)
bool DebuggerActivation::defineOwnProperty(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor, bool shouldThrow)
{
......
......@@ -152,34 +152,7 @@ bool Arguments::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyNa
return JSObject::getOwnPropertySlot(thisObject, exec, propertyName, slot);
}
bool Arguments::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
Arguments* thisObject = jsCast<Arguments*>(object);
unsigned i = propertyName.asIndex();
if (JSValue value = thisObject->tryGetArgument(i)) {
RELEASE_ASSERT(i < PropertyName::NotAnIndex);
descriptor.setDescriptor(value, None);
return true;
}
if (propertyName == exec->propertyNames().length && LIKELY(!thisObject->m_overrodeLength)) {
descriptor.setDescriptor(jsNumber(thisObject->m_numArguments), DontEnum);
return true;
}
if (propertyName == exec->propertyNames().callee && LIKELY(!thisObject->m_overrodeCallee)) {
if (!thisObject->m_isStrictMode) {
descriptor.setDescriptor(thisObject->m_callee.get(), DontEnum);
return true;
}
thisObject->createStrictModeCalleeIfNecessary(exec);
}
if (propertyName == exec->propertyNames().caller && thisObject->m_isStrictMode)
thisObject->createStrictModeCallerIfNecessary(exec);
return JSObject::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(Arguments)
void Arguments::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
......
......@@ -71,10 +71,7 @@ bool ArrayConstructor::getOwnPropertySlot(JSObject* object, ExecState* exec, Pro
return getStaticFunctionSlot<InternalFunction>(exec, ExecState::arrayConstructorTable(exec), jsCast<ArrayConstructor*>(object), propertyName, slot);
}
bool ArrayConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
return getStaticFunctionDescriptor<InternalFunction>(exec, ExecState::arrayConstructorTable(exec), jsCast<ArrayConstructor*>(object), propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(ArrayConstructor)
// ------------------------------ Functions ---------------------------
......
......@@ -141,10 +141,7 @@ bool ArrayPrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, Prope
return getStaticFunctionSlot<JSArray>(exec, ExecState::arrayPrototypeTable(exec), jsCast<ArrayPrototype*>(object), propertyName, slot);
}
bool ArrayPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
return getStaticFunctionDescriptor<JSArray>(exec, ExecState::arrayPrototypeTable(exec), jsCast<ArrayPrototype*>(object), propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(ArrayPrototype)
// ------------------------------ Array Functions ----------------------------
......
......@@ -68,10 +68,7 @@ bool BooleanPrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, Pro
return getStaticFunctionSlot<BooleanObject>(exec, ExecState::booleanPrototypeTable(exec), jsCast<BooleanPrototype*>(object), propertyName, slot);
}
bool BooleanPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
return getStaticFunctionDescriptor<BooleanObject>(exec, ExecState::booleanPrototypeTable(exec), jsCast<BooleanPrototype*>(object), propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(BooleanPrototype)
// ------------------------------ Functions ---------------------------
......
......@@ -91,10 +91,7 @@ bool DateConstructor::getOwnPropertySlot(JSObject* object, ExecState* exec, Prop
return getStaticFunctionSlot<InternalFunction>(exec, ExecState::dateConstructorTable(exec), jsCast<DateConstructor*>(object), propertyName, slot);
}
bool DateConstructor::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
return getStaticFunctionDescriptor<InternalFunction>(exec, ExecState::dateConstructorTable(exec), jsCast<DateConstructor*>(object), propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(DateConstructor)
// ECMA 15.9.3
JSObject* constructDate(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args)
......
......@@ -519,10 +519,7 @@ bool DatePrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, Proper
return getStaticFunctionSlot<JSObject>(exec, ExecState::dateTable(exec), jsCast<DatePrototype*>(object), propertyName, slot);
}
bool DatePrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
return getStaticFunctionDescriptor<JSObject>(exec, ExecState::dateTable(exec), jsCast<DatePrototype*>(object), propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(DatePrototype)
// Functions
......
......@@ -66,10 +66,7 @@ bool ErrorPrototype::getOwnPropertySlot(JSObject* object, ExecState* exec, Prope
return getStaticFunctionSlot<ErrorInstance>(exec, ExecState::errorPrototypeTable(exec), jsCast<ErrorPrototype*>(object), propertyName, slot);
}
bool ErrorPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
return getStaticFunctionDescriptor<ErrorInstance>(exec, ExecState::errorPrototypeTable(exec), jsCast<ErrorPrototype*>(object), propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(ErrorPrototype)
// ------------------------------ Functions ---------------------------
......
......@@ -178,25 +178,7 @@ bool JSActivation::getOwnPropertySlot(JSObject* object, ExecState* exec, Propert
return false;
}
bool JSActivation::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSActivation* thisObject = jsCast<JSActivation*>(object);
if (propertyName == exec->propertyNames().arguments) {
// Defend against the inspector asking for the arguments object after it has been optimized out.
if (!thisObject->isTornOff()) {
PropertySlot slot(thisObject);
JSActivation::getOwnPropertySlot(thisObject, exec, propertyName, slot);
descriptor.setDescriptor(slot.getValue(exec, propertyName), DontEnum);
return true;
}
}
if (thisObject->symbolTableGet(propertyName, descriptor))
return true;
return Base::getOwnPropertyDescriptor(object, exec, propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSActivation)
void JSActivation::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
......
......@@ -189,16 +189,7 @@ bool JSArray::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName
return JSObject::getOwnPropertySlot(thisObject, exec, propertyName, slot);
}
bool JSArray::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSArray* thisObject = jsCast<JSArray*>(object);
if (propertyName == exec->propertyNames().length) {
descriptor.setDescriptor(jsNumber(thisObject->length()), thisObject->isLengthWritable() ? DontDelete | DontEnum : DontDelete | DontEnum | ReadOnly);
return true;
}
return JSObject::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSArray)
// ECMA 15.4.5.1
void JSArray::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
......
......@@ -78,20 +78,7 @@ bool JSArrayBuffer::getOwnPropertySlot(
return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
}
bool JSArrayBuffer::getOwnPropertyDescriptor(
JSObject* object, ExecState* exec, PropertyName propertyName,
PropertyDescriptor& descriptor)
{
JSArrayBuffer* thisObject = jsCast<JSArrayBuffer*>(object);
if (propertyName == exec->propertyNames().byteLength) {
descriptor.setDescriptor(
jsNumber(thisObject->impl()->byteLength()), DontDelete | ReadOnly);
return true;
}
return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSArrayBuffer)
void JSArrayBuffer::put(
JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value,
......
......@@ -139,25 +139,7 @@ bool JSArrayBufferView::getOwnPropertySlot(
return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
}
bool JSArrayBufferView::getOwnPropertyDescriptor(
JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSArrayBufferView* thisObject = jsCast<JSArrayBufferView*>(object);
if (propertyName == exec->propertyNames().byteOffset) {
descriptor.setDescriptor(jsNumber(thisObject->byteOffset()), DontDelete | ReadOnly);
return true;
}
if (propertyName == exec->propertyNames().buffer) {
descriptor.setDescriptor(
exec->vm().m_typedArrayController->toJS(
exec, thisObject->globalObject(), thisObject->buffer()),
DontDelete | ReadOnly);
return true;
}
return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSArrayBufferView)
void JSArrayBufferView::put(
JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value,
......
......@@ -218,11 +218,7 @@ bool JSCell::defineOwnProperty(JSObject*, ExecState*, PropertyName, PropertyDesc
return false;
}
bool JSCell::getOwnPropertyDescriptor(JSObject*, ExecState*, PropertyName, PropertyDescriptor&)
{
RELEASE_ASSERT_NOT_REACHED();
return false;
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSCell)
void JSCell::slowDownAndWasteMemory(JSArrayBufferView*)
{
......
......@@ -95,18 +95,7 @@ bool JSDataView::getOwnPropertySlot(
return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
}
bool JSDataView::getOwnPropertyDescriptor(
JSObject* object, ExecState* exec, PropertyName propertyName,
PropertyDescriptor& descriptor)
{
JSDataView* thisObject = jsCast<JSDataView*>(object);
if (propertyName == exec->propertyNames().byteLength) {
descriptor.setDescriptor(jsNumber(thisObject->m_length), DontEnum | ReadOnly);
return true;
}
return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSDataView)
void JSDataView::slowDownAndWasteMemory(JSArrayBufferView*)
{
......
......@@ -90,14 +90,7 @@ bool JSDataViewPrototype::getOwnPropertySlot(
propertyName, slot);
}
bool JSDataViewPrototype::getOwnPropertyDescriptor(
JSObject* object, ExecState* exec, PropertyName propertyName,
PropertyDescriptor& descriptor)
{
return getStaticFunctionDescriptor<JSObject>(
exec, ExecState::dataViewTable(exec), jsCast<JSDataViewPrototype*>(object),
propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSDataViewPrototype)
template<typename Adaptor>
EncodedJSValue getData(ExecState* exec)
......
......@@ -302,58 +302,7 @@ bool JSFunction::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyN
return Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
}
bool JSFunction::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
JSFunction* thisObject = jsCast<JSFunction*>(object);
if (thisObject->isHostFunction())
return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
if (propertyName == exec->propertyNames().prototype) {
PropertySlot slot(thisObject);
thisObject->methodTable()->getOwnPropertySlot(thisObject, exec, propertyName, slot);
return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
}
if (propertyName == exec->propertyNames().arguments) {
if (thisObject->jsExecutable()->isStrictMode()) {
bool result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
if (!result) {
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
ASSERT(result);
}
return result;
}
descriptor.setDescriptor(retrieveArguments(exec, thisObject), ReadOnly | DontEnum | DontDelete);
return true;
}
if (propertyName == exec->propertyNames().length) {
descriptor.setDescriptor(jsNumber(thisObject->jsExecutable()->parameterCount()), ReadOnly | DontEnum | DontDelete);
return true;
}
if (propertyName == exec->propertyNames().name) {
descriptor.setDescriptor(thisObject->jsExecutable()->nameValue(), ReadOnly | DontEnum | DontDelete);
return true;
}
if (propertyName == exec->propertyNames().caller) {
if (thisObject->jsExecutable()->isStrictMode()) {
bool result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
if (!result) {
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
result = Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
ASSERT(result);
}
return result;
}
descriptor.setDescriptor(retrieveCallerFunction(exec, thisObject), ReadOnly | DontEnum | DontDelete);
return true;
}
return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSFunction)
void JSFunction::getOwnNonIndexPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode)
{
......
......@@ -234,29 +234,7 @@ bool JSGenericTypedArrayView<Adaptor>::getOwnPropertySlot(
}
template<typename Adaptor>
bool JSGenericTypedArrayView<Adaptor>::getOwnPropertyDescriptor(
JSObject* object, ExecState* exec, PropertyName propertyName,
PropertyDescriptor& descriptor)
{
JSGenericTypedArrayView* thisObject = jsCast<JSGenericTypedArrayView*>(object);
if (propertyName == exec->propertyNames().length) {
descriptor.setDescriptor(jsNumber(thisObject->length()), DontDelete | ReadOnly);
return true;
}
if (propertyName == exec->propertyNames().byteLength) {
descriptor.setDescriptor(jsNumber(thisObject->byteLength()), DontDelete | ReadOnly);
return true;
}
unsigned index = propertyName.asIndex();
if (index != PropertyName::NotAnIndex && thisObject->canGetIndexQuickly(index)) {
descriptor.setDescriptor(thisObject->getIndexQuickly(index), DontDelete | ReadOnly);
return true;
}
return Base::getOwnPropertyDescriptor(thisObject, exec, propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSGenericTypedArrayView<Adaptor>)
template<typename Adaptor>
void JSGenericTypedArrayView<Adaptor>::put(
......
......@@ -58,11 +58,7 @@ bool JSNotAnObject::getOwnPropertySlotByIndex(JSObject*, ExecState* exec, unsign
return false;
}
bool JSNotAnObject::getOwnPropertyDescriptor(JSObject*, ExecState* exec, PropertyName, PropertyDescriptor&)
{
ASSERT_UNUSED(exec, exec->hadException());
return false;
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSNotAnObject)
void JSNotAnObject::put(JSCell*, ExecState* exec, PropertyName , JSValue, PutPropertySlot&)
{
......
......@@ -596,10 +596,7 @@ bool JSONObject::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyN
return getStaticFunctionSlot<JSObject>(exec, ExecState::jsonTable(exec), jsCast<JSONObject*>(object), propertyName, slot);
}
bool JSONObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
return getStaticFunctionDescriptor<JSObject>(exec, ExecState::jsonTable(exec), jsCast<JSONObject*>(object), propertyName, descriptor);
}
GET_OWN_PROPERTY_DESCRIPTOR_IMPL(JSONObject)
class Walker {
public:
......
......@@ -2381,74 +2381,7 @@ Butterfly* JSObject::growOutOfLineStorage(VM& vm, size_t oldSize, size_t newSize
return m_butterfly->growPropertyStorage(vm, this, structure(), oldSize, newSize);
}
bool JSObject::getOwnPropertyDescriptor(JSObject* object, ExecState* exec, PropertyName propertyName, PropertyDescriptor& descriptor)
{
unsigned attributes = 0;
JSCell* cell = 0;
PropertyOffset offset = object->structure()->get(exec->vm(), propertyName, attributes, cell);
if (isValidOffset(offset)) {
descriptor.setDescriptor(object->getDirect(offset), attributes);
return true;
}
unsigned i = propertyName.asIndex();
if (i == PropertyName::NotAnIndex)
return false;
switch (object->structure()->indexingType()) {
case ALL_BLANK_INDEXING_TYPES:
case ALL_UNDECIDED_INDEXING_TYPES:
return false;
case ALL_INT32_INDEXING_TYPES:
case ALL_CONTIGUOUS_INDEXING_TYPES: {
Butterfly* butterfly = object->m_butterfly;
if (i >= butterfly->vectorLength())
return false;
JSValue value = butterfly->contiguous()[i].get();
if (!value)
return false;
descriptor.setDescriptor(value, 0);
return true;
}
case ALL_DOUBLE_INDEXING_TYPES: {
Butterfly* butterfly = object->m_butterfly;
if (i >= butterfly->vectorLength())
return false;
double value = butterfly->contiguousDouble()[i];
if (value != value)
return false;
descriptor.setDescriptor(JSValue(JSValue::EncodeAsDouble, value), 0);
return true;
}
case ALL_ARRAY_STORAGE_INDEXING_TYPES: {
ArrayStorage* storage = object->m_butterfly->arrayStorage();
if (i >= storage->length())
return false;
if (i < storage->vectorLength()) {
WriteBarrier<Unknown>& value = storage->m_vector[i];
if (!value)
return false;
descriptor.setDescriptor(value.get(), 0);
return true;
}
if (SparseArrayValueMap* map = storage->m_sparseMap.get()) {
SparseArrayValueMap::iterator it = map->find(i);
if (it == map->notFound())
return false;
it->value.get(descriptor);
return true;
}
return false;
}
default:
RELEASE_ASSERT_NOT_REACHED();
return false;