<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/vm.c, branch v3_2_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>merge revision(s) 08b3a45bc97c835b4677bf76dbce68fd51d81897: [Backport #21180]</title>
<updated>2025-03-13T05:27:06+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2025-03-13T04:28:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=774e3f0003ac53d604fb5dd080faf9cb41c21bcd'/>
<id>774e3f0003ac53d604fb5dd080faf9cb41c21bcd</id>
<content type='text'>
	Push a real iseq in rb_vm_push_frame_fname()

	Previously, vm_make_env_each() (used during proc
	creation and for the debug inspector C API) picked up the
	non-GC-allocated iseq that rb_vm_push_frame_fname() creates,
	which led to a SEGV when the GC tried to mark the non GC object.

	Put a real iseq imemo instead. Speed should be about the same since
	the old code also did a imemo allocation and a malloc allocation.

	Real iseq allows ironing out the special-casing of dummy frames in
	rb_execution_context_mark() and rb_execution_context_update(). A check
	is added to RubyVM::ISeq#eval, though, to stop attempts to run dummy
	iseqs.

	[Bug #21180]

	Co-authored-by: Aaron Patterson &lt;tenderlove@ruby-lang.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Push a real iseq in rb_vm_push_frame_fname()

	Previously, vm_make_env_each() (used during proc
	creation and for the debug inspector C API) picked up the
	non-GC-allocated iseq that rb_vm_push_frame_fname() creates,
	which led to a SEGV when the GC tried to mark the non GC object.

	Put a real iseq imemo instead. Speed should be about the same since
	the old code also did a imemo allocation and a malloc allocation.

	Real iseq allows ironing out the special-casing of dummy frames in
	rb_execution_context_mark() and rb_execution_context_update(). A check
	is added to RubyVM::ISeq#eval, though, to stop attempts to run dummy
	iseqs.

	[Bug #21180]

	Co-authored-by: Aaron Patterson &lt;tenderlove@ruby-lang.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 647390308239fbf82d159ecd83ed8df090af518d: [Backport #18257]</title>
<updated>2025-03-13T05:27:06+00:00</updated>
<author>
<name>Hiroshi SHIBATA</name>
<email>hsbt@ruby-lang.org</email>
</author>
<published>2025-03-12T08:56:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=0ef3411b98823a1cd12fda5209f09b5242a41562'/>
<id>0ef3411b98823a1cd12fda5209f09b5242a41562</id>
<content type='text'>
	[Bug #18257] Register the class path of FrozenCore to mark

	ICLASS does not have the path usually, so it needs to be registered
	separately.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #18257] Register the class path of FrozenCore to mark

	ICLASS does not have the path usually, so it needs to be registered
	separately.
</pre>
</div>
</content>
</entry>
<entry>
<title>Make `rb_ec_set_vm_stack` conformant to the C++11 requirement</title>
<updated>2024-11-19T10:31:46+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2024-11-17T10:56:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=2861aa22d01a817d84842dec8cc7a57c01f96139'/>
<id>2861aa22d01a817d84842dec8cc7a57c01f96139</id>
<content type='text'>
Https://learn.microsoft.com/en-us/cpp/build/reference/zc-inline-remove-unreferenced-comdat?view=msvc-140
&gt; If `/Zc:inline` is specified, the compiler enforces the C++11
&gt; requirement that all functions declared inline must have a definition
&gt; available in the same translation unit if they're used.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Https://learn.microsoft.com/en-us/cpp/build/reference/zc-inline-remove-unreferenced-comdat?view=msvc-140
&gt; If `/Zc:inline` is specified, the compiler enforces the C++11
&gt; requirement that all functions declared inline must have a definition
&gt; available in the same translation unit if they're used.
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) adaff1fc496b6f01fb1c4c812b9b4082618e2f79: [Backport #19592]</title>
<updated>2024-04-07T05:41:29+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2024-04-07T05:41:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=baa5bc16c17e3b4dac7b590ed5d6b7e705535e15'/>
<id>baa5bc16c17e3b4dac7b590ed5d6b7e705535e15</id>
<content type='text'>
	[Bug #19592] Fix ext/Setup support

	After [1], using ext/Setup to link some, but not all extensions failed
	during linking. I did not know about this option, and had assumed that
	only `--with-static-linked-ext` builds can include statically linked
	extensions.

	Include the support code for statically linked extensions in all
	configurations like before [1]. Initialize the table lazily to minimize
	footprint on builds that have no statically linked extensions.

	[1]: 790cf4b6d0475614afb127b416e87cfa39044d67 "Fix autoload status of
	         statically linked extensions"
	---
	 load.c    | 28 +++++++++++++++++-----------
	 vm.c      |  3 ---
	 vm_core.h |  6 ------
	 3 files changed, 17 insertions(+), 20 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #19592] Fix ext/Setup support

	After [1], using ext/Setup to link some, but not all extensions failed
	during linking. I did not know about this option, and had assumed that
	only `--with-static-linked-ext` builds can include statically linked
	extensions.

	Include the support code for statically linked extensions in all
	configurations like before [1]. Initialize the table lazily to minimize
	footprint on builds that have no statically linked extensions.

	[1]: 790cf4b6d0475614afb127b416e87cfa39044d67 "Fix autoload status of
	         statically linked extensions"
	---
	 load.c    | 28 +++++++++++++++++-----------
	 vm.c      |  3 ---
	 vm_core.h |  6 ------
	 3 files changed, 17 insertions(+), 20 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 1f115f141dd17f75049a5e17107906c5bcc372e1:</title>
<updated>2023-11-18T03:06:27+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-11-18T02:28:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5baf94f9131fb45d50c8c408e007a138ced46606'/>
<id>5baf94f9131fb45d50c8c408e007a138ced46606</id>
<content type='text'>
	Speed up rebuilding the loaded feature index

	Rebuilding the loaded feature index slowed down with the bug fix
	for #17885 in 79a4484a072e9769b603e7b4fbdb15b1d7eccb15.  The
	slowdown was extreme if realpath emulation was used, but even when
	not emulated, it could be about 10x slower.

	This adds loaded_features_realpath_map to rb_vm_struct. This is a
	hidden hash mapping loaded feature paths to realpaths. When
	rebuilding the loaded feature index, look at this hash to get
	cached realpath values, and skip calling rb_check_realpath if a
	cached value is found.

	Fixes [Bug #19246]
	---
	 load.c    | 27 +++++++++++++++++++++++----
	 vm.c      |  2 ++
	 vm_core.h |  1 +
	 3 files changed, 26 insertions(+), 4 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Speed up rebuilding the loaded feature index

	Rebuilding the loaded feature index slowed down with the bug fix
	for #17885 in 79a4484a072e9769b603e7b4fbdb15b1d7eccb15.  The
	slowdown was extreme if realpath emulation was used, but even when
	not emulated, it could be about 10x slower.

	This adds loaded_features_realpath_map to rb_vm_struct. This is a
	hidden hash mapping loaded feature paths to realpaths. When
	rebuilding the loaded feature index, look at this hash to get
	cached realpath values, and skip calling rb_check_realpath if a
	cached value is found.

	Fixes [Bug #19246]
	---
	 load.c    | 27 +++++++++++++++++++++++----
	 vm.c      |  2 ++
	 vm_core.h |  1 +
	 3 files changed, 26 insertions(+), 4 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "Re-apply "Ruby 3.2 - Speed up rebuilding the loaded feature index and realpath cache (#8023)" (#8252)"</title>
<updated>2023-08-24T07:06:32+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-08-24T05:56:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e777064e4b064fd77aca65c123f1919433f6732d'/>
<id>e777064e4b064fd77aca65c123f1919433f6732d</id>
<content type='text'>
This reverts commit 788b03d5ba82fd8b35ce1fe2618ce6bacc648333.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit 788b03d5ba82fd8b35ce1fe2618ce6bacc648333.
</pre>
</div>
</content>
</entry>
<entry>
<title>Re-apply "Ruby 3.2 - Speed up rebuilding the loaded feature index and realpath cache (#8023)" (#8252)</title>
<updated>2023-08-21T23:33:47+00:00</updated>
<author>
<name>MSP-Greg</name>
<email>MSP-Greg@users.noreply.github.com</email>
</author>
<published>2023-08-21T23:33:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=788b03d5ba82fd8b35ce1fe2618ce6bacc648333'/>
<id>788b03d5ba82fd8b35ce1fe2618ce6bacc648333</id>
<content type='text'>
* Re-apply "Ruby 3.2 - Speed up rebuilding the loaded feature index and realpath cache (#8023)"

* [CI] mingw.yml - remove IBM437 encoding for test-all, use cmd shell for test &amp; test-all

* Skip failing test on mingw with readline.so

Co-authored-by: nagachika &lt;nagachika@ruby-lang.org&gt;

---------

Co-authored-by: nagachika &lt;nagachika@ruby-lang.org&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Re-apply "Ruby 3.2 - Speed up rebuilding the loaded feature index and realpath cache (#8023)"

* [CI] mingw.yml - remove IBM437 encoding for test-all, use cmd shell for test &amp; test-all

* Skip failing test on mingw with readline.so

Co-authored-by: nagachika &lt;nagachika@ruby-lang.org&gt;

---------

Co-authored-by: nagachika &lt;nagachika@ruby-lang.org&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "Ruby 3.2 - Speed up rebuilding the loaded feature index and realpath cache (#8023)"</title>
<updated>2023-07-29T08:58:42+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-07-29T08:58:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1c7624469880bcb964be09a49e4907873f45b026'/>
<id>1c7624469880bcb964be09a49e4907873f45b026</id>
<content type='text'>
This reverts commit 8346d1630b8193eef1ec9dd537b16de74afdc2e8.
It seems break CI on MinGW.
https://github.com/ruby/ruby/actions/runs/5698775895/job/15447455988
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit 8346d1630b8193eef1ec9dd537b16de74afdc2e8.
It seems break CI on MinGW.
https://github.com/ruby/ruby/actions/runs/5698775895/job/15447455988
</pre>
</div>
</content>
</entry>
<entry>
<title>Ruby 3.2 - Speed up rebuilding the loaded feature index and realpath cache (#8023)</title>
<updated>2023-07-29T05:27:11+00:00</updated>
<author>
<name>Kerem Kat</name>
<email>keremkat@gmail.com</email>
</author>
<published>2023-07-29T05:27:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8346d1630b8193eef1ec9dd537b16de74afdc2e8'/>
<id>8346d1630b8193eef1ec9dd537b16de74afdc2e8</id>
<content type='text'>
* Speed up rebuilding the loaded feature index

Rebuilding the loaded feature index slowed down with the bug fix
for #17885 in 79a4484a072e9769b603e7b4fbdb15b1d7eccb15.  The
slowdown was extreme if realpath emulation was used, but even when
not emulated, it could be about 10x slower.

This adds loaded_features_realpath_map to rb_vm_struct. This is a
hidden hash mapping loaded feature paths to realpaths. When
rebuilding the loaded feature index, look at this hash to get
cached realpath values, and skip calling rb_check_realpath if a
cached value is found.

Fixes [Bug #19246]

* Add a realpath cache to reduce number of syscalls.

Number of lstat and stat syscalls for each 'require'd file is doubled,
because rb_realpath_internal is called from two places with the same
arguments in require_internal; once for checking the realpaths cache,
and once in load_iseq_eval when iseq is not found.

Introduce rb_realpath_internal_cached function to reuse the realpath_map
cache which memoizes rb_realpath_internal function, leading to less
syscalls and increased startup performance depending on the cost of the syscalls
in a particular environment.

---------

Co-authored-by: Jeremy Evans &lt;code@jeremyevans.net&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Speed up rebuilding the loaded feature index

Rebuilding the loaded feature index slowed down with the bug fix
for #17885 in 79a4484a072e9769b603e7b4fbdb15b1d7eccb15.  The
slowdown was extreme if realpath emulation was used, but even when
not emulated, it could be about 10x slower.

This adds loaded_features_realpath_map to rb_vm_struct. This is a
hidden hash mapping loaded feature paths to realpaths. When
rebuilding the loaded feature index, look at this hash to get
cached realpath values, and skip calling rb_check_realpath if a
cached value is found.

Fixes [Bug #19246]

* Add a realpath cache to reduce number of syscalls.

Number of lstat and stat syscalls for each 'require'd file is doubled,
because rb_realpath_internal is called from two places with the same
arguments in require_internal; once for checking the realpaths cache,
and once in load_iseq_eval when iseq is not found.

Introduce rb_realpath_internal_cached function to reuse the realpath_map
cache which memoizes rb_realpath_internal function, leading to less
syscalls and increased startup performance depending on the cost of the syscalls
in a particular environment.

---------

Co-authored-by: Jeremy Evans &lt;code@jeremyevans.net&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 72eb33066fa9e7dacb7470cd140b219abe37667e: [Backport #19320]</title>
<updated>2023-01-24T08:41:35+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>naruse@airemix.jp</email>
</author>
<published>2023-01-24T08:41:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a20061cb1aa34b73bdbdfa7cba6cfc575a05ca38'/>
<id>a20061cb1aa34b73bdbdfa7cba6cfc575a05ca38</id>
<content type='text'>
	Fix off-by-one error in rb_vm_each_stack_value

	Applying the following patch to test/erb/test_erb.rb and running that
	file will cause Ruby to crash on my machine (macOS 13.1 on M1 Pro):

	```
	--- a/test/erb/test_erb.rb
	+++ b/test/erb/test_erb.rb
	@@ -7,6 +7,12 @@
	 class TestERB &lt; Test::Unit::TestCase
	   class MyError &lt; RuntimeError ; end

	+  def setup
	+    GC.auto_compact = true
	+    GC.stress = true
	+    GC.verify_compaction_references(expand_heap: true, toward: :empty)
	+  end
	+
	```

	It crashes with the following log:

	```
	/Users/peter/src/ruby/lib/erb/compiler.rb:276: [BUG] Segmentation fault at 0x00000001083a8690
	...
	-- C level backtrace information -------------------------------------------
	...
	/Users/peter/src/ruby/build/ruby(rb_vm_each_stack_value+0xa8) [0x104cc3a44] ../vm.c:2737
	/Users/peter/src/ruby/build/ruby(rb_vm_each_stack_value+0xa8) [0x104cc3a44] ../vm.c:2737
	/Users/peter/src/ruby/build/ruby(check_stack_for_moved+0x2c) [0x104b272a4] ../gc.c:5512
	/Users/peter/src/ruby/build/ruby(gc_compact_finish) ../gc.c:5534
	/Users/peter/src/ruby/build/ruby(gc_sweep_compact) ../gc.c:8653
	/Users/peter/src/ruby/build/ruby(gc_sweep) ../gc.c:6196
	/Users/peter/src/ruby/build/ruby(has_sweeping_pages+0x0) [0x104b19c54] ../gc.c:9568
	/Users/peter/src/ruby/build/ruby(gc_rest) ../gc.c:9570
	```

	This crash happens because it's reading the VALUE at sp. But since
	sp points to the top of the stack, it's reading the VALUE above the
	top of the stack, which is causing this segfault.

	Fixes [Bug #19320]
	---
	 vm.c | 2 +-
	 1 file changed, 1 insertion(+), 1 deletion(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Fix off-by-one error in rb_vm_each_stack_value

	Applying the following patch to test/erb/test_erb.rb and running that
	file will cause Ruby to crash on my machine (macOS 13.1 on M1 Pro):

	```
	--- a/test/erb/test_erb.rb
	+++ b/test/erb/test_erb.rb
	@@ -7,6 +7,12 @@
	 class TestERB &lt; Test::Unit::TestCase
	   class MyError &lt; RuntimeError ; end

	+  def setup
	+    GC.auto_compact = true
	+    GC.stress = true
	+    GC.verify_compaction_references(expand_heap: true, toward: :empty)
	+  end
	+
	```

	It crashes with the following log:

	```
	/Users/peter/src/ruby/lib/erb/compiler.rb:276: [BUG] Segmentation fault at 0x00000001083a8690
	...
	-- C level backtrace information -------------------------------------------
	...
	/Users/peter/src/ruby/build/ruby(rb_vm_each_stack_value+0xa8) [0x104cc3a44] ../vm.c:2737
	/Users/peter/src/ruby/build/ruby(rb_vm_each_stack_value+0xa8) [0x104cc3a44] ../vm.c:2737
	/Users/peter/src/ruby/build/ruby(check_stack_for_moved+0x2c) [0x104b272a4] ../gc.c:5512
	/Users/peter/src/ruby/build/ruby(gc_compact_finish) ../gc.c:5534
	/Users/peter/src/ruby/build/ruby(gc_sweep_compact) ../gc.c:8653
	/Users/peter/src/ruby/build/ruby(gc_sweep) ../gc.c:6196
	/Users/peter/src/ruby/build/ruby(has_sweeping_pages+0x0) [0x104b19c54] ../gc.c:9568
	/Users/peter/src/ruby/build/ruby(gc_rest) ../gc.c:9570
	```

	This crash happens because it's reading the VALUE at sp. But since
	sp points to the top of the stack, it's reading the VALUE above the
	top of the stack, which is causing this segfault.

	Fixes [Bug #19320]
	---
	 vm.c | 2 +-
	 1 file changed, 1 insertion(+), 1 deletion(-)
</pre>
</div>
</content>
</entry>
</feed>
