Optimize benchmark/vm_ivar_of_class

```
compare-ruby: ruby 3.5.0dev (2025-06-17T08:45:40Z master e9d35671d2) +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|
```
This commit is contained in:
Jean Boussier 2025-06-17 11:27:05 +02:00
parent 9647dca143
commit 9e839d3c0e
Notes: git 2025-06-17 11:00:43 +00:00
2 changed files with 2 additions and 2 deletions

View file

@ -432,7 +432,7 @@ static inline rb_classext_t *
RCLASS_EXT_WRITABLE(VALUE obj) RCLASS_EXT_WRITABLE(VALUE obj)
{ {
const rb_namespace_t *ns; const rb_namespace_t *ns;
if (RCLASS_PRIME_CLASSEXT_WRITABLE_P(obj)) { if (LIKELY(RCLASS_PRIME_CLASSEXT_WRITABLE_P(obj))) {
return RCLASS_EXT_PRIME(obj); return RCLASS_EXT_PRIME(obj);
} }
// delay namespace loading to optimize for unmodified classes // delay namespace loading to optimize for unmodified classes

View file

@ -1253,7 +1253,7 @@ vm_getivar(VALUE obj, ID id, const rb_iseq_t *iseq, IVC ic, const struct rb_call
return default_value; return default_value;
} }
ivar_list = rb_imemo_class_fields_ptr(fields_obj); ivar_list = rb_imemo_class_fields_ptr(fields_obj);
shape_id = rb_obj_shape_id(fields_obj); shape_id = fields_obj ? RBASIC_SHAPE_ID_FOR_READ(fields_obj) : ROOT_SHAPE_ID;
break; break;
} }