summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2024-10-11 15:42:45 -0400
committerPeter Zhu <[email protected]>2024-10-11 17:00:30 -0400
commit2e6ddd968d5601689f59c029bb401d7cdabab3b7 (patch)
treecd25e400a79775929b790a61e80b52a633a0bcec
parent5f62522d5b8bd162ddf657680b8532eadeaae21f (diff)
Don't enable GC.auto_compact in EnvUtil.under_gc_compact_stress when not supported
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11887
-rw-r--r--tool/lib/envutil.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/tool/lib/envutil.rb b/tool/lib/envutil.rb
index 952614b8cf..7b8aa99a39 100644
--- a/tool/lib/envutil.rb
+++ b/tool/lib/envutil.rb
@@ -259,11 +259,15 @@ module EnvUtil
def under_gc_compact_stress(val = :empty, &block)
raise "compaction doesn't work well on s390x. Omit the test in the caller." if RUBY_PLATFORM =~ /s390x/ # https://github.com/ruby/ruby/pull/5077
- auto_compact = GC.auto_compact
- GC.auto_compact = val
+
+ if GC.respond_to?(:auto_compact)
+ auto_compact = GC.auto_compact
+ GC.auto_compact = val
+ end
+
under_gc_stress(&block)
ensure
- GC.auto_compact = auto_compact
+ GC.auto_compact = auto_compact if GC.respond_to?(:auto_compact)
end
module_function :under_gc_compact_stress