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

Projects
None yet
2 participants
@headius
Member

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.

Revert to using weakref.rb, since it's based on a proper weak map.
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 Jan 8, 2018

@headius

This comment has been minimized.

Member

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

0 of 2 checks passed

continuous-integration/travis-ci/push The Travis CI build failed
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details

@headius headius deleted the use_ruby_weakref branch Jan 8, 2018

@enebo

This comment has been minimized.

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