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

IR needs representation of a pre-frozen String #1992

Closed
headius opened this issue Sep 20, 2014 · 3 comments
Closed

IR needs representation of a pre-frozen String #1992

headius opened this issue Sep 20, 2014 · 3 comments
Labels

Comments

@headius
Copy link
Member

headius commented Sep 20, 2014

Ruby 2.1 introduced the compiler optimization that "literal string".freeze would be recognized by the compiler to return the same object every time. But even before that, we needed frozen strings for backtick:

$ rvm ruby-2.1 do ruby -e 'o = Object.new; def o.`(x); x; end; def o.go; `hello`; end; p o.go.frozen?'
true

We did this freezing before in the backtick AST node and by extension in the bytecode we generated for it, but IR has broken backtick into the creation of the string and the invocation of the backtick method, so it is no longer being frozen.

And we'll want this for "string".freeze, String literal hash keys, and possibly other places.

@headius headius added the ir label Sep 20, 2014
@headius headius added this to the JRuby 9000 milestone Sep 20, 2014
@headius
Copy link
Member Author

headius commented Sep 20, 2014

Adding a spec to compiler/general_spec.rb for the frozen backtick string.

@headius
Copy link
Member Author

headius commented Sep 20, 2014

Actually, I'm an idiot...I was even implementing BacktickInstr logic in the JIT when I filed this. Realized we could do this for backtick by just adding the logic to backtick...but I believe we still need something for frozen literal strings.

@enebo
Copy link
Member

enebo commented Jan 15, 2015

Already done.

@enebo enebo closed this as completed Jan 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants