aboutsummaryrefslogtreecommitdiffstats
path: root/yjit
diff options
context:
space:
mode:
authorJean Boussier <byroot@ruby-lang.org>2023-10-10 13:12:17 +0200
committerJean Boussier <jean.boussier@gmail.com>2023-10-10 14:47:54 +0200
commit5cc44f48c51974a84a40480477a4afd8901ae7e4 (patch)
tree9c252adf59e2e0b932a74a7d0cf000969039e97d /yjit
parentfd21460898d2d5044c1bcc140927142921424791 (diff)
downloadruby-5cc44f48c51974a84a40480477a4afd8901ae7e4.tar.gz
Refactor rb_shape_transition_shape_capa to not accept capacity
This way the groth factor is encapsulated, which allows rb_shape_transition_shape_capa to be smarter about ideal sizes.
Diffstat (limited to 'yjit')
-rw-r--r--yjit/src/codegen.rs5
-rw-r--r--yjit/src/cruby_bindings.inc.rs5
2 files changed, 3 insertions, 7 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index e4fa1a3665..5dff45ba8d 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -2403,7 +2403,6 @@ fn gen_setinstancevariable(
let shape = comptime_receiver.shape_of();
let current_capacity = unsafe { (*shape).capacity };
- let new_capacity = current_capacity * 2;
// If the object doesn't have the capacity to store the IV,
// then we'll need to allocate it.
@@ -2416,7 +2415,7 @@ fn gen_setinstancevariable(
// We need to add an extended table to the object
// First, create an outgoing transition that increases the
// capacity
- Some(unsafe { rb_shape_transition_shape_capa(shape, new_capacity) })
+ Some(unsafe { rb_shape_transition_shape_capa(shape) })
} else {
None
};
@@ -2429,7 +2428,7 @@ fn gen_setinstancevariable(
let new_shape_id = unsafe { rb_shape_id(dest_shape) };
let needs_extension = if needs_extension {
- Some((current_capacity, new_capacity))
+ Some((current_capacity, unsafe { (*dest_shape).capacity }))
} else {
None
};
diff --git a/yjit/src/cruby_bindings.inc.rs b/yjit/src/cruby_bindings.inc.rs
index bf554a9f85..fde68a80b5 100644
--- a/yjit/src/cruby_bindings.inc.rs
+++ b/yjit/src/cruby_bindings.inc.rs
@@ -1179,10 +1179,7 @@ extern "C" {
pub fn rb_shape_get_shape_id(obj: VALUE) -> shape_id_t;
pub fn rb_shape_get_iv_index(shape: *mut rb_shape_t, id: ID, value: *mut attr_index_t) -> bool;
pub fn rb_shape_obj_too_complex(obj: VALUE) -> bool;
- pub fn rb_shape_transition_shape_capa(
- shape: *mut rb_shape_t,
- new_capacity: u32,
- ) -> *mut rb_shape_t;
+ pub fn rb_shape_transition_shape_capa(shape: *mut rb_shape_t) -> *mut rb_shape_t;
pub fn rb_shape_get_next(shape: *mut rb_shape_t, obj: VALUE, id: ID) -> *mut rb_shape_t;
pub fn rb_shape_id(shape: *mut rb_shape_t) -> shape_id_t;
pub fn rb_gvar_get(arg1: ID) -> VALUE;