summaryrefslogtreecommitdiff
path: root/yjit/src
diff options
context:
space:
mode:
authorJemma Issroff <[email protected]>2022-12-05 16:20:11 -0500
committerGitHub <[email protected]>2022-12-05 13:20:11 -0800
commite7642d8095d7f597c322ed26797d649aec7edbd9 (patch)
treeec02470ee543d64ac730c49e14dcb6f94c73cd46 /yjit/src
parent1602d75c34c39f6d2f5a505a6532c3664288ef06 (diff)
YJIT: Extract SHAPE_ID_NUM_BITS into a constant (#6863)
Notes
Notes: Merged-By: k0kubun <[email protected]>
Diffstat (limited to 'yjit/src')
-rw-r--r--yjit/src/codegen.rs9
-rw-r--r--yjit/src/cruby_bindings.inc.rs4
2 files changed, 4 insertions, 9 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index f904c7e0e1..97768eb5fe 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -2045,9 +2045,8 @@ fn gen_get_ivar(
let embed_test_result = unsafe { FL_TEST_RAW(comptime_receiver, VALUE(ROBJECT_EMBED.as_usize())) != VALUE(0) };
let expected_shape = unsafe { rb_shape_get_shape_id(comptime_receiver) };
- let shape_bit_size = unsafe { rb_shape_id_num_bits() }; // either 16 or 32 depending on RUBY_DEBUG
let shape_id_offset = unsafe { rb_shape_id_offset() };
- let shape_opnd = Opnd::mem(shape_bit_size, recv, shape_id_offset);
+ let shape_opnd = Opnd::mem(SHAPE_ID_NUM_BITS as u8, recv, shape_id_offset);
asm.comment("guard shape");
asm.cmp(shape_opnd, Opnd::UImm(expected_shape as u64));
@@ -2269,9 +2268,8 @@ fn gen_setinstancevariable(
}
let expected_shape = unsafe { rb_shape_get_shape_id(comptime_receiver) };
- let shape_bit_size = unsafe { rb_shape_id_num_bits() }; // either 16 or 32 depending on RUBY_DEBUG
let shape_id_offset = unsafe { rb_shape_id_offset() };
- let shape_opnd = Opnd::mem(shape_bit_size, recv, shape_id_offset);
+ let shape_opnd = Opnd::mem(SHAPE_ID_NUM_BITS as u8, recv, shape_id_offset);
asm.comment("guard shape");
asm.cmp(shape_opnd, Opnd::UImm(expected_shape as u64));
@@ -2334,9 +2332,8 @@ fn gen_setinstancevariable(
asm.comment("write shape");
- let shape_bit_size = unsafe { rb_shape_id_num_bits() }; // either 16 or 32 depending on RUBY_DEBUG
let shape_id_offset = unsafe { rb_shape_id_offset() };
- let shape_opnd = Opnd::mem(shape_bit_size, recv, shape_id_offset);
+ let shape_opnd = Opnd::mem(SHAPE_ID_NUM_BITS as u8, recv, shape_id_offset);
// Store the new shape
asm.store(shape_opnd, Opnd::UImm(new_shape_id as u64));
diff --git a/yjit/src/cruby_bindings.inc.rs b/yjit/src/cruby_bindings.inc.rs
index 28a1952878..ec41de6eb5 100644
--- a/yjit/src/cruby_bindings.inc.rs
+++ b/yjit/src/cruby_bindings.inc.rs
@@ -123,6 +123,7 @@ impl<T> ::std::cmp::PartialEq for __BindgenUnionField<T> {
}
}
impl<T> ::std::cmp::Eq for __BindgenUnionField<T> {}
+pub const SHAPE_ID_NUM_BITS: u32 = 32;
pub const INTEGER_REDEFINED_OP_FLAG: u32 = 1;
pub const FLOAT_REDEFINED_OP_FLAG: u32 = 2;
pub const STRING_REDEFINED_OP_FLAG: u32 = 4;
@@ -444,9 +445,6 @@ pub struct rb_shape {
}
pub type rb_shape_t = rb_shape;
extern "C" {
- pub fn rb_shape_id_num_bits() -> u8;
-}
-extern "C" {
pub fn rb_shape_id_offset() -> i32;
}
extern "C" {