Bug 102156 - [V8] Simplify V8DOMWindowShell::getEntered
Summary: [V8] Simplify V8DOMWindowShell::getEntered
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: Adam Barth
URL:
Keywords:
Depends on:
Blocks: 102158
  Show dependency treegraph
 
Reported: 2012-11-13 17:08 PST by Adam Barth
Modified: 2012-11-19 16:21 PST (History)
5 users (show)

See Also:


Attachments
Patch (13.12 KB, patch)
2012-11-13 17:12 PST, Adam Barth
no flags Details | Formatted Diff | Diff
Patch (13.79 KB, patch)
2012-11-19 15:43 PST, Adam Barth
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Barth 2012-11-13 17:08:58 PST
[V8] Simplify V8DOMWindowShell::getEntered
Comment 1 Adam Barth 2012-11-13 17:12:20 PST
Created attachment 174033 [details]
Patch
Comment 2 Kentaro Hara 2012-11-13 17:26:28 PST
Comment on attachment 174033 [details]
Patch

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

The change looks reasonable, but is a bit confusing. Sometimes you use 'V8DOMWindowShell::isolated(v8::Context::GetEntered())', sometimes you use 'v8::Context::InContext() && V8DOMWindowShell::isolated(v8::Context::GetEntered())', and sometimes you use 'DOMWrapperWorld::isolatedWorldsExist()) && v8::Context::InContext()'. To make it clear what kind of check should be used in each place, shall we make a well-named helper function to do the checks?

> Source/WebCore/bindings/v8/DOMDataStore.cpp:60
> +    V8DOMWindowShell* context = V8DOMWindowShell::isolated(v8::Context::GetEntered());

Nit: context => shell.

> Source/WebCore/bindings/v8/WorldContextHandle.cpp:-51
> -        if (!context.IsEmpty()) {

Is it OK to remove this check? (I don't fully understand WorldContextHandle.)
Comment 3 Adam Barth 2012-11-13 17:31:11 PST
> The change looks reasonable, but is a bit confusing. Sometimes you use 'V8DOMWindowShell::isolated(v8::Context::GetEntered())', sometimes you use 'v8::Context::InContext() && V8DOMWindowShell::isolated(v8::Context::GetEntered())',

Yeah, I'm skipping the v8::Context::InContext calls in locations where we know that V8 is on the stack.

> and sometimes you use 'DOMWrapperWorld::isolatedWorldsExist()) && v8::Context::InContext()'.

isolatedWorldsExist is just a performance optimization.  It's only needed in extremely performance sensitive code.

> To make it clear what kind of check should be used in each place, shall we make a well-named helper function to do the checks?

Sure.  Do you have thoughts on what to name these functions?

> > Source/WebCore/bindings/v8/DOMDataStore.cpp:60
> > +    V8DOMWindowShell* context = V8DOMWindowShell::isolated(v8::Context::GetEntered());
> 
> Nit: context => shell.
> 
> > Source/WebCore/bindings/v8/WorldContextHandle.cpp:-51
> > -        if (!context.IsEmpty()) {
> 
> Is it OK to remove this check? (I don't fully understand WorldContextHandle.)

Yes.  If we're in a context, it's impossible for the current context to be empty.
Comment 4 Dan Carney 2012-11-16 07:20:09 PST
This patch looks great, and I'd really like to build on it. Kentaro, any chance you want to take another look?
Comment 5 Kentaro Hara 2012-11-18 17:29:19 PST
Sorry for the delayed review.

(In reply to comment #3)
> > and sometimes you use 'DOMWrapperWorld::isolatedWorldsExist()) && v8::Context::InContext()'.
> 
> isolatedWorldsExist is just a performance optimization.  It's only needed in extremely performance sensitive code.
> 
> > To make it clear what kind of check should be used in each place, shall we make a well-named helper function to do the checks?
> 
> Sure.  Do you have thoughts on what to name these functions?

(1) How about implementing:

  V8IsolatedWorld* getEnteredIsolatedWorld() {
    if (!v8::Context::InContext())
      return 0;
    V8DOMWindowShell* shell = V8DOMWindowShell::isolated(v8::Context::GetEntered());
    if (!shell)
      return 0;
    return shell->world();
  }

and use getEnteredIsolatedWorld() as much as possible.

(2) At a performance-sensitive place, you can use 'DOMWrapperWorld::isolatedWorldsExist()) && v8::Context::InContext()' instead of getEnteredIsolatedWorld(). It would be better to add a comment about that.

(Context and IsolatedWorld are one of the most difficult concepts to understand. So I want to make what each code is doing clearer.)
Comment 6 Adam Barth 2012-11-19 15:43:46 PST
Created attachment 175060 [details]
Patch
Comment 7 Eric Seidel (no email) 2012-11-19 15:52:32 PST
Comment on attachment 175060 [details]
Patch

Still looks fine.  Appears you've answered haraken's concerns.  Your judgement as to if you feel you need to wait for him to see it again.
Comment 8 Adam Barth 2012-11-19 16:12:50 PST
I think we've gotten enough data from him that it's ok to land this and unblock bug 102158 and Dan's work.  Thanks for the review.

@haraken: If there's more you'd like me to change here, I'm happy to do more work in a followup patch.
Comment 9 Kentaro Hara 2012-11-19 16:13:35 PST
LGTM too:)
Comment 10 Adam Barth 2012-11-19 16:21:48 PST
Comment on attachment 175060 [details]
Patch

Clearing flags on attachment: 175060

Committed r135208: <http://trac.webkit.org/changeset/135208>
Comment 11 Adam Barth 2012-11-19 16:21:51 PST
All reviewed patches have been landed.  Closing bug.