Unreviewed, rolling out r125884.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Aug 2012 21:11:07 +0000 (21:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 20 Aug 2012 21:11:07 +0000 (21:11 +0000)
http://trac.webkit.org/changeset/125884
https://bugs.webkit.org/show_bug.cgi?id=94523

Appears to be causing a top crash in the Canary channel
(Requested by abarth on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-08-20

* UseV8.cmake:
* WebCore.gypi:
* bindings/v8/DOMWrapperWorld.cpp:
(WebCore::DOMWrapperWorld::DOMWrapperWorld):
(WebCore::mainThreadNormalWorld):
* bindings/v8/DOMWrapperWorld.h:
(WebCore):
(WebCore::DOMWrapperWorld::create):
(WebCore::DOMWrapperWorld::~DOMWrapperWorld):
(DOMWrapperWorld):
* bindings/v8/IsolatedWorld.cpp: Copied from Source/WebCore/bindings/v8/DOMWrapperWorld.cpp.
(WebCore):
(WebCore::IsolatedWorld::IsolatedWorld):
(WebCore::IsolatedWorld::~IsolatedWorld):
* bindings/v8/IsolatedWorld.h: Copied from Source/WebCore/bindings/v8/DOMWrapperWorld.h.
(WebCore):
(IsolatedWorld):
(WebCore::IsolatedWorld::create):
(WebCore::IsolatedWorld::count):
(WebCore::IsolatedWorld::id):
(WebCore::IsolatedWorld::domDataStore):
* bindings/v8/V8DOMWrapper.h:
(WebCore::V8DOMWrapper::getCachedWrapper):
* bindings/v8/V8IsolatedContext.cpp:
(WebCore::V8IsolatedContext::V8IsolatedContext):
(WebCore::V8IsolatedContext::destroy):
* bindings/v8/V8IsolatedContext.h:
(WebCore::V8IsolatedContext::getEntered):
(WebCore::V8IsolatedContext::world):
(V8IsolatedContext):
* bindings/v8/V8PerIsolateData.h:
(WebCore::V8PerIsolateData::registerDOMDataStore):
(WebCore::V8PerIsolateData::unregisterDOMDataStore):

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

Source/WebCore/ChangeLog
Source/WebCore/UseV8.cmake
Source/WebCore/WebCore.gypi
Source/WebCore/bindings/v8/DOMWrapperWorld.cpp
Source/WebCore/bindings/v8/DOMWrapperWorld.h
Source/WebCore/bindings/v8/IsolatedWorld.cpp [new file with mode: 0644]
Source/WebCore/bindings/v8/IsolatedWorld.h [new file with mode: 0644]
Source/WebCore/bindings/v8/V8DOMWrapper.h
Source/WebCore/bindings/v8/V8IsolatedContext.cpp
Source/WebCore/bindings/v8/V8IsolatedContext.h
Source/WebCore/bindings/v8/V8PerIsolateData.h

index dd27f89..5143ded 100644 (file)
@@ -1,3 +1,46 @@
+2012-08-20  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r125884.
+        http://trac.webkit.org/changeset/125884
+        https://bugs.webkit.org/show_bug.cgi?id=94523
+
+        Appears to be causing a top crash in the Canary channel
+        (Requested by abarth on #webkit).
+
+        * UseV8.cmake:
+        * WebCore.gypi:
+        * bindings/v8/DOMWrapperWorld.cpp:
+        (WebCore::DOMWrapperWorld::DOMWrapperWorld):
+        (WebCore::mainThreadNormalWorld):
+        * bindings/v8/DOMWrapperWorld.h:
+        (WebCore):
+        (WebCore::DOMWrapperWorld::create):
+        (WebCore::DOMWrapperWorld::~DOMWrapperWorld):
+        (DOMWrapperWorld):
+        * bindings/v8/IsolatedWorld.cpp: Copied from Source/WebCore/bindings/v8/DOMWrapperWorld.cpp.
+        (WebCore):
+        (WebCore::IsolatedWorld::IsolatedWorld):
+        (WebCore::IsolatedWorld::~IsolatedWorld):
+        * bindings/v8/IsolatedWorld.h: Copied from Source/WebCore/bindings/v8/DOMWrapperWorld.h.
+        (WebCore):
+        (IsolatedWorld):
+        (WebCore::IsolatedWorld::create):
+        (WebCore::IsolatedWorld::count):
+        (WebCore::IsolatedWorld::id):
+        (WebCore::IsolatedWorld::domDataStore):
+        * bindings/v8/V8DOMWrapper.h:
+        (WebCore::V8DOMWrapper::getCachedWrapper):
+        * bindings/v8/V8IsolatedContext.cpp:
+        (WebCore::V8IsolatedContext::V8IsolatedContext):
+        (WebCore::V8IsolatedContext::destroy):
+        * bindings/v8/V8IsolatedContext.h:
+        (WebCore::V8IsolatedContext::getEntered):
+        (WebCore::V8IsolatedContext::world):
+        (V8IsolatedContext):
+        * bindings/v8/V8PerIsolateData.h:
+        (WebCore::V8PerIsolateData::registerDOMDataStore):
+        (WebCore::V8PerIsolateData::unregisterDOMDataStore):
+
 2012-08-20  Chris Rogers  <crogers@google.com>
 
         Remove improper ASSERT in AudioParamTimeline::valuesForTimeRangeImpl()
index 36ee62b..29d7e58 100755 (executable)
@@ -25,6 +25,7 @@ LIST(APPEND WebCore_SOURCES
     bindings/v8/DateExtension.cpp
     bindings/v8/IDBBindingUtilities.cpp
     bindings/v8/IDBCustomBindings.cpp
+    bindings/v8/IsolatedWorld.cpp
     bindings/v8/Dictionary.cpp
     bindings/v8/PageScriptDebugServer.cpp
     bindings/v8/RetainedDOMInfo.cpp
index 96c676d..952b800 100644 (file)
             'bindings/v8/IDBBindingUtilities.h',
             'bindings/v8/IDBCustomBindings.cpp',
             'bindings/v8/IntrusiveDOMWrapperMap.h',
+            'bindings/v8/IsolatedWorld.cpp',
+            'bindings/v8/IsolatedWorld.h',
             'bindings/v8/JavaScriptCallFrame.cpp',
             'bindings/v8/JavaScriptCallFrame.h',
             'bindings/v8/NPObjectWrapper.cpp',
index eed882b..6a9c6db 100644 (file)
 
 namespace WebCore {
 
-int DOMWrapperWorld::isolatedWorldCount = 0;
+DOMWrapperWorld::DOMWrapperWorld()
+{
+    // This class is pretty boring, huh?
+}
 
 DOMWrapperWorld* mainThreadNormalWorld()
 {
     ASSERT(isMainThread());
-    DEFINE_STATIC_LOCAL(RefPtr<DOMWrapperWorld>, cachedNormalWorld, (DOMWrapperWorld::create(DOMWrapperWorld::mainWorldId)));
+    DEFINE_STATIC_LOCAL(RefPtr<DOMWrapperWorld>, cachedNormalWorld, (DOMWrapperWorld::create()));
     return cachedNormalWorld.get();
 }
 
index 7b9f331..2a9df30 100644 (file)
@@ -31,7 +31,6 @@
 #ifndef DOMWrapperWorld_h
 #define DOMWrapperWorld_h
 
-#include "DOMDataStore.h"
 #include <wtf/PassRefPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 namespace WebCore {
 
 // This class represent a collection of DOM wrappers for a specific world.
+// The base class is pretty boring because the wrappers are actually stored
+// statically in V8DOMMap and garbage collected by V8 itself.
 class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
 public:
-    static const int mainWorldId = -1;
-    static PassRefPtr<DOMWrapperWorld> create(int worldId = mainWorldId) { return adoptRef(new DOMWrapperWorld(worldId)); }
-    ~DOMWrapperWorld()
-    {
-        if (m_worldId != mainWorldId)
-            isolatedWorldCount--;
-    }
-    static int count() { return isolatedWorldCount; }
+    static PassRefPtr<DOMWrapperWorld> create() { return adoptRef(new DOMWrapperWorld()); }
+    virtual ~DOMWrapperWorld() {}
 
-    int worldId() const { return m_worldId; }
-    DOMDataStore* domDataStore() const { return m_domDataStore.getStore(); }
-
-private:
-    DOMWrapperWorld(int worldId)
-        : m_worldId(worldId)
-    {
-        if (m_worldId != mainWorldId)
-            isolatedWorldCount++;
-    }
-
-    // The backing store for the isolated world's DOM wrappers. This class
-    // doesn't have visibility into the wrappers. This handle simply helps
-    // manage their lifetime.
-    DOMDataStoreHandle m_domDataStore;
-
-    const int m_worldId;
-    static int isolatedWorldCount;
+protected:
+    DOMWrapperWorld();
 };
 
 DOMWrapperWorld* mainThreadNormalWorld();
diff --git a/Source/WebCore/bindings/v8/IsolatedWorld.cpp b/Source/WebCore/bindings/v8/IsolatedWorld.cpp
new file mode 100644 (file)
index 0000000..3686461
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "IsolatedWorld.h"
+
+namespace WebCore {
+
+int IsolatedWorld::isolatedWorldCount = 0;
+
+IsolatedWorld::IsolatedWorld(int id)
+{
+    ++isolatedWorldCount;
+    m_id = id;
+}
+
+IsolatedWorld::~IsolatedWorld()
+{
+    --isolatedWorldCount;
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/bindings/v8/IsolatedWorld.h b/Source/WebCore/bindings/v8/IsolatedWorld.h
new file mode 100644 (file)
index 0000000..53e3476
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef IsolatedWorld_h
+#define IsolatedWorld_h
+
+#include "DOMWrapperWorld.h"
+#include "V8DOMMap.h"
+
+namespace WebCore {
+
+// An DOMWrapperWorld other than the thread's normal world.
+class IsolatedWorld : public DOMWrapperWorld {
+public:
+    static PassRefPtr<IsolatedWorld> create(int id) { return adoptRef(new IsolatedWorld(id)); }
+    static int count() { return isolatedWorldCount; }
+
+    int id() const { return m_id; }
+    DOMDataStore* domDataStore() const { return m_domDataStore.getStore(); }
+
+protected:
+    explicit IsolatedWorld(int id);
+    ~IsolatedWorld();
+
+private:
+    int m_id;
+
+    // The backing store for the isolated world's DOM wrappers.  This class
+    // doesn't have visibility into the wrappers.  This handle simply helps
+    // manage their lifetime.
+    DOMDataStoreHandle m_domDataStore;
+
+    static int isolatedWorldCount;
+};
+
+} // namespace WebCore
+
+#endif // IsolatedWorld_h
index 142be5a..d9e8059 100644 (file)
@@ -33,6 +33,7 @@
 
 #include "DOMDataStore.h"
 #include "Event.h"
+#include "IsolatedWorld.h"
 #include "Node.h"
 #include "NodeFilter.h"
 #include "PlatformString.h"
@@ -129,7 +130,7 @@ namespace WebCore {
         static v8::Handle<v8::Object> getCachedWrapper(Node* node)
         {
             ASSERT(isMainThread());
-            if (LIKELY(!DOMWrapperWorld::count())) {
+            if (LIKELY(!IsolatedWorld::count())) {
                 v8::Persistent<v8::Object>* wrapper = node->wrapper();
                 if (LIKELY(!!wrapper))
                     return *wrapper;
index 5de8de3..fc1037e 100644 (file)
@@ -66,7 +66,7 @@ static void setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContex
 }
 
 V8IsolatedContext::V8IsolatedContext(V8Proxy* proxy, int extensionGroup, int worldId)
-    : m_world(DOMWrapperWorld::create(worldId)),
+    : m_world(IsolatedWorld::create(worldId)),
       m_frame(proxy->frame())
 {
     v8::HandleScope scope;
@@ -75,7 +75,7 @@ V8IsolatedContext::V8IsolatedContext(V8Proxy* proxy, int extensionGroup, int wor
         return;
 
     // FIXME: We should be creating a new V8DOMWindowShell here instead of riping out the context.
-    m_context = SharedPersistent<v8::Context>::create(proxy->windowShell()->createNewContext(v8::Handle<v8::Object>(), extensionGroup, m_world->worldId()));
+    m_context = SharedPersistent<v8::Context>::create(proxy->windowShell()->createNewContext(v8::Handle<v8::Object>(), extensionGroup, m_world->id()));
     if (m_context->get().IsEmpty())
         return;
 
@@ -100,13 +100,13 @@ V8IsolatedContext::V8IsolatedContext(V8Proxy* proxy, int extensionGroup, int wor
     //        changes.
     m_context->get()->UseDefaultSecurityToken();
 
-    m_frame->loader()->client()->didCreateScriptContext(context(), extensionGroup, m_world->worldId());
+    m_frame->loader()->client()->didCreateScriptContext(context(), extensionGroup, m_world->id());
 }
 
 void V8IsolatedContext::destroy()
 {
     m_perContextData.clear();
-    m_frame->loader()->client()->willReleaseScriptContext(context(), m_world->worldId());
+    m_frame->loader()->client()->willReleaseScriptContext(context(), m_world->id());
     m_context->get().MakeWeak(this, &contextWeakReferenceCallback);
     m_frame = 0;
 }
index 591e05b..ecd3f6e 100644 (file)
@@ -31,7 +31,7 @@
 #ifndef V8IsolatedContext_h
 #define V8IsolatedContext_h
 
-#include "DOMWrapperWorld.h"
+#include "IsolatedWorld.h"
 #include "ScriptSourceCode.h" // for WebCore::ScriptSourceCode
 #include "SharedPersistent.h"
 #include "V8Utilities.h"
@@ -82,7 +82,7 @@ public:
         // V8 team to add a real property to v8::Context for isolated worlds.
         // Until then, we optimize the common case of not having any isolated
         // worlds at all.
-        if (!DOMWrapperWorld::count())
+        if (!IsolatedWorld::count())
             return 0;
         if (!v8::Context::InContext())
             return 0;
@@ -92,7 +92,7 @@ public:
     v8::Handle<v8::Context> context() { return m_context->get(); }
     PassRefPtr<SharedPersistent<v8::Context> > sharedContext() { return m_context; }
 
-    DOMWrapperWorld* world() const { return m_world.get(); }
+    IsolatedWorld* world() const { return m_world.get(); }
 
     SecurityOrigin* securityOrigin() const { return m_securityOrigin.get(); }
     void setSecurityOrigin(PassRefPtr<SecurityOrigin>);
@@ -115,7 +115,7 @@ private:
     // long as |m_context| has not been garbage collected.
     RefPtr<SharedPersistent<v8::Context> > m_context;
 
-    RefPtr<DOMWrapperWorld> m_world;
+    RefPtr<IsolatedWorld> m_world;
 
     RefPtr<SecurityOrigin> m_securityOrigin;
 
index b2cdd4d..72da77e 100644 (file)
@@ -90,13 +90,12 @@ public:
 
     void registerDOMDataStore(DOMDataStore* domDataStore) 
     {
-        ASSERT(m_domDataList.find(domDataStore) == notFound);
         m_domDataList.append(domDataStore);
     }
 
     void unregisterDOMDataStore(DOMDataStore* domDataStore)
     {
-        ASSERT(m_domDataList.find(domDataStore) != notFound);
+        ASSERT(m_domDataList.find(domDataStore));
         m_domDataList.remove(m_domDataList.find(domDataStore));
     }