Remove operator new from JSCell
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jul 2011 04:59:12 +0000 (04:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Jul 2011 04:59:12 +0000 (04:59 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@91903 268f45cc-cd09-0410-ab3c-d52691b4dbfc

38 files changed:
Source/JavaScriptCore/API/JSContextRef.cpp
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/debugger/DebuggerActivation.h
Source/JavaScriptCore/interpreter/Interpreter.cpp
Source/JavaScriptCore/jit/JITStubs.cpp
Source/JavaScriptCore/runtime/JSCell.h
Source/JavaScriptCore/runtime/JSGlobalObject.h
Source/JavaScriptCore/runtime/JSStaticScopeObject.h
Source/JavaScriptCore/runtime/StrictEvalActivation.h
Source/JavaScriptGlue/ChangeLog
Source/JavaScriptGlue/JSRun.cpp
Source/JavaScriptGlue/JSRun.h
Source/JavaScriptGlue/JSUtils.cpp
Source/JavaScriptGlue/UserObjectImp.h
Source/WebCore/ChangeLog
Source/WebCore/bridge/c/CRuntimeObject.h
Source/WebCore/bridge/c/c_instance.cpp
Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.h
Source/WebCore/bridge/objc/ObjCRuntimeObject.h
Source/WebCore/bridge/objc/objc_class.mm
Source/WebCore/bridge/objc/objc_instance.mm
Source/WebCore/bridge/objc/objc_runtime.h
Source/WebCore/bridge/qt/qt_class.cpp
Source/WebCore/bridge/qt/qt_instance.cpp
Source/WebCore/bridge/qt/qt_pixmapruntime.cpp
Source/WebCore/bridge/qt/qt_runtime.cpp
Source/WebCore/bridge/qt/qt_runtime.h
Source/WebCore/bridge/runtime_method.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/Plugins/Hosted/ProxyInstance.mm
Source/WebKit/mac/Plugins/Hosted/ProxyRuntimeObject.h
Source/WebKit/mac/WebView/WebScriptDebugDelegate.mm
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/Netscape/JSNPMethod.h
Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.cpp
Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h
Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp

index 354d1c8..2e6857c 100644 (file)
@@ -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()));
     }
 
index 145b587..a4b6b01 100644 (file)
@@ -1,3 +1,31 @@
+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.
index 574986a..98f7e73 100644 (file)
@@ -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;
     };
 
index 7a14ac0..2c9da49 100644 (file)
@@ -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));
         }
 
index 3413d16..de55c57 100644 (file)
@@ -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));
index 9e7c9bb..3229a41 100644 (file)
@@ -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();
index 3a54987..e933577 100644 (file)
@@ -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)
index c040886..cd47514 100644 (file)
@@ -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;
     };
index a77bac4..ddb58e9 100644 (file)
@@ -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
index f8b70f0..45e6495 100644 (file)
@@ -1,3 +1,23 @@
+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.
index 3b9d245..6a31a79 100644 (file)
@@ -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)
 {
 }
index 9fe7767..c59dfe0 100644 (file)
 
 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;
 };
index 1a826c1..bd929cc 100644 (file)
@@ -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);
     }
index 5e0f8ed..d965cf2 100644 (file)
 
 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;
index 72ed6fb..bfab4c1 100644 (file)
@@ -1,3 +1,41 @@
+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.
index c96887a..a25115e 100644 (file)
@@ -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>);
 };
 
 }
index d0fa3cf..8a7a846 100644 (file)
@@ -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)
index 38ca10b..51c6016 100644 (file)
@@ -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)
index 8a3612f..4195290 100644 (file)
@@ -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>);
 };
 
 }
index f8eada7..388cf86 100644 (file)
@@ -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>);
 };
 
 }
index 2d29499..e4a336a 100644 (file)
@@ -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);
 }
 
 }
index 546d8eb..b6c4d8a 100644 (file)
@@ -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)
index eded2fe..076aca6 100644 (file)
@@ -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:
+    ObjcFallbackObjectImp(ExecState*, JSGlobalObject*, 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&);
index c3d8b27..b7a3dea 100644 (file)
@@ -86,7 +86,7 @@ JSValue QtClass::fallbackObject(ExecState* exec, Instance* inst, const Identifie
     if (normal.contains('(') && (index = m_metaObject->indexOfMethod(normal)) != -1) {
         QMetaMethod m = m_metaObject->method(index);
         if (m.access() != QMetaMethod::Private) {
-            QtRuntimeMetaMethod* val = new (exec) QtRuntimeMetaMethod(exec, identifier, static_cast<QtInstance*>(inst), index, normal, false);
+            QtRuntimeMetaMethod* val = QtRuntimeMetaMethod::create(exec, identifier, static_cast<QtInstance*>(inst), index, normal, false);
             qtinst->m_methods.insert(name, WriteBarrier<JSObject>(exec->globalData(), qtinst->createRuntimeObject(exec), val));
             return val;
         }
@@ -105,7 +105,7 @@ JSValue QtClass::fallbackObject(ExecState* exec, Instance* inst, const Identifie
             ++iter;
 
         if (normal == QByteArray::fromRawData(signature, iter)) {
-            QtRuntimeMetaMethod* val = new (exec) QtRuntimeMetaMethod(exec, identifier, static_cast<QtInstance*>(inst), index, normal, false);
+            QtRuntimeMetaMethod* val = QtRuntimeMetaMethod::create(exec, identifier, static_cast<QtInstance*>(inst), index, normal, false);
             qtinst->m_methods.insert(name, WriteBarrier<JSObject>(exec->globalData(), qtinst->createRuntimeObject(exec), val));
             return val;
         }
index df278c9..0e862cb 100644 (file)
@@ -50,8 +50,11 @@ Q_GLOBAL_STATIC(QtInstance::QtSenderStack, senderStack)
 // Derived RuntimeObject
 class QtRuntimeObject : public RuntimeObject {
 public:
-    QtRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<Instance>);
-
+    static QtRuntimeObject* create(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<Instance> instance)
+    {
+        return new (allocateCell<QtRuntimeObject>(*exec->heap())) QtRuntimeObject(exec, globalObject, instance);
+    }
+    
     static const ClassInfo s_info;
 
     virtual void visitChildren(SlotVisitor& visitor)
@@ -69,6 +72,9 @@ public:
 
 protected:
     static const unsigned StructureFlags = RuntimeObject::StructureFlags | OverridesVisitChildren;
+
+private:
+    QtRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<Instance>);
 };
 
 const ClassInfo QtRuntimeObject::s_info = { "QtRuntimeObject", &RuntimeObject::s_info, 0, 0 };
@@ -182,7 +188,7 @@ RuntimeObject* QtInstance::newRuntimeObject(ExecState* exec)
 {
     JSLock lock(SilenceAssertionsOnly);
     m_methods.clear();
-    return new (exec) QtRuntimeObject(exec, exec->lexicalGlobalObject(), this);
+    return QtRuntimeObject::create(exec, exec->lexicalGlobalObject(), this);
 }
 
 void QtInstance::visitAggregate(SlotVisitor& visitor)
@@ -238,7 +244,7 @@ JSValue QtInstance::getMethod(ExecState* exec, const Identifier& propertyName)
     if (!getClass())
         return jsNull();
     MethodList methodList = m_class->methodsNamed(propertyName, this);
-    return new (exec) RuntimeMethod(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeMethod>(exec), propertyName, methodList);
+    return RuntimeMethod::create(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeMethod>(exec), propertyName, methodList);
 }
 
 JSValue QtInstance::invokeMethod(ExecState*, RuntimeMethod*)
index be0cd28..669cf33 100644 (file)
@@ -198,7 +198,10 @@ struct QtPixmapMetaData {
 // Derived RuntimeObject
 class QtPixmapRuntimeObject : public RuntimeObject {
 public:
-    QtPixmapRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<Instance>);
+    static QtPixmapRuntimeObject* create(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<Instance> instance)
+    {
+        return new (allocateCell<QtPixmapRuntimeObject>(*exec->heap())) QtPixmapRuntimeObject(exec, globalObject, instance);
+    }
 
     static const ClassInfo s_info;
 
@@ -209,6 +212,9 @@ public:
 
 protected:
     static const unsigned StructureFlags = RuntimeObject::StructureFlags | OverridesVisitChildren;
+
+private:
+    QtPixmapRuntimeObject(ExecState*, JSGlobalObject*, PassRefPtr<Instance>);
 };
 
 QtPixmapRuntimeObject::QtPixmapRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<Instance> instance)
@@ -231,7 +237,7 @@ Class* QtPixmapInstance::getClass() const
 JSValue QtPixmapInstance::getMethod(ExecState* exec, const Identifier& propertyName)
 {
     MethodList methodList = getClass()->methodsNamed(propertyName, this);
-    return new (exec) RuntimeMethod(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeMethod>(exec), propertyName, methodList);
+    return RuntimeMethod::create(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeMethod>(exec), propertyName, methodList);
 }
 
 JSValue QtPixmapInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
@@ -402,7 +408,7 @@ returnEmptyVariant:
 
 RuntimeObject* QtPixmapInstance::newRuntimeObject(ExecState* exec)
 {
-    return new(exec) QtPixmapRuntimeObject(exec, exec->lexicalGlobalObject(), this);
+    return QtPixmapRuntimeObject::create(exec, exec->lexicalGlobalObject(), this);
 }
 
 JSObject* QtPixmapInstance::createPixmapRuntimeObject(ExecState* exec, PassRefPtr<RootObject> root, const QVariant& data)
index 5683056..41b3e8f 100644 (file)
@@ -1546,7 +1546,7 @@ JSValue QtRuntimeMetaMethod::connectGetter(ExecState* exec, JSValue slotBase, co
     QW_DS(QtRuntimeMetaMethod, thisObj);
 
     if (!d->m_connect)
-        d->m_connect.set(exec->globalData(), thisObj, new (exec) QtRuntimeConnectionMethod(exec, ident, true, d->m_instance, d->m_index, d->m_signature));
+        d->m_connect.set(exec->globalData(), thisObj, QtRuntimeConnectionMethod::create(exec, ident, true, d->m_instance, d->m_index, d->m_signature));
     return d->m_connect.get();
 }
 
@@ -1556,7 +1556,7 @@ JSValue QtRuntimeMetaMethod::disconnectGetter(ExecState* exec, JSValue slotBase,
     QW_DS(QtRuntimeMetaMethod, thisObj);
 
     if (!d->m_disconnect)
-        d->m_disconnect.set(exec->globalData(), thisObj, new (exec) QtRuntimeConnectionMethod(exec, ident, false, d->m_instance, d->m_index, d->m_signature));
+        d->m_disconnect.set(exec->globalData(), thisObj, QtRuntimeConnectionMethod::create(exec, ident, false, d->m_instance, d->m_index, d->m_signature));
     return d->m_disconnect.get();
 }
 
index 3d09481..6f332de 100644 (file)
@@ -23,6 +23,7 @@
 #include "BridgeJSC.h"
 #include "JavaScript.h"
 #include "Weak.h"
+#include "qt_instance.h"
 #include "runtime_method.h"
 
 #include <qbytearray.h>
@@ -33,8 +34,6 @@
 namespace JSC {
 namespace Bindings {
 
-class QtInstance;
-
 class QtField : public Field {
 public:
 
@@ -151,7 +150,10 @@ protected:
 class QtRuntimeMetaMethod : public QtRuntimeMethod
 {
 public:
-    QtRuntimeMetaMethod(ExecState *exec, const Identifier &n, PassRefPtr<QtInstance> inst, int index, const QByteArray& signature, bool allowPrivate);
+    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);
+    }
 
     virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
     virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
@@ -163,6 +165,8 @@ protected:
     QtRuntimeMetaMethodData* d_func() const {return reinterpret_cast<QtRuntimeMetaMethodData*>(d_ptr);}
 
 private:
+    QtRuntimeMetaMethod(ExecState*, const Identifier&, PassRefPtr<QtInstance>, int index, const QByteArray&, bool allowPrivate);
+
     virtual CallType getCallData(CallData&);
     static EncodedJSValue JSC_HOST_CALL call(ExecState* exec);
     static JSValue lengthGetter(ExecState*, JSValue, const Identifier&);
@@ -174,7 +178,10 @@ class QtConnectionObject;
 class QtRuntimeConnectionMethod : public QtRuntimeMethod
 {
 public:
-    QtRuntimeConnectionMethod(ExecState *exec, const Identifier &n, bool isConnect, PassRefPtr<QtInstance> inst, int index, const QByteArray& signature );
+    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);
+    }
 
     virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
     virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
@@ -184,6 +191,8 @@ protected:
     QtRuntimeConnectionMethodData* d_func() const {return reinterpret_cast<QtRuntimeConnectionMethodData*>(d_ptr);}
 
 private:
+    QtRuntimeConnectionMethod(ExecState*, const Identifier&, bool isConnect, PassRefPtr<QtInstance>, int index, const QByteArray&);
+
     virtual CallType getCallData(CallData&);
     static EncodedJSValue JSC_HOST_CALL call(ExecState* exec);
     static JSValue lengthGetter(ExecState*, JSValue, const Identifier&);
index 712a305..fe0e32b 100644 (file)
@@ -35,7 +35,11 @@ namespace JSC {
 
 class RuntimeMethod : public InternalFunction {
 public:
-    RuntimeMethod(ExecState*, JSGlobalObject*, Structure*, const Identifier& name, Bindings::MethodList&);
+    static RuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, const Identifier& name, Bindings::MethodList& methodList)
+    {
+        return new (allocateCell<RuntimeMethod>(*exec->heap())) RuntimeMethod(exec, globalObject, structure, name, methodList);
+    }
+
     Bindings::MethodList* methods() const { return _methodList.get(); }
 
     static const ClassInfo s_info;
@@ -51,6 +55,7 @@ public:
     }
 
 protected:
+    RuntimeMethod(ExecState*, JSGlobalObject*, Structure*, const Identifier& name, Bindings::MethodList&);
     static const unsigned StructureFlags = OverridesGetOwnPropertySlot | InternalFunction::StructureFlags;
 
 private:
index c0e4054..c2268e2 100644 (file)
@@ -1,3 +1,23 @@
+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.
+
+        * 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]):
+
 2011-07-26  Dan Bernstein  <mitz@apple.com>
 
         <rdar://problem/9842889> Add a generic pictograph font family
index 1f96c53..09989ca 100644 (file)
@@ -134,7 +134,7 @@ ProxyInstance::~ProxyInstance()
     
 RuntimeObject* ProxyInstance::newRuntimeObject(ExecState* exec)
 {
-    return new (exec) ProxyRuntimeObject(exec, exec->lexicalGlobalObject(), this);
+    return ProxyRuntimeObject::create(exec, exec->lexicalGlobalObject(), this);
 }
 
 JSC::Bindings::Class* ProxyInstance::getClass() const
@@ -179,12 +179,9 @@ JSValue ProxyInstance::invoke(JSC::ExecState* exec, InvokeType type, uint64_t id
 
 class ProxyRuntimeMethod : public RuntimeMethod {
 public:
-    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)
+    static ProxyRuntimeMethod* create(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
     {
-        ASSERT(inherits(&s_info));
+        return new (allocateCell<ProxyRuntimeMethod>(*exec->heap())) ProxyRuntimeMethod(exec, globalObject, name, list);
     }
 
     static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
@@ -193,6 +190,15 @@ 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)
+    {
+        ASSERT(inherits(&s_info));
+    }
 };
 
 const ClassInfo ProxyRuntimeMethod::s_info = { "ProxyRuntimeMethod", &RuntimeMethod::s_info, 0, 0 };
@@ -200,7 +206,7 @@ const ClassInfo ProxyRuntimeMethod::s_info = { "ProxyRuntimeMethod", &RuntimeMet
 JSValue ProxyInstance::getMethod(JSC::ExecState* exec, const JSC::Identifier& propertyName)
 {
     MethodList methodList = getClass()->methodsNamed(propertyName, this);
-    return new (exec) ProxyRuntimeMethod(exec, exec->lexicalGlobalObject(), propertyName, methodList);
+    return ProxyRuntimeMethod::create(exec, exec->lexicalGlobalObject(), propertyName, methodList);
 }
 
 JSValue ProxyInstance::invokeMethod(ExecState* exec, JSC::RuntimeMethod* runtimeMethod)
index da6de88..f70b66a 100644 (file)
@@ -36,7 +36,11 @@ class ProxyInstance;
 
 class ProxyRuntimeObject : public JSC::Bindings::RuntimeObject {
 public:
-    ProxyRuntimeObject(JSC::ExecState*, JSC::JSGlobalObject*, PassRefPtr<ProxyInstance>);
+    static ProxyRuntimeObject* create(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject, PassRefPtr<ProxyInstance> instance)
+    {
+        return new (JSC::allocateCell<ProxyRuntimeObject>(*exec->heap())) ProxyRuntimeObject(exec, globalObject, instance);
+    }
+
     virtual ~ProxyRuntimeObject();
 
     ProxyInstance* getInternalProxyInstance() const;
@@ -47,6 +51,8 @@ public:
     }
 
     static const JSC::ClassInfo s_info;
+private:
+    ProxyRuntimeObject(JSC::ExecState*, JSC::JSGlobalObject*, PassRefPtr<ProxyInstance>);
 };
 
 }
index 738c4df..25a596c 100644 (file)
@@ -186,7 +186,7 @@ NSString * const WebScriptErrorLineNumberKey = @"WebScriptErrorLineNumber";
     for (ScopeChainIterator it = scopeChain->begin(); it != end; ++it) {
         JSObject* object = it->get();
         if (object->isActivationObject())
-            object = new (scopeChain->globalData) DebuggerActivation(*scopeChain->globalData, object);
+            object = DebuggerActivation::create(*scopeChain->globalData, object);
         [scopes addObject:[self _convertValueToObjcValue:object]];
     }
 
index 5968e57..c4c1953 100644 (file)
@@ -1,3 +1,22 @@
+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.
+
+        * 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):
+
 2011-07-27  Benjamin Poulain  <benjamin@webkit.org>
 
         [WK2][Qt] Move from QGraphicsView to Qt Scene Graph
index 0fd01ea..ecefb16 100644 (file)
@@ -35,13 +35,18 @@ namespace WebKit {
 // A JSObject that wraps an NPMethod.
 class JSNPMethod : public JSC::InternalFunction {
 public:
-    JSNPMethod(JSC::ExecState*, JSC::JSGlobalObject*, const JSC::Identifier&, NPIdentifier);
+    static JSNPMethod* create(JSC::ExecState* exec, JSC::JSGlobalObject* globalObject, const JSC::Identifier& ident, NPIdentifier npIdent)
+    {
+        return new (JSC::allocateCell<JSNPMethod>(*exec->heap())) JSNPMethod(exec, globalObject, ident, npIdent);
+    }
 
     static const JSC::ClassInfo s_info;
 
     NPIdentifier npIdentifier() const { return m_npIdentifier; }
 
 private:    
+    JSNPMethod(JSC::ExecState*, JSC::JSGlobalObject*, const JSC::Identifier&, NPIdentifier);
+
     static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype)
     {
         return JSC::Structure::create(globalData, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
index 51d62f2..2aeaad6 100644 (file)
@@ -454,7 +454,7 @@ JSValue JSNPObject::methodGetter(ExecState* exec, JSValue slotBase, const Identi
         return throwInvalidAccessError(exec);
 
     NPIdentifier npIdentifier = npIdentifierFromIdentifier(methodName);
-    return new (exec) JSNPMethod(exec, thisObj->globalObject(), methodName, npIdentifier);
+    return JSNPMethod::create(exec, thisObj->globalObject(), methodName, npIdentifier);
 }
 
 JSObject* JSNPObject::throwInvalidAccessError(ExecState* exec)
index 7b317ae..abd1d35 100644 (file)
@@ -39,7 +39,11 @@ class NPRuntimeObjectMap;
 
 class JSNPObject : public JSC::JSObjectWithGlobalObject {
 public:
-    JSNPObject(JSC::JSGlobalObject*, NPRuntimeObjectMap* objectMap, NPObject* npObject);
+    static JSNPObject* create(JSC::JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject)
+    {
+        return new (JSC::allocateCell<JSNPObject>(globalObject->globalData().heap)) JSNPObject(globalObject, objectMap, npObject);
+    }
+
     ~JSNPObject();
 
     void invalidate();
@@ -53,6 +57,8 @@ public:
     NPObject* npObject() const { return m_npObject; }
 
 private:
+    JSNPObject(JSC::JSGlobalObject*, NPRuntimeObjectMap*, NPObject*);
+
     static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::OverridesGetPropertyNames | JSObject::StructureFlags;
     
     static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSValue prototype)
index 994fdac..3c3b7a5 100644 (file)
@@ -98,7 +98,7 @@ JSObject* NPRuntimeObjectMap::getOrCreateJSObject(JSGlobalObject* globalObject,
     if (JSC::Weak<JSNPObject> jsNPObject = m_jsNPObjects.get(npObject))
         return jsNPObject.get();
 
-    JSNPObject* jsNPObject = new (&globalObject->globalData()) JSNPObject(globalObject, this, npObject);
+    JSNPObject* jsNPObject = JSNPObject::create(globalObject, this, npObject);
     m_jsNPObjects.set(npObject, JSC::Weak<JSNPObject>(globalObject->globalData(), jsNPObject, this, npObject));
 
     return jsNPObject;