Non-volatile instance variables#5187
Merged
headius merged 2 commits intojruby:masterfrom Jun 12, 2018
Merged
Conversation
The field-based variables we used by default during 9.1.x already were not volatile, which is the direction we want to move people. Volatility should be achieved through libraries like concurrent-ruby, or added to Ruby as a way to declare volatility at class definition time (attr_accessor :foo, volatile: true). The risk here seems small since 99% of variable accesses have already been nonvolatile for over a year, all major concurrency libraries are using the proper mechanisms that don't require instance variable volatility, and we have received no bugs where nonvolatile field-based variables were the cause.
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.
So it turns out that since we turned on reified instance variables by default, those variables have not been volatile. This is actually good news, since we wanted to move away from a full volatility guarantee on instance variables in favor of explicit declaration (
attr_accessor :foo, volatile: true) or libraries like concurrent-ruby.This PR simply flips the switch for the remaining varTable-based instance variables, bringing them in line with field-based instance variables as far as volatility goes.
I have also filed #5186 to finish the reification project and add back the ability to turn on volatility as desired. This will be needed in any case to support declarative volatility in a future update to Ruby.