-
Notifications
You must be signed in to change notification settings - Fork 19
majit: lower discarded inline-helper results, and give the degraded-arm registry a denominator #1235
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
majit: lower discarded inline-helper results, and give the degraded-arm registry a denominator #1235
Changes from all commits
b42cf3c
62ad963
ada0409
ad2286c
3308129
99d05d5
8cf2937
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2498,6 +2498,22 @@ pub(super) fn lower_dispatch_chain( | |
| lowerer.emit_jump(&default_label); | ||
| } | ||
|
|
||
| // The denominator for `record_degraded_dispatch_arm` below, staged from the | ||
| // same loop's own admission test so the two cannot drift: an arm is counted | ||
| // here exactly when the loop emits a body for it. Without it an empty | ||
| // degraded registry reads as "nothing degraded" and as "no portal was | ||
| // built" at once, and only the first is a pass. | ||
| { | ||
| let census_interp = config.state_type_name.clone(); | ||
| let census_arms = classified_arms | ||
| .iter() | ||
| .filter(|arm| !matches!(arm.pat, Pat::Wild(_)) && !is_lowercase_binding_pat(&arm.pat)) | ||
|
Comment on lines
+2508
to
+2510
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When AGENTS.md reference: AGENTS.md:L14-L19 Useful? React with 👍 / 👎. |
||
| .count(); | ||
| lowerer.emit_aux(quote::quote! { | ||
| majit_metainterp::record_dispatch_arm_census(#census_interp, #census_arms); | ||
| }); | ||
|
Comment on lines
+2501
to
+2514
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Record switch extraction failures as degraded arms. Lines 2508-2513 count every admitted arm before switch lowering verifies that
Proposed fix Some(mut emitters) => {
switch_case_emitters.append(&mut emitters);
switch_arm_labels[arm_idx] = Some(arm_label);
}
- None => continue,
+ None => {
+ let interp = &config.state_type_name;
+ let arm_name = quote::quote!(`#arm.pat`).to_string();
+ lowerer.emit_aux(quote::quote! {
+ majit_metainterp::record_degraded_dispatch_arm(
+ `#interp`,
+ `#arm_name`,
+ "dispatch arm pattern cannot lower to a switch case",
+ );
+ });
+ continue;
+ }🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| for (arm_idx, arm) in classified_arms.iter().enumerate() { | ||
| // `_` wildcard: skip here; handled by the default GOTO below. | ||
| // All other patterns (including Pat::Ident like `OP_NOP`) are | ||
|
|
@@ -3007,6 +3023,33 @@ pub(super) fn lower_dispatch_chain( | |
| } | ||
| } | ||
|
|
||
| // Every arm has lowered, so the consulted-key set is final: report the | ||
| // declared `int_fields` / `ref_fields` keys no access site asked about. | ||
| // | ||
| // Reported rather than rejected, and the reason is the degraded arm. An | ||
| // arm that refused to lower never reached its field accesses, so a key | ||
| // used only there is unconsulted through no fault of the declaration — | ||
| // failing the build on it would turn one refusal into two. The consumer's | ||
| // gate reads this alongside `degraded_dispatch_arms` and can tell them | ||
| // apart; a compile error could not. | ||
| { | ||
| let interp = config.state_type_name.clone(); | ||
| let consulted = config.consulted_field_keys.borrow(); | ||
| let mut unconsulted: Vec<&String> = config | ||
| .int_fields | ||
| .keys() | ||
| .chain(config.ref_fields.keys()) | ||
| .filter(|key| !consulted.contains(*key)) | ||
| .collect(); | ||
| unconsulted.sort(); | ||
| unconsulted.dedup(); | ||
| for key in unconsulted { | ||
| lowerer.emit_aux(quote::quote! { | ||
| majit_metainterp::record_unconsulted_field_declaration(#interp, #key); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| // After all arm guards, the default/exit path: unconditional GOTO. | ||
| // default_label is bound at the typed-return emission site in | ||
| // lower_dispatch_body (Task 1.7). | ||
|
|
||
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.
When a
#[jit_inline]helper carriesint_fieldsorref_fields, this emits unconsulted records under the helper name but emits no corresponding installation census. The only provided gate,assert_no_unconsulted_field_declarations, first requires an entry indispatch_arm_census, which inline-helper construction never creates, so it always reports that the helper was never installed even after__majit_inline_jitcode_*_with_asmran; for a clean helper, the empty snapshot is likewise indistinguishable from one that was never built. Record a helper-specific denominator or provide a separate helper gate so these new records can certify the success case as well as report failures.Useful? React with 👍 / 👎.