[v8] explicit isolate parameter for MakeWeak calls
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Feb 2013 15:56:52 +0000 (15:56 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Feb 2013 15:56:52 +0000 (15:56 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108818

Patch by Dan Carney <dcarney@google.com> on 2013-02-04
Reviewed by Kentaro Hara.

No new tests. No change in functionality.

* bindings/v8/DOMDataStore.cpp:
(WebCore::DOMDataStore::DOMDataStore):
(WebCore::DOMDataStore::weakCallback):
* bindings/v8/DOMDataStore.h:
(WebCore::DOMDataStore::setWrapper):
(WebCore::DOMDataStore::set):
(WebCore::DOMDataStore::setWrapperInObject):
(DOMDataStore):
* bindings/v8/DOMWrapperMap.h:
(WebCore::DOMWrapperMap::DOMWrapperMap):
(WebCore::DOMWrapperMap::set):
(WebCore::DOMWrapperMap::defaultWeakCallback):
(DOMWrapperMap):
* bindings/v8/DOMWrapperWorld.cpp:
(WebCore::isolatedWorldWeakCallback):
(WebCore::DOMWrapperWorld::makeContextWeak):
* bindings/v8/ScriptState.cpp:
(WebCore::ScriptState::ScriptState):
(WebCore::ScriptState::weakReferenceCallback):
* bindings/v8/ScriptState.h:
(ScriptState):
* bindings/v8/V8AbstractEventListener.cpp:
(WebCore::V8AbstractEventListener::weakEventListenerCallback):
(WebCore::V8AbstractEventListener::V8AbstractEventListener):
(WebCore::V8AbstractEventListener::setListenerObject):
* bindings/v8/V8AbstractEventListener.h:
(V8AbstractEventListener):
* bindings/v8/V8EventListener.cpp:
(WebCore::V8EventListener::V8EventListener):
* bindings/v8/V8LazyEventListener.cpp:
(WebCore::V8LazyEventListener::V8LazyEventListener):
* bindings/v8/V8MutationCallback.cpp:
(WebCore::V8MutationCallback::V8MutationCallback):
* bindings/v8/V8MutationCallback.h:
(WebCore::V8MutationCallback::create):
(WebCore::V8MutationCallback::weakCallback):
* bindings/v8/V8NPObject.cpp:
(WebCore::V8NPTemplateMap::set):
(WebCore::V8NPTemplateMap::sharedInstance):
(WebCore::V8NPTemplateMap::V8NPTemplateMap):
(V8NPTemplateMap):
(WebCore::V8NPTemplateMap::weakCallback):
(WebCore::npObjectGetProperty):
(WebCore):
(WebCore::staticNPObjectMap):
(WebCore::weakNPObjectCallback):
* bindings/v8/V8ValueCache.cpp:
(WebCore::cachedStringCallback):
(WebCore::StringCache::v8ExternalStringSlow):
* bindings/v8/custom/V8InjectedScriptManager.cpp:
(WebCore::WeakReferenceCallback):
(WebCore::createInjectedScriptHostV8Wrapper):
* bindings/v8/custom/V8MutationObserverCustom.cpp:
(WebCore::V8MutationObserver::constructorCallbackCustom):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141771 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/DOMDataStore.cpp
Source/WebCore/bindings/v8/DOMDataStore.h
Source/WebCore/bindings/v8/DOMWrapperMap.h
Source/WebCore/bindings/v8/DOMWrapperWorld.cpp
Source/WebCore/bindings/v8/ScriptState.cpp
Source/WebCore/bindings/v8/ScriptState.h
Source/WebCore/bindings/v8/V8AbstractEventListener.cpp
Source/WebCore/bindings/v8/V8AbstractEventListener.h
Source/WebCore/bindings/v8/V8EventListener.cpp
Source/WebCore/bindings/v8/V8LazyEventListener.cpp
Source/WebCore/bindings/v8/V8MutationCallback.cpp
Source/WebCore/bindings/v8/V8MutationCallback.h
Source/WebCore/bindings/v8/V8NPObject.cpp
Source/WebCore/bindings/v8/V8ValueCache.cpp
Source/WebCore/bindings/v8/custom/V8InjectedScriptManager.cpp
Source/WebCore/bindings/v8/custom/V8MutationObserverCustom.cpp

index 1b746ce8ff9643829e3fba0a4925475cf9ca5879..c4c88dd54d389dc12f08227c4131b080b61a69f2 100644 (file)
@@ -1,3 +1,67 @@
+2013-02-04  Dan Carney  <dcarney@google.com>
+
+        [v8] explicit isolate parameter for MakeWeak calls
+        https://bugs.webkit.org/show_bug.cgi?id=108818
+
+        Reviewed by Kentaro Hara.
+
+        No new tests. No change in functionality.
+
+        * bindings/v8/DOMDataStore.cpp:
+        (WebCore::DOMDataStore::DOMDataStore):
+        (WebCore::DOMDataStore::weakCallback):
+        * bindings/v8/DOMDataStore.h:
+        (WebCore::DOMDataStore::setWrapper):
+        (WebCore::DOMDataStore::set):
+        (WebCore::DOMDataStore::setWrapperInObject):
+        (DOMDataStore):
+        * bindings/v8/DOMWrapperMap.h:
+        (WebCore::DOMWrapperMap::DOMWrapperMap):
+        (WebCore::DOMWrapperMap::set):
+        (WebCore::DOMWrapperMap::defaultWeakCallback):
+        (DOMWrapperMap):
+        * bindings/v8/DOMWrapperWorld.cpp:
+        (WebCore::isolatedWorldWeakCallback):
+        (WebCore::DOMWrapperWorld::makeContextWeak):
+        * bindings/v8/ScriptState.cpp:
+        (WebCore::ScriptState::ScriptState):
+        (WebCore::ScriptState::weakReferenceCallback):
+        * bindings/v8/ScriptState.h:
+        (ScriptState):
+        * bindings/v8/V8AbstractEventListener.cpp:
+        (WebCore::V8AbstractEventListener::weakEventListenerCallback):
+        (WebCore::V8AbstractEventListener::V8AbstractEventListener):
+        (WebCore::V8AbstractEventListener::setListenerObject):
+        * bindings/v8/V8AbstractEventListener.h:
+        (V8AbstractEventListener):
+        * bindings/v8/V8EventListener.cpp:
+        (WebCore::V8EventListener::V8EventListener):
+        * bindings/v8/V8LazyEventListener.cpp:
+        (WebCore::V8LazyEventListener::V8LazyEventListener):
+        * bindings/v8/V8MutationCallback.cpp:
+        (WebCore::V8MutationCallback::V8MutationCallback):
+        * bindings/v8/V8MutationCallback.h:
+        (WebCore::V8MutationCallback::create):
+        (WebCore::V8MutationCallback::weakCallback):
+        * bindings/v8/V8NPObject.cpp:
+        (WebCore::V8NPTemplateMap::set):
+        (WebCore::V8NPTemplateMap::sharedInstance):
+        (WebCore::V8NPTemplateMap::V8NPTemplateMap):
+        (V8NPTemplateMap):
+        (WebCore::V8NPTemplateMap::weakCallback):
+        (WebCore::npObjectGetProperty):
+        (WebCore):
+        (WebCore::staticNPObjectMap):
+        (WebCore::weakNPObjectCallback):
+        * bindings/v8/V8ValueCache.cpp:
+        (WebCore::cachedStringCallback):
+        (WebCore::StringCache::v8ExternalStringSlow):
+        * bindings/v8/custom/V8InjectedScriptManager.cpp:
+        (WebCore::WeakReferenceCallback):
+        (WebCore::createInjectedScriptHostV8Wrapper):
+        * bindings/v8/custom/V8MutationObserverCustom.cpp:
+        (WebCore::V8MutationObserver::constructorCallbackCustom):
+
 2013-02-04  Dmitry Gozman  <dgozman@chromium.org>
 
         Web Inspector: Allow user to change dock side by dragging toolbar
index 18acd9f46870848e20b63a2bc18bc99cb53dde7e..ccb9b8a0c6fd0d158782f94541bb513d2aa23fd8 100644 (file)
@@ -40,6 +40,7 @@ namespace WebCore {
 
 DOMDataStore::DOMDataStore(Type type)
     : m_type(type)
+    , m_wrapperMap(v8::Isolate::GetCurrent()) // FIXME Don't call GetCurrent twice.
 {
     V8PerIsolateData::current()->registerDOMDataStore(this);
 }
@@ -79,7 +80,7 @@ void DOMDataStore::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
     info.addMember(m_wrapperMap, "wrapperMap");
 }
 
-void DOMDataStore::weakCallback(v8::Persistent<v8::Value> value, void* context)
+void DOMDataStore::weakCallback(v8::Isolate* isolate, v8::Persistent<v8::Value> value, void* context)
 {
     ScriptWrappable* key = static_cast<ScriptWrappable*>(context);
     ASSERT(value->IsObject());
index 416e4506bf82bfdd5ac44e4e2929eb1de74c46be..c98b5e41cfea34eec3795afb499270c561301da4 100644 (file)
@@ -93,11 +93,11 @@ public:
     {
         if (mainWorldWrapperIsStoredInObject(object) && isMainWorldObject(object)) {
             if (LIKELY(!DOMWrapperWorld::isolatedWorldsExist())) {
-                setWrapperInObject(object, wrapper);
+                setWrapperInObject(object, wrapper, isolate);
                 return;
             }
         }
-        return current(isolate)->set(object, wrapper);
+        return current(isolate)->set(object, wrapper, isolate);
     }
 
     template<typename T>
@@ -109,12 +109,12 @@ public:
     }
 
     template<typename T>
-    inline void set(T* object, v8::Persistent<v8::Object> wrapper)
+    inline void set(T* object, v8::Persistent<v8::Object> wrapper, v8::Isolate* isolate)
     {
         ASSERT(!!object);
         ASSERT(!wrapper.IsEmpty());
         if (mainWorldWrapperIsStoredInObject(object) && m_type == MainWorld) {
-            setWrapperInObject(object, wrapper);
+            setWrapperInObject(object, wrapper, isolate);
             return;
         }
         m_wrapperMap.set(object, wrapper);
@@ -154,25 +154,25 @@ private:
         return object->wrapper();
     }
 
-    static void setWrapperInObject(void*, v8::Persistent<v8::Object>)
+    static void setWrapperInObject(void*, v8::Persistent<v8::Object>, v8::Isolate*)
     {
         ASSERT_NOT_REACHED();
     }
-    static void setWrapperInObject(ScriptWrappable* object, v8::Persistent<v8::Object> wrapper)
+    static void setWrapperInObject(ScriptWrappable* object, v8::Persistent<v8::Object> wrapper, v8::Isolate* isolate)
     {
         ASSERT(object->wrapper().IsEmpty());
         object->setWrapper(wrapper);
-        wrapper.MakeWeak(object, weakCallback);
+        wrapper.MakeWeak(isolate, object, weakCallback);
     }
-    static void setWrapperInObject(Node* object, v8::Persistent<v8::Object> wrapper)
+    static void setWrapperInObject(Node* object, v8::Persistent<v8::Object> wrapper, v8::Isolate* isolate)
     {
         ASSERT(object->wrapper().IsEmpty());
         object->setWrapper(wrapper);
         V8GCController::didCreateWrapperForNode(object);
-        wrapper.MakeWeak(static_cast<ScriptWrappable*>(object), weakCallback);
+        wrapper.MakeWeak(isolate, static_cast<ScriptWrappable*>(object), weakCallback);
     }
 
-    static void weakCallback(v8::Persistent<v8::Value>, void* context);
+    static void weakCallback(v8::Isolate*, v8::Persistent<v8::Value>, void* context);
 
     Type m_type;
     DOMWrapperMap<void> m_wrapperMap;
index 7e8f266e53018af8d33f00d3eb70d695738bd864..00c03e0974370c685123eb4e5e568f3c8784c994 100644 (file)
@@ -44,8 +44,9 @@ class DOMWrapperMap {
 public:
     typedef HashMap<KeyType*, v8::Persistent<v8::Object> > MapType;
 
-    explicit DOMWrapperMap(v8::WeakReferenceCallback callback = &defaultWeakCallback)
+    explicit DOMWrapperMap(v8::Isolate* isolate, v8::NearDeathCallback callback = &defaultWeakCallback)
         : m_callback(callback)
+        , m_isolate(isolate)
     {
     }
 
@@ -58,7 +59,7 @@ public:
     {
         ASSERT(!m_map.contains(key));
         ASSERT(static_cast<KeyType*>(toNative(wrapper)) == key);
-        wrapper.MakeWeak(this, m_callback);
+        wrapper.MakeWeak(m_isolate, this, m_callback);
         m_map.set(key, wrapper);
     }
 
@@ -89,7 +90,7 @@ public:
     }
 
 private:
-    static void defaultWeakCallback(v8::Persistent<v8::Value> value, void* context)
+    static void defaultWeakCallback(v8::Isolate* isolate, v8::Persistent<v8::Value> value, void* context)
     {
         DOMWrapperMap<KeyType>* map = static_cast<DOMWrapperMap<KeyType>*>(context);
         ASSERT(value->IsObject());
@@ -104,7 +105,8 @@ private:
         type->derefObject(key);
     }
 
-    v8::WeakReferenceCallback m_callback;
+    v8::NearDeathCallback m_callback;
+    v8::Isolate* m_isolate;
     MapType m_map;
 };
 
index 91470a7454a2a01771d038541bf5b93c76d7478b..fee2f7863010f59982c32e3a9bc668ae8467fd87 100644 (file)
@@ -75,7 +75,7 @@ void DOMWrapperWorld::assertContextHasCorrectPrototype(v8::Handle<v8::Context> c
 }
 #endif
 
-static void isolatedWorldWeakCallback(v8::Persistent<v8::Value> object, void* parameter)
+static void isolatedWorldWeakCallback(v8::Isolate* isolate, v8::Persistent<v8::Value> object, void* parameter)
 {
     object.Dispose();
     object.Clear();
@@ -86,7 +86,7 @@ void DOMWrapperWorld::makeContextWeak(v8::Handle<v8::Context> context)
 {
     ASSERT(isIsolatedWorld());
     ASSERT(isolated(context) == this);
-    v8::Persistent<v8::Context>::New(context).MakeWeak(this, isolatedWorldWeakCallback);
+    v8::Persistent<v8::Context>::New(context).MakeWeak(context->GetIsolate(), this, isolatedWorldWeakCallback);
     // Matching deref is in weak callback.
     this->ref();
 }
index 722232a33c3e3a62d0a511dded92ada087a5660d..ea1e08c984f3e23c89c2d84e1e8b7c86c4ec280f 100644 (file)
@@ -48,7 +48,7 @@ namespace WebCore {
 ScriptState::ScriptState(v8::Handle<v8::Context> context)
     : m_context(context)
 {
-    m_context.get().MakeWeak(this, &ScriptState::weakReferenceCallback);
+    m_context.get().MakeWeak(context->GetIsolate(), this, &ScriptState::weakReferenceCallback);
 }
 
 ScriptState::~ScriptState()
@@ -90,7 +90,7 @@ ScriptState* ScriptState::current()
     return ScriptState::forContext(context);
 }
 
-void ScriptState::weakReferenceCallback(v8::Persistent<v8::Value> object, void* parameter)
+void ScriptState::weakReferenceCallback(v8::Isolate* isolate, v8::Persistent<v8::Value> object, void* parameter)
 {
     ScriptState* scriptState = static_cast<ScriptState*>(parameter);
     delete scriptState;
index 4e14cbe36b25b8c98531325ce9824963c2e083a9..7f8f78c8b68467bde51dc520709d57e8283fd791 100644 (file)
@@ -82,7 +82,7 @@ private:
     friend ScriptState* mainWorldScriptState(Frame*);
     explicit ScriptState(v8::Handle<v8::Context>);
 
-    static void weakReferenceCallback(v8::Persistent<v8::Value> object, void* parameter);
+    static void weakReferenceCallback(v8::Isolate*, v8::Persistent<v8::Value>, void* parameter);
 
     v8::Local<v8::Value> m_exception;
     ScopedPersistent<v8::Context> m_context;
index 464a381eb58275002f9b4bd09c78795d8943304f..33b9366e865120cf188dd04d2eb9176a2aa12d59 100644 (file)
 
 namespace WebCore {
 
-void V8AbstractEventListener::weakEventListenerCallback(v8::Persistent<v8::Value>, void* parameter)
+void V8AbstractEventListener::weakEventListenerCallback(v8::Isolate* isolate, v8::Persistent<v8::Value>, void* parameter)
 {
     V8AbstractEventListener* listener = static_cast<V8AbstractEventListener*>(parameter);
     listener->m_listener.clear();
 }
 
-V8AbstractEventListener::V8AbstractEventListener(bool isAttribute, const WorldContextHandle& worldContext)
+V8AbstractEventListener::V8AbstractEventListener(bool isAttribute, const WorldContextHandle& worldContext, v8::Isolate* isolate)
     : EventListener(JSEventListenerType)
     , m_isAttribute(isAttribute)
     , m_worldContext(worldContext)
+    , m_isolate(isolate)
 {
 #if ENABLE(INSPECTOR)
     ThreadLocalInspectorCounters::current().incrementCounter(ThreadLocalInspectorCounters::JSEventListenerCounter);
@@ -105,7 +106,7 @@ void V8AbstractEventListener::handleEvent(ScriptExecutionContext* context, Event
 void V8AbstractEventListener::setListenerObject(v8::Handle<v8::Object> listener)
 {
     m_listener.set(listener);
-    m_listener.get().MakeWeak(this, &V8AbstractEventListener::weakEventListenerCallback);
+    m_listener.get().MakeWeak(m_isolate, this, &V8AbstractEventListener::weakEventListenerCallback);
 }
 
 void V8AbstractEventListener::invokeEventHandler(ScriptExecutionContext* context, Event* event, v8::Handle<v8::Value> jsEvent)
index 61b794f95ebceecf93df0eeb6f7c0ca3208d307c..1201b188774b27a9bfb8a698ab803a5696851f07 100644 (file)
@@ -106,7 +106,7 @@ namespace WebCore {
         const WorldContextHandle& worldContext() const { return m_worldContext; }
 
     protected:
-        V8AbstractEventListener(bool isAttribute, const WorldContextHandle& worldContext);
+        V8AbstractEventListener(bool isAttribute, const WorldContextHandle&, v8::Isolate*);
 
         virtual void prepareListenerObject(ScriptExecutionContext*) { }
 
@@ -118,7 +118,7 @@ namespace WebCore {
         v8::Local<v8::Object> getReceiverObject(ScriptExecutionContext*, Event*);
 
     private:
-        static void weakEventListenerCallback(v8::Persistent<v8::Value>, void* parameter);
+        static void weakEventListenerCallback(v8::Isolate*, v8::Persistent<v8::Value>, void* parameter);
 
         // Implementation of EventListener function.
         virtual bool virtualisAttribute() const { return m_isAttribute; }
@@ -133,6 +133,7 @@ namespace WebCore {
         bool m_isAttribute;
 
         WorldContextHandle m_worldContext;
+        v8::Isolate* m_isolate;
     };
 
 } // namespace WebCore
index 1281f594b61c4f7fb5ad88a4f7a2d2885f6f3275..871c328b253aa932cf1228e2193e4d00bf4e68a0 100644 (file)
@@ -41,7 +41,7 @@
 namespace WebCore {
 
 V8EventListener::V8EventListener(v8::Local<v8::Object> listener, bool isAttribute, const WorldContextHandle& worldContext)
-    : V8AbstractEventListener(isAttribute, worldContext)
+    : V8AbstractEventListener(isAttribute, worldContext, v8::Isolate::GetCurrent()) // FIXME: Remove GetCurrent().
 {
     setListenerObject(listener);
 }
index 04da4de56c8430ffac40b883f84dca7d63e7b4a8..fb0c9c35d20a7fb1325ddde74d046b138d5f9711 100644 (file)
@@ -52,7 +52,7 @@
 namespace WebCore {
 
 V8LazyEventListener::V8LazyEventListener(const AtomicString& functionName, const AtomicString& eventParameterName, const String& code, const String sourceURL, const TextPosition& position, Node* node, const WorldContextHandle& worldContext)
-    : V8AbstractEventListener(true, worldContext)
+    : V8AbstractEventListener(true, worldContext, v8::Isolate::GetCurrent()) // FIXME Remove GetCurrent()
     , m_functionName(functionName)
     , m_eventParameterName(eventParameterName)
     , m_code(code)
index 7ed3961cab1358c310a349bd951ec2aa6fae5d43..029aee8e0c0bc25ec6d710c720ceaff874eae5d2 100644 (file)
 
 namespace WebCore {
 
-V8MutationCallback::V8MutationCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
+V8MutationCallback::V8MutationCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner, v8::Isolate* isolate)
     : ActiveDOMCallback(context)
     , m_callback(callback)
     , m_worldContext(UseCurrentWorld)
 {
     owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
-    m_callback.get().MakeWeak(this, &V8MutationCallback::weakCallback);
+    m_callback.get().MakeWeak(isolate, this, &V8MutationCallback::weakCallback);
 }
 
 bool V8MutationCallback::handleEvent(MutationRecordArray* mutations, MutationObserver* observer)
index 8b5f3e2945bca55ed4a6e99ec9facac01a5dc2c5..5a3664298a368dfd4faa3f746b3b4a50216e9965 100644 (file)
@@ -38,20 +38,20 @@ class ScriptExecutionContext;
 
 class V8MutationCallback : public MutationCallback, public ActiveDOMCallback {
 public:
-    static PassRefPtr<V8MutationCallback> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
+    static PassRefPtr<V8MutationCallback> create(v8::Handle<v8::Value> value, ScriptExecutionContext* context, v8::Handle<v8::Object> owner, v8::Isolate* isolate)
     {
         ASSERT(value->IsObject());
         ASSERT(context);
-        return adoptRef(new V8MutationCallback(v8::Handle<v8::Object>::Cast(value), context, owner));
+        return adoptRef(new V8MutationCallback(v8::Handle<v8::Object>::Cast(value), context, owner, isolate));
     }
 
     virtual bool handleEvent(MutationRecordArray*, MutationObserver*) OVERRIDE;
     virtual ScriptExecutionContext* scriptExecutionContext() const OVERRIDE { return ContextDestructionObserver::scriptExecutionContext(); }
 
 private:
-    V8MutationCallback(v8::Handle<v8::Object>, ScriptExecutionContext*, v8::Handle<v8::Object>);
+    V8MutationCallback(v8::Handle<v8::Object>, ScriptExecutionContext*, v8::Handle<v8::Object>, v8::Isolate*);
 
-    static void weakCallback(v8::Persistent<v8::Value> wrapper, void* parameter)
+    static void weakCallback(v8::Isolate* isolate, v8::Persistent<v8::Value> wrapper, void* parameter)
     {
         V8MutationCallback* object = static_cast<V8MutationCallback*>(parameter);
         object->m_callback.clear();
index 1074dc5b12297f90985ecc84b9ac50aa377f65e9..d8e5845dfcc02ac90ef8ce90b43f9576cf1845ec 100644 (file)
@@ -175,19 +175,25 @@ public:
     {
         ASSERT(!m_map.contains(key));
         m_map.set(key, wrapper);
-        wrapper.MakeWeak(key, weakCallback);
+        wrapper.MakeWeak(m_isolate, key, weakCallback);
     }
 
-    static V8NPTemplateMap& sharedInstance()
+    static V8NPTemplateMap& sharedInstance(v8::Isolate* isolate)
     {
-        DEFINE_STATIC_LOCAL(V8NPTemplateMap, map, ());
+        DEFINE_STATIC_LOCAL(V8NPTemplateMap, map, (isolate));
+        ASSERT(isolate == map.m_isolate);
         return map;
     }
 
 private:
-    static void weakCallback(v8::Persistent<v8::Value> object, void* context)
+    explicit V8NPTemplateMap(v8::Isolate* isolate)
+        : m_isolate(isolate)
     {
-        sharedInstance().dispose(static_cast<PrivateIdentifier*>(context));
+    }
+
+    static void weakCallback(v8::Isolate* isolate, v8::Persistent<v8::Value> object, void* context)
+    {
+        sharedInstance(isolate).dispose(static_cast<PrivateIdentifier*>(context));
     }
 
     void dispose(PrivateIdentifier* key)
@@ -200,6 +206,7 @@ private:
     }
 
     MapType m_map;
+    v8::Isolate* m_isolate;
 };
 
 static v8::Handle<v8::Value> npObjectGetProperty(v8::Local<v8::Object> self, NPIdentifier identifier, v8::Local<v8::Value> key, v8::Isolate* isolate)
@@ -237,14 +244,14 @@ static v8::Handle<v8::Value> npObjectGetProperty(v8::Local<v8::Object> self, NPI
             return throwError(v8ReferenceError, "NPObject deleted", isolate);
 
         PrivateIdentifier* id = static_cast<PrivateIdentifier*>(identifier);
-        v8::Persistent<v8::FunctionTemplate> functionTemplate = V8NPTemplateMap::sharedInstance().get(id);
+        v8::Persistent<v8::FunctionTemplate> functionTemplate = V8NPTemplateMap::sharedInstance(isolate).get(id);
         // Cache templates using identifier as the key.
         if (functionTemplate.IsEmpty()) {
             // Create a new template.
             v8::Local<v8::FunctionTemplate> temp = v8::FunctionTemplate::New();
             temp->SetCallHandler(npObjectMethodHandler, key);
             functionTemplate = v8::Persistent<v8::FunctionTemplate>::New(temp);
-            V8NPTemplateMap::sharedInstance().set(id, functionTemplate);
+            V8NPTemplateMap::sharedInstance(isolate).set(id, functionTemplate);
         }
 
         // FunctionTemplate caches function for each context.
@@ -376,15 +383,15 @@ v8::Handle<v8::Array> npObjectIndexedPropertyEnumerator(const v8::AccessorInfo&
     return npObjectPropertyEnumerator(info, false);
 }
 
-static void weakNPObjectCallback(v8::Persistent<v8::Value>, void*);
+static void weakNPObjectCallback(v8::Isolate*, v8::Persistent<v8::Value>, void*);
 
 static DOMWrapperMap<NPObject>& staticNPObjectMap()
 {
-    DEFINE_STATIC_LOCAL(DOMWrapperMap<NPObject>, npObjectMap, (&weakNPObjectCallback));
+    DEFINE_STATIC_LOCAL(DOMWrapperMap<NPObject>, npObjectMap, (v8::Isolate::GetCurrent(), &weakNPObjectCallback));
     return npObjectMap;
 }
 
-static void weakNPObjectCallback(v8::Persistent<v8::Value> value, void*)
+static void weakNPObjectCallback(v8::Isolate* isolate, v8::Persistent<v8::Value> value, void*)
 {
     ASSERT(value->IsObject());
     v8::Persistent<v8::Object> wrapper = v8::Persistent<v8::Object>::Cast(value);
index 981487c244b407b6e4598e9ef2d55311a4c19308..7c4ee3b47691955562ef5c2b8fd2a9e0dfdb4164 100644 (file)
@@ -62,7 +62,7 @@ static v8::Local<v8::String> makeExternalString(const String& string)
     return newString;
 }
 
-static void cachedStringCallback(v8::Persistent<v8::Value> wrapper, void* parameter)
+static void cachedStringCallback(v8::Isolate* isolate, v8::Persistent<v8::Value> wrapper, void* parameter)
 {
     StringImpl* stringImpl = static_cast<StringImpl*>(parameter);
     V8PerIsolateData::current()->stringCache()->remove(stringImpl);
@@ -107,7 +107,7 @@ v8::Handle<v8::String> StringCache::v8ExternalStringSlow(StringImpl* stringImpl,
 
     stringImpl->ref();
     wrapper.MarkIndependent();
-    wrapper.MakeWeak(stringImpl, cachedStringCallback);
+    wrapper.MakeWeak(isolate, stringImpl, cachedStringCallback);
     m_stringCache.set(stringImpl, *wrapper);
 
     m_lastStringImpl = stringImpl;
index 45fa8628904d1db749e8aa29ae2ffccfba7b0d24..1c1891852923ed736c8c5271ab39160d77cb037a 100644 (file)
@@ -45,7 +45,7 @@
 
 namespace WebCore {
 
-static void WeakReferenceCallback(v8::Persistent<v8::Value> object, void* parameter)
+static void WeakReferenceCallback(v8::Isolate* isolate, v8::Persistent<v8::Value> object, void* parameter)
 {
     InjectedScriptHost* nativeObject = static_cast<InjectedScriptHost*>(parameter);
     nativeObject->deref();
@@ -70,7 +70,7 @@ static v8::Local<v8::Object> createInjectedScriptHostV8Wrapper(InjectedScriptHos
     // InspectorBackend when the wrapper is garbage collected.
     host->ref();
     v8::Persistent<v8::Object> weakHandle = v8::Persistent<v8::Object>::New(instance);
-    weakHandle.MakeWeak(host, &WeakReferenceCallback);
+    weakHandle.MakeWeak(isolate, host, &WeakReferenceCallback);
     return instance;
 }
 
index 41e8c63d48779c4c46304c58923c6b92476bd1eb..977bcb38f6d03c256c402406cbc8a1da04ffe58a 100644 (file)
@@ -53,7 +53,7 @@ v8::Handle<v8::Value> V8MutationObserver::constructorCallbackCustom(const v8::Ar
     ScriptExecutionContext* context = getScriptExecutionContext();
     v8::Handle<v8::Object> wrapper = args.Holder();
 
-    RefPtr<MutationCallback> callback = V8MutationCallback::create(arg, context, wrapper);
+    RefPtr<MutationCallback> callback = V8MutationCallback::create(arg, context, wrapper, args.GetIsolate());
     RefPtr<MutationObserver> observer = MutationObserver::create(callback.release());
 
     V8DOMWrapper::associateObjectWithWrapper(observer.release(), &info, wrapper, args.GetIsolate());