@@ -11,10 +11,25 @@ public unsafe partial class VirtualMachine<TGasPolicy> where TGasPolicy : struct
1111{
1212 private delegate * < VirtualMachine < TGasPolicy > , ref EvmStack , ref TGasPolicy , ref int , EvmExceptionType > [ ] _opcodeMethods ;
1313
14- // For tracing-enabled execution, generate (if necessary) and cache the traced opcode set.
15- private partial void PrepareOpcodes < TTracingInst > ( IReleaseSpec spec ) where TTracingInst : struct , IFlag =>
16- _opcodeMethods = ( delegate * < VirtualMachine < TGasPolicy > , ref EvmStack , ref TGasPolicy , ref int , EvmExceptionType > [ ] ) ( spec . EvmInstructionsTraced ??= GenerateOpCodes < TTracingInst > ( spec ) ) ;
14+ // Select and lazily build the opcode dispatch table for the active tracing mode, caching each
15+ // mode separately on the spec. Mirrors the std build minus its periodic PGO-driven cache refresh,
16+ // which is moot for the AOT-compiled guest.
17+ private partial void PrepareOpcodes < TTracingInst > ( IReleaseSpec spec ) where TTracingInst : struct , IFlag
18+ {
19+ if ( ! TTracingInst . IsActive )
20+ {
21+ _opcodeMethods =
22+ ( delegate * < VirtualMachine < TGasPolicy > , ref EvmStack , ref TGasPolicy , ref int , EvmExceptionType > [ ] )
23+ ( spec . EvmInstructionsNoTrace ??= GenerateOpCodes < TTracingInst > ( spec ) ) ;
24+ }
25+ else
26+ {
27+ _opcodeMethods =
28+ ( delegate * < VirtualMachine < TGasPolicy > , ref EvmStack , ref TGasPolicy , ref int , EvmExceptionType > [ ] )
29+ ( spec . EvmInstructionsTraced ??= GenerateOpCodes < TTracingInst > ( spec ) ) ;
30+ }
31+ }
1732
1833 protected delegate * < VirtualMachine < TGasPolicy > , ref EvmStack , ref TGasPolicy , ref int , EvmExceptionType > [ ] GenerateOpCodes < TTracingInst > ( IReleaseSpec spec ) where TTracingInst : struct , IFlag =>
19- EvmInstructions . GenerateOpCodes < TGasPolicy , OffFlag > ( spec ) ;
34+ EvmInstructions . GenerateOpCodes < TGasPolicy , TTracingInst > ( spec ) ;
2035}
0 commit comments