Skip to content

Commit eaf64af

Browse files
authored
ZJIT: Let fallbacks handle unknown call types (ruby#14518)
1 parent d8bc3d8 commit eaf64af

File tree

2 files changed

+23
-45
lines changed

2 files changed

+23
-45
lines changed

zjit/src/hir.rs

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,17 +2968,8 @@ fn compute_bytecode_info(iseq: *const rb_iseq_t) -> BytecodeInfo {
29682968

29692969
#[derive(Debug, PartialEq, Clone, Copy)]
29702970
pub enum CallType {
2971-
Splat,
29722971
BlockArg,
2973-
Kwarg,
2974-
KwSplat,
29752972
Tailcall,
2976-
Super,
2977-
Zsuper,
2978-
OptSend,
2979-
KwSplatMut,
2980-
SplatMut,
2981-
Forwarding,
29822973
}
29832974

29842975
#[derive(Clone, Debug, PartialEq)]
@@ -2996,17 +2987,8 @@ fn num_locals(iseq: *const rb_iseq_t) -> usize {
29962987

29972988
/// If we can't handle the type of send (yet), bail out.
29982989
fn unknown_call_type(flag: u32) -> Result<(), CallType> {
2999-
if (flag & VM_CALL_KW_SPLAT_MUT) != 0 { return Err(CallType::KwSplatMut); }
3000-
if (flag & VM_CALL_ARGS_SPLAT_MUT) != 0 { return Err(CallType::SplatMut); }
3001-
if (flag & VM_CALL_ARGS_SPLAT) != 0 { return Err(CallType::Splat); }
3002-
if (flag & VM_CALL_KW_SPLAT) != 0 { return Err(CallType::KwSplat); }
30032990
if (flag & VM_CALL_ARGS_BLOCKARG) != 0 { return Err(CallType::BlockArg); }
3004-
if (flag & VM_CALL_KWARG) != 0 { return Err(CallType::Kwarg); }
30052991
if (flag & VM_CALL_TAILCALL) != 0 { return Err(CallType::Tailcall); }
3006-
if (flag & VM_CALL_SUPER) != 0 { return Err(CallType::Super); }
3007-
if (flag & VM_CALL_ZSUPER) != 0 { return Err(CallType::Zsuper); }
3008-
if (flag & VM_CALL_OPT_SEND) != 0 { return Err(CallType::OptSend); }
3009-
if (flag & VM_CALL_FORWARDING) != 0 { return Err(CallType::Forwarding); }
30102992
Ok(())
30112993
}
30122994

@@ -5126,7 +5108,9 @@ mod tests {
51265108
fn test@<compiled>:2:
51275109
bb0(v0:BasicObject, v1:BasicObject):
51285110
v6:ArrayExact = ToArray v1
5129-
SideExit UnhandledCallType(Splat)
5111+
v8:BasicObject = SendWithoutBlock v0, :foo, v6
5112+
CheckInterrupts
5113+
Return v8
51305114
");
51315115
}
51325116

@@ -5151,7 +5135,9 @@ mod tests {
51515135
fn test@<compiled>:2:
51525136
bb0(v0:BasicObject, v1:BasicObject):
51535137
v5:Fixnum[1] = Const Value(1)
5154-
SideExit UnhandledCallType(Kwarg)
5138+
v7:BasicObject = SendWithoutBlock v0, :foo, v5
5139+
CheckInterrupts
5140+
Return v7
51555141
");
51565142
}
51575143

@@ -5163,7 +5149,9 @@ mod tests {
51635149
assert_snapshot!(hir_string("test"), @r"
51645150
fn test@<compiled>:2:
51655151
bb0(v0:BasicObject, v1:BasicObject):
5166-
SideExit UnhandledCallType(KwSplat)
5152+
v6:BasicObject = SendWithoutBlock v0, :foo, v1
5153+
CheckInterrupts
5154+
Return v6
51675155
");
51685156
}
51695157

@@ -5252,7 +5240,9 @@ mod tests {
52525240
v13:StaticSymbol[:b] = Const Value(VALUE(0x1008))
52535241
v14:Fixnum[1] = Const Value(1)
52545242
v16:BasicObject = SendWithoutBlock v12, :core#hash_merge_ptr, v11, v13, v14
5255-
SideExit UnhandledCallType(KwSplatMut)
5243+
v18:BasicObject = SendWithoutBlock v0, :foo, v16
5244+
CheckInterrupts
5245+
Return v18
52565246
");
52575247
}
52585248

@@ -5267,7 +5257,9 @@ mod tests {
52675257
v6:ArrayExact = ToNewArray v1
52685258
v7:Fixnum[1] = Const Value(1)
52695259
ArrayPush v6, v7
5270-
SideExit UnhandledCallType(SplatMut)
5260+
v11:BasicObject = SendWithoutBlock v0, :foo, v6
5261+
CheckInterrupts
5262+
Return v11
52715263
");
52725264
}
52735265

@@ -7863,7 +7855,9 @@ mod opt_tests {
78637855
fn test@<compiled>:3:
78647856
bb0(v0:BasicObject):
78657857
v4:Fixnum[1] = Const Value(1)
7866-
SideExit UnhandledCallType(Kwarg)
7858+
v6:BasicObject = SendWithoutBlock v0, :foo, v4
7859+
CheckInterrupts
7860+
Return v6
78677861
");
78687862
}
78697863

@@ -7879,7 +7873,9 @@ mod opt_tests {
78797873
fn test@<compiled>:3:
78807874
bb0(v0:BasicObject):
78817875
v4:Fixnum[1] = Const Value(1)
7882-
SideExit UnhandledCallType(Kwarg)
7876+
v6:BasicObject = SendWithoutBlock v0, :foo, v4
7877+
CheckInterrupts
7878+
Return v6
78837879
");
78847880
}
78857881

zjit/src/stats.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -114,17 +114,8 @@ make_counters! {
114114
}
115115

116116
// unhanded_call_: Unhandled call types
117-
unhandled_call_splat,
118117
unhandled_call_block_arg,
119-
unhandled_call_kwarg,
120-
unhandled_call_kw_splat,
121118
unhandled_call_tailcall,
122-
unhandled_call_super,
123-
unhandled_call_zsuper,
124-
unhandled_call_optsend,
125-
unhandled_call_kw_splat_mut,
126-
unhandled_call_splat_mut,
127-
unhandled_call_forwarding,
128119

129120
// compile_error_: Compile error reasons
130121
compile_error_iseq_stack_too_large,
@@ -176,17 +167,8 @@ pub fn exit_counter_ptr_for_call_type(call_type: crate::hir::CallType) -> *mut u
176167
use crate::hir::CallType::*;
177168
use crate::stats::Counter::*;
178169
let counter = match call_type {
179-
Splat => unhandled_call_splat,
180-
BlockArg => unhandled_call_block_arg,
181-
Kwarg => unhandled_call_kwarg,
182-
KwSplat => unhandled_call_kw_splat,
183-
Tailcall => unhandled_call_tailcall,
184-
Super => unhandled_call_super,
185-
Zsuper => unhandled_call_zsuper,
186-
OptSend => unhandled_call_optsend,
187-
KwSplatMut => unhandled_call_kw_splat_mut,
188-
SplatMut => unhandled_call_splat_mut,
189-
Forwarding => unhandled_call_forwarding,
170+
BlockArg => unhandled_call_block_arg,
171+
Tailcall => unhandled_call_tailcall,
190172
};
191173
counter_ptr(counter)
192174
}

0 commit comments

Comments
 (0)