Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (99674 => 99675)
--- trunk/Source/_javascript_Core/ChangeLog 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-11-09 10:18:04 UTC (rev 99675)
@@ -1,3 +1,30 @@
+2011-11-09 Mark Hahnenberg <[email protected]>
+
+ De-virtualize JSObject::defineOwnProperty
+ https://bugs.webkit.org/show_bug.cgi?id=71429
+
+ Reviewed by Geoffrey Garen.
+
+ Added defineOwnProperty to the MethodTable, changed all the virtual
+ implementations of defineOwnProperty to static ones, and replaced
+ all call sites with corresponding lookups in the MethodTable.
+
+ * _javascript_Core.exp:
+ * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
+ * runtime/Arguments.cpp:
+ (JSC::Arguments::createStrictModeCallerIfNecessary):
+ (JSC::Arguments::createStrictModeCalleeIfNecessary):
+ * runtime/ClassInfo.h:
+ * runtime/JSCell.cpp:
+ (JSC::JSCell::defineOwnProperty):
+ * runtime/JSCell.h:
+ * runtime/JSObject.cpp:
+ (JSC::JSObject::defineOwnProperty):
+ * runtime/JSObject.h:
+ * runtime/ObjectConstructor.cpp:
+ (JSC::objectConstructorDefineProperty):
+ (JSC::defineProperties):
+
2011-11-09 Simon Hausmann <[email protected]>
[Qt] Build system cleanup
Modified: trunk/Source/_javascript_Core/_javascript_Core.exp (99674 => 99675)
--- trunk/Source/_javascript_Core/_javascript_Core.exp 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/_javascript_Core/_javascript_Core.exp 2011-11-09 10:18:04 UTC (rev 99675)
@@ -314,7 +314,7 @@
__ZN3JSC8JSObject13visitChildrenEPNS_6JSCellERNS_11SlotVisitorE
__ZN3JSC8JSObject14deletePropertyEPNS_6JSCellEPNS_9ExecStateERKNS_10IdentifierE
__ZN3JSC8JSObject16getPropertyNamesEPS0_PNS_9ExecStateERNS_17PropertyNameArrayENS_15EnumerationModeE
-__ZN3JSC8JSObject17defineOwnPropertyEPNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorEb
+__ZN3JSC8JSObject17defineOwnPropertyEPS0_PNS_9ExecStateERKNS_10IdentifierERNS_18PropertyDescriptorEb
__ZN3JSC8JSObject17preventExtensionsERNS_12JSGlobalDataE
__ZN3JSC8JSObject17putWithAttributesEPNS_12JSGlobalDataERKNS_10IdentifierENS_7JSValueEj
__ZN3JSC8JSObject17putWithAttributesEPS0_PNS_9ExecStateERKNS_10IdentifierENS_7JSValueEj
Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (99674 => 99675)
--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def 2011-11-09 10:18:04 UTC (rev 99675)
@@ -134,9 +134,9 @@
?decrement@RefCountedLeakCounter@WTF@@QAEXXZ
?defaultAttributes@PropertyDescriptor@JSC@@0IA
?defaultValue@JSObject@JSC@@SA?AVJSValue@2@PBV12@PAVExecState@2@W4PreferredPrimitiveType@2@@Z
- ?defineOwnProperty@JSObject@JSC@@UAE_NPAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@_N@Z
?defineGetter@JSGlobalObject@JSC@@SAXPAVJSObject@2@PAVExecState@2@ABVIdentifier@2@0I@Z
?defineGetter@JSObject@JSC@@SAXPAV12@PAVExecState@2@ABVIdentifier@2@0I@Z
+ ?defineOwnProperty@JSObject@JSC@@SA_NPAV12@PAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@_N@Z
?defineSetter@JSGlobalObject@JSC@@SAXPAVJSObject@2@PAVExecState@2@ABVIdentifier@2@0I@Z
?defineSetter@JSObject@JSC@@SAXPAV12@PAVExecState@2@ABVIdentifier@2@0I@Z
?deleteOwnedPtr@WTF@@YAXPAUHBITMAP__@@@Z
Modified: trunk/Source/_javascript_Core/runtime/Arguments.cpp (99674 => 99675)
--- trunk/Source/_javascript_Core/runtime/Arguments.cpp 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/_javascript_Core/runtime/Arguments.cpp 2011-11-09 10:18:04 UTC (rev 99675)
@@ -168,7 +168,7 @@
PropertyDescriptor descriptor;
JSValue thrower = createTypeErrorFunction(exec, "Unable to access caller of strict mode function");
descriptor.setAccessorDescriptor(thrower, thrower, DontEnum | DontDelete | Getter | Setter);
- defineOwnProperty(exec, exec->propertyNames().caller, descriptor, false);
+ methodTable()->defineOwnProperty(this, exec, exec->propertyNames().caller, descriptor, false);
}
void Arguments::createStrictModeCalleeIfNecessary(ExecState* exec)
@@ -180,7 +180,7 @@
PropertyDescriptor descriptor;
JSValue thrower = createTypeErrorFunction(exec, "Unable to access callee of strict mode function");
descriptor.setAccessorDescriptor(thrower, thrower, DontEnum | DontDelete | Getter | Setter);
- defineOwnProperty(exec, exec->propertyNames().callee, descriptor, false);
+ methodTable()->defineOwnProperty(this, exec, exec->propertyNames().callee, descriptor, false);
}
bool Arguments::getOwnPropertySlot(JSCell* cell, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
Modified: trunk/Source/_javascript_Core/runtime/ClassInfo.h (99674 => 99675)
--- trunk/Source/_javascript_Core/runtime/ClassInfo.h 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/_javascript_Core/runtime/ClassInfo.h 2011-11-09 10:18:04 UTC (rev 99675)
@@ -86,6 +86,9 @@
typedef void (*PutWithAttributesFunctionPtr)(JSObject*, ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
PutWithAttributesFunctionPtr putWithAttributes;
+
+ typedef bool (*DefineOwnPropertyFunctionPtr)(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&, bool);
+ DefineOwnPropertyFunctionPtr defineOwnProperty;
};
#define CREATE_MEMBER_CHECKER(member) \
@@ -126,6 +129,7 @@
&ClassName::className, \
&ClassName::hasInstance, \
&ClassName::putWithAttributes, \
+ &ClassName::defineOwnProperty, \
}, \
sizeof(ClassName)
Modified: trunk/Source/_javascript_Core/runtime/JSCell.cpp (99674 => 99675)
--- trunk/Source/_javascript_Core/runtime/JSCell.cpp 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/_javascript_Core/runtime/JSCell.cpp 2011-11-09 10:18:04 UTC (rev 99675)
@@ -201,4 +201,10 @@
ASSERT_NOT_REACHED();
}
+bool JSCell::defineOwnProperty(JSObject*, ExecState*, const Identifier&, PropertyDescriptor&, bool)
+{
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/JSCell.h (99674 => 99675)
--- trunk/Source/_javascript_Core/runtime/JSCell.h 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/_javascript_Core/runtime/JSCell.h 2011-11-09 10:18:04 UTC (rev 99675)
@@ -37,6 +37,7 @@
class JSGlobalObject;
class Structure;
+ class PropertyDescriptor;
class PropertyNameArray;
enum EnumerationMode {
@@ -148,6 +149,7 @@
static UString className(const JSObject*);
static bool hasInstance(JSObject*, ExecState*, JSValue, JSValue prototypeProperty);
static NO_RETURN_DUE_TO_ASSERT void putWithAttributes(JSObject*, ExecState*, const Identifier& propertyName, JSValue, unsigned attributes);
+ static bool defineOwnProperty(JSObject*, ExecState*, const Identifier& propertyName, PropertyDescriptor&, bool shouldThrow);
private:
WriteBarrier<Structure> m_structure;
Modified: trunk/Source/_javascript_Core/runtime/JSObject.cpp (99674 => 99675)
--- trunk/Source/_javascript_Core/runtime/JSObject.cpp 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/_javascript_Core/runtime/JSObject.cpp 2011-11-09 10:18:04 UTC (rev 99675)
@@ -704,20 +704,20 @@
return !exec->hadException();
}
-bool JSObject::defineOwnProperty(ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException)
+bool JSObject::defineOwnProperty(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertyDescriptor& descriptor, bool throwException)
{
// If we have a new property we can just put it on normally
PropertyDescriptor current;
- if (!getOwnPropertyDescriptor(exec, propertyName, current)) {
+ if (!object->getOwnPropertyDescriptor(exec, propertyName, current)) {
// unless extensions are prevented!
- if (!isExtensible()) {
+ if (!object->isExtensible()) {
if (throwException)
throwError(exec, createTypeError(exec, "Attempting to define property on object that is not extensible."));
return false;
}
PropertyDescriptor oldDescriptor;
oldDescriptor.setValue(jsUndefined());
- return putDescriptor(exec, this, propertyName, descriptor, descriptor.attributes(), oldDescriptor);
+ return putDescriptor(exec, object, propertyName, descriptor, descriptor.attributes(), oldDescriptor);
}
if (descriptor.isEmpty())
@@ -743,8 +743,8 @@
// A generic descriptor is simply changing the attributes of an existing property
if (descriptor.isGenericDescriptor()) {
if (!current.attributesEqual(descriptor)) {
- methodTable()->deleteProperty(this, exec, propertyName);
- putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current);
+ object->methodTable()->deleteProperty(object, exec, propertyName);
+ putDescriptor(exec, object, propertyName, descriptor, current.attributesWithOverride(descriptor), current);
}
return true;
}
@@ -756,8 +756,8 @@
throwError(exec, createTypeError(exec, "Attempting to change access mechanism for an unconfigurable property."));
return false;
}
- methodTable()->deleteProperty(this, exec, propertyName);
- return putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current);
+ object->methodTable()->deleteProperty(object, exec, propertyName);
+ return putDescriptor(exec, object, propertyName, descriptor, current.attributesWithOverride(descriptor), current);
}
// Changing the value and attributes of an existing property
@@ -779,13 +779,13 @@
if (!descriptor.value())
return true;
PutPropertySlot slot;
- methodTable()->put(this, exec, propertyName, descriptor.value(), slot);
+ object->methodTable()->put(object, exec, propertyName, descriptor.value(), slot);
if (exec->hadException())
return false;
return true;
}
- methodTable()->deleteProperty(this, exec, propertyName);
- return putDescriptor(exec, this, propertyName, descriptor, current.attributesWithOverride(descriptor), current);
+ object->methodTable()->deleteProperty(object, exec, propertyName);
+ return putDescriptor(exec, object, propertyName, descriptor, current.attributesWithOverride(descriptor), current);
}
// Changing the accessor functions of an existing accessor property
@@ -802,7 +802,7 @@
return false;
}
}
- JSValue accessor = getDirect(exec->globalData(), propertyName);
+ JSValue accessor = object->getDirect(exec->globalData(), propertyName);
if (!accessor)
return false;
GetterSetter* getterSetter = asGetterSetter(accessor);
@@ -813,13 +813,13 @@
getterSetter->setGetter(exec->globalData(), asObject(descriptor.getter()));
return true;
}
- methodTable()->deleteProperty(this, exec, propertyName);
+ object->methodTable()->deleteProperty(object, exec, propertyName);
unsigned attrs = current.attributesWithOverride(descriptor);
if (descriptor.setter())
attrs |= Setter;
if (descriptor.getter())
attrs |= Getter;
- putDirect(exec->globalData(), propertyName, getterSetter, attrs);
+ object->putDirect(exec->globalData(), propertyName, getterSetter, attrs);
return true;
}
Modified: trunk/Source/_javascript_Core/runtime/JSObject.h (99674 => 99675)
--- trunk/Source/_javascript_Core/runtime/JSObject.h 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/_javascript_Core/runtime/JSObject.h 2011-11-09 10:18:04 UTC (rev 99675)
@@ -185,7 +185,7 @@
static void defineSetter(JSObject*, ExecState*, const Identifier& propertyName, JSObject* setterFunction, unsigned attributes = 0);
JSValue lookupGetter(ExecState*, const Identifier& propertyName);
JSValue lookupSetter(ExecState*, const Identifier& propertyName);
- virtual bool defineOwnProperty(ExecState*, const Identifier& propertyName, PropertyDescriptor&, bool shouldThrow);
+ static bool defineOwnProperty(JSObject*, ExecState*, const Identifier& propertyName, PropertyDescriptor&, bool shouldThrow);
bool isGlobalObject() const;
bool isVariableObject() const;
Modified: trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp (99674 => 99675)
--- trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/_javascript_Core/runtime/ObjectConstructor.cpp 2011-11-09 10:18:04 UTC (rev 99675)
@@ -299,7 +299,7 @@
return JSValue::encode(jsNull());
ASSERT((descriptor.attributes() & (Getter | Setter)) || (!descriptor.isAccessorDescriptor()));
ASSERT(!exec->hadException());
- O->defineOwnProperty(exec, Identifier(exec, propertyName), descriptor, true);
+ O->methodTable()->defineOwnProperty(O, exec, Identifier(exec, propertyName), descriptor, true);
return JSValue::encode(O);
}
@@ -330,7 +330,7 @@
}
}
for (size_t i = 0; i < numProperties; i++) {
- object->defineOwnProperty(exec, propertyNames[i], descriptors[i], true);
+ object->methodTable()->defineOwnProperty(object, exec, propertyNames[i], descriptors[i], true);
if (exec->hadException())
return jsNull();
}
Modified: trunk/Source/WebCore/ChangeLog (99674 => 99675)
--- trunk/Source/WebCore/ChangeLog 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/WebCore/ChangeLog 2011-11-09 10:18:04 UTC (rev 99675)
@@ -1,3 +1,24 @@
+2011-11-09 Mark Hahnenberg <[email protected]>
+
+ De-virtualize JSObject::defineOwnProperty
+ https://bugs.webkit.org/show_bug.cgi?id=71429
+
+ Reviewed by Geoffrey Garen.
+
+ No new tests.
+
+ Added defineOwnProperty to the MethodTable, changed all the virtual
+ implementations of defineOwnProperty to static ones, and replaced
+ all call sites with corresponding lookups in the MethodTable.
+
+ * bindings/js/JSDOMWindowCustom.cpp:
+ (WebCore::JSDOMWindow::defineOwnProperty):
+ * bindings/js/JSDOMWindowShell.cpp:
+ (WebCore::JSDOMWindowShell::defineOwnProperty):
+ * bindings/js/JSDOMWindowShell.h:
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (GenerateHeader):
+
2011-11-09 Kentaro Hara <[email protected]>
Make [CanBeConstructed] IDL redundant
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp (99674 => 99675)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowCustom.cpp 2011-11-09 10:18:04 UTC (rev 99675)
@@ -409,12 +409,13 @@
Base::defineSetter(thisObject, exec, propertyName, setterFunction, attributes);
}
-bool JSDOMWindow::defineOwnProperty(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertyDescriptor& descriptor, bool shouldThrow)
+bool JSDOMWindow::defineOwnProperty(JSC::JSObject* object, JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertyDescriptor& descriptor, bool shouldThrow)
{
+ JSDOMWindow* thisObject = static_cast<JSDOMWindow*>(object);
// Only allow defining properties in this way by frames in the same origin, as it allows setters to be introduced.
- if (!allowsAccessFrom(exec))
+ if (!thisObject->allowsAccessFrom(exec))
return false;
- return Base::defineOwnProperty(exec, propertyName, descriptor, shouldThrow);
+ return Base::defineOwnProperty(thisObject, exec, propertyName, descriptor, shouldThrow);
}
// Custom Attributes
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowShell.cpp (99674 => 99675)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowShell.cpp 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowShell.cpp 2011-11-09 10:18:04 UTC (rev 99675)
@@ -113,9 +113,10 @@
thisObject->window()->putWithAttributes(thisObject->window(), exec, propertyName, value, attributes);
}
-bool JSDOMWindowShell::defineOwnProperty(JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertyDescriptor& descriptor, bool shouldThrow)
+bool JSDOMWindowShell::defineOwnProperty(JSC::JSObject* object, JSC::ExecState* exec, const JSC::Identifier& propertyName, JSC::PropertyDescriptor& descriptor, bool shouldThrow)
{
- return window()->defineOwnProperty(exec, propertyName, descriptor, shouldThrow);
+ JSDOMWindowShell* thisObject = static_cast<JSDOMWindowShell*>(object);
+ return thisObject->window()->methodTable()->defineOwnProperty(thisObject->window(), exec, propertyName, descriptor, shouldThrow);
}
bool JSDOMWindowShell::deleteProperty(JSCell* cell, ExecState* exec, const Identifier& propertyName)
Modified: trunk/Source/WebCore/bindings/js/JSDOMWindowShell.h (99674 => 99675)
--- trunk/Source/WebCore/bindings/js/JSDOMWindowShell.h 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/WebCore/bindings/js/JSDOMWindowShell.h 2011-11-09 10:18:04 UTC (rev 99675)
@@ -88,7 +88,7 @@
static void getPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode);
static void defineGetter(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* getterFunction, unsigned attributes);
static void defineSetter(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::JSObject* setterFunction, unsigned attributes);
- virtual bool defineOwnProperty(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&, bool shouldThrow);
+ static bool defineOwnProperty(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&, bool shouldThrow);
RefPtr<DOMWrapperWorld> m_world;
};
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (99674 => 99675)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2011-11-09 10:11:53 UTC (rev 99674)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2011-11-09 10:18:04 UTC (rev 99675)
@@ -833,7 +833,7 @@
}
# Custom defineProperty function exists on DOMWindow
- push(@headerContent, " virtual bool defineOwnProperty(JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&, bool shouldThrow);\n") if $interfaceName eq "DOMWindow";
+ push(@headerContent, " static bool defineOwnProperty(JSC::JSObject*, JSC::ExecState*, const JSC::Identifier& propertyName, JSC::PropertyDescriptor&, bool shouldThrow);\n") if $interfaceName eq "DOMWindow";
# Custom getOwnPropertyNames function
if ($dataNode->extendedAttributes->{"CustomGetPropertyNames"} || $dataNode->extendedAttributes->{"HasIndexGetter"} || $dataNode->extendedAttributes->{"HasCustomIndexGetter"} || $dataNode->extendedAttributes->{"HasNumericIndexGetter"}) {