Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Cranelift: perform aggressive splitting of generated ISLE function bodies in debug builds. (#12841)

Chris Fallinfa8cd552ea4c
diff --git a/cranelift/codegen/build.rs b/cranelift/codegen/build.rs
index 18cc7b8bf1..cbd2731df0 100644
--- a/cranelift/codegen/build.rs
+++ b/cranelift/codegen/build.rs
@@ -216,12 +216,26 @@ fn run_compilation(compilation: &IsleCompilation) -> Result<(), Errors> {
// the generated code to help debug rule matching.
options.emit_logging = std::env::var("CARGO_FEATURE_TRACE_LOG").is_ok();
- // Enable optional match-arm splitting in iterator terms for faster compile times.
- options.split_match_arms = std::env::var("CARGO_FEATURE_ISLE_SPLIT_MATCH").is_ok();
- if let Ok(value) = std::env::var("ISLE_SPLIT_MATCH_THRESHOLD") {
- options.match_arm_split_threshold = Some(value.parse().unwrap_or_else(|err| {
- panic!("invalid ISLE_SPLIT_MATCH_THRESHOLD value '{value}': {err}");
- }));
+ // Enable optional match-arm splitting in iterator terms for
+ // faster compile times in release builds.
+ //
+ // In debug builds, *always* split with an aggressive
+ // threshold, because we cannot rely on rustc doing regalloc
+ // on all of the local bindings to shrink the stack frame to a
+ // reasonable size.
+ #[cfg(not(debug_assertions))]
+ {
+ options.split_match_arms = std::env::var("CARGO_FEATURE_ISLE_SPLIT_MATCH").is_ok();
+ if let Ok(value) = std::env::var("ISLE_SPLIT_MATCH_THRESHOLD") {
+ options.match_arm_split_threshold = Some(value.parse().unwrap_or_else(|err| {
+ panic!("invalid ISLE_SPLIT_MATCH_THRESHOLD value '{value}': {err}");
+ }));
+ }
+ }
+ #[cfg(debug_assertions)]
+ {
+ options.split_match_arms = true;
+ options.match_arm_split_threshold = Some(4);
}
if let Ok(out_dir) = std::env::var("OUT_DIR") {