Commit 79c8e6e4 authored by mhahnenberg@apple.com's avatar mhahnenberg@apple.com
Browse files

Add static version of JSCell::getConstructData

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

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

Added static version of getConstructData to all classes that
override it and changed the virtual versions to call the static
versions.  This is the first step in de-virtualizing JSCell::getConstructData.

* API/JSCallbackConstructor.cpp:
(JSC::JSCallbackConstructor::getConstructData):
* API/JSCallbackConstructor.h:
* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
(JSC::::getConstructData):
* runtime/ArrayConstructor.cpp:
(JSC::ArrayConstructor::getConstructData):
* runtime/ArrayConstructor.h:
* runtime/BooleanConstructor.cpp:
(JSC::BooleanConstructor::getConstructData):
* runtime/BooleanConstructor.h:
* runtime/DateConstructor.cpp:
(JSC::DateConstructor::getConstructData):
* runtime/DateConstructor.h:
* runtime/ErrorConstructor.cpp:
(JSC::ErrorConstructor::getConstructData):
* runtime/ErrorConstructor.h:
* runtime/FunctionConstructor.cpp:
(JSC::FunctionConstructor::getConstructData):
* runtime/FunctionConstructor.h:
* runtime/JSCell.cpp:
(JSC::JSCell::getConstructData):
* runtime/JSCell.h:
* runtime/JSFunction.cpp:
(JSC::JSFunction::getConstructData):
* runtime/JSFunction.h:
* runtime/NativeErrorConstructor.cpp:
(JSC::NativeErrorConstructor::getConstructData):
* runtime/NativeErrorConstructor.h:
* runtime/NumberConstructor.cpp:
(JSC::NumberConstructor::getConstructData):
* runtime/NumberConstructor.h:
* runtime/ObjectConstructor.cpp:
(JSC::ObjectConstructor::getConstructData):
* runtime/ObjectConstructor.h:
* runtime/RegExpConstructor.cpp:
(JSC::RegExpConstructor::getConstructData):
* runtime/RegExpConstructor.h:
* runtime/StringConstructor.cpp:
(JSC::StringConstructor::getConstructData):
* runtime/StringConstructor.h:

Source/WebCore:

No new tests.

Added static version of getConstructData to all classes that
override it and changed the virtual versions to call the static
versions.  This is the first step in de-virtualizing JSCell::getConstructData.

* bindings/js/JSAudioConstructor.cpp:
(WebCore::JSAudioConstructor::getConstructData):
* bindings/js/JSAudioConstructor.h:
* bindings/js/JSImageConstructor.cpp:
(WebCore::JSImageConstructor::getConstructData):
* bindings/js/JSImageConstructor.h:
* bindings/js/JSOptionConstructor.cpp:
(WebCore::JSOptionConstructor::getConstructData):
* bindings/js/JSOptionConstructor.h:
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateConstructorDeclaration):
(GenerateConstructorDefinition):
* bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore::JSTestInterfaceConstructor::getConstructData):
* bridge/runtime_object.cpp:
(JSC::Bindings::RuntimeObject::getConstructData):
* bridge/runtime_object.h:

Source/WebKit2:

Added static version of getConstructData to all classes that
override it and changed the virtual versions to call the static
versions.  This is the first step in de-virtualizing JSCell::getConstructData.

* WebProcess/Plugins/Netscape/JSNPObject.cpp:
(WebKit::JSNPObject::getConstructData):
* WebProcess/Plugins/Netscape/JSNPObject.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@97016 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1986964e
......@@ -87,6 +87,11 @@ static EncodedJSValue JSC_HOST_CALL constructJSCallback(ExecState* exec)
}
ConstructType JSCallbackConstructor::getConstructData(ConstructData& constructData)
{
return getConstructData(this, constructData);
}
ConstructType JSCallbackConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = constructJSCallback;
return ConstructTypeHost;
......
......@@ -59,6 +59,7 @@ protected:
private:
virtual ConstructType getConstructData(ConstructData&);
static ConstructType getConstructData(JSCell*, ConstructData&);
JSClassRef m_class;
JSObjectCallAsConstructorCallback m_callback;
......
......@@ -197,6 +197,7 @@ private:
virtual UString toString(ExecState*) const;
virtual ConstructType getConstructData(ConstructData&);
static ConstructType getConstructData(JSCell*, ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
......
......@@ -330,7 +330,14 @@ bool JSCallbackObject<Parent>::deleteProperty(JSCell* cell, ExecState* exec, uns
template <class Parent>
ConstructType JSCallbackObject<Parent>::getConstructData(ConstructData& constructData)
{
for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) {
return getConstructData(this, constructData);
}
template <class Parent>
ConstructType JSCallbackObject<Parent>::getConstructData(JSCell* cell, ConstructData& constructData)
{
JSCallbackObject* thisObject = static_cast<JSCallbackObject*>(cell);
for (JSClassRef jsClass = thisObject->classRef(); jsClass; jsClass = jsClass->parentClass) {
if (jsClass->callAsConstructor) {
constructData.native.function = construct;
return ConstructTypeHost;
......
2011-10-08 Mark Hahnenberg <mhahnenberg@apple.com>
Add static version of JSCell::getConstructData
https://bugs.webkit.org/show_bug.cgi?id=69673
Reviewed by Geoffrey Garen.
Added static version of getConstructData to all classes that
override it and changed the virtual versions to call the static
versions. This is the first step in de-virtualizing JSCell::getConstructData.
* API/JSCallbackConstructor.cpp:
(JSC::JSCallbackConstructor::getConstructData):
* API/JSCallbackConstructor.h:
* API/JSCallbackObject.h:
* API/JSCallbackObjectFunctions.h:
(JSC::::getConstructData):
* runtime/ArrayConstructor.cpp:
(JSC::ArrayConstructor::getConstructData):
* runtime/ArrayConstructor.h:
* runtime/BooleanConstructor.cpp:
(JSC::BooleanConstructor::getConstructData):
* runtime/BooleanConstructor.h:
* runtime/DateConstructor.cpp:
(JSC::DateConstructor::getConstructData):
* runtime/DateConstructor.h:
* runtime/ErrorConstructor.cpp:
(JSC::ErrorConstructor::getConstructData):
* runtime/ErrorConstructor.h:
* runtime/FunctionConstructor.cpp:
(JSC::FunctionConstructor::getConstructData):
* runtime/FunctionConstructor.h:
* runtime/JSCell.cpp:
(JSC::JSCell::getConstructData):
* runtime/JSCell.h:
* runtime/JSFunction.cpp:
(JSC::JSFunction::getConstructData):
* runtime/JSFunction.h:
* runtime/NativeErrorConstructor.cpp:
(JSC::NativeErrorConstructor::getConstructData):
* runtime/NativeErrorConstructor.h:
* runtime/NumberConstructor.cpp:
(JSC::NumberConstructor::getConstructData):
* runtime/NumberConstructor.h:
* runtime/ObjectConstructor.cpp:
(JSC::ObjectConstructor::getConstructData):
* runtime/ObjectConstructor.h:
* runtime/RegExpConstructor.cpp:
(JSC::RegExpConstructor::getConstructData):
* runtime/RegExpConstructor.h:
* runtime/StringConstructor.cpp:
(JSC::StringConstructor::getConstructData):
* runtime/StringConstructor.h:
2011-10-08 Mark Hahnenberg <mhahnenberg@apple.com>
 
Add static version of JSCell::getOwnPropertySlot
......@@ -98,6 +98,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithArrayConstructor(ExecState* exe
}
ConstructType ArrayConstructor::getConstructData(ConstructData& constructData)
{
return getConstructData(this, constructData);
}
ConstructType ArrayConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = constructWithArrayConstructor;
return ConstructTypeHost;
......
......@@ -57,6 +57,7 @@ namespace JSC {
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
virtual ConstructType getConstructData(ConstructData&);
static ConstructType getConstructData(JSCell*, ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
};
......
......@@ -59,6 +59,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithBooleanConstructor(ExecState* e
}
ConstructType BooleanConstructor::getConstructData(ConstructData& constructData)
{
return getConstructData(this, constructData);
}
ConstructType BooleanConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = constructWithBooleanConstructor;
return ConstructTypeHost;
......
......@@ -51,6 +51,7 @@ namespace JSC {
private:
BooleanConstructor(JSGlobalObject*, Structure*);
virtual ConstructType getConstructData(ConstructData&);
static ConstructType getConstructData(JSCell*, ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
};
......
......@@ -162,6 +162,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithDateConstructor(ExecState* exec
}
ConstructType DateConstructor::getConstructData(ConstructData& constructData)
{
return getConstructData(this, constructData);
}
ConstructType DateConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = constructWithDateConstructor;
return ConstructTypeHost;
......
......@@ -52,6 +52,7 @@ namespace JSC {
private:
DateConstructor(JSGlobalObject*, Structure*);
virtual ConstructType getConstructData(ConstructData&);
static ConstructType getConstructData(JSCell*, ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
......
......@@ -54,6 +54,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithErrorConstructor(ExecState* exe
}
ConstructType ErrorConstructor::getConstructData(ConstructData& constructData)
{
return getConstructData(this, constructData);
}
ConstructType ErrorConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = constructWithErrorConstructor;
return ConstructTypeHost;
......
......@@ -52,6 +52,7 @@ namespace JSC {
private:
ErrorConstructor(JSGlobalObject*, Structure*);
virtual ConstructType getConstructData(ConstructData&);
static ConstructType getConstructData(JSCell*, ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
};
......
......@@ -60,6 +60,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithFunctionConstructor(ExecState*
}
ConstructType FunctionConstructor::getConstructData(ConstructData& constructData)
{
return getConstructData(this, constructData);
}
ConstructType FunctionConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = constructWithFunctionConstructor;
return ConstructTypeHost;
......
......@@ -49,6 +49,7 @@ namespace JSC {
FunctionConstructor(JSGlobalObject*, Structure*);
void finishCreation(ExecState*, FunctionPrototype*);
virtual ConstructType getConstructData(ConstructData&);
static ConstructType getConstructData(JSCell*, ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
};
......
......@@ -69,6 +69,11 @@ ConstructType JSCell::getConstructData(ConstructData&)
return ConstructTypeNone;
}
ConstructType JSCell::getConstructData(JSCell*, ConstructData&)
{
return ConstructTypeNone;
}
bool JSCell::getOwnPropertySlot(ExecState* exec, const Identifier& identifier, PropertySlot& slot)
{
return getOwnPropertySlot(this, exec, identifier, slot);
......
......@@ -76,6 +76,7 @@ namespace JSC {
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
virtual ConstructType getConstructData(ConstructData&);
static ConstructType getConstructData(JSCell*, ConstructData&);
// Basic conversions.
JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;
......
......@@ -353,15 +353,21 @@ bool JSFunction::deleteProperty(JSCell* cell, ExecState* exec, const Identifier&
return Base::deleteProperty(thisObject, exec, propertyName);
}
// ECMA 13.2.2 [[Construct]]
ConstructType JSFunction::getConstructData(ConstructData& constructData)
{
if (isHostFunction()) {
constructData.native.function = nativeConstructor();
return getConstructData(this, constructData);
}
// ECMA 13.2.2 [[Construct]]
ConstructType JSFunction::getConstructData(JSCell* cell, ConstructData& constructData)
{
JSFunction* thisObject = static_cast<JSFunction*>(cell);
if (thisObject->isHostFunction()) {
constructData.native.function = thisObject->nativeConstructor();
return ConstructTypeHost;
}
constructData.js.functionExecutable = jsExecutable();
constructData.js.scopeChain = scope();
constructData.js.functionExecutable = thisObject->jsExecutable();
constructData.js.scopeChain = thisObject->scope();
return ConstructTypeJS;
}
......
......@@ -109,6 +109,7 @@ namespace JSC {
NativeFunction nativeConstructor();
virtual ConstructType getConstructData(ConstructData&);
static ConstructType getConstructData(JSCell*, ConstructData&);
virtual CallType getCallDataVirtual(CallData&);
static CallType getCallData(JSCell*, CallData&);
......
......@@ -57,6 +57,11 @@ static EncodedJSValue JSC_HOST_CALL constructWithNativeErrorConstructor(ExecStat
}
ConstructType NativeErrorConstructor::getConstructData(ConstructData& constructData)
{
return getConstructData(this, constructData);
}
ConstructType NativeErrorConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = constructWithNativeErrorConstructor;
return ConstructTypeHost;
......
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