cranelift: Only emit stack maps when a function actually uses reference types
This fix avoids a small slow down in scenarios where reference types are enabled but a given function doesn't actually use them. Fixes #1883
This commit is contained in:
@@ -203,17 +203,22 @@ impl Context {
|
|||||||
&mut self.tracker,
|
&mut self.tracker,
|
||||||
);
|
);
|
||||||
|
|
||||||
// This function runs after register allocation has taken
|
// If there are any reference types used, encode safepoints and emit
|
||||||
// place, meaning values have locations assigned already.
|
// stack maps.
|
||||||
if isa.flags().enable_safepoints() {
|
//
|
||||||
emit_stack_maps(func, domtree, &self.liveness, &mut self.tracker, isa);
|
// This function runs after register allocation has taken place, meaning
|
||||||
} else {
|
// values have locations assigned already, which is necessary for
|
||||||
// Make sure no references are used.
|
// creating the stack maps.
|
||||||
|
let safepoints_enabled = isa.flags().enable_safepoints();
|
||||||
for val in func.dfg.values() {
|
for val in func.dfg.values() {
|
||||||
let ty = func.dfg.value_type(val);
|
let ty = func.dfg.value_type(val);
|
||||||
if ty.lane_type().is_ref() {
|
if ty.lane_type().is_ref() {
|
||||||
panic!("reference types were found but safepoints were not enabled.");
|
assert!(
|
||||||
}
|
safepoints_enabled,
|
||||||
|
"reference types were found but safepoints were not enabled"
|
||||||
|
);
|
||||||
|
emit_stack_maps(func, domtree, &self.liveness, &mut self.tracker, isa);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user