RESOLVED FIXED Bug 102156
[V8] Simplify V8DOMWindowShell::getEntered
https://bugs.webkit.org/show_bug.cgi?id=102156
Summary [V8] Simplify V8DOMWindowShell::getEntered
Adam Barth
Reported 2012-11-13 17:08:58 PST
[V8] Simplify V8DOMWindowShell::getEntered
Attachments
Patch (13.12 KB, patch)
2012-11-13 17:12 PST, Adam Barth
no flags
Patch (13.79 KB, patch)
2012-11-19 15:43 PST, Adam Barth
no flags
Adam Barth
Comment 1 2012-11-13 17:12:20 PST
Kentaro Hara
Comment 2 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.)
Adam Barth
Comment 3 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.
Dan Carney
Comment 4 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?
Kentaro Hara
Comment 5 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.)
Adam Barth
Comment 6 2012-11-19 15:43:46 PST
Eric Seidel (no email)
Comment 7 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.
Adam Barth
Comment 8 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.
Kentaro Hara
Comment 9 2012-11-19 16:13:35 PST
LGTM too:)
Adam Barth
Comment 10 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>
Adam Barth
Comment 11 2012-11-19 16:21:51 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.