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

Revert to using weakref.rb, since it's based on a proper weak map. #4955

Merged
merged 1 commit into from
Jan 8, 2018

Conversation

headius
Copy link
Member

@headius headius commented Jan 8, 2018

Opening as PR since this is a nontrivial change to put into 9.1, even though it aligns us better with MRI. Primary reason for this change is to get weakref specs to be more reliable...perhaps bringing our impl closer to theirs will do this.

This library used to use _id2ref (an internal API) for its
implementation. This was not only very VM-specific (most VMs
can't reconstitute an object reference given only its ID) but also
buggy (an evacuated reference might get overlaid by a new object
due to MRI's conservative GC and use of address for IDs.

The new implementation of the library uses ObjectSpace::WeakMap,
which is considered an internal API but which exposes an opaque
weak identity map that can be implemented on other VMs more
more easily. Given this and our need to continue descending from
Delegate, moving back to the Ruby version may make sense.

This library used to use _id2ref (an internal API) for its
implementation. This was not only very VM-specific (most VMs
can't reconstitute an object reference given only its ID) but also
buggy (an evacuated reference might get overlaid by a new object
due to MRI's conservative GC and use of address for IDs.

The new implementation of the library uses ObjectSpace::WeakMap,
which is considered an internal API but which exposes an opaque
weak identity map that can be implemented on other VMs more
more easily. Given this and our need to continue descending from
Delegate, moving back to the Ruby version may make sense.
@headius headius added this to the JRuby 9.1.16.0 milestone Jan 8, 2018
@headius headius requested review from enebo and kares January 8, 2018 19:41
@headius
Copy link
Member Author

headius commented Jan 8, 2018

@enebo @kares In the interest of getting CI green I'm going forward with this on 9.1 branch. Let me know if you have any concerns.

@headius headius merged commit 1b4a2f3 into jruby-9.1 Jan 8, 2018
@headius headius deleted the use_ruby_weakref branch January 8, 2018 20:59
@enebo
Copy link
Member

enebo commented Jan 8, 2018

for posterity I liked the notion of leaning on this library to only have one thing we need to maintain involving weak references :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants