-
Notifications
You must be signed in to change notification settings - Fork 5.4k
ZJIT: throw
to HIR
#13729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
ZJIT: throw
to HIR
#13729
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome
@@ -488,6 +488,7 @@ pub enum Insn { | |||
|
|||
/// Control flow instructions | |||
Return { val: InsnId }, | |||
Throw { state: u32, val: InsnId }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not use state
; we're probably going to need that for side exits and that's our conventional use case for the Snapshot InsnId. Maybe throw_state
?
(Do we need to have a FrameState for throw? It feels like yes but I don't actually know how this works)
@@ -1013,6 +1031,7 @@ impl Function { | |||
} | |||
}, | |||
Return { val } => Return { val: find!(*val) }, | |||
&Throw { state, val } => Throw { state, val: find!(val) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self: we can probably make a smarter macro find!(x)
that expands to x: find!(x)
, etc
@@ -1117,7 +1136,7 @@ impl Function { | |||
match &self.insns[insn.0] { | |||
Insn::Param { .. } => unimplemented!("params should not be present in block.insns"), | |||
Insn::SetGlobal { .. } | Insn::ArraySet { .. } | Insn::Snapshot { .. } | Insn::Jump(_) | |||
| Insn::IfTrue { .. } | Insn::IfFalse { .. } | Insn::Return { .. } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self: we should probably use has_output
here
@@ -2696,6 +2716,10 @@ pub fn iseq_to_hir(iseq: *const rb_iseq_t) -> Result<Function, ParseError> { | |||
fun.push_insn(block, Insn::Return { val: state.stack_pop()? }); | |||
break; // Don't enqueue the next block as a successor | |||
} | |||
YARVINSN_throw => { | |||
fun.push_insn(block, Insn::Throw { state: get_arg(pc, 0).as_u32(), val: state.stack_pop()? }); | |||
break; // Don't enqueue the next block as a successor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note to self: we can probably extract this into is_terminator
below? maybe?
Since codegen for this (and others) is challenging, maybe we should be compiling hard-to-codegen instructions into explicit side-exits for now instead of aborting compilation. Though that does require that they have a FrameState |
throw
to HIRNo codegen for this for now since the calling convention is
somewhat in flux, and I'm not sure how best to do a unwind
with a value other than
Qundef
.