Backport string deduplication fixes from 9.3#7021
Merged
headius merged 5 commits intojruby:jruby-9.2from Jan 20, 2022
Merged
Conversation
* Always freeze and dedup, even if already frozen * Dup first if not "bare" (without ivars and with String class)
This is different in Ruby 3.0, which appears to deduplicate and return a new string always. The 3.0 behavior will need to be preserved in JRuby 9.4.
We use the same table to store the infrequently used object_id, FFI native pointer reference, and ObjectSpace weakref-manager objects. When these are the only variables on a given type, any allocated ivar table will only be large enough to contain these values. However when the type in question has had a Ruby instance variable assigned anywhere in the system, all future variable tables will be sized to handle both the internal variable and the instance variables, whether or not the instance variables have been set. This results in future objects looking like they have instance variables even if they only have internal variables. This change scans the variable table list, skipping internal variables, to see if any instance variables have actually been set. This allows the instance variable check for interned strings to work properly when some other string in the system received an instance variable.
* Check for tainting during deduplication and skip interning if tainted. Fixes jruby#7018 Backported to 9.2 from 9.3 via 59f08d5 minus hash key deduplication not present in Ruby 2.5.
Member
Author
|
This also fixes #7018 for 9.2.21.0. |
* Frozen strings are not deduplicated in Ruby 2.5. * Cherry-pick of eb11c5d brought along this behavior. See jruby#7021
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 PR combines the following commits, cherry-picked to the 9.2 branch:
String#-@.