aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2022-11-01 11:44:55 -0400
committerAlan Wu <XrXr@users.noreply.github.com>2022-11-01 14:16:32 -0400
commitcbf15e5cbe30cbca45810ef65224ad1bc19c67b4 (patch)
tree07c67bad9d5446a77b1d550e1d3d58f5ac6b4f6b
parenta70f90e1a95cf4dfbaa2485767156997eb958c4b (diff)
downloadruby-cbf15e5cbe30cbca45810ef65224ad1bc19c67b4.tar.gz
YJIT: Add an assert to help with Context changes
While experimenting I found that it's easy to change Context and forget to also change the copying operation in limit_block_versions(). Add an assert to make sure we substitute a compatible generic context when limiting the number of versions.
-rw-r--r--yjit/src/core.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/yjit/src/core.rs b/yjit/src/core.rs
index 70a6540b5b..dd28c2361e 100644
--- a/yjit/src/core.rs
+++ b/yjit/src/core.rs
@@ -846,7 +846,12 @@ pub fn limit_block_versions(blockid: BlockId, ctx: &Context) -> Context {
generic_ctx.stack_size = ctx.stack_size;
generic_ctx.sp_offset = ctx.sp_offset;
- // Mutate the incoming context
+ debug_assert_ne!(
+ usize::MAX,
+ ctx.diff(&generic_ctx),
+ "should substitute a compatible context",
+ );
+
return generic_ctx;
}