$. never seems to change once JIT'd #4508

Closed
enebo opened this Issue Feb 25, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@enebo
Member

enebo commented Feb 25, 2017

I was debugging some stuff around $. and ARGF and noticed $. was not changing:

jruby -e 'ARGF.skip; ARGF.each_line { |d| $. = 100 if $. == 3;puts "file: #{ARGF.file}, $.: #{$.}, lineno: #{ARGF.lineno}, file.lineno: #{ARGF.file.lineno}" }' Rakefile Gemfile

look at the $. output:

file: #<File:0x587d1d39>, $.: 1, lineno: 1, file.lineno: 1
file: #<File:0x587d1d39>, $.: 1, lineno: 2, file.lineno: 2
file: #<File:0x6b9651f3>, $.: 1, lineno: 3, file.lineno: 1
file: #<File:0x6b9651f3>, $.: 1, lineno: 4, file.lineno: 2
file: #<File:0x6b9651f3>, $.: 1, lineno: 5, file.lineno: 3
file: #<File:0x6b9651f3>, $.: 1, lineno: 6, file.lineno: 4
file: #<File:0x6b9651f3>, $.: 1, lineno: 7, file.lineno: 5

If I run in interp:

file: #<File:0x6acdbdf5>, $.: 1, lineno: 1, file.lineno: 1
file: #<File:0x6acdbdf5>, $.: 2, lineno: 2, file.lineno: 2
file: #<File:0x3712b94>, $.: 100, lineno: 100, file.lineno: 1
file: #<File:0x3712b94>, $.: 101, lineno: 101, file.lineno: 2
file: #<File:0x3712b94>, $.: 102, lineno: 102, file.lineno: 3
file: #<File:0x3712b94>, $.: 103, lineno: 103, file.lineno: 4
file: #<File:0x3712b94>, $.: 104, lineno: 104, file.lineno: 5

(Note: This is local on my branch on the $. number in the first output will display like this until I land my changes)

So $. is always 1 and that is because global bootstrapping is setting up a switchpoint and caching a value but $. is special in that it is an opaque global. It never changes as an object. It's get looks at Ruby.getCurrentLine(). So we need to be able to invalidate $. whenever we set setCurrentLine and have our switch point see that...

I suspect this one of a few other special system gloabsl which are similiarly opaque to our indy caching strategy.

@enebo enebo added this to the JRuby 9.1.8.0 milestone Feb 25, 2017

@enebo

This comment has been minimized.

Show comment
Hide comment
@enebo

enebo Feb 27, 2017

Member

$FILENAME is also unsurprisingly affected.

Member

enebo commented Feb 27, 2017

$FILENAME is also unsurprisingly affected.

@headius headius closed this in a591b4a Mar 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment