Title: [135325] trunk/Source/WebCore
Revision
135325
Author
commit-qu...@webkit.org
Date
2012-11-20 15:50:59 -0800 (Tue, 20 Nov 2012)

Log Message

[V8] Pass ScriptState::current() to functions marked with CallWith=ScriptState
https://bugs.webkit.org/show_bug.cgi?id=102739

Patch by Michael Pruett <mich...@68k.org> on 2012-11-20
Reviewed by Kentaro Hara.

Previously EmptyScriptState rather than ScriptState::current()
was passed to functions marked with [CallWith=ScriptState].
Since the EmptyScriptState has a null v8::Context, any functions
which depended upon a valid v8::Context would fail.

No new tests. Covered by existing tests.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateNormalAttrGetter):
(GenerateNormalAttrSetter):
(GenerateCallWith):
(GenerateFunctionCallString):
* bindings/v8/ScriptState.h:
(WebCore::ScriptState::clearException): Added.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (135324 => 135325)


--- trunk/Source/WebCore/ChangeLog	2012-11-20 23:47:56 UTC (rev 135324)
+++ trunk/Source/WebCore/ChangeLog	2012-11-20 23:50:59 UTC (rev 135325)
@@ -1,3 +1,25 @@
+2012-11-20  Michael Pruett  <mich...@68k.org>
+
+        [V8] Pass ScriptState::current() to functions marked with CallWith=ScriptState
+        https://bugs.webkit.org/show_bug.cgi?id=102739
+
+        Reviewed by Kentaro Hara.
+
+        Previously EmptyScriptState rather than ScriptState::current()
+        was passed to functions marked with [CallWith=ScriptState].
+        Since the EmptyScriptState has a null v8::Context, any functions
+        which depended upon a valid v8::Context would fail.
+
+        No new tests. Covered by existing tests.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateNormalAttrGetter):
+        (GenerateNormalAttrSetter):
+        (GenerateCallWith):
+        (GenerateFunctionCallString):
+        * bindings/v8/ScriptState.h:
+        (WebCore::ScriptState::clearException): Added.
+
 2012-11-20  Brent Fulgham  <bfulg...@webkit.org>
 
         [Qt] Build fix after r135217.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (135324 => 135325)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-11-20 23:47:56 UTC (rev 135324)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-11-20 23:50:59 UTC (rev 135325)
@@ -982,7 +982,7 @@
         } else {
             $functionName = "imp->${functionName}";
         }
-        unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContentDecls, "    ", 0, 0));
+        unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContentDecls, "    ", 0));
         $getterString = "${functionName}(" . join(", ", @arguments) . ")";
     } else {
         $getterString = "impInstance";
@@ -1299,7 +1299,7 @@
             } else {
                 $functionName = "imp->${functionName}";
             }
-            unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContentDecls, "    ", 1, 0));
+            unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContentDecls, "    ", 1));
             push(@implContentDecls, "    ${functionName}(" . join(", ", @arguments) . ");\n");
         }
     }
@@ -1621,20 +1621,15 @@
     my $outputArray = shift;
     my $indent = shift;
     my $returnVoid = shift;
-    my $emptyContext = shift;
     my $function = shift;
 
     my @callWithArgs;
     if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptState")) {
-        if ($emptyContext) {
-            push(@$outputArray, $indent . "EmptyScriptState state;\n");
-            push(@callWithArgs, "&state");
-        } else {
-            push(@$outputArray, $indent . "ScriptState* state = ScriptState::current();\n");
-            push(@$outputArray, $indent . "if (!state)\n");
-            push(@$outputArray, $indent . "    return" . ($returnVoid ? "" : " v8Undefined()") . ";\n");
-            push(@callWithArgs, "state");
-        }
+        push(@$outputArray, $indent . "ScriptState* currentState = ScriptState::current();\n");
+        push(@$outputArray, $indent . "if (!currentState)\n");
+        push(@$outputArray, $indent . "    return" . ($returnVoid ? "" : " v8Undefined()") . ";\n");
+        push(@$outputArray, $indent . "ScriptState& state = *currentState;\n");
+        push(@callWithArgs, "&state");
     }
     if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptExecutionContext")) {
         push(@$outputArray, $indent . "ScriptExecutionContext* scriptContext = getScriptExecutionContext();\n");
@@ -3532,7 +3527,7 @@
 
     my $callWith = $function->signature->extendedAttributes->{"CallWith"};
     my @callWithOutput = ();
-    my @callWithArgs = GenerateCallWith($callWith, \@callWithOutput, $indent, 0, 1, $function);
+    my @callWithArgs = GenerateCallWith($callWith, \@callWithOutput, $indent, 0, $function);
     $result .= join("", @callWithOutput);
     unshift(@arguments, @callWithArgs);
     $index += @callWithArgs;
@@ -3590,8 +3585,11 @@
     }
 
     if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptState")) {
-        $result .= $indent . "if (state.hadException())\n";
-        $result .= $indent . "    return throwError(state.exception(), args.GetIsolate());\n"
+        $result .= $indent . "if (state.hadException()) {\n";
+        $result .= $indent . "    v8::Local<v8::Value> exception = state.exception();\n";
+        $result .= $indent . "    state.clearException();\n";
+        $result .= $indent . "    return throwError(exception, args.GetIsolate());\n";
+        $result .= $indent . "}\n";
     }
 
     if ($isSVGTearOffType) {

Modified: trunk/Source/WebCore/bindings/v8/ScriptState.h (135324 => 135325)


--- trunk/Source/WebCore/bindings/v8/ScriptState.h	2012-11-20 23:47:56 UTC (rev 135324)
+++ trunk/Source/WebCore/bindings/v8/ScriptState.h	2012-11-20 23:50:59 UTC (rev 135325)
@@ -56,6 +56,7 @@
         m_exception = exception;
     }
     v8::Local<v8::Value> exception() { return m_exception; }
+    void clearException() { m_exception.Clear(); }
 
     v8::Local<v8::Context> context() const
     {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to