summaryrefslogtreecommitdiff
path: root/yjit.rb
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2021-11-04 12:30:30 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2021-11-22 18:23:28 -0500
commit13d1ded253940585a993e92648ab9f77d355586d (patch)
tree40cd992d429c0e7c53e6e3c4b829b69d662099ff /yjit.rb
parente42f994f6b20416853af0252029af94ff7c9b9a9 (diff)
downloadruby-13d1ded253940585a993e92648ab9f77d355586d.tar.gz
YJIT: Make block invalidation more robust
This commit adds an entry_exit field to block_t for use in invalidate_block_version(). By patching the start of the block while invalidating it, invalidate_block_version() can function correctly while there is no executable memory left for new branch stubs. This change additionally fixes correctness for situations where we cannot patch incoming jumps to the invalidated block. In situations such as Shopify/yjit#226, the address to the start of the block is saved and used later, possibly after the block is invalidated. The assume_* family of function now generate block->entry_exit before remembering blocks for invalidation. RubyVM::YJIT.simulate_oom! is introduced for testing out of memory conditions. The test for it is disabled for now because OOM triggers other failure conditions not addressed by this commit. Fixes Shopify/yjit#226
Diffstat (limited to 'yjit.rb')
-rw-r--r--yjit.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/yjit.rb b/yjit.rb
index 3592e20a7f..c555fd27cc 100644
--- a/yjit.rb
+++ b/yjit.rb
@@ -149,6 +149,10 @@ module RubyVM::YJIT
Primitive.cexpr! 'rb_yjit_enabled_p() ? Qtrue : Qfalse'
end
+ def self.simulate_oom!
+ Primitive.simulate_oom_bang
+ end
+
# Avoid calling a method here to not interfere with compilation tests
if Primitive.yjit_stats_enabled_p
at_exit { _print_stats }