DescriptionMove hasPendingActivity from ActiveDOMObject to ScriptWrappable
Currently hasPendingActivity is a method of ActiveDOMObject (by accident),
so a lot of objects need to become ActiveDOMObject just to override hasPendingActivity.
This is not nice in terms of both design and performance.
- In terms of design, ActiveDOMObject is an object whose lifetime is tied
with ExecutionContext. On the other hand, hasPendingActivity is a mechanism to
keep alive a wrapper while the underlying DOM object has some pending activities.
These two are totally different notions.
- In terms of performance, ActiveDOMObjects are heavy because they must be observed
by LifecycleObservers and notified when the observing context changes its lifetime state.
It's not nice to increase the number of ActiveDOMObjects.
Given the above, this CL moves hasPendingActivity from ActiveDOMObject to ScriptWrappable.
The most tricky part is how to detect the fact that all pending activities of a worker are gone.
Before this CL, this was detected by scanning a list of ActiveDOMObjects and checking their
pending activities when the main thread posts a message to the worker. After this CL,
it is detected by scanning a list of ScriptWrappables and checking their pending activities.
Given that the number of ScriptWrappables is larger than the number of ActiveDOMObjects,
this CL will increase the overhead of scanning at every postMessage. I don't know how large
the overhead is, but I hope that the number of ScriptWrappables in workers is limited in
common cases and thus the overhead wouldn't be an issue.
This CL passes all tests in fast/workers, in particular the following tests:
- worker-messageport-gc.html (which checks that a worker that has a pending timer task doesn't get garbage-collected)
- dedicated-worker-lifecycle.html (which checks that a worker that doesn't have any pending activity is garbage-collected in a finite time period)
BUG=483722
TEST=fast/workers/
Committed: https://crrev.com/485c63ccd15b1e6efe6baf67010da6ea2db94e0d
Cr-Commit-Position: refs/heads/master@{#374584}
Patch Set 1 #Patch Set 2 : #Patch Set 3 : #
Total comments: 5
Patch Set 4 : #
Total comments: 3
Patch Set 5 : #Messages
Total messages: 24 (9 generated)
|