Bug 217980 - Merge WorkerScriptController and WorkletScriptController into WorkerOrWorkletScriptController
Summary: Merge WorkerScriptController and WorkletScriptController into WorkerOrWorklet...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Audio (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks: 217724 217058 217995
  Show dependency treegraph
 
Reported: 2020-10-20 12:37 PDT by Chris Dumez
Modified: 2020-10-20 17:01 PDT (History)
17 users (show)

See Also:


Attachments
Patch (108.80 KB, patch)
2020-10-20 13:07 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (108.86 KB, patch)
2020-10-20 13:12 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (109.74 KB, patch)
2020-10-20 15:14 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (109.73 KB, patch)
2020-10-20 15:17 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff
Patch (109.80 KB, patch)
2020-10-20 15:20 PDT, Chris Dumez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2020-10-20 12:37:03 PDT
Merge WorkerScriptController and WorkletScriptController into WorkerOrWorkletScriptController, to share more code.
Comment 1 Chris Dumez 2020-10-20 13:07:02 PDT
Created attachment 411903 [details]
Patch
Comment 2 Chris Dumez 2020-10-20 13:12:18 PDT
Created attachment 411905 [details]
Patch
Comment 3 Darin Adler 2020-10-20 14:43:32 PDT
Comment on attachment 411905 [details]
Patch

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

> Source/WebCore/bindings/js/JSDOMGlobalObject.cpp:299
> +    auto guardedObjects = m_guardedObjects;

We are copying this so it does the right thing even if some objects are removed while we iterate. Three questions:

1) Can we make clearer that this is a copy, perhaps by including copy in the name of the local variable or adding a comment?
2) Is it OK to call clear if this object is removed and then perhaps reused in some way?
3) Is it OK that this does not clear objects that are added during the iteration?

Looks like this code was just moved, so none of this is new.

> Source/WebCore/bindings/js/JSDOMGlobalObject.h:87
> +    JSC::JSProxy* proxy() const { ASSERT(m_proxy); return m_proxy.get(); }

If we can assert this, it seems we should return a reference, not a pointer.

> Source/WebCore/bindings/js/JSDOMWindowBase.cpp:253
>  JSWindowProxy* JSDOMWindowBase::proxy() const

Reference?
Comment 4 Chris Dumez 2020-10-20 14:48:49 PDT
(In reply to Darin Adler from comment #3)
> Comment on attachment 411905 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=411905&action=review
> 
> > Source/WebCore/bindings/js/JSDOMGlobalObject.cpp:299
> > +    auto guardedObjects = m_guardedObjects;
> 
> We are copying this so it does the right thing even if some objects are
> removed while we iterate. Three questions:
> 
> 1) Can we make clearer that this is a copy, perhaps by including copy in the
> name of the local variable or adding a comment?

Will add "Copy" suffix.

> 2) Is it OK to call clear if this object is removed and then perhaps reused
> in some way?
> 3) Is it OK that this does not clear objects that are added during the
> iteration?

I am actually not familiar with this code. However, looking at it, it seems that calling clear() on the DOMGuardedObjects is not a complex operation and from my glancing at it, I do not believe it can cause objects to get added to the list. Pretty much all clear() does it grab a lock and remove the object from the list.

> 
> Looks like this code was just moved, so none of this is new.

Correct, I merely moved it.

> 
> > Source/WebCore/bindings/js/JSDOMGlobalObject.h:87
> > +    JSC::JSProxy* proxy() const { ASSERT(m_proxy); return m_proxy.get(); }
> 
> If we can assert this, it seems we should return a reference, not a pointer.
> 
> > Source/WebCore/bindings/js/JSDOMWindowBase.cpp:253
> >  JSWindowProxy* JSDOMWindowBase::proxy() const
> 
> Reference?

Ok, will do.
Comment 5 Chris Dumez 2020-10-20 15:14:09 PDT
Created attachment 411925 [details]
Patch
Comment 6 Chris Dumez 2020-10-20 15:17:24 PDT
Created attachment 411927 [details]
Patch
Comment 7 Chris Dumez 2020-10-20 15:20:38 PDT
Created attachment 411928 [details]
Patch
Comment 8 EWS 2020-10-20 17:00:48 PDT
Committed r268775: <https://trac.webkit.org/changeset/268775>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 411928 [details].
Comment 9 Radar WebKit Bug Importer 2020-10-20 17:01:29 PDT
<rdar://problem/70508220>