Title: [134372] trunk/Source/WebCore
Revision
134372
Author
[email protected]
Date
2012-11-12 23:32:07 -0800 (Mon, 12 Nov 2012)

Log Message

[V8] We should be able to recover the V8DOMWindowShell more quickly
https://bugs.webkit.org/show_bug.cgi?id=102020

Reviewed by Kentaro Hara.

For isolated worlds, we used to store the V8DOMWindowShell as an
internal field of the inner DOM window. This patch moves the pointer to
an internal field of the v8::Context, which saves us the work of
looking up the inner DOM window.

Unfortunately, we cannot store the V8DOMWindowShell in V8PerContextData
because the V8DOMWindowShell outlives the V8PerContextData. (We destroy
the V8PerContextData when we detach the V8DOMWindowShell from the
frame.)

* bindings/scripts/CodeGeneratorV8.pm:
(GetInternalFields):
* bindings/v8/V8DOMWindowShell.cpp:
(WebCore::V8DOMWindowShell::initializeIfNeeded):
* bindings/v8/V8DOMWindowShell.h:
(WebCore::V8DOMWindowShell::getEntered):
* bindings/v8/V8PerContextData.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (134371 => 134372)


--- trunk/Source/WebCore/ChangeLog	2012-11-13 07:29:59 UTC (rev 134371)
+++ trunk/Source/WebCore/ChangeLog	2012-11-13 07:32:07 UTC (rev 134372)
@@ -1,3 +1,28 @@
+2012-11-12  Adam Barth  <[email protected]>
+
+        [V8] We should be able to recover the V8DOMWindowShell more quickly
+        https://bugs.webkit.org/show_bug.cgi?id=102020
+
+        Reviewed by Kentaro Hara.
+
+        For isolated worlds, we used to store the V8DOMWindowShell as an
+        internal field of the inner DOM window. This patch moves the pointer to
+        an internal field of the v8::Context, which saves us the work of
+        looking up the inner DOM window.
+
+        Unfortunately, we cannot store the V8DOMWindowShell in V8PerContextData
+        because the V8DOMWindowShell outlives the V8PerContextData. (We destroy
+        the V8PerContextData when we detach the V8DOMWindowShell from the
+        frame.)
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GetInternalFields):
+        * bindings/v8/V8DOMWindowShell.cpp:
+        (WebCore::V8DOMWindowShell::initializeIfNeeded):
+        * bindings/v8/V8DOMWindowShell.h:
+        (WebCore::V8DOMWindowShell::getEntered):
+        * bindings/v8/V8PerContextData.h:
+
 2012-11-12  Kentaro Hara  <[email protected]>
 
         [V8] Add ASSERT() to guarantee that we don't store NULL pointers to V8 internal fields

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (134371 => 134372)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-11-13 07:29:59 UTC (rev 134371)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-11-13 07:32:07 UTC (rev 134372)
@@ -611,9 +611,6 @@
         push(@customInternalFields, "eventListenerCacheIndex");
     }
 
-    if ($name eq "DOMWindow") {
-        push(@customInternalFields, "enteredIsolatedWorldIndex");
-    }
     return @customInternalFields;
 }
 

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp (134371 => 134372)


--- trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp	2012-11-13 07:29:59 UTC (rev 134371)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp	2012-11-13 07:32:07 UTC (rev 134372)
@@ -169,16 +169,6 @@
     ASSERT(!document->isHTMLDocument() || (V8Document::toNative(v8::Handle<v8::Object>::Cast(wrapper->GetPrototype())) == document));
 }
 
-static void setIsolatedWorldField(V8DOMWindowShell* shell, v8::Local<v8::Context> context)
-{
-    toInnerGlobalObject(context)->SetAlignedPointerInInternalField(V8DOMWindow::enteredIsolatedWorldIndex, shell);
-}
-
-V8DOMWindowShell* V8DOMWindowShell::enteredIsolatedWorldContext()
-{
-    return static_cast<V8DOMWindowShell*>(toInnerGlobalObject(v8::Context::GetEntered())->GetAlignedPointerFromInternalField(V8DOMWindow::enteredIsolatedWorldIndex));
-}
-
 static void setInjectedScriptContextDebugId(v8::Handle<v8::Context> targetContext, int debugId)
 {
     char buffer[32];
@@ -339,12 +329,12 @@
     }
 
     if (isMainWorld)
-        setIsolatedWorldField(0, context);
+        context->SetAlignedPointerInEmbedderData(v8ContextIsolatedWindowShell, 0);
     else {
         V8DOMWindowShell* mainWindow = m_frame->script()->existingWindowShell(mainThreadNormalWorld());
         if (mainWindow && !mainWindow->context().IsEmpty())
             setInjectedScriptContextDebugId(m_context.get(), m_frame->script()->contextDebugId(mainWindow->context()));
-        setIsolatedWorldField(this, context);
+        context->SetAlignedPointerInEmbedderData(v8ContextIsolatedWindowShell, this);
     }
 
     m_perContextData = V8PerContextData::create(m_context.get());

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.h (134371 => 134372)


--- trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.h	2012-11-13 07:29:59 UTC (rev 134371)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.h	2012-11-13 07:32:07 UTC (rev 134372)
@@ -99,7 +99,7 @@
             return 0;
         if (!v8::Context::InContext())
             return 0;
-        return enteredIsolatedWorldContext();
+        return static_cast<V8DOMWindowShell*>(v8::Context::GetEntered()->GetAlignedPointerFromEmbedderData(v8ContextIsolatedWindowShell));
     }
 
     void destroyIsolatedShell();

Modified: trunk/Source/WebCore/bindings/v8/V8PerContextData.h (134371 => 134372)


--- trunk/Source/WebCore/bindings/v8/V8PerContextData.h	2012-11-13 07:29:59 UTC (rev 134371)
+++ trunk/Source/WebCore/bindings/v8/V8PerContextData.h	2012-11-13 07:32:07 UTC (rev 134372)
@@ -46,7 +46,8 @@
 
 enum V8ContextEmbedderDataField {
     v8ContextDebugIdIndex,
-    v8ContextPerContextDataIndex
+    v8ContextPerContextDataIndex,
+    v8ContextIsolatedWindowShell,
     // Rather than adding more embedder data fields to v8::Context,
     // consider adding the data to V8PerContextData instead.
 };
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to