Skip to content

Commit 9e839d3

Browse files
committed
Optimize benchmark/vm_ivar_of_class
``` compare-ruby: ruby 3.5.0dev (2025-06-17T08:45:40Z master e9d3567) +PRISM [arm64-darwin24] last_commit=[ruby/json] Fix a typo built-ruby: ruby 3.5.0dev (2025-06-17T09:27:05Z opt-getivar-for-cl.. ed1d7cd778) +PRISM [arm64-darwin24] | |compare-ruby|built-ruby| |:---------------------|-----------:|---------:| |vm_ivar_of_class_set | 12.306M| 13.957M| | | -| 1.13x| |vm_ivar_of_class | 16.167M| 24.029M| | | -| 1.49x| ```
1 parent 9647dca commit 9e839d3

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

internal/class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ static inline rb_classext_t *
432432
RCLASS_EXT_WRITABLE(VALUE obj)
433433
{
434434
const rb_namespace_t *ns;
435-
if (RCLASS_PRIME_CLASSEXT_WRITABLE_P(obj)) {
435+
if (LIKELY(RCLASS_PRIME_CLASSEXT_WRITABLE_P(obj))) {
436436
return RCLASS_EXT_PRIME(obj);
437437
}
438438
// delay namespace loading to optimize for unmodified classes

vm_insnhelper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call
12531253
return default_value;
12541254
}
12551255
ivar_list = rb_imemo_class_fields_ptr(fields_obj);
1256-
shape_id = rb_obj_shape_id(fields_obj);
1256+
shape_id = fields_obj ? RBASIC_SHAPE_ID_FOR_READ(fields_obj) : ROOT_SHAPE_ID;
12571257

12581258
break;
12591259
}

0 commit comments

Comments
 (0)