Improve tagged pointer emulation#6545
Merged
headius merged 2 commits intojruby:masterfrom Feb 1, 2021
Merged
Conversation
* Floats are considered equal? if they have the same value within flonum range. * Float#object_id and ObjectSpace.id2ref produce and recognize the flonum bits for round-tripping IDs. * RubyFloat.eql added to short-circuit RubyBasicObject.eql dynamic call. Ref ruby/spec#829
In CRuby, only integer values within the valid range for fixnum tagged pointers are considered identical. JRuby considered all Fixnum objects identical. This commit narows the JRuby identity logic to only values within the fixnum tagged pointer range.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit improves the emulation of CRuby's fixnum and flonum tagged pointers.
Float emulation of flonum:
object_idthat is reversible by ObjectSpace._id2ref.equal?.Fixnum emulation of fixnum:
equal?. Previously all equivalent Fixnum objects were consideredequal?.Impact to existing behavior:
_id2ref, non-fixnum non-flonum values are now modulo 4. This means we have halved the number of incremental object ID values available (Long.MAX_VALUE / 4 versus Long.MAX_VALUE / 2 for fixnum emulation alone).See ruby/spec#829 for some discussion of this.