@@ -7,7 +7,7 @@ use self::ser::serialize_to_js;
77use self :: string:: { str_from_ident, IntoJsString } ;
88use self :: syscall:: {
99 call_call_procedure, call_call_reducer, call_call_view, call_call_view_anon, call_describe_module, get_hooks,
10- get_registered_hooks , process_thrown_exception, resolve_sys_module, FnRet , HookFunctions ,
10+ process_thrown_exception, resolve_sys_module, FnRet , HookFunctions ,
1111} ;
1212use super :: module_common:: { build_common_module_from_raw, run_describer, ModuleCommon } ;
1313use super :: module_host:: { CallProcedureParams , CallReducerParams , ModuleInfo , ModuleWithInstance } ;
@@ -1653,16 +1653,6 @@ struct V8Instance<'a, 'scope, 'isolate> {
16531653 args : & ' a Global < ArrayBuffer > ,
16541654}
16551655
1656- macro_rules! with_call_scope {
1657- ( $scope: expr, |$call_scope: ident, $hooks: ident| $body: block) => { {
1658- // Open a fresh HandleScope for this invocation so call-local V8 handles
1659- // are released when the reducer/view/procedure returns.
1660- v8:: scope!( let $call_scope, $scope) ;
1661- let $hooks = get_registered_hooks( $call_scope) . expect( "module hooks should be registered before invoking JS" ) ;
1662- $body
1663- } } ;
1664- }
1665-
16661656impl WasmInstance for V8Instance < ' _ , ' _ , ' _ > {
16671657 fn extract_descriptions ( & mut self ) -> Result < RawModuleDef , DescribeError > {
16681658 extract_description ( self . scope , self . hooks , self . replica_ctx )
@@ -1681,26 +1671,22 @@ impl WasmInstance for V8Instance<'_, '_, '_> {
16811671 }
16821672
16831673 fn call_reducer ( & mut self , op : ReducerOp < ' _ > , budget : FunctionBudget ) -> ReducerExecuteResult {
1684- with_call_scope ! ( self . scope, |scope, hooks| {
1685- common_call( scope, & hooks, budget, op, |scope, op| {
1686- let reducer_args_buf = Local :: new( scope, self . args) ;
1687- Ok ( call_call_reducer( scope, & hooks, op, reducer_args_buf) ?)
1688- } )
1674+ common_call ( self . scope , self . hooks , budget, op, |scope, op| {
1675+ let reducer_args_buf = Local :: new ( scope, self . args ) ;
1676+ Ok ( call_call_reducer ( scope, self . hooks , op, reducer_args_buf) ?)
16891677 } )
16901678 . map_result ( |call_result| call_result. and_then ( |res| res. map_err ( ExecutionError :: User ) ) )
16911679 }
16921680
16931681 fn call_view ( & mut self , op : ViewOp < ' _ > , budget : FunctionBudget ) -> ViewExecuteResult {
1694- with_call_scope ! ( self . scope, |scope, hooks | {
1695- common_call ( scope , & hooks , budget , op , |scope , op| call_call_view( scope, & hooks, op) )
1682+ common_call ( self . scope , self . hooks , budget , op , |scope, op | {
1683+ call_call_view ( scope, self . hooks , op)
16961684 } )
16971685 }
16981686
16991687 fn call_view_anon ( & mut self , op : AnonymousViewOp < ' _ > , budget : FunctionBudget ) -> ViewExecuteResult {
1700- with_call_scope ! ( self . scope, |scope, hooks| {
1701- common_call( scope, & hooks, budget, op, |scope, op| {
1702- call_call_view_anon( scope, & hooks, op)
1703- } )
1688+ common_call ( self . scope , self . hooks , budget, op, |scope, op| {
1689+ call_call_view_anon ( scope, self . hooks , op)
17041690 } )
17051691 }
17061692
@@ -1713,10 +1699,8 @@ impl WasmInstance for V8Instance<'_, '_, '_> {
17131699 op : ProcedureOp ,
17141700 budget : FunctionBudget ,
17151701 ) -> ( ProcedureExecuteResult , Option < TransactionOffset > ) {
1716- let result = with_call_scope ! ( self . scope, |scope, hooks| {
1717- common_call( scope, & hooks, budget, op, |scope, op| {
1718- call_call_procedure( scope, & hooks, op)
1719- } )
1702+ let result = common_call ( self . scope , self . hooks , budget, op, |scope, op| {
1703+ call_call_procedure ( scope, self . hooks , op)
17201704 } )
17211705 . map_result ( |call_result| {
17221706 call_result. map_err ( |e| match e {
@@ -1733,15 +1717,19 @@ impl WasmInstance for V8Instance<'_, '_, '_> {
17331717
17341718fn common_call < ' scope , R , O , F > (
17351719 scope : & mut PinScope < ' scope , ' _ > ,
1736- hooks : & HookFunctions < ' scope > ,
1720+ hooks : & HookFunctions < ' _ > ,
17371721 budget : FunctionBudget ,
17381722 op : O ,
17391723 call : F ,
17401724) -> ExecutionResult < R , ExecutionError >
17411725where
17421726 O : InstanceOp ,
1743- F : FnOnce ( & mut PinTryCatch < ' scope , ' _ , ' _ , ' _ > , O ) -> Result < R , ErrorOrException < ExceptionThrown > > ,
1727+ F : FnOnce ( & mut PinTryCatch < ' _ , ' _ , ' _ , ' _ > , O ) -> Result < R , ErrorOrException < ExceptionThrown > > ,
17441728{
1729+ // Open a fresh HandleScope for this invocation so call-local V8 handles
1730+ // are released when the reducer/view/procedure returns.
1731+ v8:: scope!( let scope, scope) ;
1732+
17451733 // TODO(v8): Start the budget timeout and long-running logger.
17461734 let env = env_on_isolate_unwrap ( scope) ;
17471735
0 commit comments