-
Notifications
You must be signed in to change notification settings - Fork 5.5k
ZJIT: Remove more Option from codegen #14265
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?
Conversation
segfault in not-ZJIT :( |
@@ -1184,7 +1180,7 @@ fn gen_guard_type(jit: &mut JITState, asm: &mut Assembler, val: lir::Opnd, guard | |||
// Static symbols have (val & 0xff) == RUBY_SYMBOL_FLAG | |||
// Use 8-bit comparison like YJIT does | |||
debug_assert!(val.try_num_bits(8).is_some(), "GuardType should not be used for a known constant, but val was: {val:?}"); | |||
asm.cmp(val.try_num_bits(8)?, Opnd::UImm(RUBY_SYMBOL_FLAG as u64)); | |||
asm.cmp(val.try_num_bits(8).unwrap(), Opnd::UImm(RUBY_SYMBOL_FLAG as u64)); |
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.
If we have an HIR validator for GuardType
not using known operands and we're going to unwrap this, let's remove the try_num_bits
function from Opnd
and use with_num_bits(8)
instead.
} | ||
|
||
fn gen_invokebuiltin(jit: &JITState, asm: &mut Assembler, state: &FrameState, bf: &rb_builtin_function, args: Vec<Opnd>) -> lir::Opnd { | ||
assert!(bf.argc + 2 <= C_ARG_OPNDS.len() as i32, "Builtin function {} has too many arguments: {}", unsafe { std::ffi::CStr::from_ptr(bf.name).to_str().unwrap() }, bf.argc); |
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.
There's no such guarantee. You shouldn't crash just because a Primitive takes 5+ arguments.
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.
Oh, you're checking it on gen_insn
. I hope the panic message explains that it should not happen because it's checked by the caller gen_insn
. There's nothing wrong in "Builtin function {} has too many arguments" itself.
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.
e.g.
assert!(bf.argc + 2 <= C_ARG_OPNDS.len() as i32, "Builtin function {} has too many arguments: {}", unsafe { std::ffi::CStr::from_ptr(bf.name).to_str().unwrap() }, bf.argc); | |
assert!( | |
bf.argc + 2 <= C_ARG_OPNDS.len() as i32, | |
"gen_invokebuiltin should not be called for builtin function {} with too many arguments: {}", | |
unsafe { std::ffi::CStr::from_ptr(bf.name).to_str().unwrap() }, bf.argc, | |
); |
No description provided.