Skip to content

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

@enebo

Description

@enebo

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions