mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 04:07:58 +00:00
YJIT: Pass class and shape ID directly instead of object
This commit is contained in:
parent
f167073324
commit
b43e66d3b3
Notes:
git
2025-12-03 21:59:56 +00:00
4
shape.c
4
shape.c
@ -950,12 +950,10 @@ rb_shape_transition_add_ivar(VALUE obj, ID id)
|
||||
}
|
||||
|
||||
shape_id_t
|
||||
rb_shape_transition_add_ivar_no_warnings(VALUE obj, ID id)
|
||||
rb_shape_transition_add_ivar_no_warnings(VALUE klass, shape_id_t original_shape_id, ID id)
|
||||
{
|
||||
shape_id_t original_shape_id = RBASIC_SHAPE_ID(obj);
|
||||
RUBY_ASSERT(!shape_frozen_p(original_shape_id));
|
||||
|
||||
VALUE klass = obj_get_owner_class(obj);
|
||||
rb_shape_t *next_shape = shape_get_next(RSHAPE(original_shape_id), SHAPE_IVAR, klass, id, false);
|
||||
if (next_shape) {
|
||||
return shape_id(next_shape, original_shape_id);
|
||||
|
||||
2
shape.h
2
shape.h
@ -230,7 +230,7 @@ shape_id_t rb_shape_transition_frozen(VALUE obj);
|
||||
shape_id_t rb_shape_transition_complex(VALUE obj);
|
||||
shape_id_t rb_shape_transition_remove_ivar(VALUE obj, ID id, shape_id_t *removed_shape_id);
|
||||
shape_id_t rb_shape_transition_add_ivar(VALUE obj, ID id);
|
||||
shape_id_t rb_shape_transition_add_ivar_no_warnings(VALUE obj, ID id);
|
||||
shape_id_t rb_shape_transition_add_ivar_no_warnings(VALUE klass, shape_id_t original_shape_id, ID id);
|
||||
shape_id_t rb_shape_transition_object_id(VALUE obj);
|
||||
shape_id_t rb_shape_transition_heap(VALUE obj, size_t heap_index);
|
||||
shape_id_t rb_shape_object_id(shape_id_t original_shape_id);
|
||||
|
||||
@ -3101,7 +3101,9 @@ fn gen_set_ivar(
|
||||
let mut new_shape_too_complex = false;
|
||||
let new_shape = if !shape_too_complex && receiver_t_object && ivar_index.is_none() {
|
||||
let current_shape_id = comptime_receiver.shape_id_of();
|
||||
let next_shape_id = unsafe { rb_shape_transition_add_ivar_no_warnings(comptime_receiver, ivar_name) };
|
||||
// We don't need to check about imemo_fields here because we're definitely looking at a T_OBJECT.
|
||||
let klass = unsafe { rb_obj_class(comptime_receiver) };
|
||||
let next_shape_id = unsafe { rb_shape_transition_add_ivar_no_warnings(klass, current_shape_id, ivar_name) };
|
||||
|
||||
// If the VM ran out of shapes, or this class generated too many leaf,
|
||||
// it may be de-optimized into OBJ_TOO_COMPLEX_SHAPE (hash-table).
|
||||
|
||||
6
yjit/src/cruby_bindings.inc.rs
generated
6
yjit/src/cruby_bindings.inc.rs
generated
@ -1064,7 +1064,11 @@ extern "C" {
|
||||
pub fn rb_shape_id_offset() -> i32;
|
||||
pub fn rb_obj_shape_id(obj: VALUE) -> shape_id_t;
|
||||
pub fn rb_shape_get_iv_index(shape_id: shape_id_t, id: ID, value: *mut attr_index_t) -> bool;
|
||||
pub fn rb_shape_transition_add_ivar_no_warnings(obj: VALUE, id: ID) -> shape_id_t;
|
||||
pub fn rb_shape_transition_add_ivar_no_warnings(
|
||||
klass: VALUE,
|
||||
original_shape_id: shape_id_t,
|
||||
id: ID,
|
||||
) -> shape_id_t;
|
||||
pub fn rb_ivar_get_at(obj: VALUE, index: attr_index_t, id: ID) -> VALUE;
|
||||
pub fn rb_ivar_get_at_no_ractor_check(obj: VALUE, index: attr_index_t) -> VALUE;
|
||||
pub fn rb_gvar_get(arg1: ID) -> VALUE;
|
||||
|
||||
6
zjit/src/cruby_bindings.inc.rs
generated
6
zjit/src/cruby_bindings.inc.rs
generated
@ -2033,7 +2033,11 @@ unsafe extern "C" {
|
||||
pub fn rb_shape_id_offset() -> i32;
|
||||
pub fn rb_obj_shape_id(obj: VALUE) -> shape_id_t;
|
||||
pub fn rb_shape_get_iv_index(shape_id: shape_id_t, id: ID, value: *mut attr_index_t) -> bool;
|
||||
pub fn rb_shape_transition_add_ivar_no_warnings(obj: VALUE, id: ID) -> shape_id_t;
|
||||
pub fn rb_shape_transition_add_ivar_no_warnings(
|
||||
klass: VALUE,
|
||||
original_shape_id: shape_id_t,
|
||||
id: ID,
|
||||
) -> shape_id_t;
|
||||
pub fn rb_ivar_get_at_no_ractor_check(obj: VALUE, index: attr_index_t) -> VALUE;
|
||||
pub fn rb_gvar_get(arg1: ID) -> VALUE;
|
||||
pub fn rb_gvar_set(arg1: ID, arg2: VALUE) -> VALUE;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user