Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable refcounting arbitrary DOM types #4057

Merged
merged 2 commits into from Dec 29, 2014
Merged

Enable refcounting arbitrary DOM types #4057

merged 2 commits into from Dec 29, 2014

Conversation

@jdm
Copy link
Member

jdm commented Nov 21, 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.

@hoppipolla-critic-bot
Copy link

hoppipolla-critic-bot commented Nov 21, 2014

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
Copy link
Member Author

jdm commented Dec 3, 2014

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

@Manishearth
Copy link
Member

Manishearth commented Dec 8, 2014

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 force-pushed the jdm:refcountdom branch from a5674fc to f2aae16 Dec 19, 2014
@jdm jdm force-pushed the jdm:refcountdom branch from e3908eb to 31c944a Dec 29, 2014
jdm added 2 commits Nov 20, 2014
…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 force-pushed the jdm:refcountdom branch from 31c944a to 9a7cd31 Dec 29, 2014
@jdm jdm added S-awaiting-merge and removed S-needs-squash labels Dec 29, 2014
@jdm

This comment has been minimized.

Copy link
Owner Author

jdm commented on 9a7cd31 Dec 29, 2014

r=Ms2ger,Manishearth

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo commented on 9a7cd31 Dec 29, 2014

saw approval from Ms2ger
at jdm@9a7cd31

This comment has been minimized.

Copy link
Contributor

bors-servo replied Dec 29, 2014

merging jdm/servo/refcountdom = 9a7cd31 into auto

This comment has been minimized.

Copy link
Contributor

bors-servo replied Dec 29, 2014

jdm/servo/refcountdom = 9a7cd31 merged ok, testing candidate = 2c259f4

This comment has been minimized.

Copy link
Contributor

bors-servo replied Dec 29, 2014

fast-forwarding master to auto = 2c259f4

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
1 check passed
1 check passed
default all tests passed
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 jdm:refcountdom branch Aug 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.