Bug 94596

Summary: [V8] Move matchesCurrentContext() from V8Proxy to ScriptController
Product: WebKit Reporter: Kentaro Hara <haraken>
Component: WebCore JavaScriptAssignee: Kentaro Hara <haraken>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, japhet, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 85330    
Attachments:
Description Flags
Patch
none
Patch none

Kentaro Hara
Reported 2012-08-21 06:49:43 PDT
To kill V8Proxy: - We can move matchesCurrentContext() from V8Proxy to ScriptController. - We can remove V8Proxy::isolatedWorldContext() since it is not used by anybody. - We can remove V8Proxy::finishedWithEvent() since it is empty.
Attachments
Patch (8.36 KB, patch)
2012-08-21 06:52 PDT, Kentaro Hara
no flags
Patch (8.71 KB, patch)
2012-08-21 21:14 PDT, Kentaro Hara
no flags
Kentaro Hara
Comment 1 2012-08-21 06:52:07 PDT
Adam Barth
Comment 2 2012-08-21 08:34:36 PDT
Comment on attachment 159681 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=159681&action=review > Source/WebCore/bindings/v8/ScriptController.cpp:392 > +bool ScriptController::matchesCurrentContext() How is this different from v8::Context::GetCurrent() == contextForCurrentWorld() or I guess v8::Context::GetCurrent() == m_proxy->context() since the other patch hasn't landed yet?
Adam Barth
Comment 3 2012-08-21 08:35:52 PDT
Sorry to be asking all these questions, but we're getting to the really yucky functions in V8Proxy. We can move them around without changing them, but this is a good opportunity to understand them and clean them up.
Kentaro Hara
Comment 4 2012-08-21 08:46:17 PDT
Comment on attachment 159681 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=159681&action=review >> Source/WebCore/bindings/v8/ScriptController.cpp:392 >> +bool ScriptController::matchesCurrentContext() > > How is this different from v8::Context::GetCurrent() == contextForCurrentWorld() or I guess v8::Context::GetCurrent() == m_proxy->context() since the other patch hasn't landed yet? This is the code I wrote:) I introduced it in https://bugs.webkit.org/show_bug.cgi?id=82201 for perf optimization. Let me take a detailed look tomorrow. Thanks for review!
Adam Barth
Comment 5 2012-08-21 08:51:23 PDT
> This is the code I wrote:) Sorry, I didn't mean to impune your code! I just meant that it's using a pattern I introduced sometime around http://trac.webkit.org/changeset/46523 that I'm not proud of.
Kentaro Hara
Comment 6 2012-08-21 21:08:08 PDT
Comment on attachment 159681 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=159681&action=review >>> Source/WebCore/bindings/v8/ScriptController.cpp:392 >>> +bool ScriptController::matchesCurrentContext() >> >> How is this different from v8::Context::GetCurrent() == contextForCurrentWorld() or I guess v8::Context::GetCurrent() == m_proxy->context() since the other patch hasn't landed yet? > > This is the code I wrote:) I introduced it in https://bugs.webkit.org/show_bug.cgi?id=82201 for perf optimization. Let me take a detailed look tomorrow. Thanks for review! v8::Context::GetCurrent() == contextForCurrentWorld() works correctly, but it will be slow because contextForCurrentWorld() creates a new local context. As discussed in bug 82201, this is a hot call path of creating DOM object constructor. So it might make sense to leave the current matchesCurrentContext() as is. I'll add a comment that explains this.
Kentaro Hara
Comment 7 2012-08-21 21:14:32 PDT
Adam Barth
Comment 8 2012-08-22 11:59:30 PDT
Comment on attachment 159855 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=159855&action=review > Source/WebCore/bindings/v8/ScriptController.cpp:397 > + // This method is equivalent to 'return v8::Context::GetCurrent() == contextForCurrentWorld()', > + // but is written without using contextForCurrentWorld(). > + // Given that this method is used by a hot call path of DOM object constructor, > + // we want to avoid the overhead of contextForCurrentWorld() creating Local<Context> every time. Ok. One option is to split contextForCurrentWorld() into two pieces: a private piece that returns the underlying persistent handle and a second pieces that returns a new local handle to the object. This function could then share the first piece with currentWorldContext. We don't need to do that in this patch if you'd rather get this one landed first. nit: contextForCurrentWorld -> currentWorldContext > Source/WebCore/bindings/v8/ScriptController.cpp:407 > + return context == context->GetCurrent(); Can we change context->GetCurrent() to v8::Context::GetCurrent()? (It's a static function right?)
Kentaro Hara
Comment 9 2012-08-22 17:30:52 PDT
(In reply to comment #8) > Ok. One option is to split contextForCurrentWorld() into two pieces: a private piece that returns the underlying persistent handle and a second pieces that returns a new local handle to the object. This function could then share the first piece with currentWorldContext. We don't need to do that in this patch if you'd rather get this one landed first. OK, let me fix it in a later patch. > nit: contextForCurrentWorld -> currentWorldContext Done. > > Source/WebCore/bindings/v8/ScriptController.cpp:407 > > + return context == context->GetCurrent(); > > Can we change context->GetCurrent() to v8::Context::GetCurrent()? (It's a static function right?) Done.
Kentaro Hara
Comment 10 2012-08-22 17:38:08 PDT
Note You need to log in before you can comment on or make changes to this bug.