Changeset 135325 in webkit


Ignore:
Timestamp:
Nov 20, 2012, 3:50:59 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

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

Patch by Michael Pruett <michael@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.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r135324 r135325  
     12012-11-20  Michael Pruett  <michael@68k.org>
     2
     3        [V8] Pass ScriptState::current() to functions marked with CallWith=ScriptState
     4        https://bugs.webkit.org/show_bug.cgi?id=102739
     5
     6        Reviewed by Kentaro Hara.
     7
     8        Previously EmptyScriptState rather than ScriptState::current()
     9        was passed to functions marked with [CallWith=ScriptState].
     10        Since the EmptyScriptState has a null v8::Context, any functions
     11        which depended upon a valid v8::Context would fail.
     12
     13        No new tests. Covered by existing tests.
     14
     15        * bindings/scripts/CodeGeneratorV8.pm:
     16        (GenerateNormalAttrGetter):
     17        (GenerateNormalAttrSetter):
     18        (GenerateCallWith):
     19        (GenerateFunctionCallString):
     20        * bindings/v8/ScriptState.h:
     21        (WebCore::ScriptState::clearException): Added.
     22
    1232012-11-20  Brent Fulgham  <bfulgham@webkit.org>
    224
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r135322 r135325  
    983983            $functionName = "imp->${functionName}";
    984984        }
    985         unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContentDecls, "    ", 0, 0));
     985        unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContentDecls, "    ", 0));
    986986        $getterString = "${functionName}(" . join(", ", @arguments) . ")";
    987987    } else {
     
    13001300                $functionName = "imp->${functionName}";
    13011301            }
    1302             unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContentDecls, "    ", 1, 0));
     1302            unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContentDecls, "    ", 1));
    13031303            push(@implContentDecls, "    ${functionName}(" . join(", ", @arguments) . ");\n");
    13041304        }
     
    16221622    my $indent = shift;
    16231623    my $returnVoid = shift;
    1624     my $emptyContext = shift;
    16251624    my $function = shift;
    16261625
    16271626    my @callWithArgs;
    16281627    if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptState")) {
    1629         if ($emptyContext) {
    1630             push(@$outputArray, $indent . "EmptyScriptState state;\n");
    1631             push(@callWithArgs, "&state");
    1632         } else {
    1633             push(@$outputArray, $indent . "ScriptState* state = ScriptState::current();\n");
    1634             push(@$outputArray, $indent . "if (!state)\n");
    1635             push(@$outputArray, $indent . "    return" . ($returnVoid ? "" : " v8Undefined()") . ";\n");
    1636             push(@callWithArgs, "state");
    1637         }
     1628        push(@$outputArray, $indent . "ScriptState* currentState = ScriptState::current();\n");
     1629        push(@$outputArray, $indent . "if (!currentState)\n");
     1630        push(@$outputArray, $indent . "    return" . ($returnVoid ? "" : " v8Undefined()") . ";\n");
     1631        push(@$outputArray, $indent . "ScriptState& state = *currentState;\n");
     1632        push(@callWithArgs, "&state");
    16381633    }
    16391634    if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptExecutionContext")) {
     
    35333528    my $callWith = $function->signature->extendedAttributes->{"CallWith"};
    35343529    my @callWithOutput = ();
    3535     my @callWithArgs = GenerateCallWith($callWith, \@callWithOutput, $indent, 0, 1, $function);
     3530    my @callWithArgs = GenerateCallWith($callWith, \@callWithOutput, $indent, 0, $function);
    35363531    $result .= join("", @callWithOutput);
    35373532    unshift(@arguments, @callWithArgs);
     
    35913586
    35923587    if ($codeGenerator->ExtendedAttributeContains($callWith, "ScriptState")) {
    3593         $result .= $indent . "if (state.hadException())\n";
    3594         $result .= $indent . "    return throwError(state.exception(), args.GetIsolate());\n"
     3588        $result .= $indent . "if (state.hadException()) {\n";
     3589        $result .= $indent . "    v8::Local<v8::Value> exception = state.exception();\n";
     3590        $result .= $indent . "    state.clearException();\n";
     3591        $result .= $indent . "    return throwError(exception, args.GetIsolate());\n";
     3592        $result .= $indent . "}\n";
    35953593    }
    35963594
  • trunk/Source/WebCore/bindings/v8/ScriptState.h

    r126502 r135325  
    5757    }
    5858    v8::Local<v8::Value> exception() { return m_exception; }
     59    void clearException() { m_exception.Clear(); }
    5960
    6061    v8::Local<v8::Context> context() const
Note: See TracChangeset for help on using the changeset viewer.