Remove operator new from JSCell

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

Patch by Mark Hahnenberg <mhahnenberg@apple.com> on 2011-07-27
Reviewed by Oliver Hunt.

Source/JavaScriptCore:

Removed the implementation of operator new in JSCell, so any further uses
will not successfully link.  Also removed any remaining uses of operator new.

* API/JSContextRef.cpp:
* debugger/DebuggerActivation.h:
(JSC::DebuggerActivation::create):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::execute):
(JSC::Interpreter::createExceptionScope):
(JSC::Interpreter::privateExecute):
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
* runtime/JSCell.h:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::create):
* runtime/JSStaticScopeObject.h:
(JSC::JSStaticScopeObject::create):
(JSC::JSStaticScopeObject::JSStaticScopeObject):
* runtime/StrictEvalActivation.h:
(JSC::StrictEvalActivation::create):

Source/JavaScriptGlue:

Removed the implementation of operator new in JSCell, so any further uses
will not successfully link.  Also removed any remaining uses of operator new.

* JSRun.cpp:
(JSRun::JSRun):
* JSRun.h:
(JSGlueGlobalObject::create):
* JSUtils.cpp:
(JSObjectKJSValue):
(getThreadGlobalObject):
* UserObjectImp.h:
(UserObjectImp::create):

Source/WebCore:

No new tests.

Removed the implementation of operator new in JSCell, so any further uses
will not successfully link.  Also removed any remaining uses of operator new.

* bridge/c/CRuntimeObject.h:
(JSC::Bindings::CRuntimeObject::create):
* bridge/c/c_instance.cpp:
(JSC::Bindings::CInstance::newRuntimeObject):
(JSC::Bindings::CRuntimeMethod::create):
(JSC::Bindings::CRuntimeMethod::CRuntimeMethod):
(JSC::Bindings::CInstance::getMethod):
* bridge/jni/jsc/JavaInstanceJSC.cpp:
(JavaInstance::newRuntimeObject):
(JavaRuntimeMethod::create):
(JavaRuntimeMethod::JavaRuntimeMethod):
(JavaInstance::getMethod):
* bridge/jni/jsc/JavaRuntimeObject.h:
(JSC::Bindings::JavaRuntimeObject::create):
* bridge/objc/ObjCRuntimeObject.h:
(JSC::Bindings::ObjCRuntimeObject::create):
* bridge/objc/objc_class.mm:
(JSC::Bindings::ObjcClass::fallbackObject):
* bridge/objc/objc_instance.mm:
(ObjcInstance::newRuntimeObject):
(ObjCRuntimeMethod::create):
(ObjCRuntimeMethod::ObjCRuntimeMethod):
(ObjcInstance::getMethod):
* bridge/objc/objc_runtime.h:
(JSC::Bindings::ObjcFallbackObjectImp::create):

Source/WebKit/mac:

Removed the implementation of operator new in JSCell, so any further uses
will not successfully link.  Also removed any remaining uses of operator new.

* Plugins/Hosted/ProxyInstance.mm:
(WebKit::ProxyInstance::newRuntimeObject):
(WebKit::ProxyRuntimeMethod::create):
(WebKit::ProxyRuntimeMethod::ProxyRuntimeMethod):
(WebKit::ProxyInstance::getMethod):
* Plugins/Hosted/ProxyRuntimeObject.h:
(WebKit::ProxyRuntimeObject::create):
* WebView/WebScriptDebugDelegate.mm:
(-[WebScriptCallFrame scopeChain]):

Source/WebKit2:

Removed the implementation of operator new in JSCell, so any further uses
will not successfully link.  Also removed any remaining uses of operator new.

* WebProcess/Plugins/Netscape/JSNPMethod.h:
(WebKit::JSNPMethod::create):
* WebProcess/Plugins/Netscape/JSNPObject.cpp:
(WebKit::JSNPObject::methodGetter):
* WebProcess/Plugins/Netscape/JSNPObject.h:
(WebKit::JSNPObject::create):
* WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
(WebKit::NPRuntimeObjectMap::getOrCreateJSObject):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@91903 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5a3d8bbf
......@@ -97,7 +97,7 @@ JSGlobalContextRef JSGlobalContextCreateInGroup(JSContextGroupRef group, JSClass
#endif
if (!globalObjectClass) {
JSGlobalObject* globalObject = new (globalData.get()) JSGlobalObject(*globalData, JSGlobalObject::createStructure(*globalData, jsNull()));
JSGlobalObject* globalObject = JSGlobalObject::create(*globalData, JSGlobalObject::createStructure(*globalData, jsNull()));
return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec()));
}
......
2011-07-27 Mark Hahnenberg <mhahnenberg@apple.com>
Remove operator new from JSCell
https://bugs.webkit.org/show_bug.cgi?id=64999
Reviewed by Oliver Hunt.
Removed the implementation of operator new in JSCell, so any further uses
will not successfully link. Also removed any remaining uses of operator new.
* API/JSContextRef.cpp:
* debugger/DebuggerActivation.h:
(JSC::DebuggerActivation::create):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::execute):
(JSC::Interpreter::createExceptionScope):
(JSC::Interpreter::privateExecute):
* jit/JITStubs.cpp:
(JSC::DEFINE_STUB_FUNCTION):
* runtime/JSCell.h:
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::create):
* runtime/JSStaticScopeObject.h:
(JSC::JSStaticScopeObject::create):
(JSC::JSStaticScopeObject::JSStaticScopeObject):
* runtime/StrictEvalActivation.h:
(JSC::StrictEvalActivation::create):
2011-07-27 Filip Pizlo <fpizlo@apple.com>
DFG graph has no notion of double prediction.
......
......@@ -34,7 +34,10 @@ namespace JSC {
class DebuggerActivation : public JSNonFinalObject {
public:
DebuggerActivation(JSGlobalData&, JSObject*);
static DebuggerActivation* create(JSGlobalData& globalData, JSObject* object)
{
return new (allocateCell<DebuggerActivation>(globalData.heap)) DebuggerActivation(globalData, object);
}
virtual void visitChildren(SlotVisitor&);
virtual UString className() const;
......@@ -58,6 +61,7 @@ namespace JSC {
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesVisitChildren | JSObject::StructureFlags;
private:
DebuggerActivation(JSGlobalData&, JSObject*);
WriteBarrier<JSActivation> m_activation;
};
......
......@@ -1222,7 +1222,7 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSValue
bool pushedScope = false;
if (numVariables || numFunctions) {
if (codeBlock->isStrictMode()) {
variableObject = new (callFrame) StrictEvalActivation(callFrame);
variableObject = StrictEvalActivation::create(callFrame);
scopeChain = scopeChain->push(variableObject);
pushedScope = true;
}
......@@ -1327,7 +1327,7 @@ NEVER_INLINE ScopeChainNode* Interpreter::createExceptionScope(CallFrame* callFr
CodeBlock* codeBlock = callFrame->codeBlock();
Identifier& property = codeBlock->identifier(vPC[2].u.operand);
JSValue value = callFrame->r(vPC[3].u.operand).jsValue();
JSObject* scope = new (callFrame) JSStaticScopeObject(callFrame, property, value, DontDelete);
JSObject* scope = JSStaticScopeObject::create(callFrame, property, value, DontDelete);
callFrame->uncheckedR(dst) = JSValue(scope);
return callFrame->scopeChain()->push(scope);
......@@ -4152,7 +4152,7 @@ skip_id_custom_self:
does not affect the scope enclosing the FunctionExpression.
*/
if (!function->name().isNull()) {
JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, function->name(), func, ReadOnly | DontDelete);
JSStaticScopeObject* functionScopeObject = JSStaticScopeObject::create(callFrame, function->name(), func, ReadOnly | DontDelete);
func->setScope(*globalData, func->scope()->push(functionScopeObject));
}
......
......@@ -3082,7 +3082,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_new_func_exp)
does not affect the scope enclosing the FunctionExpression.
*/
if (!function->name().isNull()) {
JSStaticScopeObject* functionScopeObject = new (callFrame) JSStaticScopeObject(callFrame, function->name(), func, ReadOnly | DontDelete);
JSStaticScopeObject* functionScopeObject = JSStaticScopeObject::create(callFrame, function->name(), func, ReadOnly | DontDelete);
func->setScope(callFrame->globalData(), func->scope()->push(functionScopeObject));
}
......@@ -3378,7 +3378,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_push_new_scope)
{
STUB_INIT_STACK_FRAME(stackFrame);
JSObject* scope = new (stackFrame.globalData) JSStaticScopeObject(stackFrame.callFrame, stackFrame.args[0].identifier(), stackFrame.args[1].jsValue(), DontDelete);
JSObject* scope = JSStaticScopeObject::create(stackFrame.callFrame, stackFrame.args[0].identifier(), stackFrame.args[1].jsValue(), DontDelete);
CallFrame* callFrame = stackFrame.callFrame;
callFrame->setScopeChain(callFrame->scopeChain()->push(scope));
......
......@@ -121,8 +121,6 @@ namespace JSC {
virtual JSObject* toObject(ExecState*, JSGlobalObject*) const;
// Garbage collection.
void* operator new(size_t, ExecState*);
void* operator new(size_t, JSGlobalData*);
void* operator new(size_t, void* placementNewDestination) { return placementNewDestination; }
virtual void visitChildren(SlotVisitor&);
......@@ -165,6 +163,11 @@ namespace JSC {
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
// Note that the first two declarations of operator new have no corresponding implementation and
// will cause link errors if you use them.
void* operator new(size_t, ExecState*);
void* operator new(size_t, JSGlobalData*);
WriteBarrier<Structure> m_structure;
};
......@@ -358,20 +361,6 @@ namespace JSC {
}
#endif
inline void* JSCell::operator new(size_t size, JSGlobalData* globalData)
{
JSCell* result = static_cast<JSCell*>(globalData->heap.allocate(size));
result->m_structure.clear();
return result;
}
inline void* JSCell::operator new(size_t size, ExecState* exec)
{
JSCell* result = static_cast<JSCell*>(exec->heap()->allocate(size));
result->m_structure.clear();
return result;
}
inline void destructor(JSCell* cell)
{
cell->~JSCell();
......
......@@ -122,6 +122,14 @@ namespace JSC {
bool m_evalEnabled;
public:
static JSGlobalObject* create(JSGlobalData& globalData, Structure* structure)
{
return new (allocateCell<JSGlobalObject>(globalData.heap)) JSGlobalObject(globalData, structure);
}
static JS_EXPORTDATA const ClassInfo s_info;
protected:
explicit JSGlobalObject(JSGlobalData& globalData, Structure* structure)
: JSVariableObject(globalData, structure, &m_symbolTable, 0)
, m_registerArraySize(0)
......@@ -134,9 +142,6 @@ namespace JSC {
init(this);
}
static JS_EXPORTDATA const ClassInfo s_info;
protected:
JSGlobalObject(JSGlobalData& globalData, Structure* structure, JSObject* thisValue)
: JSVariableObject(globalData, structure, &m_symbolTable, 0)
, m_registerArraySize(0)
......
......@@ -32,11 +32,9 @@ namespace JSC{
class JSStaticScopeObject : public JSVariableObject {
public:
JSStaticScopeObject(ExecState* exec, const Identifier& ident, JSValue value, unsigned attributes)
: JSVariableObject(exec->globalData(), exec->globalData().staticScopeStructure.get(), &m_symbolTable, reinterpret_cast<Register*>(&m_registerStore + 1))
static JSStaticScopeObject* create(ExecState* exec, const Identifier& ident, JSValue value, unsigned attributes)
{
m_registerStore.set(exec->globalData(), this, value);
symbolTable().add(ident.impl(), SymbolTableEntry(-1, attributes));
return new (allocateCell<JSStaticScopeObject>(*exec->heap())) JSStaticScopeObject(exec, ident, value, attributes);
}
virtual void visitChildren(SlotVisitor&);
......@@ -53,6 +51,13 @@ namespace JSC{
static const unsigned StructureFlags = IsEnvironmentRecord | OverridesGetOwnPropertySlot | OverridesVisitChildren | OverridesGetPropertyNames | JSVariableObject::StructureFlags;
private:
JSStaticScopeObject(ExecState* exec, const Identifier& ident, JSValue value, unsigned attributes)
: JSVariableObject(exec->globalData(), exec->globalData().staticScopeStructure.get(), &m_symbolTable, reinterpret_cast<Register*>(&m_registerStore + 1))
{
m_registerStore.set(exec->globalData(), this, value);
symbolTable().add(ident.impl(), SymbolTableEntry(-1, attributes));
}
SymbolTable m_symbolTable;
WriteBarrier<Unknown> m_registerStore;
};
......
......@@ -32,7 +32,11 @@ namespace JSC {
class StrictEvalActivation : public JSNonFinalObject {
public:
StrictEvalActivation(ExecState*);
static StrictEvalActivation* create(ExecState* exec)
{
return new (allocateCell<StrictEvalActivation>(*exec->heap())) StrictEvalActivation(exec);
}
virtual bool deleteProperty(ExecState*, const Identifier&);
virtual JSObject* toThisObject(ExecState*) const;
virtual JSValue toStrictThisObject(ExecState*) const;
......@@ -44,6 +48,9 @@ public:
protected:
static const unsigned StructureFlags = IsEnvironmentRecord | JSNonFinalObject::StructureFlags;
private:
StrictEvalActivation(ExecState*);
};
} // namespace JSC
......
2011-07-27 Mark Hahnenberg <mhahnenberg@apple.com>
Remove operator new from JSCell
https://bugs.webkit.org/show_bug.cgi?id=64999
Reviewed by Oliver Hunt.
Removed the implementation of operator new in JSCell, so any further uses
will not successfully link. Also removed any remaining uses of operator new.
* JSRun.cpp:
(JSRun::JSRun):
* JSRun.h:
(JSGlueGlobalObject::create):
* JSUtils.cpp:
(JSObjectKJSValue):
(getThreadGlobalObject):
* UserObjectImp.h:
(UserObjectImp::create):
2011-07-01 Jungshik Shin <jshin@chromium.org>
Reviewed by Alexey Proskuryakov.
......
......@@ -43,7 +43,7 @@ JSGlueGlobalObject::JSGlueGlobalObject(JSGlobalData& globalData, Structure* stru
JSRun::JSRun(CFStringRef source, JSFlags inFlags)
: JSBase(kJSRunTypeID),
fSource(CFStringToUString(source)),
fGlobalObject(getThreadGlobalExecState()->globalData(), new (&getThreadGlobalExecState()->globalData()) JSGlueGlobalObject(getThreadGlobalExecState()->globalData(), JSGlueGlobalObject::createStructure(getThreadGlobalExecState()->globalData(), jsNull()), inFlags)),
fGlobalObject(getThreadGlobalExecState()->globalData(), JSGlueGlobalObject::create(getThreadGlobalExecState()->globalData(), JSGlueGlobalObject::createStructure(getThreadGlobalExecState()->globalData(), jsNull()), inFlags)),
fFlags(inFlags)
{
}
......
......@@ -35,12 +35,17 @@
class JSGlueGlobalObject : public JSGlobalObject {
public:
JSGlueGlobalObject(JSGlobalData&, Structure*, JSFlags = kJSFlagNone);
static JSGlueGlobalObject* create(JSGlobalData& globalData, Structure* structure, JSFlags flags = kJSFlagNone)
{
return new (allocateCell<JSGlueGlobalObject>(globalData.heap)) JSGlueGlobalObject(globalData, structure, flags);
}
JSFlags Flags() const { return m_flags; }
Structure* userObjectStructure() const { return m_userObjectStructure.get(); }
private:
JSGlueGlobalObject(JSGlobalData&, Structure*, JSFlags = kJSFlagNone);
JSFlags m_flags;
Strong<Structure> m_userObjectStructure;
};
......
......@@ -184,7 +184,7 @@ JSValue JSObjectKJSValue(JSUserObject* ptr)
if (!handled)
{
ExecState* exec = getThreadGlobalExecState();
result = new (exec) UserObjectImp(exec->globalData(), getThreadGlobalObject()->userObjectStructure(), ptr);
result = UserObjectImp::create(exec->globalData(), getThreadGlobalObject()->userObjectStructure(), ptr);
}
}
return result;
......@@ -414,7 +414,7 @@ static JSGlueGlobalObject* getThreadGlobalObject()
pthread_once(&globalObjectKeyOnce, initializeGlobalObjectKey);
JSGlueGlobalObject* globalObject = static_cast<JSGlueGlobalObject*>(pthread_getspecific(globalObjectKey));
if (!globalObject) {
globalObject = new (getThreadGlobalData()) JSGlueGlobalObject(*getThreadGlobalData(), JSGlueGlobalObject::createStructure(*getThreadGlobalData(), jsNull()));
globalObject = JSGlueGlobalObject::create(*getThreadGlobalData(), JSGlueGlobalObject::createStructure(*getThreadGlobalData(), jsNull()));
gcProtect(globalObject);
pthread_setspecific(globalObjectKey, globalObject);
}
......
......@@ -36,7 +36,11 @@
class UserObjectImp : public JSNonFinalObject {
public:
UserObjectImp(JSGlobalData&, Structure*, JSUserObject*);
static UserObjectImp* create(JSGlobalData& globalData, Structure* structure, JSUserObject* userObject)
{
return new (allocateCell<UserObjectImp>(globalData.heap)) UserObjectImp(globalData, structure, userObject);
}
virtual ~UserObjectImp();
static const ClassInfo s_info;
......@@ -64,6 +68,7 @@ public:
}
private:
UserObjectImp(JSGlobalData&, Structure*, JSUserObject*);
static JSValue userObjectGetter(ExecState*, JSValue, const Identifier& propertyName);
JSUserObject* fJSUserObject;
......
2011-07-27 Mark Hahnenberg <mhahnenberg@apple.com>
Remove operator new from JSCell
https://bugs.webkit.org/show_bug.cgi?id=64999
Reviewed by Oliver Hunt.
No new tests.
Removed the implementation of operator new in JSCell, so any further uses
will not successfully link. Also removed any remaining uses of operator new.
* bridge/c/CRuntimeObject.h:
(JSC::Bindings::CRuntimeObject::create):
* bridge/c/c_instance.cpp:
(JSC::Bindings::CInstance::newRuntimeObject):
(JSC::Bindings::CRuntimeMethod::create):
(JSC::Bindings::CRuntimeMethod::CRuntimeMethod):
(JSC::Bindings::CInstance::getMethod):
* bridge/jni/jsc/JavaInstanceJSC.cpp:
(JavaInstance::newRuntimeObject):
(JavaRuntimeMethod::create):
(JavaRuntimeMethod::JavaRuntimeMethod):
(JavaInstance::getMethod):
* bridge/jni/jsc/JavaRuntimeObject.h:
(JSC::Bindings::JavaRuntimeObject::create):
* bridge/objc/ObjCRuntimeObject.h:
(JSC::Bindings::ObjCRuntimeObject::create):
* bridge/objc/objc_class.mm:
(JSC::Bindings::ObjcClass::fallbackObject):
* bridge/objc/objc_instance.mm:
(ObjcInstance::newRuntimeObject):
(ObjCRuntimeMethod::create):
(ObjCRuntimeMethod::ObjCRuntimeMethod):
(ObjcInstance::getMethod):
* bridge/objc/objc_runtime.h:
(JSC::Bindings::ObjcFallbackObjectImp::create):
2011-07-27 Vsevolod Vlasov <vsevik@chromium.org>
Web Inspector: Network panel sidebar should have width saved in preferences when resource is selected.
......@@ -37,7 +37,11 @@ class CInstance;
class CRuntimeObject : public RuntimeObject {
public:
CRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<CInstance>);
static CRuntimeObject* create(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<CInstance> instance)
{
return new (allocateCell<CRuntimeObject>(*exec->heap())) CRuntimeObject(exec, globalObject, instance);
}
virtual ~CRuntimeObject();
CInstance* getInternalCInstance() const;
......@@ -48,6 +52,9 @@ public:
{
return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
private:
CRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<CInstance>);
};
}
......
......@@ -94,7 +94,7 @@ CInstance::~CInstance()
RuntimeObject* CInstance::newRuntimeObject(ExecState* exec)
{
return new (exec) CRuntimeObject(exec, exec->lexicalGlobalObject(), this);
return CRuntimeObject::create(exec, exec->lexicalGlobalObject(), this);
}
Class *CInstance::getClass() const
......@@ -111,12 +111,9 @@ bool CInstance::supportsInvokeDefaultMethod() const
class CRuntimeMethod : public RuntimeMethod {
public:
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)
static CRuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
{
ASSERT(inherits(&s_info));
return new (allocateCell<CRuntimeMethod>(*exec->heap())) CRuntimeMethod(exec, globalObject, name, list);
}
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
......@@ -125,6 +122,16 @@ 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)
{
ASSERT(inherits(&s_info));
}
};
const ClassInfo CRuntimeMethod::s_info = { "CRuntimeMethod", &RuntimeMethod::s_info, 0, 0 };
......@@ -132,7 +139,7 @@ const ClassInfo CRuntimeMethod::s_info = { "CRuntimeMethod", &RuntimeMethod::s_i
JSValue CInstance::getMethod(ExecState* exec, const Identifier& propertyName)
{
MethodList methodList = getClass()->methodsNamed(propertyName, this);
return new (exec) CRuntimeMethod(exec, exec->lexicalGlobalObject(), propertyName, methodList);
return CRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName, methodList);
}
JSValue CInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
......
......@@ -63,7 +63,7 @@ JavaInstance::~JavaInstance()
RuntimeObject* JavaInstance::newRuntimeObject(ExecState* exec)
{
return new (exec) JavaRuntimeObject(exec, exec->lexicalGlobalObject(), this);
return JavaRuntimeObject::create(exec, exec->lexicalGlobalObject(), this);
}
#define NUM_LOCAL_REFS 64
......@@ -116,12 +116,9 @@ JSValue JavaInstance::booleanValue() const
class JavaRuntimeMethod : public RuntimeMethod {
public:
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)
static JavaRuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
{
ASSERT(inherits(&s_info));
return new (allocateCell<JavaRuntimeMethod>(*exec->heap())) JavaRuntimeMethod(exec, globalObject, name, list);
}
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
......@@ -130,6 +127,16 @@ 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)
{
ASSERT(inherits(&s_info));
}
};
const ClassInfo JavaRuntimeMethod::s_info = { "JavaRuntimeMethod", &RuntimeMethod::s_info, 0, 0 };
......@@ -137,7 +144,7 @@ const ClassInfo JavaRuntimeMethod::s_info = { "JavaRuntimeMethod", &RuntimeMetho
JSValue JavaInstance::getMethod(ExecState* exec, const Identifier& propertyName)
{
MethodList methodList = getClass()->methodsNamed(propertyName, this);
return new (exec) JavaRuntimeMethod(exec, exec->lexicalGlobalObject(), propertyName, methodList);
return JavaRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName, methodList);
}
JSValue JavaInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
......
......@@ -35,7 +35,11 @@ class JavaInstance;
class JavaRuntimeObject : public RuntimeObject {
public:
JavaRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<JavaInstance>);
static JavaRuntimeObject* create(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<JavaInstance> javaInst)
{
return new (allocateCell<JavaRuntimeObject>(*exec->heap())) JavaRuntimeObject(exec, globalObject, javaInst);
}
virtual ~JavaRuntimeObject();
JavaInstance* getInternalJavaInstance() const;
......@@ -46,6 +50,9 @@ public:
{
return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
private:
JavaRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<JavaInstance>);
};
}
......
......@@ -35,7 +35,11 @@ class ObjcInstance;
class ObjCRuntimeObject : public RuntimeObject {
public:
ObjCRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<ObjcInstance>);
static ObjCRuntimeObject* create(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<ObjcInstance> inst)
{
return new (allocateCell<ObjCRuntimeObject>(*exec->heap())) ObjCRuntimeObject(exec, globalObject, inst);
}
virtual ~ObjCRuntimeObject();
ObjcInstance* getInternalObjCInstance() const;
......@@ -46,6 +50,9 @@ public:
{
return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
private:
ObjCRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<ObjcInstance>);
};
}
......
......@@ -246,7 +246,7 @@ JSValue ObjcClass::fallbackObject(ExecState* exec, Instance* instance, const Ide
if (![targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)])
return jsUndefined();
return new (exec) ObjcFallbackObjectImp(exec, exec->lexicalGlobalObject(), objcInstance, propertyName);
return ObjcFallbackObjectImp::create(exec, exec->lexicalGlobalObject(), objcInstance, propertyName);
}
}
......
......@@ -62,7 +62,7 @@ static NSMapTable *createInstanceWrapperCache()
RuntimeObject* ObjcInstance::newRuntimeObject(ExecState* exec)
{
return new (exec) ObjCRuntimeObject(exec, exec->lexicalGlobalObject(), this);
return ObjCRuntimeObject::create(exec, exec->lexicalGlobalObject(), this);
}
void ObjcInstance::setGlobalException(NSString* exception, JSGlobalObject* exceptionEnvironment)
......@@ -172,12 +172,9 @@ bool ObjcInstance::supportsInvokeDefaultMethod() const
class ObjCRuntimeMethod : public RuntimeMethod {
public:
ObjCRuntimeMethod(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<ObjCRuntimeMethod>(exec), name, list)
static ObjCRuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
{
ASSERT(inherits(&s_info));
return new (allocateCell<ObjCRuntimeMethod>(*exec->heap())) ObjCRuntimeMethod(exec, globalObject, name, list);
}
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
......@@ -186,6 +183,15 @@ public:
}
static const ClassInfo s_info;
private:
ObjCRuntimeMethod(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<ObjCRuntimeMethod>(exec), name, list)
{
ASSERT(inherits(&s_info));
}
};
const ClassInfo ObjCRuntimeMethod::s_info = { "ObjCRuntimeMethod", &RuntimeMethod::s_info, 0, 0 };
......@@ -193,7 +199,7 @@ const ClassInfo ObjCRuntimeMethod::s_info = { "ObjCRuntimeMethod", &RuntimeMetho
JSValue ObjcInstance::getMethod(ExecState* exec, const Identifier& propertyName)
{
MethodList methodList = getClass()->methodsNamed(propertyName, this);
return new (exec) ObjCRuntimeMethod(exec, exec->lexicalGlobalObject(), propertyName, methodList);
return ObjCRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName, methodList);
}
JSValue ObjcInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
......
......@@ -92,7 +92,10 @@ private:
class ObjcFallbackObjectImp : public JSObjectWithGlobalObject {
public:
ObjcFallbackObjectImp(ExecState*, JSGlobalObject*, ObjcInstance*, const Identifier& propertyName);
static ObjcFallbackObjectImp* create(ExecState* exec, JSGlobalObject* globalObject, ObjcInstance* instance, const Identifier& propertyName)
{
return new (allocateCell<ObjcFallbackObjectImp>(*exec->heap())) ObjcFallbackObjectImp(exec, globalObject, instance, propertyName);
}
static const ClassInfo s_info;
......@@ -109,6 +112,7 @@ public:
}
private: