2009-11-26 Anton Muhin <antonm@chromium.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Nov 2009 15:59:46 +0000 (15:59 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Nov 2009 15:59:46 +0000 (15:59 +0000)
        Reviewed by Adam Barth.

        Use an internal field instead of hidden property to speedup lookup
        of entered isolated world.

        Plus some inlinings.
        https://bugs.webkit.org/show_bug.cgi?id=31884

        Covered by layout tests + manual running of some benchmarks as
        content scripts.

        * bindings/v8/V8DOMWrapper.cpp:
        * bindings/v8/V8DOMWrapper.h:
        (WebCore::V8DOMWrapper::setDOMWrapper):
        * bindings/v8/V8HiddenPropertyName.h:
        * bindings/v8/V8IsolatedWorld.cpp:
        (WebCore::V8IsolatedWorld::V8IsolatedWorld):
        * bindings/v8/V8IsolatedWorld.h:
        (WebCore::V8IsolatedWorld::getEntered):
        (WebCore::V8IsolatedWorld::getGlobalObject):
        * bindings/v8/custom/V8CustomBinding.h:

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

WebCore/ChangeLog
WebCore/bindings/v8/V8DOMWrapper.cpp
WebCore/bindings/v8/V8DOMWrapper.h
WebCore/bindings/v8/V8HiddenPropertyName.h
WebCore/bindings/v8/V8IsolatedWorld.cpp
WebCore/bindings/v8/V8IsolatedWorld.h
WebCore/bindings/v8/custom/V8CustomBinding.h

index 0857df9172222bb11c63e99b3b27aabca308146f..1d56f71da87160cb94efdcd5466e2fa84543630b 100644 (file)
@@ -1,3 +1,27 @@
+2009-11-26  Anton Muhin  <antonm@chromium.org>
+
+        Reviewed by Adam Barth.
+
+        Use an internal field instead of hidden property to speedup lookup
+        of entered isolated world.
+
+        Plus some inlinings.
+        https://bugs.webkit.org/show_bug.cgi?id=31884
+
+        Covered by layout tests + manual running of some benchmarks as
+        content scripts.
+
+        * bindings/v8/V8DOMWrapper.cpp:
+        * bindings/v8/V8DOMWrapper.h:
+        (WebCore::V8DOMWrapper::setDOMWrapper):
+        * bindings/v8/V8HiddenPropertyName.h:
+        * bindings/v8/V8IsolatedWorld.cpp:
+        (WebCore::V8IsolatedWorld::V8IsolatedWorld):
+        * bindings/v8/V8IsolatedWorld.h:
+        (WebCore::V8IsolatedWorld::getEntered):
+        (WebCore::V8IsolatedWorld::getGlobalObject):
+        * bindings/v8/custom/V8CustomBinding.h:
+
 2009-11-26  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
 
         Reviewed by Kenneth Rohde Christiansen.
index 15f966eaa23f11124e0c985465faa11f380cd659..f8fb4a000841a55b8ada17641590c93dd7e585ee 100644 (file)
@@ -920,13 +920,6 @@ v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, V8ClassI
     return instance;
 }
 
-void V8DOMWrapper::setDOMWrapper(v8::Handle<v8::Object> object, int type, void* cptr)
-{
-    ASSERT(object->InternalFieldCount() >= 2);
-    object->SetPointerInInternalField(V8Custom::kDOMWrapperObjectIndex, cptr);
-    object->SetInternalField(V8Custom::kDOMWrapperTypeIndex, v8::Integer::New(type));
-}
-
 #ifndef NDEBUG
 bool V8DOMWrapper::maybeDOMWrapper(v8::Handle<v8::Value> value)
 {
index 7ca2e63edcc7a2fde51c990332d19a345f4c3bc8..0ea3669a79c663d60d7a2e860bfdd871318033d5 100644 (file)
@@ -109,7 +109,12 @@ namespace WebCore {
 #endif
 
         // Sets contents of a DOM wrapper.
-        static void setDOMWrapper(v8::Handle<v8::Object>, int type, void* ptr);
+        static void setDOMWrapper(v8::Handle<v8::Object> object, int type, void* cptr)
+        {
+            ASSERT(object->InternalFieldCount() >= 2);
+            object->SetPointerInInternalField(V8Custom::kDOMWrapperObjectIndex, cptr);
+            object->SetInternalField(V8Custom::kDOMWrapperTypeIndex, v8::Integer::New(type));
+        }
 
         static v8::Handle<v8::Object> lookupDOMWrapper(V8ClassIndex::V8WrapperType type, v8::Handle<v8::Object> object)
         {
index 5ef89cb92fb5af2393a89d58b2abe2bc68c4a7fc..bb1ca4c657fd9731f765adfcd8a91b10bddef3c0 100644 (file)
@@ -37,7 +37,6 @@ namespace WebCore {
 
 #define V8_HIDDEN_PROPERTIES(V) \
     V(objectPrototype) \
-    V(isolatedWorld) \
     V(listener) \
     V(attributeListener) \
     V(sleepFunction) \
index a417930ac2473cf66bb0a0dfd13b71b1934d469b..cb65097e3b07799d497688676b04555d22e9e1b0 100644 (file)
@@ -64,7 +64,7 @@ V8IsolatedWorld::V8IsolatedWorld(V8Proxy* proxy, int extensionGroup)
     // Run code in the new context.
     v8::Context::Scope context_scope(m_context->get());
 
-    m_context->get()->Global()->SetHiddenValue(V8HiddenPropertyName::isolatedWorld(), v8::External::Wrap(this));
+    getGlobalObject(m_context->get())->SetPointerInInternalField(V8Custom::kDOMWindowEnteredIsolatedWorldIndex, this);
 
     V8Proxy::installHiddenObjectPrototype(m_context->get());
     proxy->installDOMWindow(m_context->get(), proxy->frame()->domWindow());
@@ -91,17 +91,4 @@ V8IsolatedWorld::~V8IsolatedWorld()
     m_context->disposeHandle();
 }
 
-V8IsolatedWorld* V8IsolatedWorld::getEnteredImpl()
-{
-    if (!v8::Context::InContext())
-        return 0;
-    v8::HandleScope scope;
-
-    v8::Local<v8::Value> world = v8::Context::GetEntered()->Global()->GetHiddenValue(V8HiddenPropertyName::isolatedWorld());
-    if (world.IsEmpty())
-        return 0;
-
-    return static_cast<V8IsolatedWorld*>(v8::External::Unwrap(world));
-}
-
 } // namespace WebCore
index 2b23092ad39d11e393ede6eaaf31732b10196ca0..6313da8e4a490afb7bea1def853c699e89fe8bf4 100644 (file)
@@ -85,7 +85,9 @@ namespace WebCore {
             // worlds at all.
             if (!isolatedWorldCount)
                 return 0;
-            return getEnteredImpl();
+            if (!v8::Context::InContext())
+                return 0;
+            return reinterpret_cast<V8IsolatedWorld*>(getGlobalObject(v8::Context::GetEntered())->GetPointerFromInternalField(V8Custom::kDOMWindowEnteredIsolatedWorldIndex));
         }
 
         v8::Handle<v8::Context> context() { return m_context->get(); }
@@ -94,7 +96,10 @@ namespace WebCore {
         DOMDataStore* getDOMDataStore() const { return m_domDataStore.getStore(); }
 
     private:
-        static V8IsolatedWorld* getEnteredImpl();
+        static v8::Handle<v8::Object> getGlobalObject(v8::Handle<v8::Context> context)
+        {
+            return v8::Handle<v8::Object>::Cast(context->Global()->GetPrototype());
+        }
 
         // Called by the garbage collector when our JavaScript context is about
         // to be destroyed.
index 7a220eb86920bab99d4afc9c05891be93cbb18b1..4bd6d7924af6fa24a4c5fd58710bea2ed14c21aa 100644 (file)
@@ -168,7 +168,8 @@ namespace WebCore {
         static const int kDOMWindowLocationIndex = kDefaultWrapperInternalFieldCount + 11;
         static const int kDOMWindowDOMSelectionIndex = kDefaultWrapperInternalFieldCount + 12;
         static const int kDOMWindowEventListenerCacheIndex = kDefaultWrapperInternalFieldCount + 13;
-        static const int kDOMWindowInternalFieldCount = kDefaultWrapperInternalFieldCount + 14;
+        static const int kDOMWindowEnteredIsolatedWorldIndex = kDefaultWrapperInternalFieldCount + 14;
+        static const int kDOMWindowInternalFieldCount = kDefaultWrapperInternalFieldCount + 15;
 
         static const int kStyleSheetOwnerNodeIndex = kDefaultWrapperInternalFieldCount + 0;
         static const int kStyleSheetInternalFieldCount = kDefaultWrapperInternalFieldCount + 1;