Skip to content

ZJIT: Remove a bunch of Option from codegen #14238

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

tekknolagi
Copy link
Contributor

@tekknolagi tekknolagi commented Aug 15, 2025

I want to reduce the chance of accidentally having a not-implemented or
internal-compiler-error related side-exit after some code for an instruction
has already been emitted. So in this PR I make some of these ICEs cause a noisy
error and remove the spurious use of Options.

let ep = gen_get_ep(asm, level);
let offset = -(SIZEOF_VALUE_I32 * i32::try_from(local_ep_offset).ok()?);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the few cases I am uncertain about. Maybe we should catch these cases in the caller for a clearer signal

let ep = gen_get_ep(asm, level);
match val {
// If we're writing a constant, non-heap VALUE, do a raw memory write without
// running write barrier.
lir::Opnd::Value(const_val) if const_val.special_const_p() => {
let offset = -(SIZEOF_VALUE_I32 * i32::try_from(local_ep_offset).ok()?);
let offset = -(SIZEOF_VALUE_I32 * i32::try_from(local_ep_offset).unwrap());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the few cases I am uncertain about. Maybe we should catch these cases in the caller for a clearer signal

asm.mov(Opnd::mem(64, ep, offset), val);
}
// We're potentially writing a reference to an IMEMO/env object,
// so take care of the write barrier with a function.
_ => {
let local_index = c_int::try_from(local_ep_offset).ok().and_then(|idx| idx.checked_mul(-1))?;
let local_index = c_int::try_from(local_ep_offset).ok().and_then(|idx| idx.checked_mul(-1)).unwrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is one of the few cases I am uncertain about. Maybe we should catch these cases in the caller for a clearer signal

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we include the value of local_ep_offset in the panic message then?

@tekknolagi

This comment was marked as outdated.

@tekknolagi

This comment was marked as outdated.

@tekknolagi

This comment was marked as outdated.

@tekknolagi

This comment was marked as outdated.

@tekknolagi tekknolagi force-pushed the mb-fix-codegen-2 branch 2 times, most recently from cc75c3f to b4bc4b6 Compare August 15, 2025 19:07
@tekknolagi tekknolagi marked this pull request as ready for review August 15, 2025 19:34
@tekknolagi tekknolagi requested a review from a team August 15, 2025 19:34
@matzbot matzbot requested a review from a team August 15, 2025 19:34
@tekknolagi
Copy link
Contributor Author

tekknolagi commented Aug 15, 2025

Opening this up for review

@tekknolagi
Copy link
Contributor Author

Defined was failing to compile before. Fixed a bug in DCE related to Defined. Now it is compiling but incorrect in one case, so made a temporary SideExit in HIR building.

@@ -439,6 +439,7 @@ pub enum SideExitReason {
CalleeSideExit,
ObjToStringFallback,
UnknownSpecialVariable(u64),
TemporaryBug,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get that you want to leave the bug only temporarily, but it's always nice to describe what it is. Could we call it UnknownDefinedType(op) (also I feel like they are not "Unknown" to us but just "Unhandled" btw) or DefinedMethod?

Copy link
Member

@k0kubun k0kubun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants