<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_rubyvm.rb, branch v3_4_9</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>[PRISM] Refactor parser support into its own module</title>
<updated>2024-07-19T01:15:54+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2024-07-18T19:04:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1c81d1a69dfc909baf128d6d1ffe636f2e8a3194'/>
<id>1c81d1a69dfc909baf128d6d1ffe636f2e8a3194</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[PRISM] Enable RubyVM tests for prism</title>
<updated>2024-05-03T17:11:09+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2024-05-03T16:27:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=461d6d441febd882d53fcf8cfef9635962e5b08c'/>
<id>461d6d441febd882d53fcf8cfef9635962e5b08c</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove unused class serial</title>
<updated>2022-10-21T21:56:48+00:00</updated>
<author>
<name>Jemma Issroff</name>
<email>jemmaissroff@gmail.com</email>
</author>
<published>2022-10-21T16:58:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=13bd617ea6fdf72467c593639cf33312a06c330c'/>
<id>13bd617ea6fdf72467c593639cf33312a06c330c</id>
<content type='text'>
Before object shapes, we were using class serial to invalidate
inline caches. Now that we use shape_id for inline cache keys,
the class serial is unnecessary.

Co-Authored-By: Aaron Patterson &lt;tenderlove@ruby-lang.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Before object shapes, we were using class serial to invalidate
inline caches. Now that we use shape_id for inline cache keys,
the class serial is unnecessary.

Co-Authored-By: Aaron Patterson &lt;tenderlove@ruby-lang.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Finer-grained constant cache invalidation (take 2)</title>
<updated>2022-04-01T18:48:22+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2022-03-31T15:04:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=6068da8937d7e4358943f95e7450dae7179a7763'/>
<id>6068da8937d7e4358943f95e7450dae7179a7763</id>
<content type='text'>
This commit reintroduces finer-grained constant cache invalidation.
After 8008fb7 got merged, it was causing issues on token-threaded
builds (such as on Windows).

The issue was that when you're iterating through instruction sequences
and using the translator functions to get back the instruction structs,
you're either using `rb_vm_insn_null_translator` or
`rb_vm_insn_addr2insn2` depending if it's a direct-threading build.
`rb_vm_insn_addr2insn2` does some normalization to always return to
you the non-trace version of whatever instruction you're looking at.
`rb_vm_insn_null_translator` does not do that normalization.

This means that when you're looping through the instructions if you're
trying to do an opcode comparison, it can change depending on the type
of threading that you're using. This can be very confusing. So, this
commit creates a new translator function
`rb_vm_insn_normalizing_translator` to always return the non-trace
version so that opcode comparisons don't have to worry about different
configurations.

[Feature #18589]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit reintroduces finer-grained constant cache invalidation.
After 8008fb7 got merged, it was causing issues on token-threaded
builds (such as on Windows).

The issue was that when you're iterating through instruction sequences
and using the translator functions to get back the instruction structs,
you're either using `rb_vm_insn_null_translator` or
`rb_vm_insn_addr2insn2` depending if it's a direct-threading build.
`rb_vm_insn_addr2insn2` does some normalization to always return to
you the non-trace version of whatever instruction you're looking at.
`rb_vm_insn_null_translator` does not do that normalization.

This means that when you're looping through the instructions if you're
trying to do an opcode comparison, it can change depending on the type
of threading that you're using. This can be very confusing. So, this
commit creates a new translator function
`rb_vm_insn_normalizing_translator` to always return the non-trace
version so that opcode comparisons don't have to worry about different
configurations.

[Feature #18589]
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "Finer-grained inline constant cache invalidation"</title>
<updated>2022-03-25T11:29:09+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2022-03-25T11:29:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=69967ee64eac9ce65b83533a566d69d12a6046d0'/>
<id>69967ee64eac9ce65b83533a566d69d12a6046d0</id>
<content type='text'>
This reverts commits for [Feature #18589]:
* 8008fb7352abc6fba433b99bf20763cf0d4adb38
  "Update formatting per feedback"
* 8f6eaca2e19828e92ecdb28b0fe693d606a03f96
  "Delete ID from constant cache table if it becomes empty on ISEQ free"
* 629908586b4bead1103267652f8b96b1083573a8
  "Finer-grained inline constant cache invalidation"

MSWin builds on AppVeyor have been crashing since the merger.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commits for [Feature #18589]:
* 8008fb7352abc6fba433b99bf20763cf0d4adb38
  "Update formatting per feedback"
* 8f6eaca2e19828e92ecdb28b0fe693d606a03f96
  "Delete ID from constant cache table if it becomes empty on ISEQ free"
* 629908586b4bead1103267652f8b96b1083573a8
  "Finer-grained inline constant cache invalidation"

MSWin builds on AppVeyor have been crashing since the merger.
</pre>
</div>
</content>
</entry>
<entry>
<title>Finer-grained inline constant cache invalidation</title>
<updated>2022-03-24T16:14:38+00:00</updated>
<author>
<name>Kevin Newton</name>
<email>kddnewton@gmail.com</email>
</author>
<published>2021-11-24T15:31:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=629908586b4bead1103267652f8b96b1083573a8'/>
<id>629908586b4bead1103267652f8b96b1083573a8</id>
<content type='text'>
Current behavior - caches depend on a global counter. All constant mutations cause caches to be invalidated.

```ruby
class A
  B = 1
end

def foo
  A::B # inline cache depends on global counter
end

foo # populate inline cache
foo # hit inline cache

C = 1 # global counter increments, all caches are invalidated

foo # misses inline cache due to `C = 1`
```

Proposed behavior - caches depend on name components. Only constant mutations with corresponding names will invalidate the cache.

```ruby
class A
  B = 1
end

def foo
  A::B # inline cache depends constants named "A" and "B"
end

foo # populate inline cache
foo # hit inline cache

C = 1 # caches that depend on the name "C" are invalidated

foo # hits inline cache because IC only depends on "A" and "B"
```

Examples of breaking the new cache:

```ruby
module C
  # Breaks `foo` cache because "A" constant is set and the cache in foo depends
  # on "A" and "B"
  class A; end
end

B = 1
```

We expect the new cache scheme to be invalidated less often because names aren't frequently reused. With the cache being invalidated less, we can rely on its stability more to keep our constant references fast and reduce the need to throw away generated code in YJIT.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Current behavior - caches depend on a global counter. All constant mutations cause caches to be invalidated.

```ruby
class A
  B = 1
end

def foo
  A::B # inline cache depends on global counter
end

foo # populate inline cache
foo # hit inline cache

C = 1 # global counter increments, all caches are invalidated

foo # misses inline cache due to `C = 1`
```

Proposed behavior - caches depend on name components. Only constant mutations with corresponding names will invalidate the cache.

```ruby
class A
  B = 1
end

def foo
  A::B # inline cache depends constants named "A" and "B"
end

foo # populate inline cache
foo # hit inline cache

C = 1 # caches that depend on the name "C" are invalidated

foo # hits inline cache because IC only depends on "A" and "B"
```

Examples of breaking the new cache:

```ruby
module C
  # Breaks `foo` cache because "A" constant is set and the cache in foo depends
  # on "A" and "B"
  class A; end
end

B = 1
```

We expect the new cache scheme to be invalidated less often because names aren't frequently reused. With the cache being invalidated less, we can rely on its stability more to keep our constant references fast and reduce the need to throw away generated code in YJIT.
</pre>
</div>
</content>
</entry>
<entry>
<title>pend some tests while using to_binary</title>
<updated>2022-01-30T18:47:03+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2022-01-30T18:27:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e75bd8df51648a35442649fd3e4b9ac4e223752a'/>
<id>e75bd8df51648a35442649fd3e4b9ac4e223752a</id>
<content type='text'>
ISeqs from ISeq#to_binary/load do not support `keep_script_lines`
now so some tests should be pending tests with
`RUBY_ISEQ_DUMP_DEBUG=to_binary`
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ISeqs from ISeq#to_binary/load do not support `keep_script_lines`
now so some tests should be pending tests with
`RUBY_ISEQ_DUMP_DEBUG=to_binary`
</pre>
</div>
</content>
</entry>
<entry>
<title>test/ruby/test_rubyvm.rb: prevent "assigned but unused variable" warnings</title>
<updated>2021-10-25T11:45:05+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2021-10-25T11:45:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1eac38c6093a03688c2f046cfb6a16028b9395f5'/>
<id>1eac38c6093a03688c2f046cfb6a16028b9395f5</id>
<content type='text'>
http://rubyci.s3.amazonaws.com/centos7/ruby-master/log/20211025T093004Z.log.html.gz
```
[ 4896/21159] TestRubyVM#test_keep_script_lines(none):3: warning: assigned but unused variable - b
(none):6: warning: assigned but unused variable - c
(none):1: warning: assigned but unused variable - a
&lt;compiled&gt;:3: warning: assigned but unused variable - b
(none):3: warning: assigned but unused variable - b
(none):6: warning: assigned but unused variable - c
(none):1: warning: assigned but unused variable - a
&lt;compiled&gt;:3: warning: assigned but unused variable - b
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
http://rubyci.s3.amazonaws.com/centos7/ruby-master/log/20211025T093004Z.log.html.gz
```
[ 4896/21159] TestRubyVM#test_keep_script_lines(none):3: warning: assigned but unused variable - b
(none):6: warning: assigned but unused variable - c
(none):1: warning: assigned but unused variable - a
&lt;compiled&gt;:3: warning: assigned but unused variable - b
(none):3: warning: assigned but unused variable - b
(none):6: warning: assigned but unused variable - c
(none):1: warning: assigned but unused variable - a
&lt;compiled&gt;:3: warning: assigned but unused variable - b
```
</pre>
</div>
</content>
</entry>
<entry>
<title>freeze (make shareable) script_lines</title>
<updated>2021-10-21T07:17:39+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2021-09-30T08:30:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7185c00fcc330db8951b684f548ba3d10983bb92'/>
<id>7185c00fcc330db8951b684f548ba3d10983bb92</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>`RubyVM.keep_script_lines`</title>
<updated>2021-10-21T07:17:39+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2021-09-30T07:58:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c7550537f11dcf6450a9d3df3af3fa1f4fe05b15'/>
<id>c7550537f11dcf6450a9d3df3af3fa1f4fe05b15</id>
<content type='text'>
`RubyVM.keep_script_lines` enables to keep script lines
for each ISeq and AST. This feature is for debugger/REPL
support.

```ruby
RubyVM.keep_script_lines = true
RubyVM::keep_script_lines = true

eval("def foo = nil\ndef bar = nil")
pp RubyVM::InstructionSequence.of(method(:foo)).script_lines
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`RubyVM.keep_script_lines` enables to keep script lines
for each ISeq and AST. This feature is for debugger/REPL
support.

```ruby
RubyVM.keep_script_lines = true
RubyVM::keep_script_lines = true

eval("def foo = nil\ndef bar = nil")
pp RubyVM::InstructionSequence.of(method(:foo)).script_lines
```
</pre>
</div>
</content>
</entry>
</feed>
