Skip to content

Enable refcounting arbitrary DOM types - #4057

Merged
bors-servo merged 2 commits into
servo:masterfrom
jdm:refcountdom
Dec 29, 2014
Merged

bors-servo merged 2 commits into
servo:masterfrom
jdm:refcountdom

Conversation

@jdm

@jdm jdm commented Nov 21, 2014

Copy link
Copy Markdown
Member

This replaces the specialized TrustedXHRAddress and TrustedWorkerAddress code that was used for the same purpose. A non-zero refcount pins the given DOM object's reflector and prevents it from being GCed even when there are no other outstanding references visible to SpiderMonkey. This will enable us to implement asynchronous operations that refer to particular DOM objects (such as "queue a task to fire a simple event named load at the iframe element" from the spec) safely and conveniently, and paves the way for things like asynchronous network responses.

Some concerns about the resulting size of XHR progress messages have been expressed, but I believe optimizations to reduce that can be implemented in subsequent PRs.

r? @Ms2ger - note in particular the changes to the worker lifetime code. I couldn't figure out how to achieve an identical lifetime to the previous addref/release pairing, and I also was having trouble figuring out why the existing setup was safe. The new implementation now holds the main script task Worker object alive via the TrustedWorkerAddress field in the dedicated worker global scope, which is a significant difference.

@hoppipolla-critic-bot

Copy link
Copy Markdown

Critic review: https://critic.hoppipolla.co.uk/r/3237

This is an external review system which you may optionally use for the code review of your pull request.

In order to help critic track your changes, please do not make in-place history rewrites (e.g. via git rebase -i or git commit --amend) when updating this pull request.

@jdm jdm added the S-needs-code-changes Changes have not yet been made that were requested by a reviewer. label Nov 28, 2014
@jdm

jdm commented Dec 3, 2014

Copy link
Copy Markdown
Member Author

@mukilan @Ms2ger Please take a look at the newest commit that should avoid all of the aforementioned Worker lifetime cycle problems.

@Manishearth

Copy link
Copy Markdown
Member

Note: #4173 kind of obsoletes the lint. It currently doesn't check that the first field is a reflector (just that the first field is another DOM struct OR it just contains a reflector), but it's a short fix. Should I incorporate the improvement to reflector checking in that PR?

@jdm jdm added S-needs-squash Some (or all) of the commits in the PR should be combined. and removed S-needs-code-changes Changes have not yet been made that were requested by a reviewer. labels Dec 29, 2014
jdm added 2 commits December 29, 2014 13:53
…ble safe, asynchronous/cross-task references to pinned objects.
…ng with the ScriptMsg. This ensures that the main-thread Worker object is rooted for as long as there are events in flight or being processed.
@jdm jdm added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-needs-squash Some (or all) of the commits in the PR should be combined. labels Dec 29, 2014
bors-servo pushed a commit that referenced this pull request Dec 29, 2014
This replaces the specialized TrustedXHRAddress and TrustedWorkerAddress code that was used for the same purpose. A non-zero refcount pins the given DOM object's reflector and prevents it from being GCed even when there are no other outstanding references visible to SpiderMonkey. This will enable us to implement asynchronous operations that refer to particular DOM objects (such as "queue a task to fire a simple event named load at the iframe element" from the spec) safely and conveniently, and paves the way for things like asynchronous network responses.

Some concerns about the resulting size of XHR progress messages have been expressed, but I believe optimizations to reduce that can be implemented in subsequent PRs.

r? @Ms2ger - note in particular the changes to the worker lifetime code. I couldn't figure out how to achieve an identical lifetime to the previous addref/release pairing, and I also was having trouble figuring out why the existing setup was safe. The new implementation now holds the main script task Worker object alive via the TrustedWorkerAddress field in the dedicated worker global scope, which is a significant difference.
@bors-servo bors-servo closed this Dec 29, 2014
@bors-servo
bors-servo merged commit 9a7cd31 into servo:master Dec 29, 2014
mukilan added a commit to mukilan/servo that referenced this pull request Jan 4, 2015
As noted in servo#4057, this commit optimizes the size of Trusted<T> so
that XHR progress messages do not have to be too heavy, considering
that a large number of progress messages will be generated. This
commit also replaces the mutex based reference counting with one
based on atomic integer operations.
mukilan added a commit to mukilan/servo that referenced this pull request Jan 5, 2015
As noted in servo#4057, this commit optimizes the size of Trusted<T> so
that XHR progress messages do not have to be too heavy, considering
that a large number of progress messages will be generated. This
commit also replaces the mutex based reference counting with one
based on atomic integer operations.
@mukilan mukilan mentioned this pull request Jan 5, 2015
@jdm
jdm deleted the refcountdom branch August 4, 2015 04:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants