Title: [118944] trunk
Revision
118944
Author
[email protected]
Date
2012-05-30 11:33:02 -0700 (Wed, 30 May 2012)

Log Message

[V8] Clean up V8LazyEventListener to use one less function call
https://bugs.webkit.org/show_bug.cgi?id=87785

Reviewed by Kentaro Hara.

Instead of relying on 'arguments' we rely on 'this'. 'this' cannot be intercepted by a
with-statement so it is safe to use that to bind the context objects. This allows us to
remove one layer of function indirection in the generated code.

Source/WebCore:

Covered by existing tests.

* bindings/v8/V8LazyEventListener.cpp:
(WebCore::V8LazyEventListener::prepareListenerObject):

LayoutTests:

* platform/chromium-win/inspector/debugger/debugger-scripts-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (118943 => 118944)


--- trunk/LayoutTests/ChangeLog	2012-05-30 18:31:02 UTC (rev 118943)
+++ trunk/LayoutTests/ChangeLog	2012-05-30 18:33:02 UTC (rev 118944)
@@ -1,3 +1,16 @@
+2012-05-30  Erik Arvidsson  <[email protected]>
+
+        [V8] Clean up V8LazyEventListener to use one less function call
+        https://bugs.webkit.org/show_bug.cgi?id=87785
+
+        Reviewed by Kentaro Hara.
+
+        Instead of relying on 'arguments' we rely on 'this'. 'this' cannot be intercepted by a
+        with-statement so it is safe to use that to bind the context objects. This allows us to
+        remove one layer of function indirection in the generated code.
+
+        * platform/chromium-win/inspector/debugger/debugger-scripts-expected.txt:
+
 2012-05-30  Stephen Chenney  <[email protected]>
 
         Unreviewed Chromium test expectations for fast/layers/scroll-with-transform-composited-layer.html

Modified: trunk/LayoutTests/platform/chromium-win/inspector/debugger/debugger-scripts-expected.txt (118943 => 118944)


--- trunk/LayoutTests/platform/chromium-win/inspector/debugger/debugger-scripts-expected.txt	2012-05-30 18:31:02 UTC (rev 118943)
+++ trunk/LayoutTests/platform/chromium-win/inspector/debugger/debugger-scripts-expected.txt	2012-05-30 18:33:02 UTC (rev 118944)
@@ -18,6 +18,6 @@
     end: 48:0
 script 6:
     start: 51:56
-    end: 52:31
+    end: 52:7
 Debugger was disabled.
 

Modified: trunk/Source/WebCore/ChangeLog (118943 => 118944)


--- trunk/Source/WebCore/ChangeLog	2012-05-30 18:31:02 UTC (rev 118943)
+++ trunk/Source/WebCore/ChangeLog	2012-05-30 18:33:02 UTC (rev 118944)
@@ -1,3 +1,19 @@
+2012-05-30  Erik Arvidsson  <[email protected]>
+
+        [V8] Clean up V8LazyEventListener to use one less function call
+        https://bugs.webkit.org/show_bug.cgi?id=87785
+
+        Reviewed by Kentaro Hara.
+
+        Instead of relying on 'arguments' we rely on 'this'. 'this' cannot be intercepted by a
+        with-statement so it is safe to use that to bind the context objects. This allows us to
+        remove one layer of function indirection in the generated code.
+
+        Covered by existing tests.
+
+        * bindings/v8/V8LazyEventListener.cpp:
+        (WebCore::V8LazyEventListener::prepareListenerObject):
+
 2012-05-30  Tim Horton  <[email protected]>
 
         Factor DeferrableOneShotTimer out of GraphicsContextCG/GeneratorGeneratedImage

Modified: trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp (118943 => 118944)


--- trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp	2012-05-30 18:31:02 UTC (rev 118943)
+++ trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp	2012-05-30 18:33:02 UTC (rev 118944)
@@ -141,7 +141,6 @@
     // By calling the function with 4 arguments, we create a setter on arguments object
     // which would shadow property "3" on the prototype.
     String code = "(function() {" \
-        "arguments[3] = function() {" \
         "with (this[2]) {" \
         "with (this[1]) {" \
         "with (this[0]) {";
@@ -150,8 +149,7 @@
     code.append(") {");
     code.append(m_code);
     // Insert '\n' otherwise //-style comments could break the handler.
-    code.append("\n};}}}};");
-    code.append("return arguments[3]();})");
+    code.append("\n};}}}})");
     v8::Handle<v8::String> codeExternalString = v8ExternalString(code);
 
     v8::Handle<v8::Script> script = V8Proxy::compileScript(codeExternalString, m_sourceURL, m_position);
@@ -179,13 +177,21 @@
     v8::Handle<v8::Object> formWrapper = toObjectWrapper<HTMLFormElement>(formElement);
     v8::Handle<v8::Object> documentWrapper = toObjectWrapper<Document>(m_node ? m_node->ownerDocument() : 0);
 
-    v8::Handle<v8::Value> parameters[4] = { nodeWrapper, formWrapper, documentWrapper, v8::Handle<v8::Value>(v8::Null()) };
+    v8::Local<v8::Object> thisObject = v8::Object::New();
+    if (thisObject.IsEmpty())
+        return;
+    if (!thisObject->ForceSet(v8::Integer::NewFromUnsigned(0), nodeWrapper))
+        return;
+    if (!thisObject->ForceSet(v8::Integer::NewFromUnsigned(1), formWrapper))
+        return;
+    if (!thisObject->ForceSet(v8::Integer::NewFromUnsigned(2), documentWrapper))
+        return;
 
     // FIXME: Remove this code when we stop doing the 'with' hack above.
     v8::Local<v8::Value> innerValue;
     {
         V8RecursionScope::MicrotaskSuppression scope;
-        innerValue = intermediateFunction->Call(v8Context->Global(), 3, parameters);
+        innerValue = intermediateFunction->Call(thisObject, 0, 0);
     }
     if (innerValue.IsEmpty() || !innerValue->IsFunction())
         return;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to