Skip to content

Commit 5eeeecd

Browse files
committed
YJIT: Pass class and shape ID directly instead of object
1 parent a461374 commit 5eeeecd

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

shape.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -950,12 +950,10 @@ rb_shape_transition_add_ivar(VALUE obj, ID id)
950950
}
951951

952952
shape_id_t
953-
rb_shape_transition_add_ivar_no_warnings(VALUE obj, ID id)
953+
rb_shape_transition_add_ivar_no_warnings(VALUE klass, shape_id_t original_shape_id, ID id)
954954
{
955-
shape_id_t original_shape_id = RBASIC_SHAPE_ID(obj);
956955
RUBY_ASSERT(!shape_frozen_p(original_shape_id));
957956

958-
VALUE klass = obj_get_owner_class(obj);
959957
rb_shape_t *next_shape = shape_get_next(RSHAPE(original_shape_id), SHAPE_IVAR, klass, id, false);
960958
if (next_shape) {
961959
return shape_id(next_shape, original_shape_id);

shape.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ shape_id_t rb_shape_transition_frozen(VALUE obj);
230230
shape_id_t rb_shape_transition_complex(VALUE obj);
231231
shape_id_t rb_shape_transition_remove_ivar(VALUE obj, ID id, shape_id_t *removed_shape_id);
232232
shape_id_t rb_shape_transition_add_ivar(VALUE obj, ID id);
233-
shape_id_t rb_shape_transition_add_ivar_no_warnings(VALUE obj, ID id);
233+
shape_id_t rb_shape_transition_add_ivar_no_warnings(VALUE klass, shape_id_t original_shape_id, ID id);
234234
shape_id_t rb_shape_transition_object_id(VALUE obj);
235235
shape_id_t rb_shape_transition_heap(VALUE obj, size_t heap_index);
236236
shape_id_t rb_shape_object_id(shape_id_t original_shape_id);

yjit/src/codegen.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3101,7 +3101,9 @@ fn gen_set_ivar(
31013101
let mut new_shape_too_complex = false;
31023102
let new_shape = if !shape_too_complex && receiver_t_object && ivar_index.is_none() {
31033103
let current_shape_id = comptime_receiver.shape_id_of();
3104-
let next_shape_id = unsafe { rb_shape_transition_add_ivar_no_warnings(comptime_receiver, ivar_name) };
3104+
// We don't need to check about imemo_fields here because we're definitely looking at a T_OBJECT.
3105+
let klass = unsafe { rb_obj_class(comptime_receiver) };
3106+
let next_shape_id = unsafe { rb_shape_transition_add_ivar_no_warnings(klass, current_shape_id, ivar_name) };
31053107

31063108
// If the VM ran out of shapes, or this class generated too many leaf,
31073109
// it may be de-optimized into OBJ_TOO_COMPLEX_SHAPE (hash-table).

yjit/src/cruby_bindings.inc.rs

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zjit/src/cruby_bindings.inc.rs

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)