chore(codegen): #1098 — split expr.rs (pure refactor, no behavior change) - #1147
Merged
Conversation
… submodules (behavior-preserving)
… url_helpers, object_literal, array_literal, index submodules (behavior-preserving)
… v8_interop submodules (behavior-preserving)
This was referenced May 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1098. Part of #1097.
Pure mechanical split of the 15.3k-line LLVM expr lowering into
expr/submodules.expr.rsis nowexpr/mod.rs(renamed; git detects with-Mat 88% similarity), with self-contained helper clusters extracted into 11 submodules.lower_expritself stays inmod.rsas the single dispatch entry point — its match body is byte-for-byte identical to origin/main.Final module list
expr/mod.rs(~13,260 lines)lower_expr+FnCtxstruct/impl +FlatConstInfoexpr/nanbox_inline.rsnanbox_pointer_inline,nanbox_bigint_inline,nanbox_pointer_inline_pub,nanbox_string_inline,i32_bool_to_nanboxexpr/v8_interop.rsimport_origin_suffix,emit_v8_export_call,emit_v8_member_method_call,try_static_class_nameexpr/strings.rsemit_string_literal_globalexpr/write_barrier.rsemit_write_barrier,emit_write_barrier_slot_on_block,lower_stream_super_initexpr/helpers.rsproxy_build_args_array,buffer_alias_metadata_suffix,lower_js_args_array,unbox_to_i64,unbox_str_handle,is_global_this_builtin_name,is_global_this_builtin_function_nameexpr/url_helpers.rslower_url_string_getterexpr/object_literal.rslower_object_literalexpr/array_literal.rslower_array_literalexpr/index.rslower_index_set_fastexpr/i32_fast_path.rsis_known_finite,try_lower_flat_const_index_get,try_flat_const_2d_int,can_lower_expr_as_i32,lower_expr_as_i32expr/channel.rsvariant_name,extract_array_of_object_shape,ChannelReduction,try_match_channel_reduction,lower_channel_reductionScope deviation from the issue's proposed map
The issue suggested also splitting each
Expr::*arm of the giantlower_exprmatch into its own submodule (binary.rs, unary.rs, compare.rs, property_get.rs, typeof_void.rs). I did not do this. Those arms sharelower_expr's recursion and a large amount of local context, and extracting them safely would require careful per-arm context threading — a risk multiplier on a hot codegen path that the issue itself explicitly accepts ("a partial-but-substantial split is acceptable if a full split risks correctness"). What landed:mod.rs) is untouched and byte-identical to origin/main, including thelower_exprsignature and every arm body.Public surface preservation
Every
pub(crate)item that was used outsideexpr.rsis re-exported fromexpr/mod.rsviapub(crate) use submodule::*blocks, so existingcrate::expr::Xpaths (instmt.rs,codegen.rs,lower_call.rs,lower_call/*.rs,lower_array_method.rs,lower_string_method.rs,lower_conditional.rs,type_analysis.rs,runtime_decls.rs) resolve unchanged.FnCtx,FlatConstInfo, andChannelReductiontypes remain at their originalcrate::expr::paths. No external imports needed updating.Verification
cargo build --release -p perry-codegen— clean, 4 warnings (all pre-existing baseline)cargo build --release(full workspace) — clean,Finished release profile in 5m 13scargo test --release --workspace --exclude perry-ui-{ios,tvos,watchos,visionos,android,windows,gtk4}— 1304 passed, 0 failed, no panics, no errors./run_parity_tests.sh(LLVM backend) — 438 pass / 35 known-fail / 13 known-compile-fail / 13 skipped → 92.6% pass rateorigin/main: every output mismatch on this branch is intest-parity/known_failures.json, excepttest_node_http_client_requestandtest_parity_cron— both verified to fail identically on origin/main (rebuilt + re-ran origin/main parity on these two tests; they're pre-existing known-failure-list gaps tracked by test-parity: audit known_failures.json — every entry needs an issue # and date #797, not regressions).lower_expr(619 KB body),FnCtxstruct,impl FnCtx,FlatConstInfo, and 7 spot-checked moved helpers (lower_channel_reduction,lower_expr_as_i32,lower_object_literal,lower_array_literal,lower_index_set_fast,emit_v8_member_method_call,lower_stream_super_init) are byte-for-byte identical between this branch andorigin/main.git diff origin/main -M -C --summary:rename crates/perry-codegen/src/{expr.rs => expr/mod.rs} (88%)— well above the 90% issue threshold isn't quite met because so much code moved out, but the rename is detected and every submodule is a verbatim extraction.Commits
3 pure-move commits, each builds cleanly on its own:
0c192b2cextractchannel+i32_fast_pathsubmodules1220d255extractwrite_barrier,helpers,url_helpers,object_literal,array_literal,indexsubmodulesa9f16bbdextractnanbox_inline,strings,v8_interopsubmodulesNo version bump / changelog per external-contributor convention.