summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorywenc <[email protected]>2024-01-12 10:41:58 -0500
committer<[email protected]>2024-01-12 15:41:58 +0000
commit16624ef463f214367720b7cf486e43e48a2df4e6 ()
treea998bc5feddc2df038f0376061e6130fd61ca327
parent524770d3dc8f44a5caca5533f22297d1e0dd5d32 (diff)
YJIT: expandarray for non-arrays (#9495)
* YJIT: expandarray for non-arrays Co-authored-by: John Hawthorn <[email protected]> * Skip the new test on RJIT * Increment counter for to_ary exit --------- Co-authored-by: John Hawthorn <[email protected]> Co-authored-by: Takashi Kokubun <[email protected]>
-rw-r--r--bootstraptest/test_yjit.rb17
-rw-r--r--yjit/src/codegen.rs62
-rw-r--r--yjit/src/cruby.rs1
-rw-r--r--yjit/src/stats.rs2
4 files changed, 65 insertions, 17 deletions
@@ -2494,6 +2494,23 @@ assert_equal '[:not_array, nil, nil]', %q{
expandarray_not_array(obj)
}
assert_equal '[1, 2, nil]', %q{
def expandarray_rhs_too_small
a, b, c = [1, 2]
@@ -1637,18 +1637,6 @@ fn gen_expandarray(
let array_opnd = asm.stack_opnd(0);
- // If the array operand is nil, just push on nils
- if asm.ctx.get_opnd_type(array_opnd.into()) == Type::Nil {
- asm.stack_pop(1); // pop after using the type info
- // special case for a, b = nil pattern
- // push N nils onto the stack
- for _ in 0..num {
- let push_opnd = asm.stack_push(Type::Nil);
- asm.mov(push_opnd, Qnil.into());
- }
- return Some(KeepCompiling);
- }
-
// Defer compilation so we can specialize on a runtime `self`
if !jit.at_current_insn() {
defer_compilation(jit, asm, ocb);
@@ -1657,10 +1645,52 @@ fn gen_expandarray(
let comptime_recv = jit.peek_at_stack(&asm.ctx, 0);
- // If the comptime receiver is not an array, bail
- if comptime_recv.class_of() != unsafe { rb_cArray } {
- gen_counter_incr(asm, Counter::expandarray_comptime_not_array);
- return None;
}
// Get the compile-time array length
@@ -781,6 +781,7 @@ pub(crate) mod ids {
name: max content: b"max"
name: hash content: b"hash"
name: respond_to_missing content: b"respond_to_missing?"
}
}
@@ -469,7 +469,7 @@ make_counters! {
expandarray_splat,
expandarray_postarg,
expandarray_not_array,
- expandarray_comptime_not_array,
expandarray_chain_max_depth,
// getblockparam