Bug 93971 - [V8] Refactor away IsolatedWorld
Summary: [V8] Refactor away IsolatedWorld
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:
: 94318 (view as bug list)
Depends on: 94272 94523
Blocks:
  Show dependency treegraph
 
Reported: 2012-08-14 08:31 PDT by Dan Carney
Modified: 2012-08-24 02:40 PDT (History)
7 users (show)

See Also:


Attachments
Patch (15.72 KB, patch)
2012-08-14 08:35 PDT, Dan Carney
no flags Details | Formatted Diff | Diff
Patch (14.99 KB, patch)
2012-08-14 12:07 PDT, Dan Carney
no flags Details | Formatted Diff | Diff
Patch (15.91 KB, patch)
2012-08-17 02:45 PDT, Dan Carney
no flags Details | Formatted Diff | Diff
Patch (25.01 KB, patch)
2012-08-23 09:10 PDT, Dan Carney
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Carney 2012-08-14 08:31:16 PDT
Refactor away IsolatedWorld
Comment 1 Dan Carney 2012-08-14 08:35:39 PDT
Created attachment 158339 [details]
Patch
Comment 2 Dan Carney 2012-08-14 09:35:20 PDT
Comment on attachment 158339 [details]
Patch

killing patch - some test code made it in
Comment 3 Dan Carney 2012-08-14 12:07:24 PDT
Created attachment 158389 [details]
Patch
Comment 4 Adam Barth 2012-08-14 13:35:42 PDT
Comment on attachment 158389 [details]
Patch

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

> Source/WebCore/bindings/v8/DOMWrapperWorld.h:45
> +    static PassRefPtr<DOMWrapperWorld> create(int worldId = mainWorldId) { return adoptRef(new DOMWrapperWorld(worldId)); }

Can you make createMainWorld be a separate function?  It's a bit too tempting to call create() and duplicate the main world.

> Source/WebCore/bindings/v8/DOMWrapperWorld.h:49
> +        if (m_worldId != mainWorldId)
> +            isolatedWorldCount--;

I would just make this unconditional and have a domWrapperWorldCount.  There's always going to be a main world, so we know how to interpet the value.

> Source/WebCore/bindings/v8/DOMWrapperWorld.h:57
> +

Please remove this blank line.

> Source/WebCore/bindings/v8/DOMWrapperWorld.h:58
> +    DOMWrapperWorld(int worldId): m_worldId(worldId)

This should be split onto two lines with the : as the first character of the second line (indented four spaces).
Comment 5 Dan Carney 2012-08-15 00:58:56 PDT
Comment on attachment 158389 [details]
Patch

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

>> Source/WebCore/bindings/v8/DOMWrapperWorld.h:45
>> +    static PassRefPtr<DOMWrapperWorld> create(int worldId = mainWorldId) { return adoptRef(new DOMWrapperWorld(worldId)); }
> 
> Can you make createMainWorld be a separate function?  It's a bit too tempting to call create() and duplicate the main world.

This is transitional.  There are 2 places in the code where DOMWrapperWorld() was being called, as opposed to IsolatedWorld().  This logic replicates that.  I think those are only called in tests, but I'm not certain.

>> Source/WebCore/bindings/v8/DOMWrapperWorld.h:49
>> +            isolatedWorldCount--;
> 
> I would just make this unconditional and have a domWrapperWorldCount.  There's always going to be a main world, so we know how to interpet the value.

Same issue as above.
Comment 6 Dan Carney 2012-08-15 03:13:15 PDT
Comment on attachment 158389 [details]
Patch

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

>>> Source/WebCore/bindings/v8/DOMWrapperWorld.h:45
>>> +    static PassRefPtr<DOMWrapperWorld> create(int worldId = mainWorldId) { return adoptRef(new DOMWrapperWorld(worldId)); }
>> 
>> Can you make createMainWorld be a separate function?  It's a bit too tempting to call create() and duplicate the main world.
> 
> This is transitional.  There are 2 places in the code where DOMWrapperWorld() was being called, as opposed to IsolatedWorld().  This logic replicates that.  I think those are only called in tests, but I'm not certain.

The problematic calls are in WebViewImpl  http://code.google.com/p/chromium/source/search?q=DOMWrapperWorld%3A%3Acreate&origq=DOMWrapperWorld%3A%3Acreate&btnG=Search+Trunk
Do you happen to know if I can replace them with a call to mainThreadNormalWorld()?
Comment 7 Adam Barth 2012-08-15 14:51:23 PDT
Comment on attachment 158389 [details]
Patch

Ok.  It's fine to move in small steps like this.  We shouldn't be afraid to break things though.  That's what the tests are for.
Comment 8 Adam Barth 2012-08-15 14:51:59 PDT
Comment on attachment 158389 [details]
Patch

Ok.  It's fine to move in small steps like this.  We shouldn't be afraid to break things though.  That's what the tests are for.
Comment 9 WebKit Review Bot 2012-08-15 15:37:15 PDT
Comment on attachment 158389 [details]
Patch

Clearing flags on attachment: 158389

Committed r125717: <http://trac.webkit.org/changeset/125717>
Comment 10 WebKit Review Bot 2012-08-15 15:37:22 PDT
All reviewed patches have been landed.  Closing bug.
Comment 11 WebKit Review Bot 2012-08-16 17:10:02 PDT
Re-opened since this is blocked by 94272
Comment 12 Kentaro Hara 2012-08-17 02:33:09 PDT
*** Bug 94318 has been marked as a duplicate of this bug. ***
Comment 13 Dan Carney 2012-08-17 02:45:02 PDT
Created attachment 159059 [details]
Patch
Comment 14 Kentaro Hara 2012-08-17 02:50:02 PDT
Comment on attachment 159059 [details]
Patch

Looks OK.

By the way, do you have a plan to rename DOMWrapperWorld to IsolatedWorld? (You can do it in a follow-up patch.) A bunch of method names and variable names are using "isolatedWorld". In particular, some Chromium API names (e.g. evaluateInIsolatedWorld()) are using "IsolatedWorld", and it is difficult to rename Chromium APIs. So I think that it would be reasonable to rename DOMWrapperWorld to IsolatedWorld.
Comment 15 Dan Carney 2012-08-17 02:59:15 PDT
(In reply to comment #14)
> (From update of attachment 159059 [details])
> Looks OK.
> 
> By the way, do you have a plan to rename DOMWrapperWorld to IsolatedWorld? (You can do it in a follow-up patch.) A bunch of method names and variable names are using "isolatedWorld". In particular, some Chromium API names (e.g. evaluateInIsolatedWorld()) are using "IsolatedWorld", and it is difficult to rename Chromium APIs. So I think that it would be reasonable to rename DOMWrapperWorld to IsolatedWorld.

I have some follow up patches, but they just rename the constructors to createIsolatedWorld and createMainWorld.  I wasn't planning to rename back to IsolatedWorld as we are trying to match the JSC api a little more.
Comment 16 Kentaro Hara 2012-08-17 03:03:46 PDT
(In reply to comment #15)
> I have some follow up patches, but they just rename the constructors to createIsolatedWorld and createMainWorld.  I wasn't planning to rename back to IsolatedWorld as we are trying to match the JSC api a little more.

It looks like that JSC binding is sometimes using "IsolatedWorld" and "DOMWrapperWorld" interchangeably. What is the difference between IsolatedWorld and DOMWrapperWorld conceptually?
Comment 17 WebKit Review Bot 2012-08-17 05:22:53 PDT
Comment on attachment 159059 [details]
Patch

Clearing flags on attachment: 159059

Committed r125884: <http://trac.webkit.org/changeset/125884>
Comment 18 WebKit Review Bot 2012-08-17 05:22:59 PDT
All reviewed patches have been landed.  Closing bug.
Comment 19 WebKit Review Bot 2012-08-20 13:56:19 PDT
Re-opened since this is blocked by 94523
Comment 20 Dan Carney 2012-08-23 09:10:45 PDT
Created attachment 160180 [details]
Patch
Comment 21 Dan Carney 2012-08-23 09:13:33 PDT
(In reply to comment #16)
> (In reply to comment #15)
> > I have some follow up patches, but they just rename the constructors to createIsolatedWorld and createMainWorld.  I wasn't planning to rename back to IsolatedWorld as we are trying to match the JSC api a little more.
> 
> It looks like that JSC binding is sometimes using "IsolatedWorld" and "DOMWrapperWorld" interchangeably. What is the difference between IsolatedWorld and DOMWrapperWorld conceptually?

No difference.  That's why I'm removing the distinction.  The main world is the one the user sees in the inspector, but it's ultimately just an isolated world, too.
Comment 22 Dan Carney 2012-08-23 09:16:17 PDT
(In reply to comment #20)
> Created an attachment (id=160180) [details]
> Patch

Attempt #3.  This version works around an issue where WebViewImpl needs a throwaway main world that it doesn't use but needs it before the v8 isolate is set, causing a crash.
Comment 23 Adam Barth 2012-08-23 13:43:52 PDT
Comment on attachment 160180 [details]
Patch

It looks like you've got all green bubbles.  If you'd like this patch reviewed, please set the Review flag to "?".
Comment 24 Dan Carney 2012-08-23 23:12:48 PDT
(In reply to comment #23)
> (From update of attachment 160180 [details])
> It looks like you've got all green bubbles.  If you'd like this patch reviewed, please set the Review flag to "?".

Yeah, I have to run this through the unit tests and browser tests locally in debug mode to be sure this is good.  It's very easy to trigger assertions by getting this slightly wrong.  I'll flap the flag shortly.
Comment 25 Kentaro Hara 2012-08-23 23:14:36 PDT
(In reply to comment #21)
> (In reply to comment #16)
> > (In reply to comment #15)
> > > I have some follow up patches, but they just rename the constructors to createIsolatedWorld and createMainWorld.  I wasn't planning to rename back to IsolatedWorld as we are trying to match the JSC api a little more.
> > 
> > It looks like that JSC binding is sometimes using "IsolatedWorld" and "DOMWrapperWorld" interchangeably. What is the difference between IsolatedWorld and DOMWrapperWorld conceptually?
> 
> No difference.  That's why I'm removing the distinction.  The main world is the one the user sees in the inspector, but it's ultimately just an isolated world, too.

Then you might want to rename DOMWrapperWorld to IsolatedWorld in a follow-up patch (in both JSC and V8). Having two names for one concept would be confusing.
Comment 26 Kentaro Hara 2012-08-24 00:40:20 PDT
Comment on attachment 160180 [details]
Patch

OK
Comment 27 WebKit Review Bot 2012-08-24 02:40:22 PDT
Comment on attachment 160180 [details]
Patch

Clearing flags on attachment: 160180

Committed r126566: <http://trac.webkit.org/changeset/126566>
Comment 28 WebKit Review Bot 2012-08-24 02:40:28 PDT
All reviewed patches have been landed.  Closing bug.