1- use crate :: backend:: CompiledWhole ;
1+ use crate :: backend:: { CompiledWhole , DispatchOutcome } ;
22use crate :: component:: loader:: ComponentError ;
33use crate :: component:: runtime:: { RuntimeComponent , build_components} ;
44use crate :: ir:: write_log:: {
@@ -8,11 +8,15 @@ use crate::ir::{
88 Event , Ir , ModuleVariables , Statement , Value , VarId , VarPath , dispatch_stmt_fast,
99 read_native_value, write_native_value,
1010} ;
11+ use crate :: residency;
1112use crate :: wave_dumper:: { DumpVar , WaveDumper } ;
1213use smallvec:: SmallVec ;
1314use std:: collections:: { BTreeSet , HashMap } ;
1415use std:: str:: FromStr ;
1516use std:: sync:: Arc ;
17+ use std:: sync:: atomic:: Ordering ;
18+ #[ cfg( feature = "profile" ) ]
19+ use std:: time:: Instant ;
1620use veryl_analyzer:: value:: MaskCache ;
1721
1822#[ cfg( feature = "profile" ) ]
@@ -455,7 +459,7 @@ impl Simulator {
455459 pub fn ensure_comb_updated ( & mut self ) {
456460 if self . comb_dirty {
457461 #[ cfg( feature = "profile" ) ]
458- let start = std :: time :: Instant :: now ( ) ;
462+ let start = Instant :: now ( ) ;
459463
460464 self . do_settle_comb ( ) ;
461465 self . comb_dirty = false ;
@@ -514,7 +518,7 @@ impl Simulator {
514518
515519 if self . comb_dirty {
516520 #[ cfg( feature = "profile" ) ]
517- let start = std :: time :: Instant :: now ( ) ;
521+ let start = Instant :: now ( ) ;
518522
519523 self . do_settle_comb ( ) ;
520524 self . comb_dirty = false ;
@@ -690,7 +694,7 @@ impl Simulator {
690694 /// one pre-commit state and one commit.
691695 fn eval_event_stmts ( & mut self , event : & Event ) {
692696 #[ cfg( feature = "profile" ) ]
693- let event_start = std :: time :: Instant :: now ( ) ;
697+ let event_start = Instant :: now ( ) ;
694698
695699 // Cache both the per-stmt list AND the whole-event AOT-C handle for
696700 // the current event, keyed on `last_event`. `event_statements` and
@@ -719,7 +723,6 @@ impl Simulator {
719723 // current values and pushes WriteLogEntries into the buffer
720724 // (3rd arg), exactly as the Cranelift event JIT does;
721725 // `ff_commit_from_log` below applies them.
722- use crate :: backend:: DispatchOutcome ;
723726 let dispatched = if let Some ( wptr) = whole_event_ptr {
724727 // SAFETY: `wptr` = `Arc::as_ptr` of an `Arc` owned by
725728 // `self.ir.whole_events`, which is never mutated after `Ir`
@@ -734,10 +737,21 @@ impl Simulator {
734737 let validate = self . ir . aot_c_validate ;
735738
736739 if !validate {
737- matches ! (
738- whole. try_dispatch( ff_ptr, comb_ptr, log_ptr) ,
739- DispatchOutcome :: Done ,
740- )
740+ match whole. try_dispatch ( ff_ptr, comb_ptr, log_ptr) {
741+ DispatchOutcome :: Done => true ,
742+ DispatchOutcome :: NotReady => {
743+ // `false` degrades to the per-stmt path below
744+ // (see `residency`).
745+ if !self
746+ . ir
747+ . whole_event_fallback_recorded
748+ . swap ( true , Ordering :: Relaxed )
749+ {
750+ residency:: record_fallback ( "whole_event" , & self . ir . name . to_string ( ) ) ;
751+ }
752+ false
753+ }
754+ }
741755 } else {
742756 // For validate, the wrapper compares the whole-event
743757 // dispatch against the per-stmt Cranelift path and panics
@@ -768,7 +782,7 @@ impl Simulator {
768782 /// Apply the accumulated write log to FF storage and reset the buffer.
769783 fn commit_event_log ( & mut self ) {
770784 #[ cfg( feature = "profile" ) ]
771- let ff_start = std :: time :: Instant :: now ( ) ;
785+ let ff_start = Instant :: now ( ) ;
772786
773787 ff_commit_from_log ( & mut self . ir . ff_values , & self . ir . write_log_buffer ) ;
774788
@@ -1019,7 +1033,7 @@ impl Simulator {
10191033 // Whole-event backend, then capture its pushed entries + ff/comb.
10201034 if matches ! (
10211035 whole. try_dispatch( ff_ptr, comb_ptr, log_ptr) ,
1022- crate :: backend :: DispatchOutcome :: NotReady ,
1036+ DispatchOutcome :: NotReady ,
10231037 ) {
10241038 return false ;
10251039 }
0 commit comments