@@ -5,7 +5,10 @@ use std::{
5
5
6
6
use num_bigint:: BigUint ;
7
7
use 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
+ } ;
9
12
use openvm_circuit_primitives:: AlignedBytesBorrow ;
10
13
use openvm_instructions:: {
11
14
instruction:: Instruction ,
@@ -174,13 +177,17 @@ impl<'a, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2: bool>
174
177
impl < F : PrimeField32 , const BLOCKS : usize , const BLOCK_SIZE : usize , const IS_FP2 : bool > Executor < F >
175
178
for FieldExprVecHeapExecutor < BLOCKS , BLOCK_SIZE , IS_FP2 >
176
179
{
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 > (
179
186
& self ,
180
187
pc : u32 ,
181
188
inst : & Instruction < F > ,
182
189
data : & mut [ u8 ] ,
183
- ) -> Result < Handler < F , Ctx > , StaticProgramError >
190
+ ) -> Result < ExecuteFunc < F , Ctx > , StaticProgramError >
184
191
where
185
192
Ctx : ExecutionCtxTrait ,
186
193
{
@@ -197,7 +204,7 @@ impl<F: PrimeField32, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2
197
204
op,
198
205
BLOCKS ,
199
206
BLOCK_SIZE ,
200
- execute_e1_tco_handler ,
207
+ execute_e1_impl ,
201
208
[
202
209
( BN254Coordinate , Add ) ,
203
210
( BN254Coordinate , Sub ) ,
@@ -210,15 +217,15 @@ impl<F: PrimeField32, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2
210
217
]
211
218
)
212
219
} else {
213
- Ok ( execute_e1_generic_tco_handler :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
220
+ Ok ( execute_e1_generic_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
214
221
}
215
222
} else if let Some ( field_type) = get_field_type ( modulus) {
216
223
generate_field_dispatch ! (
217
224
field_type,
218
225
op,
219
226
BLOCKS ,
220
227
BLOCK_SIZE ,
221
- execute_e1_tco_handler ,
228
+ execute_e1_impl ,
222
229
[
223
230
( K256Coordinate , Add ) ,
224
231
( K256Coordinate , Sub ) ,
@@ -255,24 +262,20 @@ impl<F: PrimeField32, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2
255
262
]
256
263
)
257
264
} else {
258
- Ok ( execute_e1_generic_tco_handler :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
265
+ Ok ( execute_e1_generic_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
259
266
}
260
267
} else {
261
- Ok ( execute_e1_setup_tco_handler :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
268
+ Ok ( execute_e1_setup_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
262
269
}
263
270
}
264
271
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 > (
271
274
& self ,
272
275
pc : u32 ,
273
276
inst : & Instruction < F > ,
274
277
data : & mut [ u8 ] ,
275
- ) -> Result < ExecuteFunc < F , Ctx > , StaticProgramError >
278
+ ) -> Result < Handler < F , Ctx > , StaticProgramError >
276
279
where
277
280
Ctx : ExecutionCtxTrait ,
278
281
{
@@ -289,7 +292,7 @@ impl<F: PrimeField32, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2
289
292
op,
290
293
BLOCKS ,
291
294
BLOCK_SIZE ,
292
- execute_e1_impl ,
295
+ execute_e1_tco_handler ,
293
296
[
294
297
( BN254Coordinate , Add ) ,
295
298
( BN254Coordinate , Sub ) ,
@@ -302,15 +305,15 @@ impl<F: PrimeField32, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2
302
305
]
303
306
)
304
307
} else {
305
- Ok ( execute_e1_generic_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
308
+ Ok ( execute_e1_generic_tco_handler :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
306
309
}
307
310
} else if let Some ( field_type) = get_field_type ( modulus) {
308
311
generate_field_dispatch ! (
309
312
field_type,
310
313
op,
311
314
BLOCKS ,
312
315
BLOCK_SIZE ,
313
- execute_e1_impl ,
316
+ execute_e1_tco_handler ,
314
317
[
315
318
( K256Coordinate , Add ) ,
316
319
( K256Coordinate , Sub ) ,
@@ -347,10 +350,10 @@ impl<F: PrimeField32, const BLOCKS: usize, const BLOCK_SIZE: usize, const IS_FP2
347
350
]
348
351
)
349
352
} else {
350
- Ok ( execute_e1_generic_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
353
+ Ok ( execute_e1_generic_tco_handler :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
351
354
}
352
355
} else {
353
- Ok ( execute_e1_setup_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
356
+ Ok ( execute_e1_setup_tco_handler :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 > )
354
357
}
355
358
}
356
359
}
@@ -581,6 +584,7 @@ unsafe fn execute_e12_setup_impl<
581
584
vm_state. instret += 1 ;
582
585
}
583
586
587
+ #[ create_tco_handler]
584
588
unsafe fn execute_e1_setup_impl <
585
589
F : PrimeField32 ,
586
590
CTX : ExecutionCtxTrait ,
@@ -629,6 +633,7 @@ unsafe fn execute_e1_impl<
629
633
execute_e12_impl :: < _ , _ , BLOCKS , BLOCK_SIZE , IS_FP2 , FIELD_TYPE , OP > ( pre_compute, vm_state) ;
630
634
}
631
635
636
+ #[ create_tco_handler]
632
637
unsafe fn execute_e2_impl <
633
638
F : PrimeField32 ,
634
639
CTX : MeteredExecutionCtxTrait ,
@@ -651,6 +656,7 @@ unsafe fn execute_e2_impl<
651
656
) ;
652
657
}
653
658
659
+ #[ create_tco_handler]
654
660
unsafe fn execute_e1_generic_impl <
655
661
F : PrimeField32 ,
656
662
CTX : ExecutionCtxTrait ,
0 commit comments