summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2023-03-04 15:39:47 +0900
committerNARUSE, Yui <naruse@airemix.jp>2023-03-04 15:39:47 +0900
commitf93c7b9f58966fd04496bfeb2538fb1ff41f788e (patch)
tree9d847e7fcc04d164ce9177cb3b67f773ae0b51c0 /test/ruby
parent53f6173cfc085a7422b4a76c85e6c35969209327 (diff)
merge revision(s) b78f871d838c168789648738e5c67b071beb8a19,ecd0cdaf820af789f355f1a18c31d6adfe8aad94: [Backport #19400]
YJIT: Use the system page size when the code page size is too small (#7267) Previously on ARM64 Linux systems that use 64 KiB pages (`CONFIG_ARM64_64K_PAGES=y`), YJIT was panicking on boot due to a failed assertion. The assertion was making sure that code GC can free the last code page that YJIT manages without freeing unrelated memory. YJIT prefers picking 16 KiB as the granularity at which to free code memory, but when the system can only free at 64 KiB granularity, that is not possible. The fix is to use the system page size as the code page size when the system page size is 64 KiB. Continue to use 16 KiB as the code page size on common systems that use 16/4 KiB pages. Add asserts to code_gc() and free_page() about code GC's assumptions. Fixes [Bug #19400] --- yjit/src/asm/mod.rs | 78 ++++++++++++++++++++++++++++++++------------------ yjit/src/codegen.rs | 2 -- yjit/src/virtualmem.rs | 13 +++++++++ 3 files changed, 63 insertions(+), 30 deletions(-) YJIT: Fix assertion for partially mapped last pages (#7337) Follows up [Bug #19400] --- test/ruby/test_yjit.rb | 19 +++++++++++++++++++ yjit/src/asm/mod.rs | 2 +- yjit/src/virtualmem.rs | 18 +++++++++++++----- 3 files changed, 33 insertions(+), 6 deletions(-)
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_yjit.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb
index 6b6ea6619e..565e9843ab 100644
--- a/test/ruby/test_yjit.rb
+++ b/test/ruby/test_yjit.rb
@@ -974,6 +974,25 @@ class TestYJIT < Test::Unit::TestCase
RUBY
end
+ def test_code_gc_partial_last_page
+ # call_threshold: 2 to avoid JIT-ing code_gc itself. If code_gc were JITed right before
+ # code_gc is called, the last page would be on stack.
+ assert_compiles(<<~'RUBY', exits: :any, result: :ok, call_threshold: 2)
+ # Leave a bunch of off-stack pages
+ i = 0
+ while i < 1000
+ eval("x = proc { 1.to_s }; x.call; x.call")
+ i += 1
+ end
+
+ # On Linux, memory page size != code page size. So the last code page could be partially
+ # mapped. This call tests that assertions and other things work fine under the situation.
+ RubyVM::YJIT.code_gc
+
+ :ok
+ RUBY
+ end
+
def test_trace_script_compiled # not ISEQ_TRACE_EVENTS
assert_compiles(<<~'RUBY', exits: :any, result: :ok)
@eval_counter = 0