Refactor JS objects to allocate in static create methods rather than constructors

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

Patch by Mark Hahnenberg <mhahnenberg@apple.com> on 2011-08-15
Reviewed by Geoffrey Garen.

Source/JavaScriptGlue:

Removed all calls to deprecatedGetDOMObject from initialization lists as part of a
larger refactoring to get rid of all allocation during initialization.

* JSRun.cpp:
(JSGlueGlobalObject::JSGlueGlobalObject):
* JSRun.h:
(JSGlueGlobalObject::create):

Source/WebCore:

No new tests.

Removed all calls to deprecatedGetDOMObject from initialization lists as part of a
larger refactoring to get rid of all allocation during initialization.

* bindings/js/JSDOMBinding.h:
* bridge/c/CRuntimeObject.cpp:
(JSC::Bindings::CRuntimeObject::CRuntimeObject):
* bridge/c/CRuntimeObject.h:
(JSC::Bindings::CRuntimeObject::create):
* bridge/c/c_instance.cpp:
(JSC::Bindings::CRuntimeMethod::create):
(JSC::Bindings::CRuntimeMethod::CRuntimeMethod):
* bridge/jni/jsc/JavaInstanceJSC.cpp:
(JavaRuntimeMethod::create):
(JavaRuntimeMethod::JavaRuntimeMethod):
* bridge/jni/jsc/JavaRuntimeObject.cpp:
(JSC::Bindings::JavaRuntimeObject::JavaRuntimeObject):
* bridge/jni/jsc/JavaRuntimeObject.h:
(JSC::Bindings::JavaRuntimeObject::create):
* bridge/objc/objc_runtime.h:
(JSC::Bindings::ObjcFallbackObjectImp::create):
* bridge/objc/objc_runtime.mm:
(JSC::Bindings::ObjcFallbackObjectImp::ObjcFallbackObjectImp):
* bridge/qt/qt_instance.cpp:
(JSC::Bindings::QtRuntimeObject::create):
(JSC::Bindings::QtRuntimeObject::QtRuntimeObject):
* bridge/qt/qt_pixmapruntime.cpp:
(JSC::Bindings::QtPixmapRuntimeObject::create):
(JSC::Bindings::QtPixmapRuntimeObject::QtPixmapRuntimeObject):
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::QtRuntimeMethod::QtRuntimeMethod):
(JSC::Bindings::QtRuntimeMetaMethod::QtRuntimeMetaMethod):
(JSC::Bindings::QtRuntimeConnectionMethod::QtRuntimeConnectionMethod):
* bridge/qt/qt_runtime.h:
(JSC::Bindings::QtRuntimeMetaMethod::create):
(JSC::Bindings::QtRuntimeConnectionMethod::create):
* bridge/runtime_array.cpp:
(JSC::RuntimeArray::RuntimeArray):
* bridge/runtime_array.h:
(JSC::RuntimeArray::create):
* bridge/runtime_object.cpp:

Source/WebKit/mac:

Removed all calls to deprecatedGetDOMObject from initialization lists as part of a
larger refactoring to get rid of all allocation during initialization.

* Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyRuntimeMethod::create):
(WebKit::ProxyRuntimeMethod::ProxyRuntimeMethod):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@93059 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ee6f6180
2011-08-15 Mark Hahnenberg <mhahnenberg@apple.com>
Refactor JS objects to allocate in static create methods rather than constructors
https://bugs.webkit.org/show_bug.cgi?id=65347
Reviewed by Geoffrey Garen.
Removed all calls to deprecatedGetDOMObject from initialization lists as part of a
larger refactoring to get rid of all allocation during initialization.
* JSRun.cpp:
(JSGlueGlobalObject::JSGlueGlobalObject):
* JSRun.h:
(JSGlueGlobalObject::create):
2011-08-12 Mark Rowe <mrowe@apple.com>
Be more forward-looking in the choice of compiler.
......
......@@ -33,10 +33,10 @@
#include <JavaScriptCore/Completion.h>
#include <JavaScriptCore/SourceCode.h>
JSGlueGlobalObject::JSGlueGlobalObject(JSGlobalData& globalData, Structure* structure, JSFlags flags)
JSGlueGlobalObject::JSGlueGlobalObject(JSGlobalData& globalData, Structure* structure, Structure* userObjectStructure, JSFlags flags)
: JSGlobalObject(globalData, structure)
, m_flags(flags)
, m_userObjectStructure(globalData, UserObjectImp::createStructure(globalData, jsNull()))
, m_userObjectStructure(globalData, userObjectStructure)
{
}
......
......@@ -32,6 +32,7 @@
#include <JavaScriptCore/Strong.h>
#include "JSBase.h"
#include "JSUtils.h"
#include "UserObjectImp.h"
class JSGlueGlobalObject : public JSGlobalObject {
public:
......@@ -39,14 +40,15 @@ class JSGlueGlobalObject : public JSGlobalObject {
static JSGlueGlobalObject* create(JSGlobalData& globalData, Structure* structure, JSFlags flags = kJSFlagNone)
{
return new (allocateCell<JSGlueGlobalObject>(globalData.heap)) JSGlueGlobalObject(globalData, structure, flags);
Structure* userObjectStructure = UserObjectImp::createStructure(globalData, jsNull());
return new (allocateCell<JSGlueGlobalObject>(globalData.heap)) JSGlueGlobalObject(globalData, structure, userObjectStructure, flags);
}
JSFlags Flags() const { return m_flags; }
Structure* userObjectStructure() const { return m_userObjectStructure.get(); }
private:
JSGlueGlobalObject(JSGlobalData&, Structure*, JSFlags = kJSFlagNone);
JSGlueGlobalObject(JSGlobalData&, Structure*, Structure*, JSFlags = kJSFlagNone);
JSFlags m_flags;
Strong<Structure> m_userObjectStructure;
......
2011-08-15 Mark Hahnenberg <mhahnenberg@apple.com>
Refactor JS objects to allocate in static create methods rather than constructors
https://bugs.webkit.org/show_bug.cgi?id=65347
Reviewed by Geoffrey Garen.
No new tests.
Removed all calls to deprecatedGetDOMObject from initialization lists as part of a
larger refactoring to get rid of all allocation during initialization.
* bindings/js/JSDOMBinding.h:
* bridge/c/CRuntimeObject.cpp:
(JSC::Bindings::CRuntimeObject::CRuntimeObject):
* bridge/c/CRuntimeObject.h:
(JSC::Bindings::CRuntimeObject::create):
* bridge/c/c_instance.cpp:
(JSC::Bindings::CRuntimeMethod::create):
(JSC::Bindings::CRuntimeMethod::CRuntimeMethod):
* bridge/jni/jsc/JavaInstanceJSC.cpp:
(JavaRuntimeMethod::create):
(JavaRuntimeMethod::JavaRuntimeMethod):
* bridge/jni/jsc/JavaRuntimeObject.cpp:
(JSC::Bindings::JavaRuntimeObject::JavaRuntimeObject):
* bridge/jni/jsc/JavaRuntimeObject.h:
(JSC::Bindings::JavaRuntimeObject::create):
* bridge/objc/objc_runtime.h:
(JSC::Bindings::ObjcFallbackObjectImp::create):
* bridge/objc/objc_runtime.mm:
(JSC::Bindings::ObjcFallbackObjectImp::ObjcFallbackObjectImp):
* bridge/qt/qt_instance.cpp:
(JSC::Bindings::QtRuntimeObject::create):
(JSC::Bindings::QtRuntimeObject::QtRuntimeObject):
* bridge/qt/qt_pixmapruntime.cpp:
(JSC::Bindings::QtPixmapRuntimeObject::create):
(JSC::Bindings::QtPixmapRuntimeObject::QtPixmapRuntimeObject):
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::QtRuntimeMethod::QtRuntimeMethod):
(JSC::Bindings::QtRuntimeMetaMethod::QtRuntimeMetaMethod):
(JSC::Bindings::QtRuntimeConnectionMethod::QtRuntimeConnectionMethod):
* bridge/qt/qt_runtime.h:
(JSC::Bindings::QtRuntimeMetaMethod::create):
(JSC::Bindings::QtRuntimeConnectionMethod::create):
* bridge/runtime_array.cpp:
(JSC::RuntimeArray::RuntimeArray):
* bridge/runtime_array.h:
(JSC::RuntimeArray::create):
* bridge/runtime_object.cpp:
2011-08-15 Adam Roben <aroben@apple.com>
Update pages' style and content scale when the window's backing scale factor changes
......@@ -29,7 +29,9 @@
#include "Element.h"
#include "StyleBase.h"
#include <heap/Weak.h>
#include <runtime/FunctionPrototype.h>
#include <runtime/Lookup.h>
#include <runtime/ObjectPrototype.h>
#include <wtf/Forward.h>
#include <wtf/Noncopyable.h>
......
......@@ -37,10 +37,8 @@ namespace Bindings {
const ClassInfo CRuntimeObject::s_info = { "CRuntimeObject", &RuntimeObject::s_info, 0, 0 };
CRuntimeObject::CRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<CInstance> instance)
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
// We need to pass in the right global object for "i".
: RuntimeObject(exec, globalObject, WebCore::deprecatedGetDOMStructure<CRuntimeObject>(exec), instance)
CRuntimeObject::CRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, PassRefPtr<CInstance> instance)
: RuntimeObject(exec, globalObject, structure, instance)
{
ASSERT(inherits(&s_info));
}
......
......@@ -28,6 +28,7 @@
#if ENABLE(NETSCAPE_PLUGIN_API)
#include "JSDOMBinding.h"
#include "runtime_object.h"
namespace JSC {
......@@ -41,7 +42,10 @@ public:
static CRuntimeObject* create(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<CInstance> instance)
{
return new (allocateCell<CRuntimeObject>(*exec->heap())) CRuntimeObject(exec, globalObject, instance);
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
// We need to pass in the right global object for "i".
Structure* domStructure = WebCore::deprecatedGetDOMStructure<CRuntimeObject>(exec);
return new (allocateCell<CRuntimeObject>(*exec->heap())) CRuntimeObject(exec, globalObject, domStructure, instance);
}
virtual ~CRuntimeObject();
......@@ -56,7 +60,7 @@ public:
}
private:
CRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<CInstance>);
CRuntimeObject(ExecState*, JSGlobalObject*, Structure*, PassRefPtr<CInstance>);
};
}
......
......@@ -115,7 +115,10 @@ public:
static CRuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
{
return new (allocateCell<CRuntimeMethod>(*exec->heap())) CRuntimeMethod(exec, globalObject, name, list);
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
// We need to pass in the right global object for "i".
Structure* domStructure = WebCore::deprecatedGetDOMStructure<CRuntimeMethod>(exec);
return new (allocateCell<CRuntimeMethod>(*exec->heap())) CRuntimeMethod(exec, globalObject, domStructure, name, list);
}
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
......@@ -126,10 +129,8 @@ public:
static const ClassInfo s_info;
private:
CRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
// We need to pass in the right global object for "i".
: RuntimeMethod(exec, globalObject, WebCore::deprecatedGetDOMStructure<CRuntimeMethod>(exec), name, list)
CRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, const Identifier& name, Bindings::MethodList& list)
: RuntimeMethod(exec, globalObject, structure, name, list)
{
ASSERT(inherits(&s_info));
}
......
......@@ -120,7 +120,10 @@ public:
static JavaRuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
{
return new (allocateCell<JavaRuntimeMethod>(*exec->heap())) JavaRuntimeMethod(exec, globalObject, name, list);
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
// We need to pass in the right global object for "i".
Structure* domStructure = WebCore::deprecatedGetDOMStructure<JavaRuntimeMethod>(exec);
return new (allocateCell<JavaRuntimeMethod>(*exec->heap())) JavaRuntimeMethod(exec, globalObject, domStructure, name, list);
}
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
......@@ -131,10 +134,8 @@ public:
static const ClassInfo s_info;
private:
JavaRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
// We need to pass in the right global object for "i".
: RuntimeMethod(exec, globalObject, WebCore::deprecatedGetDOMStructure<JavaRuntimeMethod>(exec), name, list)
JavaRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, const Identifier& name, Bindings::MethodList& list)
: RuntimeMethod(exec, globalObject, structure, name, list)
{
ASSERT(inherits(&s_info));
}
......
......@@ -35,10 +35,8 @@ namespace Bindings {
const ClassInfo JavaRuntimeObject::s_info = { "JavaRuntimeObject", &RuntimeObject::s_info, 0, 0 };
JavaRuntimeObject::JavaRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<JavaInstance> instance)
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
// We need to pass in the right global object for "i".
: RuntimeObject(exec, globalObject, WebCore::deprecatedGetDOMStructure<JavaRuntimeObject>(exec), instance)
JavaRuntimeObject::JavaRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, PassRefPtr<JavaInstance> instance)
: RuntimeObject(exec, globalObject, structure, instance)
{
ASSERT(inherits(&s_info));
}
......
......@@ -26,6 +26,7 @@
#ifndef JavaRuntimeObject_h
#define JavaRuntimeObject_h
#include "JSDOMBinding.h"
#include "runtime_object.h"
namespace JSC {
......@@ -39,7 +40,10 @@ public:
static JavaRuntimeObject* create(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<JavaInstance> javaInst)
{
return new (allocateCell<JavaRuntimeObject>(*exec->heap())) JavaRuntimeObject(exec, globalObject, javaInst);
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
// We need to pass in the right global object for "i".
Structure* domStructure = WebCore::deprecatedGetDOMStructure<JavaRuntimeObject>(exec);
return new (allocateCell<JavaRuntimeObject>(*exec->heap())) JavaRuntimeObject(exec, globalObject, domStructure, javaInst);
}
virtual ~JavaRuntimeObject();
......@@ -54,7 +58,7 @@ public:
}
private:
JavaRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<JavaInstance>);
JavaRuntimeObject(ExecState*, JSGlobalObject*, Structure*, PassRefPtr<JavaInstance>);
};
}
......
......@@ -27,6 +27,7 @@
#define KJS_BINDINGS_OBJC_RUNTIME_H
#include "BridgeJSC.h"
#include "JSDOMBinding.h"
#include "objc_header.h"
#include <runtime/JSGlobalObject.h>
#include <runtime/JSObjectWithGlobalObject.h>
......@@ -96,7 +97,9 @@ public:
static ObjcFallbackObjectImp* create(ExecState* exec, JSGlobalObject* globalObject, ObjcInstance* instance, const Identifier& propertyName)
{
return new (allocateCell<ObjcFallbackObjectImp>(*exec->heap())) ObjcFallbackObjectImp(exec, globalObject, instance, propertyName);
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
Structure* domStructure = WebCore::deprecatedGetDOMStructure<ObjcFallbackObjectImp>(exec);
return new (allocateCell<ObjcFallbackObjectImp>(*exec->heap())) ObjcFallbackObjectImp(globalObject, domStructure, instance, propertyName);
}
static const ClassInfo s_info;
......@@ -114,7 +117,7 @@ public:
}
private:
ObjcFallbackObjectImp(ExecState*, JSGlobalObject*, ObjcInstance*, const Identifier& propertyName);
ObjcFallbackObjectImp(JSGlobalObject*, Structure*, ObjcInstance*, const Identifier& propertyName);
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | JSObject::StructureFlags;
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
......
......@@ -35,7 +35,6 @@
#include <runtime/Error.h>
#include <runtime/JSGlobalObject.h>
#include <runtime/JSLock.h>
#include <runtime/ObjectPrototype.h>
#include <wtf/RetainPtr.h>
using namespace WebCore;
......@@ -197,9 +196,8 @@ unsigned int ObjcArray::getLength() const
const ClassInfo ObjcFallbackObjectImp::s_info = { "ObjcFallbackObject", &JSObjectWithGlobalObject::s_info, 0, 0 };
ObjcFallbackObjectImp::ObjcFallbackObjectImp(ExecState* exec, JSGlobalObject* globalObject, ObjcInstance* i, const Identifier& propertyName)
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
: JSObjectWithGlobalObject(globalObject, deprecatedGetDOMStructure<ObjcFallbackObjectImp>(exec))
ObjcFallbackObjectImp::ObjcFallbackObjectImp(JSGlobalObject* globalObject, Structure* structure, ObjcInstance* i, const Identifier& propertyName)
: JSObjectWithGlobalObject(globalObject, structure)
, _instance(i)
, _item(propertyName)
{
......
......@@ -54,7 +54,8 @@ public:
static QtRuntimeObject* create(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<Instance> instance)
{
return new (allocateCell<QtRuntimeObject>(*exec->heap())) QtRuntimeObject(exec, globalObject, instance);
Structure* domStructure = WebCore::deprecatedGetDOMStructure<QtRuntimeObject>(exec);
return new (allocateCell<QtRuntimeObject>(*exec->heap())) QtRuntimeObject(exec, globalObject, domStructure, instance);
}
static const ClassInfo s_info;
......@@ -76,13 +77,13 @@ protected:
static const unsigned StructureFlags = RuntimeObject::StructureFlags | OverridesVisitChildren;
private:
QtRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<Instance>);
QtRuntimeObject(ExecState*, JSGlobalObject*, Structure*, PassRefPtr<Instance>);
};
const ClassInfo QtRuntimeObject::s_info = { "QtRuntimeObject", &RuntimeObject::s_info, 0, 0 };
QtRuntimeObject::QtRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<Instance> instance)
: RuntimeObject(exec, globalObject, WebCore::deprecatedGetDOMStructure<QtRuntimeObject>(exec), instance)
QtRuntimeObject::QtRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, PassRefPtr<Instance> instance)
: RuntimeObject(exec, globalObject, structure, instance)
{
}
......
......@@ -23,6 +23,7 @@
#include "HTMLImageElement.h"
#include "ImageData.h"
#include "IntSize.h"
#include "JSDOMBinding.h"
#include "JSGlobalObject.h"
#include "JSHTMLImageElement.h"
#include "JSImageData.h"
......@@ -202,7 +203,8 @@ public:
static QtPixmapRuntimeObject* create(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<Instance> instance)
{
return new (allocateCell<QtPixmapRuntimeObject>(*exec->heap())) QtPixmapRuntimeObject(exec, globalObject, instance);
Structure* domStructure = WebCore::deprecatedGetDOMStructure<QtPixmapRuntimeObject>(exec);
return new (allocateCell<QtPixmapRuntimeObject>(*exec->heap())) QtPixmapRuntimeObject(exec, globalObject, domStructure, instance);
}
static const ClassInfo s_info;
......@@ -216,11 +218,11 @@ protected:
static const unsigned StructureFlags = RuntimeObject::StructureFlags | OverridesVisitChildren;
private:
QtPixmapRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<Instance>);
QtPixmapRuntimeObject(ExecState*, JSGlobalObject*, Structure*, PassRefPtr<Instance>);
};
QtPixmapRuntimeObject::QtPixmapRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<Instance> instance)
: RuntimeObject(exec, globalObject, WebCore::deprecatedGetDOMStructure<QtPixmapRuntimeObject>(exec), instance)
QtPixmapRuntimeObject::QtPixmapRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, PassRefPtr<Instance> instance)
: RuntimeObject(exec, globalObject, structure, instance)
{
}
......
......@@ -1006,8 +1006,8 @@ JSValue convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, con
const ClassInfo QtRuntimeMethod::s_info = { "QtRuntimeMethod", &InternalFunction::s_info, 0, 0 };
QtRuntimeMethod::QtRuntimeMethod(QtRuntimeMethodData* dd, ExecState* exec, const Identifier& ident, PassRefPtr<QtInstance> inst)
: InternalFunction(&exec->globalData(), exec->lexicalGlobalObject(), deprecatedGetDOMStructure<QtRuntimeMethod>(exec), ident)
QtRuntimeMethod::QtRuntimeMethod(QtRuntimeMethodData* dd, ExecState* exec, Structure* structure, const Identifier& ident, PassRefPtr<QtInstance> inst)
: InternalFunction(&exec->globalData(), exec->lexicalGlobalObject(), structure, ident)
, d_ptr(dd)
{
QW_D(QtRuntimeMethod);
......@@ -1420,8 +1420,8 @@ static int findSignalIndex(const QMetaObject* meta, int initialIndex, QByteArray
return index;
}
QtRuntimeMetaMethod::QtRuntimeMetaMethod(ExecState* exec, const Identifier& ident, PassRefPtr<QtInstance> inst, int index, const QByteArray& signature, bool allowPrivate)
: QtRuntimeMethod (new QtRuntimeMetaMethodData(), exec, ident, inst)
QtRuntimeMetaMethod::QtRuntimeMetaMethod(ExecState* exec, Structure* structure, const Identifier& ident, PassRefPtr<QtInstance> inst, int index, const QByteArray& signature, bool allowPrivate)
: QtRuntimeMethod (new QtRuntimeMetaMethodData(), exec, structure, ident, inst)
{
QW_D(QtRuntimeMetaMethod);
d->m_signature = signature;
......@@ -1564,8 +1564,8 @@ JSValue QtRuntimeMetaMethod::disconnectGetter(ExecState* exec, JSValue slotBase,
QMultiMap<QObject*, QtConnectionObject*> QtRuntimeConnectionMethod::connections;
QtRuntimeConnectionMethod::QtRuntimeConnectionMethod(ExecState* exec, const Identifier& ident, bool isConnect, PassRefPtr<QtInstance> inst, int index, const QByteArray& signature)
: QtRuntimeMethod (new QtRuntimeConnectionMethodData(), exec, ident, inst)
QtRuntimeConnectionMethod::QtRuntimeConnectionMethod(ExecState* exec, Structure* structure, const Identifier& ident, bool isConnect, PassRefPtr<QtInstance> inst, int index, const QByteArray& signature)
: QtRuntimeMethod (new QtRuntimeConnectionMethodData(), exec, structure, ident, inst)
{
QW_D(QtRuntimeConnectionMethod);
......
......@@ -21,6 +21,7 @@
#define BINDINGS_QT_RUNTIME_H_
#include "BridgeJSC.h"
#include "JSDOMBinding.h"
#include "JavaScript.h"
#include "Weak.h"
#include "qt_instance.h"
......@@ -145,18 +146,18 @@ protected:
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | InternalFunction::StructureFlags | OverridesVisitChildren;
QtRuntimeMethodData *d_func() const {return d_ptr;}
QtRuntimeMethod(QtRuntimeMethodData *dd, ExecState *exec, const Identifier &n, PassRefPtr<QtInstance> inst);
QtRuntimeMethod(QtRuntimeMethodData *dd, ExecState *, Structure*, const Identifier &name, PassRefPtr<QtInstance>);
QtRuntimeMethodData *d_ptr;
};
class QtRuntimeMetaMethod : public QtRuntimeMethod
{
class QtRuntimeMetaMethod : public QtRuntimeMethod {
public:
typedef QtRuntimeMethod Base;
static QtRuntimeMetaMethod* create(ExecState* exec, const Identifier& n, PassRefPtr<QtInstance> inst, int index, const QByteArray& signature, bool allowPrivate)
{
return new (allocateCell<QtRuntimeMetaMethod>(*exec->heap())) QtRuntimeMetaMethod(exec, n, inst, index, signature, allowPrivate);
Structure* domStructure = WebCore::deprecatedGetDOMStructure<QtRuntimeMethod>(exec);
return new (allocateCell<QtRuntimeMetaMethod>(*exec->heap())) QtRuntimeMetaMethod(exec, domStructure, n, inst, index, signature, allowPrivate);
}
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
......@@ -169,7 +170,7 @@ protected:
QtRuntimeMetaMethodData* d_func() const {return reinterpret_cast<QtRuntimeMetaMethodData*>(d_ptr);}
private:
QtRuntimeMetaMethod(ExecState*, const Identifier&, PassRefPtr<QtInstance>, int index, const QByteArray&, bool allowPrivate);
QtRuntimeMetaMethod(ExecState*, Structure*, const Identifier&, PassRefPtr<QtInstance>, int index, const QByteArray&, bool allowPrivate);
virtual CallType getCallData(CallData&);
static EncodedJSValue JSC_HOST_CALL call(ExecState* exec);
......@@ -185,7 +186,8 @@ public:
static QtRuntimeConnectionMethod* create(ExecState* exec, const Identifier& n, bool isConnect, PassRefPtr<QtInstance> inst, int index, const QByteArray& signature)
{
return new (allocateCell<QtRuntimeConnectionMethod>(*exec->heap())) QtRuntimeConnectionMethod(exec, n, isConnect, inst, index, signature);
Structure* domStructure = WebCore::deprecatedGetDOMStructure<QtRuntimeMethod>(exec);
return new (allocateCell<QtRuntimeConnectionMethod>(*exec->heap())) QtRuntimeConnectionMethod(exec, domStructure, n, isConnect, inst, index, signature);
}
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
......@@ -196,7 +198,7 @@ protected:
QtRuntimeConnectionMethodData* d_func() const {return reinterpret_cast<QtRuntimeConnectionMethodData*>(d_ptr);}
private:
QtRuntimeConnectionMethod(ExecState*, const Identifier&, bool isConnect, PassRefPtr<QtInstance>, int index, const QByteArray&);
QtRuntimeConnectionMethod(ExecState*, Structure*, const Identifier&, bool isConnect, PassRefPtr<QtInstance>, int index, const QByteArray&);
virtual CallType getCallData(CallData&);
static EncodedJSValue JSC_HOST_CALL call(ExecState* exec);
......
......@@ -37,10 +37,10 @@ namespace JSC {
const ClassInfo RuntimeArray::s_info = { "RuntimeArray", &JSArray::s_info, 0, 0 };
RuntimeArray::RuntimeArray(ExecState* exec, Bindings::Array* array)
RuntimeArray::RuntimeArray(ExecState* exec, Structure* structure, Bindings::Array* array)
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
// We need to pass in the right global object for "array".
: JSArray(exec->globalData(), deprecatedGetDOMStructure<RuntimeArray>(exec))
: JSArray(exec->globalData(), structure)
{
ASSERT(inherits(&s_info));
setSubclassData(array);
......
......@@ -27,6 +27,7 @@
#define RUNTIME_ARRAY_H_
#include "BridgeJSC.h"
#include "JSDOMBinding.h"
#include <runtime/ArrayPrototype.h>
namespace JSC {
......@@ -37,7 +38,8 @@ public:
static RuntimeArray* create(ExecState* exec, Bindings::Array* array)
{
return new (allocateCell<RuntimeArray>(*exec->heap())) RuntimeArray(exec, array);
Structure* domStructure = WebCore::deprecatedGetDOMStructure<RuntimeArray>(exec);
return new (allocateCell<RuntimeArray>(*exec->heap())) RuntimeArray(exec, domStructure, array);
}
typedef Bindings::Array BindingsArray;
......@@ -73,7 +75,7 @@ protected:
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSArray::StructureFlags;
private:
RuntimeArray(ExecState*, Bindings::Array*);
RuntimeArray(ExecState*, Structure*, Bindings::Array*);
static JSValue lengthGetter(ExecState*, JSValue, const Identifier&);
static JSValue indexGetter(ExecState*, JSValue, unsigned);
};
......
......@@ -29,7 +29,6 @@
#include "JSDOMBinding.h"
#include "runtime_method.h"
#include <runtime/Error.h>
#include <runtime/ObjectPrototype.h>
using namespace WebCore;
......
2011-08-15 Mark Hahnenberg <mhahnenberg@apple.com>
Refactor JS objects to allocate in static create methods rather than constructors
https://bugs.webkit.org/show_bug.cgi?id=65347
Reviewed by Geoffrey Garen.
Removed all calls to deprecatedGetDOMObject from initialization lists as part of a
larger refactoring to get rid of all allocation during initialization.
* Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyRuntimeMethod::create):
(WebKit::ProxyRuntimeMethod::ProxyRuntimeMethod):
2011-08-15 Adam Roben <aroben@apple.com>
Update pages' style and content scale when the window's backing scale factor changes
......
......@@ -183,7 +183,10 @@ public:
static ProxyRuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
{
return new (allocateCell<ProxyRuntimeMethod>(*exec->heap())) ProxyRuntimeMethod(exec, globalObject, name, list);
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
// exec-globalData() is also likely wrong.
Structure* domStructure = deprecatedGetDOMStructure<ProxyRuntimeMethod>(exec);
return new (allocateCell<ProxyRuntimeMethod>(*exec->heap())) ProxyRuntimeMethod(exec, globalObject, domStructure, name, list);
}
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
......@@ -194,10 +197,8 @@ public:
static const ClassInfo s_info;
private:
ProxyRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
// exec-globalData() is also likely wrong.
: RuntimeMethod(exec, globalObject, deprecatedGetDOMStructure<ProxyRuntimeMethod>(exec), name, list)
ProxyRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, const Identifier& name, Bindings::MethodList& list)
: RuntimeMethod(exec, globalObject, structure, name, list)
{
ASSERT(inherits(&s_info));
}
......
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