@@ -235,17 +235,19 @@ impl InspectorStackBuilder {
235235/// dispatch.
236236#[ macro_export]
237237macro_rules! call_inspectors {
238- ( [ $( $inspector: expr) ,+ $( , ) ?] , |$id: ident $( , ) ?| $call : expr $( , ) ?) => {
238+ ( [ $( $inspector: expr) ,+ $( , ) ?] , |$id: ident $( , ) ?| $body : expr $( , ) ?) => {
239239 $(
240240 if let Some ( $id) = $inspector {
241- ( { #[ inline( always) ] #[ cold] || $call } ) ( ) ;
241+ $crate:: utils:: cold_path( ) ;
242+ $body;
242243 }
243244 ) +
244245 } ;
245- ( #[ ret] [ $( $inspector: expr) ,+ $( , ) ?] , |$id: ident $( , ) ?| $call : expr $( , ) ?) => { {
246+ ( #[ ret] [ $( $inspector: expr) ,+ $( , ) ?] , |$id: ident $( , ) ?| $body : expr $( , ) ?) => { {
246247 $(
247248 if let Some ( $id) = $inspector {
248- if let Some ( result) = ( { #[ inline( always) ] #[ cold] || $call } ) ( ) {
249+ $crate:: utils:: cold_path( ) ;
250+ if let Some ( result) = $body {
249251 return result;
250252 }
251253 }
@@ -297,19 +299,21 @@ pub struct InspectorStack {
297299/// See [`InspectorStack`].
298300#[ derive( Default , Clone , Debug ) ]
299301pub struct InspectorStackInner {
302+ // Inspectors.
300303 pub chisel_state : Option < ChiselState > ,
301- pub line_coverage : Option < LineCoverageCollector > ,
302304 pub edge_coverage : Option < EdgeCovInspector > ,
303305 pub fuzzer : Option < Fuzzer > ,
306+ pub line_coverage : Option < LineCoverageCollector > ,
304307 pub log_collector : Option < LogCollector > ,
305308 pub printer : Option < CustomPrintTracer > ,
306- pub tracer : Option < TracingInspector > ,
309+ pub revert_diag : Option < RevertDiagnostic > ,
307310 pub script_execution_inspector : Option < ScriptExecutionInspector > ,
311+ pub tracer : Option < TracingInspector > ,
312+
313+ // InspectorExt and other internal data.
308314 pub enable_isolation : bool ,
309315 pub odyssey : bool ,
310316 pub create2_deployer : Address ,
311- pub revert_diag : Option < RevertDiagnostic > ,
312-
313317 /// Flag marking if we are in the inner EVM context.
314318 pub in_inner_context : bool ,
315319 pub inner_context_data : Option < InnerContextData > ,
@@ -759,7 +763,7 @@ impl InspectorStackRefMut<'_> {
759763 if self . enable_isolation {
760764 // If we're in isolation mode, we need to keep track of the state at the beginning of
761765 // the frame to be able to roll back on revert
762- self . top_frame_journal = ecx. journaled_state . state . clone ( ) ;
766+ self . top_frame_journal . clone_from ( & ecx. journaled_state . state ) ;
763767 }
764768 }
765769
@@ -786,63 +790,84 @@ impl InspectorStackRefMut<'_> {
786790 ecx. journaled_state . state = std:: mem:: take ( & mut self . top_frame_journal ) ;
787791 }
788792 }
789- }
790793
791- impl Inspector < EthEvmContext < & mut dyn DatabaseExt > > for InspectorStackRefMut < ' _ > {
792- fn initialize_interp (
794+ # [ inline ( always ) ]
795+ fn step_inlined (
793796 & mut self ,
794797 interpreter : & mut Interpreter ,
795798 ecx : & mut EthEvmContext < & mut dyn DatabaseExt > ,
796799 ) {
797800 call_inspectors ! (
798801 [
799- & mut self . line_coverage ,
802+ & mut self . fuzzer ,
800803 & mut self . tracer,
801- & mut self . cheatcodes,
804+ & mut self . line_coverage,
805+ & mut self . edge_coverage,
802806 & mut self . script_execution_inspector,
803- & mut self . printer
807+ & mut self . printer,
808+ & mut self . revert_diag,
809+ // Keep `cheatcodes` last to make use of the tail call.
810+ & mut self . cheatcodes,
804811 ] ,
805- |inspector| inspector. initialize_interp ( interpreter, ecx) ,
812+ |inspector| ( * inspector) . step ( interpreter, ecx) ,
806813 ) ;
807814 }
808815
809- fn step (
816+ #[ inline( always) ]
817+ fn step_end_inlined (
810818 & mut self ,
811819 interpreter : & mut Interpreter ,
812820 ecx : & mut EthEvmContext < & mut dyn DatabaseExt > ,
813821 ) {
814822 call_inspectors ! (
815823 [
816- & mut self . fuzzer,
817824 & mut self . tracer,
818- & mut self . line_coverage,
819- & mut self . edge_coverage,
820- & mut self . cheatcodes,
821- & mut self . script_execution_inspector,
825+ & mut self . chisel_state,
822826 & mut self . printer,
823- & mut self . revert_diag
827+ & mut self . revert_diag,
828+ // Keep `cheatcodes` last to make use of the tail call.
829+ & mut self . cheatcodes,
824830 ] ,
825- |inspector| inspector. step ( interpreter, ecx) ,
831+ |inspector| ( * inspector) . step_end ( interpreter, ecx) ,
826832 ) ;
827833 }
834+ }
828835
829- fn step_end (
836+ impl Inspector < EthEvmContext < & mut dyn DatabaseExt > > for InspectorStackRefMut < ' _ > {
837+ fn initialize_interp (
830838 & mut self ,
831839 interpreter : & mut Interpreter ,
832840 ecx : & mut EthEvmContext < & mut dyn DatabaseExt > ,
833841 ) {
834842 call_inspectors ! (
835843 [
844+ & mut self . line_coverage,
836845 & mut self . tracer,
837846 & mut self . cheatcodes,
838- & mut self . chisel_state,
839- & mut self . printer,
840- & mut self . revert_diag
847+ & mut self . script_execution_inspector,
848+ & mut self . printer
841849 ] ,
842- |inspector| inspector. step_end ( interpreter, ecx) ,
850+ |inspector| inspector. initialize_interp ( interpreter, ecx) ,
843851 ) ;
844852 }
845853
854+ fn step (
855+ & mut self ,
856+ interpreter : & mut Interpreter ,
857+ ecx : & mut EthEvmContext < & mut dyn DatabaseExt > ,
858+ ) {
859+ self . step_inlined ( interpreter, ecx) ;
860+ }
861+
862+ fn step_end (
863+ & mut self ,
864+ interpreter : & mut Interpreter ,
865+ ecx : & mut EthEvmContext < & mut dyn DatabaseExt > ,
866+ ) {
867+ self . step_end_inlined ( interpreter, ecx) ;
868+ }
869+
870+ #[ allow( clippy:: redundant_clone) ]
846871 fn log (
847872 & mut self ,
848873 interpreter : & mut Interpreter ,
@@ -1060,22 +1085,20 @@ impl InspectorExt for InspectorStackRefMut<'_> {
10601085}
10611086
10621087impl Inspector < EthEvmContext < & mut dyn DatabaseExt > > for InspectorStack {
1063- #[ inline]
10641088 fn step (
10651089 & mut self ,
10661090 interpreter : & mut Interpreter ,
10671091 ecx : & mut EthEvmContext < & mut dyn DatabaseExt > ,
10681092 ) {
1069- self . as_mut ( ) . step ( interpreter, ecx)
1093+ self . as_mut ( ) . step_inlined ( interpreter, ecx)
10701094 }
10711095
1072- #[ inline]
10731096 fn step_end (
10741097 & mut self ,
10751098 interpreter : & mut Interpreter ,
10761099 ecx : & mut EthEvmContext < & mut dyn DatabaseExt > ,
10771100 ) {
1078- self . as_mut ( ) . step_end ( interpreter, ecx)
1101+ self . as_mut ( ) . step_end_inlined ( interpreter, ecx)
10791102 }
10801103
10811104 fn call (
0 commit comments