@@ -9,7 +9,6 @@ use crate::{
99 libfuncs:: r#struct:: build_struct_value,
1010 metadata:: {
1111 drop_overrides:: DropOverridesMeta ,
12- realloc_bindings:: ReallocBindingsMeta ,
1312 runtime_bindings:: { CircuitArithOperationType , RuntimeBindingsMeta } ,
1413 MetadataStorage ,
1514 } ,
@@ -102,8 +101,6 @@ fn build_init_circuit_data<'ctx, 'this>(
102101 metadata : & mut MetadataStorage ,
103102 info : & SignatureAndTypeConcreteLibfunc ,
104103) -> Result < ( ) > {
105- metadata. get_or_insert_with ( || ReallocBindingsMeta :: new ( context, helper) ) ;
106-
107104 let circuit_info = match registry. get_type ( & info. ty ) ? {
108105 CoreTypeConcrete :: Circuit ( CircuitTypeConcrete :: Circuit ( info) ) => & info. circuit_info ,
109106 _ => return Err ( SierraAssertError :: BadTypeInfo . into ( ) ) ,
@@ -119,22 +116,21 @@ fn build_init_circuit_data<'ctx, 'this>(
119116
120117 // Calculate full capacity for array.
121118 let capacity = circuit_info. n_inputs ;
122- let u384_layout = get_integer_layout ( 384 ) ;
123- let capacity_bytes = layout_repeat ( & u384_layout, capacity) ?
124- . 0
125- . pad_to_align ( )
126- . size ( ) ;
127- let capacity_bytes_value = entry. const_int ( context, location, capacity_bytes, 64 ) ?;
128-
129- // Alloc memory for array.
130- let ptr_ty = llvm:: r#type:: pointer ( context, 0 ) ;
131- let ptr = entry. append_op_result ( llvm:: zero ( ptr_ty, location) ) ?;
132- let ptr = entry. append_op_result ( ReallocBindingsMeta :: realloc (
119+ let inputs_layout = layout_repeat ( & get_integer_layout ( 384 ) , capacity) ?. 0 ;
120+ let capacity_bytes_value =
121+ entry. const_int ( context, location, inputs_layout. pad_to_align ( ) . size ( ) , 64 ) ?;
122+
123+ // Alloc memory for array from the arena.
124+ let align_value = entry. const_int ( context, location, inputs_layout. align ( ) , 64 ) ?;
125+ let rtb = metadata. get_or_insert_with ( RuntimeBindingsMeta :: default) ;
126+ let ptr = rtb. arena_alloc (
133127 context,
134- ptr ,
135- capacity_bytes_value ,
128+ helper . module ,
129+ entry ,
136130 location,
137- ) ?) ?;
131+ capacity_bytes_value,
132+ align_value,
133+ ) ?;
138134
139135 // Create accumulator struct.
140136 let k0 = entry. const_int ( context, location, 0 , 64 ) ?;
@@ -309,8 +305,6 @@ fn build_eval<'ctx, 'this>(
309305 metadata : & mut MetadataStorage ,
310306 info : & SignatureAndTypeConcreteLibfunc ,
311307) -> Result < ( ) > {
312- metadata. get_or_insert_with ( || ReallocBindingsMeta :: new ( context, helper) ) ;
313-
314308 let circuit_info = match registry. get_type ( & info. ty ) ? {
315309 CoreTypeConcrete :: Circuit ( CircuitTypeConcrete :: Circuit ( info) ) => & info. circuit_info ,
316310 _ => return Err ( SierraAssertError :: BadTypeInfo . into ( ) ) ,
@@ -373,21 +367,22 @@ fn build_eval<'ctx, 'this>(
373367
374368 // Calculate capacity for array.
375369 let outputs_capacity = circuit_info. values . len ( ) ;
376- let u384_integer_layout = get_integer_layout ( 384 ) ;
377- let outputs_layout = layout_repeat ( & u384_integer_layout, outputs_capacity) ?. 0 ;
378- let outputs_capacity_bytes = outputs_layout. pad_to_align ( ) . size ( ) ;
370+ let outputs_layout = layout_repeat ( & get_integer_layout ( 384 ) , outputs_capacity) ?. 0 ;
379371 let outputs_capacity_bytes_value =
380- ok_block. const_int ( context, location, outputs_capacity_bytes , 64 ) ?;
372+ ok_block. const_int ( context, location, outputs_layout . pad_to_align ( ) . size ( ) , 64 ) ?;
381373
382- // Alloc memory for array.
383- let ptr_ty = llvm:: r#type:: pointer ( context, 0 ) ;
384- let outputs_ptr = ok_block. append_op_result ( llvm:: zero ( ptr_ty, location) ) ?;
385- let outputs_ptr = ok_block. append_op_result ( ReallocBindingsMeta :: realloc (
374+ // Alloc memory for array from the arena.
375+ let outputs_align_value =
376+ ok_block. const_int ( context, location, outputs_layout. align ( ) , 64 ) ?;
377+ let rtb = metadata. get_or_insert_with ( RuntimeBindingsMeta :: default) ;
378+ let outputs_ptr = rtb. arena_alloc (
386379 context,
387- outputs_ptr ,
388- outputs_capacity_bytes_value ,
380+ helper . module ,
381+ ok_block ,
389382 location,
390- ) ?) ?;
383+ outputs_capacity_bytes_value,
384+ outputs_align_value,
385+ ) ?;
391386
392387 // Insert evaluated gates into the array.
393388 for ( i, gate) in gates. into_iter ( ) . enumerate ( ) {
0 commit comments