This commit is contained in:
Jemma Issroff 2022-12-02 12:33:20 -05:00 коммит произвёл Takashi Kokubun
Родитель 606653e43a
Коммит 4c5e89791b
5 изменённых файлов: 17 добавлений и 6 удалений

Просмотреть файл

@ -306,6 +306,12 @@ rb_shape_id_num_bits(void)
return SHAPE_ID_NUM_BITS; return SHAPE_ID_NUM_BITS;
} }
int32_t
rb_shape_id_offset(void)
{
return 8 - rb_shape_id_num_bits() / 8;
}
uint8_t uint8_t
rb_shape_flag_shift(void) rb_shape_flag_shift(void)
{ {

Просмотреть файл

@ -124,6 +124,7 @@ static inline shape_id_t RCLASS_SHAPE_ID(VALUE obj)
bool rb_shape_root_shape_p(rb_shape_t* shape); bool rb_shape_root_shape_p(rb_shape_t* shape);
rb_shape_t * rb_shape_get_root_shape(void); rb_shape_t * rb_shape_get_root_shape(void);
uint8_t rb_shape_id_num_bits(void); uint8_t rb_shape_id_num_bits(void);
int32_t rb_shape_id_offset(void);
uint64_t rb_shape_flag_mask(void); uint64_t rb_shape_flag_mask(void);
uint8_t rb_shape_flag_shift(void); uint8_t rb_shape_flag_shift(void);

Просмотреть файл

@ -86,6 +86,7 @@ fn main() {
.allowlist_function("rb_shape_get_shape_id") .allowlist_function("rb_shape_get_shape_id")
.allowlist_function("rb_shape_get_shape_by_id") .allowlist_function("rb_shape_get_shape_by_id")
.allowlist_function("rb_shape_id_num_bits") .allowlist_function("rb_shape_id_num_bits")
.allowlist_function("rb_shape_id_offset")
.allowlist_function("rb_shape_get_iv_index") .allowlist_function("rb_shape_get_iv_index")
.allowlist_function("rb_shape_get_next") .allowlist_function("rb_shape_get_next")
.allowlist_function("rb_shape_id") .allowlist_function("rb_shape_id")

Просмотреть файл

@ -2046,8 +2046,8 @@ fn gen_get_ivar(
let expected_shape = unsafe { rb_shape_get_shape_id(comptime_receiver) }; 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_bit_size = unsafe { rb_shape_id_num_bits() }; // either 16 or 32 depending on RUBY_DEBUG
let shape_byte_size = shape_bit_size / 8; let shape_id_offset = unsafe { rb_shape_id_offset() };
let shape_opnd = Opnd::mem(shape_bit_size, recv, RUBY_OFFSET_RBASIC_FLAGS + (8 - shape_byte_size as i32)); let shape_opnd = Opnd::mem(shape_bit_size, recv, shape_id_offset);
asm.comment("guard shape"); asm.comment("guard shape");
asm.cmp(shape_opnd, Opnd::UImm(expected_shape as u64)); asm.cmp(shape_opnd, Opnd::UImm(expected_shape as u64));
@ -2270,8 +2270,8 @@ fn gen_setinstancevariable(
let expected_shape = unsafe { rb_shape_get_shape_id(comptime_receiver) }; 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_bit_size = unsafe { rb_shape_id_num_bits() }; // either 16 or 32 depending on RUBY_DEBUG
let shape_byte_size = shape_bit_size / 8; let shape_id_offset = unsafe { rb_shape_id_offset() };
let shape_opnd = Opnd::mem(shape_bit_size, recv, RUBY_OFFSET_RBASIC_FLAGS + (8 - shape_byte_size as i32)); let shape_opnd = Opnd::mem(shape_bit_size, recv, shape_id_offset);
asm.comment("guard shape"); asm.comment("guard shape");
asm.cmp(shape_opnd, Opnd::UImm(expected_shape as u64)); asm.cmp(shape_opnd, Opnd::UImm(expected_shape as u64));
@ -2335,8 +2335,8 @@ fn gen_setinstancevariable(
asm.comment("write shape"); asm.comment("write shape");
let shape_bit_size = unsafe { rb_shape_id_num_bits() }; // either 16 or 32 depending on RUBY_DEBUG let shape_bit_size = unsafe { rb_shape_id_num_bits() }; // either 16 or 32 depending on RUBY_DEBUG
let shape_byte_size = shape_bit_size / 8; let shape_id_offset = unsafe { rb_shape_id_offset() };
let shape_opnd = Opnd::mem(shape_bit_size, recv, RUBY_OFFSET_RBASIC_FLAGS + (8 - shape_byte_size as i32)); let shape_opnd = Opnd::mem(shape_bit_size, recv, shape_id_offset);
// Store the new shape // Store the new shape
asm.store(shape_opnd, Opnd::UImm(new_shape_id as u64)); asm.store(shape_opnd, Opnd::UImm(new_shape_id as u64));

Просмотреть файл

@ -443,6 +443,9 @@ pub type rb_shape_t = rb_shape;
extern "C" { extern "C" {
pub fn rb_shape_id_num_bits() -> u8; pub fn rb_shape_id_num_bits() -> u8;
} }
extern "C" {
pub fn rb_shape_id_offset() -> i32;
}
extern "C" { extern "C" {
pub fn rb_shape_flag_mask() -> u64; pub fn rb_shape_flag_mask() -> u64;
} }