@@ -5,7 +5,10 @@ use std::{
55
66use num_bigint:: BigUint ;
77use openvm_algebra_transpiler:: { Fp2Opcode , Rv32ModularArithmeticOpcode } ;
8- use openvm_circuit:: arch:: * ;
8+ use openvm_circuit:: {
9+ arch:: * ,
10+ system:: memory:: { online:: GuestMemory , POINTER_MAX_BITS } ,
11+ } ;
912use openvm_circuit_primitives:: AlignedBytesBorrow ;
1013use openvm_instructions:: {
1114 instruction:: Instruction ,
@@ -174,13 +177,17 @@ impl<'a, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2: bool>
174177impl < F : PrimeField32 , const BLOCKS : usize , const BLOCK_SIZE : usize , const IS_FP2 : bool > Executor < F >
175178 for FieldExprVecHeapExecutor < BLOCKS , BLOCK_SIZE , IS_FP2 >
176179{
177- #[ cfg( feature = "tco" ) ]
178- fn handler < Ctx > (
180+ #[ inline( always) ]
181+ fn pre_compute_size ( & self ) -> usize {
182+ std:: mem:: size_of :: < FieldExpressionPreCompute > ( )
183+ }
184+
185+ fn pre_compute < Ctx > (
179186 & self ,
180187 pc : u32 ,
181188 inst : & Instruction < F > ,
182189 data : & mut [ u8 ] ,
183- ) -> Result < Handler < F , Ctx > , StaticProgramError >
190+ ) -> Result < ExecuteFunc < F , Ctx > , StaticProgramError >
184191 where
185192 Ctx : ExecutionCtxTrait ,
186193 {
@@ -197,7 +204,7 @@ impl<F: PrimeField32, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2
197204 op,
198205 BLOCKS ,
199206 BLOCK_SIZE ,
200- execute_e1_tco_handler ,
207+ execute_e1_impl ,
201208 [
202209 ( BN254Coordinate , Add ) ,
203210 ( BN254Coordinate , Sub ) ,
@@ -210,15 +217,15 @@ impl<F: PrimeField32, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2
210217 ]
211218 )
212219 } else {
213- Ok ( execute_e1_generic_tco_handler :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
220+ Ok ( execute_e1_generic_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
214221 }
215222 } else if let Some ( field_type) = get_field_type ( modulus) {
216223 generate_field_dispatch ! (
217224 field_type,
218225 op,
219226 BLOCKS ,
220227 BLOCK_SIZE ,
221- execute_e1_tco_handler ,
228+ execute_e1_impl ,
222229 [
223230 ( K256Coordinate , Add ) ,
224231 ( K256Coordinate , Sub ) ,
@@ -255,24 +262,20 @@ impl<F: PrimeField32, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2
255262 ]
256263 )
257264 } else {
258- Ok ( execute_e1_generic_tco_handler :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
265+ Ok ( execute_e1_generic_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
259266 }
260267 } else {
261- Ok ( execute_e1_setup_tco_handler :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
268+ Ok ( execute_e1_setup_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
262269 }
263270 }
264271
265- #[ inline( always) ]
266- fn pre_compute_size ( & self ) -> usize {
267- std:: mem:: size_of :: < FieldExpressionPreCompute > ( )
268- }
269-
270- fn pre_compute < Ctx > (
272+ #[ cfg( feature = "tco" ) ]
273+ fn handler < Ctx > (
271274 & self ,
272275 pc : u32 ,
273276 inst : & Instruction < F > ,
274277 data : & mut [ u8 ] ,
275- ) -> Result < ExecuteFunc < F , Ctx > , StaticProgramError >
278+ ) -> Result < Handler < F , Ctx > , StaticProgramError >
276279 where
277280 Ctx : ExecutionCtxTrait ,
278281 {
@@ -289,7 +292,7 @@ impl<F: PrimeField32, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2
289292 op,
290293 BLOCKS ,
291294 BLOCK_SIZE ,
292- execute_e1_impl ,
295+ execute_e1_tco_handler ,
293296 [
294297 ( BN254Coordinate , Add ) ,
295298 ( BN254Coordinate , Sub ) ,
@@ -302,15 +305,15 @@ impl<F: PrimeField32, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2
302305 ]
303306 )
304307 } else {
305- Ok ( execute_e1_generic_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
308+ Ok ( execute_e1_generic_tco_handler :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
306309 }
307310 } else if let Some ( field_type) = get_field_type ( modulus) {
308311 generate_field_dispatch ! (
309312 field_type,
310313 op,
311314 BLOCKS ,
312315 BLOCK_SIZE ,
313- execute_e1_impl ,
316+ execute_e1_tco_handler ,
314317 [
315318 ( K256Coordinate , Add ) ,
316319 ( K256Coordinate , Sub ) ,
@@ -347,10 +350,10 @@ impl<F: PrimeField32, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2
347350 ]
348351 )
349352 } else {
350- Ok ( execute_e1_generic_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
353+ Ok ( execute_e1_generic_tco_handler :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
351354 }
352355 } else {
353- Ok ( execute_e1_setup_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
356+ Ok ( execute_e1_setup_tco_handler :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
354357 }
355358 }
356359}
@@ -581,6 +584,7 @@ unsafe fn execute_e12_setup_impl<
581584 vm_state. instret += 1 ;
582585}
583586
587+ #[ create_tco_handler]
584588unsafe fn execute_e1_setup_impl <
585589 F : PrimeField32 ,
586590 CTX : ExecutionCtxTrait ,
@@ -629,6 +633,7 @@ unsafe fn execute_e1_impl<
629633 execute_e12_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 , FIELD_TYPE , OP > ( pre_compute, vm_state) ;
630634}
631635
636+ #[ create_tco_handler]
632637unsafe fn execute_e2_impl <
633638 F : PrimeField32 ,
634639 CTX : MeteredExecutionCtxTrait ,
@@ -651,6 +656,7 @@ unsafe fn execute_e2_impl<
651656 ) ;
652657}
653658
659+ #[ create_tco_handler]
654660unsafe fn execute_e1_generic_impl <
655661 F : PrimeField32 ,
656662 CTX : ExecutionCtxTrait ,
0 commit comments