Replace assert! with debug_assert! in production code paths.
This allows the assertions to be disabled in release builds, so that the code is faster and smaller, at the expense of not performing the checks. Assertions can be re-enabled in release builds with the debug-assertions flag in Cargo.toml, as the top-level Cargo.toml file does.
This commit is contained in:
@@ -1026,7 +1026,7 @@ fn get_heap_addr(
|
||||
use std::cmp::min;
|
||||
|
||||
let guard_size: i64 = builder.func.heaps[heap].guard_size.into();
|
||||
assert!(guard_size > 0, "Heap guard pages currently required");
|
||||
debug_assert!(guard_size > 0, "Heap guard pages currently required");
|
||||
|
||||
// Generate `heap_addr` instructions that are friendly to CSE by checking offsets that are
|
||||
// multiples of the guard size. Add one to make sure that we check the pointer itself is in
|
||||
|
||||
@@ -74,8 +74,8 @@ impl FuncTranslator {
|
||||
func.name,
|
||||
func.signature
|
||||
);
|
||||
assert_eq!(func.dfg.num_ebbs(), 0, "Function must be empty");
|
||||
assert_eq!(func.dfg.num_insts(), 0, "Function must be empty");
|
||||
debug_assert_eq!(func.dfg.num_ebbs(), 0, "Function must be empty");
|
||||
debug_assert_eq!(func.dfg.num_insts(), 0, "Function must be empty");
|
||||
|
||||
// This clears the `ILBuilder`.
|
||||
let mut builder = FunctionBuilder::new(func, &mut self.il_builder);
|
||||
@@ -191,7 +191,7 @@ fn parse_function_body<FE: FuncEnvironment + ?Sized>(
|
||||
environ: &mut FE,
|
||||
) -> CtonResult {
|
||||
// The control stack is initialized with a single block representing the whole function.
|
||||
assert_eq!(state.control_stack.len(), 1, "State not initialized");
|
||||
debug_assert_eq!(state.control_stack.len(), 1, "State not initialized");
|
||||
|
||||
// Keep going until the final `End` operator which pops the outermost block.
|
||||
while !state.control_stack.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user