Bug 102739 - V8: EmptyScriptState passed to functions marked with CallWith=ScriptState
Summary: V8: EmptyScriptState passed to functions marked with CallWith=ScriptState
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 102552
  Show dependency treegraph
 
Reported: 2012-11-19 16:36 PST by Michael Pruett
Modified: 2012-11-20 15:51 PST (History)
7 users (show)

See Also:


Attachments
Patch (1.58 KB, patch)
2012-11-19 18:41 PST, Michael Pruett
no flags Details | Formatted Diff | Diff
Patch (4.49 KB, patch)
2012-11-19 19:17 PST, Michael Pruett
no flags Details | Formatted Diff | Diff
Patch (4.49 KB, patch)
2012-11-19 23:43 PST, Michael Pruett
haraken: review+
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff
Patch (5.74 KB, patch)
2012-11-20 10:50 PST, Michael Pruett
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Pruett 2012-11-19 16:36:24 PST
Adding CallWith=ScriptState to a function causes the V8 binding generator to invoke the function with an EmptyScriptState rather than with ScriptState::current(). Since the EmptyScriptState has a null v8::Context, any clients which depend upon a valid v8::Context will fail.
Comment 1 Michael Pruett 2012-11-19 18:41:49 PST
Created attachment 175112 [details]
Patch

This change causes CodeGeneratorV8.pm to pass ScriptState::current() rather than an EmptyScriptState to functions marked with CallWith=ScriptState. With this patch I was able to update IndexedDB to use the ScriptState provided by the binding generator for serialization.
Comment 2 Adam Barth 2012-11-19 18:42:56 PST
Comment on attachment 175112 [details]
Patch

Great.  Do you want to prepare a proper patch for review (e.g., with a ChangeLog)
Comment 3 Kentaro Hara 2012-11-19 18:49:36 PST
Comment on attachment 175112 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=175112&action=review

The change makes sense.

> Source/WebCore/bindings/scripts/CodeGeneratorV8.pm:3529
> -    my @callWithArgs = GenerateCallWith($callWith, \@callWithOutput, $indent, 0, 1, $function);
> +    my @callWithArgs = GenerateCallWith($callWith, \@callWithOutput, $indent, 0, 0, $function);

I think that now no one uses 1. Maybe you can kill the $emptyContext argument from GenerateCallWith().
Comment 4 Kentaro Hara 2012-11-19 18:50:05 PST
Comment on attachment 175112 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=175112&action=review

> Source/WebCore/bindings/scripts/CodeGeneratorV8.pm:1633
>          } else {

Then you can remove this if-else branch.
Comment 5 Michael Pruett 2012-11-19 19:17:05 PST
Created attachment 175115 [details]
Patch
Comment 6 Kentaro Hara 2012-11-19 19:18:53 PST
Comment on attachment 175115 [details]
Patch

LGTM. If you set r?, I can r+ it.
Comment 7 Michael Pruett 2012-11-19 19:22:20 PST
Do you know if there is a reason why EmptyScriptState was used in the past in preference to ScriptState::current()?
Comment 8 Kentaro Hara 2012-11-19 19:23:53 PST
(In reply to comment #7)
> Do you know if there is a reason why EmptyScriptState was used in the past in preference to ScriptState::current()?

Don't know. Would you git blame its history and cc folks?
Comment 9 Michael Pruett 2012-11-19 20:10:39 PST
Passing EmptyScriptState to functions marked with CallWith=ScriptState seems to have been introduced to CodeGeneratorV8.pm in revision 58298 on 2010-04-27 by Adam Barth. There was no previous use of either EmptyScriptState or ScriptState::current().
Comment 10 Adam Barth 2012-11-19 23:38:44 PST
I have no idea why I used EmptyScriptState.
Comment 11 Kentaro Hara 2012-11-19 23:39:17 PST
Either way I think this change looks reasonable.
Comment 12 Michael Pruett 2012-11-19 23:43:46 PST
Created attachment 175158 [details]
Patch

I have updated the ChangeLog to note that this patch has been reviewed by Kentaro Hara.
Comment 13 Kentaro Hara 2012-11-19 23:44:48 PST
Comment on attachment 175158 [details]
Patch

From next time, instead of writing my name to the ChangeLog, please set r?. Then a reviewer can set r+ or r-.
Comment 14 Kentaro Hara 2012-11-19 23:45:30 PST
Comment on attachment 175158 [details]
Patch

And if you want to commit it, please set cq?. (You can find these forms at the right bottom of https://bugs.webkit.org/attachment.cgi?id=175158&action=review)
Comment 15 WebKit Review Bot 2012-11-20 00:37:56 PST
Comment on attachment 175158 [details]
Patch

Attachment 175158 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14912534

New failing tests:
traversal/exception-forwarding.html
Comment 16 Michael Pruett 2012-11-20 10:50:47 PST
Created attachment 175245 [details]
Patch

Previously any exception thrown while in EmptyScriptState was cleared when EmptyScriptState went out of scope. I've updated the patch to explicitly clear an exception before throwing it.
Comment 17 WebKit Review Bot 2012-11-20 12:13:44 PST
Comment on attachment 175245 [details]
Patch

Attachment 175245 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/14894690

New failing tests:
fast/dom/shadow/shadow-dom-event-dispatching.html
Comment 18 Kentaro Hara 2012-11-20 15:34:19 PST
Comment on attachment 175245 [details]
Patch

It looks like the failure is not related to the patch. Let's try again.
Comment 19 WebKit Review Bot 2012-11-20 15:51:39 PST
Comment on attachment 175245 [details]
Patch

Clearing flags on attachment: 175245

Committed r135325: <http://trac.webkit.org/changeset/135325>
Comment 20 WebKit Review Bot 2012-11-20 15:51:44 PST
All reviewed patches have been landed.  Closing bug.