@@ -134,11 +134,14 @@ impl JsModule {
134134 }
135135}
136136
137- /// Access the `JsInstanceEnv` bound to an [`Isolate`].
138- ///
139- /// This assumes that the slot has been set in the isolate already.
140- fn env_on_isolate ( isolate : & mut Isolate ) -> & mut JsInstanceEnv {
141- isolate. get_slot_mut ( ) . expect ( "there should be a `JsInstanceEnv`" )
137+ /// Returns the `JsInstanceEnv` bound to an [`Isolate`], fallibly.
138+ fn env_on_isolate ( isolate : & mut Isolate ) -> Option < & mut JsInstanceEnv > {
139+ isolate. get_slot_mut ( )
140+ }
141+
142+ /// Returns the `JsInstanceEnv` bound to an [`Isolate`], or panic if not set.
143+ fn env_on_isolate_unwrap ( isolate : & mut Isolate ) -> & mut JsInstanceEnv {
144+ env_on_isolate ( isolate) . expect ( "there should be a `JsInstanceEnv`" )
142145}
143146
144147/// The environment of a [`JsInstance`].
@@ -574,7 +577,7 @@ fn call_reducer<'scope>(
574577
575578 let ( res, _) = instance_common. call_reducer_with_tx ( replica_ctx, tx, params, log_traceback, |tx, op, budget| {
576579 // TODO(v8): Start the budget timeout and long-running logger.
577- let env = env_on_isolate ( scope) ;
580+ let env = env_on_isolate_unwrap ( scope) ;
578581 let mut tx_slot = env. instance_env . tx . clone ( ) ;
579582
580583 // Start the timer.
@@ -607,7 +610,7 @@ fn call_reducer<'scope>(
607610 } ) ;
608611
609612 // Finish timings.
610- let timings = env_on_isolate ( scope) . finish_reducer ( ) ;
613+ let timings = env_on_isolate_unwrap ( scope) . finish_reducer ( ) ;
611614
612615 // Derive energy stats.
613616 let energy = energy_from_elapsed ( budget, timings. total_duration ) ;
0 commit comments