<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/vm_method.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) 56ecc243e230e8e99761ec0ffc5116601f094bb0: [Backport #20868]</title>
<updated>2024-11-10T04:04:43+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2024-11-10T04:04:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ee3428aa0e3a11ed1574b7d99222f6f08737f818'/>
<id>ee3428aa0e3a11ed1574b7d99222f6f08737f818</id>
<content type='text'>
	[Bug #20868] Fix Method#hash to not change after compaction

	The hash value of a Method must remain constant after a compaction, otherwise
	it may not work as the key in a hash table.

	For example:

	    def a; end

	    # Need this method here because otherwise the iseq may be on the C stack
	    # which would get pinned and not move during compaction
	    def get_hash
	      method(:a).hash
	    end

	    puts get_hash # =&gt; 2993401401091578131

	    GC.verify_compaction_references(expand_heap: true, toward: :empty)

	    puts get_hash # =&gt; -2162775864511574135
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #20868] Fix Method#hash to not change after compaction

	The hash value of a Method must remain constant after a compaction, otherwise
	it may not work as the key in a hash table.

	For example:

	    def a; end

	    # Need this method here because otherwise the iseq may be on the C stack
	    # which would get pinned and not move during compaction
	    def get_hash
	      method(:a).hash
	    end

	    puts get_hash # =&gt; 2993401401091578131

	    GC.verify_compaction_references(expand_heap: true, toward: :empty)

	    puts get_hash # =&gt; -2162775864511574135
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 58918788abd63901588e4aa1e39b5c057321c10a: [Backport #20342]</title>
<updated>2024-07-15T08:56:01+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2024-07-15T08:56:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b72deb7ca1198f8c799cd5e7e44635cf50abd7ec'/>
<id>b72deb7ca1198f8c799cd5e7e44635cf50abd7ec</id>
<content type='text'>
	[Bug #20342] Consider wrapped load in `main` methods
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #20342] Consider wrapped load in `main` methods
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 8b236e0c66da8f92e9fc33de66cfbc8e4b0c0763: [Backport #19896]</title>
<updated>2023-09-30T04:46:29+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-09-30T04:46:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=97b7070ebd5493de8d3a6a9b0ecc91bef5068d3f'/>
<id>97b7070ebd5493de8d3a6a9b0ecc91bef5068d3f</id>
<content type='text'>
	[Bug #19896]

	fix memory leak in vm_method

	This introduces a unified reference_count to clarify who is referencing a method.
	This also allows us to treat the refinement method as the def owner since it counts itself as a reference

	Co-authored-by: Peter Zhu &lt;peter@peterzhu.ca&gt;
	---
	 gc.c                     |   4 +-
	 method.h                 |   6 +--
	 rjit_c.rb                |   6 +--
	 test/ruby/test_module.rb |   4 +-
	 vm_insnhelper.c          |   2 +-
	 vm_method.c              | 105 +++++++++++++++++++----------------------------
	 6 files changed, 54 insertions(+), 73 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #19896]

	fix memory leak in vm_method

	This introduces a unified reference_count to clarify who is referencing a method.
	This also allows us to treat the refinement method as the def owner since it counts itself as a reference

	Co-authored-by: Peter Zhu &lt;peter@peterzhu.ca&gt;
	---
	 gc.c                     |   4 +-
	 method.h                 |   6 +--
	 rjit_c.rb                |   6 +--
	 test/ruby/test_module.rb |   4 +-
	 vm_insnhelper.c          |   2 +-
	 vm_method.c              | 105 +++++++++++++++++++----------------------------
	 6 files changed, 54 insertions(+), 73 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 96c5a4be7b0d72502001734770af0f4a735c544c: [Backport #19894]</title>
<updated>2023-09-24T06:13:32+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-09-24T06:13:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9ee58b2054c1bbe722ae5a2a4ec6a750ee583220'/>
<id>9ee58b2054c1bbe722ae5a2a4ec6a750ee583220</id>
<content type='text'>
	Fix memory leak in complemented method entries

	[Bug #19894]

	When a copy of a complemented method entry is created, there are two
	issues:

	1. IMEMO_FL_USER3 is not copied, so the complemented status is not
	   copied over.
	2. In rb_method_entry_clone we increment both alias_count and
	   complemented_count. However, when we free the method entry in
	   rb_method_definition_release, we only decrement one of the two
	   counters, resulting in the rb_method_definition_t being leaked.

	Co-authored-by: Adam Hess &lt;adamhess1991@gmail.com&gt;
	---
	 method.h                 |  5 +++--
	 test/ruby/test_module.rb | 29 +++++++++++++++++++++++++++++
	 vm_method.c              |  8 +++++---
	 3 files changed, 37 insertions(+), 5 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Fix memory leak in complemented method entries

	[Bug #19894]

	When a copy of a complemented method entry is created, there are two
	issues:

	1. IMEMO_FL_USER3 is not copied, so the complemented status is not
	   copied over.
	2. In rb_method_entry_clone we increment both alias_count and
	   complemented_count. However, when we free the method entry in
	   rb_method_definition_release, we only decrement one of the two
	   counters, resulting in the rb_method_definition_t being leaked.

	Co-authored-by: Adam Hess &lt;adamhess1991@gmail.com&gt;
	---
	 method.h                 |  5 +++--
	 test/ruby/test_module.rb | 29 +++++++++++++++++++++++++++++
	 vm_method.c              |  8 +++++---
	 3 files changed, 37 insertions(+), 5 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 537183cd2ac0163851277b46a2f21ea5914c11c0: [Backport #19577]</title>
<updated>2023-07-17T00:50:10+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-07-17T00:50:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=98b4ac7287928c202c90e9de1ae02c0707ec68b8'/>
<id>98b4ac7287928c202c90e9de1ae02c0707ec68b8</id>
<content type='text'>
	Fix write barrier order for `klass` to `cme` edge

	Previously, the following crashes with
	`CFLAGS=-DRGENGC_CHECK_MODE=2 -DRUBY_DEBUG=1 -fno-inline`:

	    $ ./miniruby -e 'GC.stress = true; Marshal.dump({})'

	It crashes with a write barrier (WB) miss assertion on an edge from the
	`Hash` class object to a newly allocated negative method entry.

	This is due to usages of vm_ccs_create() running the WB too early,
	before the method entry is inserted into the cc table, so before the
	reference edge is established. The insertion can trigger GC and promote
	the class object, so running the WB after the insertion is necessary.
	Move the insertion into vm_ccs_create() and run the WB after the
	insertion.

	Discovered on CI:
	http://ci.rvm.jp/results/trunk-asserts@ruby-sp2-docker/4391770
	---
	 vm_eval.c       |  3 +--
	 vm_insnhelper.c | 10 ++++++----
	 vm_method.c     |  3 +--
	 3 files changed, 8 insertions(+), 8 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Fix write barrier order for `klass` to `cme` edge

	Previously, the following crashes with
	`CFLAGS=-DRGENGC_CHECK_MODE=2 -DRUBY_DEBUG=1 -fno-inline`:

	    $ ./miniruby -e 'GC.stress = true; Marshal.dump({})'

	It crashes with a write barrier (WB) miss assertion on an edge from the
	`Hash` class object to a newly allocated negative method entry.

	This is due to usages of vm_ccs_create() running the WB too early,
	before the method entry is inserted into the cc table, so before the
	reference edge is established. The insertion can trigger GC and promote
	the class object, so running the WB after the insertion is necessary.
	Move the insertion into vm_ccs_create() and run the WB after the
	insertion.

	Discovered on CI:
	http://ci.rvm.jp/results/trunk-asserts@ruby-sp2-docker/4391770
	---
	 vm_eval.c       |  3 +--
	 vm_insnhelper.c | 10 ++++++----
	 vm_method.c     |  3 +--
	 3 files changed, 8 insertions(+), 8 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>MJIT: Cancel all on disastrous situations (#7019)</title>
<updated>2022-12-24T09:13:40+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-12-24T09:13:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b9332ac8e7126066ac4238443d63eaa4c06789f9'/>
<id>b9332ac8e7126066ac4238443d63eaa4c06789f9</id>
<content type='text'>
I noticed this while running test_yjit with --mjit-call-threshold=1, 
which redefines `Integer#&lt;`. When Ruby is monkey-patched, 
MJIT itself could be broken.

Similarly, Ruby scripts could break MJIT in many different ways. I
prepared the same set of hooks as YJIT so that we could possibly
override it and disable it on those moments. Every constant under
RubyVM::MJIT is private and thus it's an unsupported behavior though.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I noticed this while running test_yjit with --mjit-call-threshold=1, 
which redefines `Integer#&lt;`. When Ruby is monkey-patched, 
MJIT itself could be broken.

Similarly, Ruby scripts could break MJIT in many different ways. I
prepared the same set of hooks as YJIT so that we could possibly
override it and disable it on those moments. Every constant under
RubyVM::MJIT is private and thus it's an unsupported behavior though.</pre>
</div>
</content>
</entry>
<entry>
<title>Use consistent style [ci skip]</title>
<updated>2022-12-02T14:46:21+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2022-12-02T14:43:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f28e79caaa592e6198a2af66ac4d55719383b67c'/>
<id>f28e79caaa592e6198a2af66ac4d55719383b67c</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Module#remove_method: Check frozen on the right object</title>
<updated>2022-12-01T22:32:41+00:00</updated>
<author>
<name>Jean byroot Boussier</name>
<email>jean.boussier+github@shopify.com</email>
</author>
<published>2022-12-01T22:32:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=3d272b0fc822f5c2e9c716377b7fcecf15426b27'/>
<id>3d272b0fc822f5c2e9c716377b7fcecf15426b27</id>
<content type='text'>
Previously, the frozen check happened on `RCLASS_ORIGIN(self)`, which
can return an iclass. The frozen check is supposed to respond to objects
that users can call methods on while iclasses are hidden from users.
Other mutation methods like Module#{define_method,alias_method,public}
don't do this. Check frozen status on the module itself.

Fixes [Bug #19164] and [Bug #19166].

Co-authored-by: Alan Wu &lt;XrXr@users.noreply.github.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, the frozen check happened on `RCLASS_ORIGIN(self)`, which
can return an iclass. The frozen check is supposed to respond to objects
that users can call methods on while iclasses are hidden from users.
Other mutation methods like Module#{define_method,alias_method,public}
don't do this. Check frozen status on the module itself.

Fixes [Bug #19164] and [Bug #19166].

Co-authored-by: Alan Wu &lt;XrXr@users.noreply.github.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>Using UNDEF_P macro</title>
<updated>2022-11-16T09:58:33+00:00</updated>
<author>
<name>S-H-GAMELINKS</name>
<email>gamelinks007@gmail.com</email>
</author>
<published>2022-11-15T04:24:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6'/>
<id>1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: Invalidate redefined methods only through cme (#6734)</title>
<updated>2022-11-15T20:57:43+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-11-15T20:57:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1125274c4e8aeffd8609ced41c05d26d45b9b5ad'/>
<id>1125274c4e8aeffd8609ced41c05d26d45b9b5ad</id>
<content type='text'>
Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;

Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;

Co-authored-by: Alan Wu &lt;alansi.xingwu@shopify.com&gt;</pre>
</div>
</content>
</entry>
</feed>
