diff options
author | Aaron Patterson <[email protected]> | 2023-10-24 12:37:27 -0700 |
---|---|---|
committer | Aaron Patterson <[email protected]> | 2023-10-24 14:23:17 -0700 |
commit | afae8df373ba1b53b64bffa0e3df668d86585243 (patch) | |
tree | 6adb79b61e9cf073f658e4a1cfa1afe8a5d2bafc /shape.c | |
parent | cfd7c1a2763d727f8a578da27317b55111aa6894 (diff) |
`get_next_shape_internal` should always return a shape
If it runs out of shapes, or new variations aren't allowed, it will
return "too complex"
Diffstat (limited to 'shape.c')
-rw-r--r-- | shape.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -484,6 +484,9 @@ get_next_shape_internal(rb_shape_t * shape, ID id, enum shape_type shape_type, b rb_id_table_insert(shape->edges, id, (VALUE)new_shape); res = new_shape; } + else { + res = rb_shape_get_shape_by_id(OBJ_TOO_COMPLEX_SHAPE_ID); + } } } else { @@ -496,6 +499,9 @@ get_next_shape_internal(rb_shape_t * shape, ID id, enum shape_type shape_type, b } RB_VM_LOCK_LEAVE(); } + else { + res = rb_shape_get_shape_by_id(OBJ_TOO_COMPLEX_SHAPE_ID); + } return res; } @@ -611,9 +617,6 @@ rb_shape_transition_shape_frozen(VALUE obj) bool dont_care; next_shape = get_next_shape_internal(shape, (ID)id_frozen, SHAPE_FROZEN, &dont_care, true); - if (!next_shape) { - next_shape = rb_shape_get_shape_by_id(OBJ_TOO_COMPLEX_SHAPE_ID); - } RUBY_ASSERT(next_shape); return next_shape; } @@ -646,10 +649,6 @@ rb_shape_get_next(rb_shape_t* shape, VALUE obj, ID id) bool variation_created = false; rb_shape_t * new_shape = get_next_shape_internal(shape, id, SHAPE_IVAR, &variation_created, allow_new_shape); - if (!new_shape) { - new_shape = rb_shape_get_shape_by_id(OBJ_TOO_COMPLEX_SHAPE_ID); - } - // Check if we should update max_iv_count on the object's class if (BUILTIN_TYPE(obj) == T_OBJECT) { VALUE klass = rb_obj_class(obj); @@ -683,6 +682,7 @@ rb_shape_transition_shape_capa_create(rb_shape_t* shape, size_t new_capacity) ID edge_name = rb_make_temporary_id(new_capacity); bool dont_care; rb_shape_t * new_shape = get_next_shape_internal(shape, edge_name, SHAPE_CAPACITY_CHANGE, &dont_care, true); + RUBY_ASSERT(rb_shape_id(new_shape) != OBJ_TOO_COMPLEX_SHAPE_ID); new_shape->capacity = (uint32_t)new_capacity; return new_shape; } |