10000 Get rid of `rb_shape_lookup` · ruby/ruby@5fbb72a · GitHub
[go: up one dir, main page]

Skip to content

Commit 5fbb72a

Browse files
committed
Get rid of rb_shape_lookup
1 parent 8ae4b04 commit 5fbb72a

File tree

10 files changed

+9
-79
lines changed

10 files changed

+9
-79
lines changed

shape.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,6 @@ rb_shape_each_shape_id(each_shape_callback callback, void *data)
380380
}
381381
}
382382

383-
RUBY_FUNC_EXPORTED rb_shape_t *
384-
rb_shape_lookup(shape_id_t shape_id)
385-
{
386-
return RSHAPE(shape_id);
387-
}
388-
389383
RUBY_FUNC_EXPORTED shape_id_t
390384
rb_obj_shape_id(VALUE obj)
391385
{

shape.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,6 @@ RSHAPE(shape_id_t shape_id)
163163

164164
int32_t rb_shape_id_offset(void);
165165

166-
RUBY_FUNC_EXPORTED rb_shape_t *rb_shape_lookup(shape_id_t shape_id);
167166
RUBY_FUNC_EXPORTED shape_id_t rb_obj_shape_id(VALUE obj);
168167
shape_id_t rb_shape_get_next_iv_shape(shape_id_t shape_id, ID id);
169168
bool rb_shape_get_iv_index(shape_id_t shape_id, ID id, attr_index_t *value);

yjit.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,12 @@ rb_yjit_shape_capacity(shape_id_t shape_id)
799799
return RSHAPE_CAPACITY(shape_id);
800800
}
801801

802+
attr_index_t
803+
rb_yjit_shape_index(shape_id_t shape_id)
804+
{
805+
return RSHAPE_INDEX(shape_id);
806+
}
807+
802808
// Assert that we have the VM lock. Relevant mostly for multi ractor situations.
803809
// The GC takes the lock before calling us, and this asserts that it indeed happens.
804810
void

yjit/bindgen/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,13 @@ fn main() {
9595

9696
// From shape.h
9797
.allowlist_function("rb_obj_shape_id")
98-
.allowlist_function("rb_shape_lookup")
9998
.allowlist_function("rb_shape_id_offset")
10099
.allowlist_function("rb_shape_get_iv_index")
101100
.allowlist_function("rb_shape_transition_add_ivar_no_warnings")
102101
.allowlist_function("rb_yjit_shape_obj_too_complex_p")
103102
.allowlist_function("rb_yjit_shape_too_complex_p")
104103
.allowlist_function("rb_yjit_shape_capacity")
104+
.allowlist_function("rb_yjit_shape_index")
105105
.allowlist_var("SHAPE_ID_NUM_BITS")
106106

107107
// From ruby/internal/intern/object.h

yjit/src/codegen.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,8 +3128,6 @@ fn gen_set_ivar(
31283128
if new_shape_too_complex {
31293129
Some((next_shape_id, None, 0_usize))
31303130
} else {
3131-
let current_shape = unsafe { rb_shape_lookup(current_shape_id) };
3132-
31333131
let current_capacity = unsafe { rb_yjit_shape_capacity(current_shape_id) };
31343132
let next_capacity = unsafe { rb_yjit_shape_capacity(next_shape_id) };
31353133

@@ -3138,7 +3136,7 @@ fn gen_set_ivar(
31383136
let needs_extension = next_capacity != current_capacity;
31393137

31403138
// We can write to the object, but we need to transition the shape
3141-
let ivar_index = unsafe { (*current_shape).next_field_index } as usize;
3139+
let ivar_index = unsafe { rb_yjit_shape_index(next_shape_id) } as usize;
31423140

31433141
let needs_extension = if needs_extension {
31443142
Some((current_capacity, next_capacity))

yjit/src/cruby.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -448,18 +448,6 @@ impl VALUE {
448448
unsafe { rb_obj_shape_id(self) }
449449
}
450450

451-
pub fn shape_of(self) -> *mut rb_shape {
452-
unsafe {
453-
let shape = rb_shape_lookup(self.shape_id_of());
454-
455-
if shape.is_null() {
456-
panic!("Shape should not be null");
457-
} else {
458-
shape
459-
}
460-
}
461-
}
462-
463451
pub fn embedded_p(self) -> bool {
464452
unsafe {
465453
FL_TEST_RAW(self, VALUE(ROBJECT_EMBED as usize)) != VALUE(0)

yjit/src/cruby_bindings.inc.rs

Lines changed: 1 addition & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zjit/bindgen/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ fn main() {
108108

109109
// From shape.h
110110
.allowlist_function("rb_obj_shape_id")
111-
.allowlist_function("rb_shape_lookup")
112111
.allowlist_function("rb_shape_id_offset")
113112
.allowlist_function("rb_shape_get_iv_index")
114113
.allowlist_function("rb_shape_transition_add_ivar_no_warnings")

zjit/src/cruby.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -485,18 +485,6 @@ impl VALUE {
485485
unsafe { rb_obj_shape_id(self) }
486486
}
487487

488-
pub fn shape_of(self) -> *mut rb_shape {
489-
unsafe {
490-
let shape = rb_shape_lookup(self.shape_id_of());
491-
492-
if shape.is_null() {
493-
panic!("Shape should not be null");
494-
} else {
495-
shape
496-
}
497-
}
498-
}
499-
500488
pub fn embedded_p(self) -> bool {
501489
unsafe {
502490
FL_TEST_RAW(self, VALUE(ROBJECT_EMBED as usize)) != VALUE(0)

zjit/src/cruby_bindings.inc.rs

Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
0