@@ -9,6 +9,8 @@ use crate::db::db_metrics::DB_METRICS;
99use crate :: db:: relational_db:: { self , DiskSizeFn , RelationalDB , Txdata } ;
1010use crate :: db:: { self , spawn_tx_metrics_recorder} ;
1111use crate :: energy:: { EnergyMonitor , EnergyQuanta , NullEnergyMonitor } ;
12+ use crate :: host:: module_host:: ModuleRuntime as _;
13+ use crate :: host:: v8:: V8Runtime ;
1214use crate :: messages:: control_db:: { Database , HostType } ;
1315use crate :: module_host_context:: ModuleCreationContext ;
1416use crate :: replica_context:: ReplicaContext ;
@@ -106,12 +108,14 @@ pub struct HostController {
106108
107109struct HostRuntimes {
108110 wasmtime : WasmtimeRuntime ,
111+ v8 : V8Runtime ,
109112}
110113
111114impl HostRuntimes {
112115 fn new ( data_dir : Option < & ServerDataDir > ) -> Arc < Self > {
113116 let wasmtime = WasmtimeRuntime :: new ( data_dir) ;
114- Arc :: new ( Self { wasmtime } )
117+ let v8 = V8Runtime :: default ( ) ;
118+ Arc :: new ( Self { wasmtime, v8 } )
115119 }
116120}
117121
@@ -671,19 +675,25 @@ async fn make_module_host(
671675 // threads, but those aren't for computation. Also, wasmtime uses rayon
672676 // to run compilation in parallel, so it'll need to run stuff in rayon anyway.
673677 asyncify ( move || {
678+ let mcc = ModuleCreationContext {
679+ replica_ctx,
680+ scheduler,
681+ program : & program,
682+ energy_monitor,
683+ } ;
684+
685+ let start = Instant :: now ( ) ;
674686 let module_host = match host_type {
675687 HostType :: Wasm => {
676- let mcc = ModuleCreationContext {
677- replica_ctx,
678- scheduler,
679- program : & program,
680- energy_monitor,
681- } ;
682- let start = Instant :: now ( ) ;
683688 let actor = runtimes. wasmtime . make_actor ( mcc) ?;
684689 trace ! ( "wasmtime::make_actor blocked for {:?}" , start. elapsed( ) ) ;
685690 ModuleHost :: new ( actor, unregister, core)
686691 }
692+ HostType :: Js => {
693+ let actor = runtimes. v8 . make_actor ( mcc) ?;
694+ trace ! ( "v8::make_actor blocked for {:?}" , start. elapsed( ) ) ;
695+ ModuleHost :: new ( actor, unregister, core)
696+ }
687697 } ;
688698 Ok ( ( program, module_host) )
689699 } )
0 commit comments