File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
vm/src/vm/runners/builtin_runner Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -522,6 +522,8 @@ impl BuiltinRunner {
522522 Ok ( ( ) )
523523 }
524524
525+ // TODO(yg): add tests for 16.
526+ const MIN_N_INSTANCES_IN_BUILTIN_SEGMENT : usize = 16 ;
525527 pub fn get_used_cells_and_allocated_size (
526528 & self ,
527529 vm : & VirtualMachine ,
@@ -535,10 +537,15 @@ impl BuiltinRunner {
535537 let used_cells = self . get_used_cells ( & vm. segments ) ?;
536538 if vm. disable_trace_padding {
537539 // If trace padding is disabled, we pad the used cells to still ensure that the
538- // number of instances is a power of 2.
540+ // number of instances is a power of 2, and at least
541+ // MIN_N_INSTANCES_IN_BUILTIN_SEGMENT.
539542 let num_instances = self . get_used_instances ( & vm. segments ) ?;
540543 let padded_used_cells = if num_instances > 0 {
541- num_instances. next_power_of_two ( ) * self . cells_per_instance ( ) as usize
544+ let padded_num_instances = std:: cmp:: max (
545+ Self :: MIN_N_INSTANCES_IN_BUILTIN_SEGMENT ,
546+ num_instances. next_power_of_two ( ) ,
547+ ) ;
548+ padded_num_instances * self . cells_per_instance ( ) as usize
542549 } else {
543550 0
544551 } ;
You can’t perform that action at this time.
0 commit comments