@@ -9,6 +9,7 @@ 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:: v8:: V8Runtime ;
1213use crate :: messages:: control_db:: { Database , HostType } ;
1314use crate :: module_host_context:: ModuleCreationContext ;
1415use crate :: replica_context:: ReplicaContext ;
@@ -106,12 +107,14 @@ pub struct HostController {
106107
107108struct HostRuntimes {
108109 wasmtime : WasmtimeRuntime ,
110+ v8 : V8Runtime ,
109111}
110112
111113impl HostRuntimes {
112114 fn new ( data_dir : Option < & ServerDataDir > ) -> Arc < Self > {
113115 let wasmtime = WasmtimeRuntime :: new ( data_dir) ;
114- Arc :: new ( Self { wasmtime } )
116+ let v8 = V8Runtime :: new ( ) ;
117+ Arc :: new ( Self { wasmtime, v8 } )
115118 }
116119}
117120
@@ -671,19 +674,25 @@ async fn make_module_host(
671674 // threads, but those aren't for computation. Also, wasmtime uses rayon
672675 // to run compilation in parallel, so it'll need to run stuff in rayon anyway.
673676 asyncify ( move || {
677+ let mcc = ModuleCreationContext {
678+ replica_ctx,
679+ scheduler,
680+ program : & program,
681+ energy_monitor,
682+ } ;
683+
684+ let start = Instant :: now ( ) ;
674685 let module_host = match host_type {
675686 HostType :: Wasm => {
676- let mcc = ModuleCreationContext {
677- replica_ctx,
678- scheduler,
679- program : & program,
680- energy_monitor,
681- } ;
682- let start = Instant :: now ( ) ;
683687 let actor = runtimes. wasmtime . make_actor ( mcc) ?;
684688 trace ! ( "wasmtime::make_actor blocked for {:?}" , start. elapsed( ) ) ;
685689 ModuleHost :: new ( actor, unregister, core)
686690 }
691+ HostType :: Js => {
692+ let actor = runtimes. v8 . make_actor ( mcc) ?;
693+ trace ! ( "v8::make_actor blocked for {:?}" , start. elapsed( ) ) ;
694+ ModuleHost :: new ( actor, unregister, core)
695+ }
687696 } ;
688697 Ok ( ( program, module_host) )
689698 } )
0 commit comments