diff options
author | Aaron Patterson <[email protected]> | 2024-02-14 18:03:35 -0800 |
---|---|---|
committer | Aaron Patterson <[email protected]> | 2024-02-15 16:38:21 -0800 |
commit | cfe77db00d433d75848974cffe5b3b402a127799 (patch) | |
tree | f9c6d7bb1b64887eb9e94fd502c4d67992566fa4 | |
parent | 1b9b9609631edd27377b3c8954964146983d763b (diff) |
Spill fewer temps on iv writes
Not all IV writes require calling a C function. If we don't need to
execute a write barrier (IOW the written value is an immediate), and we
don't need to expand the object to accommodate a new IV, we won't need
to make a C call and we can avoid spilling temps.
-rw-r--r-- | yjit/src/codegen.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index 6a518292ab..3a08f981b6 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -2788,7 +2788,6 @@ fn gen_setinstancevariable( Counter::setivar_megamorphic, ); - asm.spill_temps(); // for ccall (must be done before write_val is popped) let write_val; match ivar_index { @@ -2797,6 +2796,11 @@ fn gen_setinstancevariable( None => { let (new_shape_id, needs_extension, ivar_index) = new_shape.unwrap(); if let Some((current_capacity, new_capacity)) = needs_extension { + // We already spilled temps in the case the stack type is _not_ an immediate. + // If it is an immediate, but we need to expand the object, then spill temps + if stack_type.is_imm() { + asm.spill_temps(); // for ccall + } // Generate the C call so that runtime code will increase // the capacity and set the buffer. asm_comment!(asm, "call rb_ensure_iv_list_size"); @@ -2842,6 +2846,7 @@ fn gen_setinstancevariable( // If we know the stack value is an immediate, there's no need to // generate WB code. if !stack_type.is_imm() { + asm.spill_temps(); // for ccall let skip_wb = asm.new_label("skip_wb"); // If the value we're writing is an immediate, we don't need to WB asm.test(write_val, (RUBY_IMMEDIATE_MASK as u64).into()); |