File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -296,6 +296,10 @@ wasmtime_option_group! {
296296 /// Yield when a global epoch counter changes, allowing for async
297297 /// operation without blocking the executor.
298298 pub epoch_interruption: Option <bool >,
299+ /// Use MMU tricks to speed epoch deadline checks.
300+ /// TODO: Document whether this should be used mutually exclusively with
301+ /// epoch_interruption.
302+ pub epoch_interruption_via_mmu: Option <bool >,
299303 /// Maximum stack size, in bytes, that wasm is allowed to consume before a
300304 /// stack overflow is reported.
301305 pub max_wasm_stack: Option <usize >,
@@ -818,6 +822,9 @@ impl CommonOptions {
818822 if let Some ( enable) = self . wasm . epoch_interruption {
819823 config. epoch_interruption ( enable) ;
820824 }
825+ if let Some ( enable) = self . wasm . epoch_interruption_via_mmu {
826+ config. epoch_interruption_via_mmu ( enable) ;
827+ }
821828 if let Some ( enable) = self . debug . address_map {
822829 config. generate_address_map ( enable) ;
823830 }
Original file line number Diff line number Diff line change @@ -3372,6 +3372,11 @@ impl FuncEnvironment<'_> {
33723372 self . epoch_function_entry ( builder) ;
33733373 }
33743374
3375+ if self . tunables . epoch_interruption_via_mmu {
3376+ builder. ins ( ) . iconst ( I32 , 33 ) ; // a useless constant, hopefully not optimized out
3377+ // NEXT: Dead-load something from the vmctx instead.
3378+ }
3379+
33753380 #[ cfg( feature = "wmemcheck" ) ]
33763381 if self . compiler . wmemcheck {
33773382 let func_name = self . current_func_name ( builder) ;
Original file line number Diff line number Diff line change @@ -86,6 +86,11 @@ define_tunables! {
8686 /// Whether or not we use epoch-based interruption.
8787 pub epoch_interruption: bool ,
8888
89+ /// Whether or not to use MMU tricks to speed epoch deadline checks.
90+ /// TODO: Consider whether this should be orthogonal to
91+ /// epoch_interruption. If not, combine them into an enum or something.
92+ pub epoch_interruption_via_mmu: bool ,
93+
8994 /// Whether or not linear memories are allowed to be reallocated after
9095 /// initial allocation at runtime.
9196 pub memory_may_move: bool ,
@@ -197,6 +202,7 @@ impl Tunables {
197202 parse_wasm_debuginfo : true ,
198203 consume_fuel : false ,
199204 epoch_interruption : false ,
205+ epoch_interruption_via_mmu : false ,
200206 memory_may_move : true ,
201207 guard_before_linear_memory : true ,
202208 table_lazy_init : true ,
Original file line number Diff line number Diff line change @@ -669,6 +669,12 @@ impl Config {
669669 self
670670 }
671671
672+ /// Stuff
673+ pub fn epoch_interruption_via_mmu ( & mut self , enable : bool ) -> & mut Self {
674+ self . tunables . epoch_interruption_via_mmu = Some ( enable) ;
675+ self
676+ }
677+
672678 /// Configures the maximum amount of stack space available for
673679 /// executing WebAssembly code.
674680 ///
Original file line number Diff line number Diff line change @@ -281,6 +281,7 @@ impl Metadata<'_> {
281281 parse_wasm_debuginfo,
282282 consume_fuel,
283283 epoch_interruption,
284+ epoch_interruption_via_mmu,
284285 memory_may_move,
285286 guard_before_linear_memory,
286287 table_lazy_init,
@@ -333,6 +334,11 @@ impl Metadata<'_> {
333334 other. epoch_interruption ,
334335 "epoch interruption" ,
335336 ) ?;
337+ Self :: check_bool (
338+ epoch_interruption_via_mmu,
339+ other. epoch_interruption_via_mmu ,
340+ "epoch interruption via MMU" ,
341+ ) ?;
336342 Self :: check_bool ( memory_may_move, other. memory_may_move , "memory may move" ) ?;
337343 Self :: check_bool (
338344 guard_before_linear_memory,
Original file line number Diff line number Diff line change 1+ ;; ! target = "x86_64"
2+ ;; ! flags = ["-Wepoch-interruption-via-mmu=y"]
3+
4+ (module
5+ (memory 0 )
6+ (func )
7+ )
8+ ;; function u0:0(i64 vmctx, i64) tail {
9+ ;; gv0 = vmctx
10+ ;; gv1 = load.i64 notrap aligned readonly gv0+8
11+ ;; gv2 = load.i64 notrap aligned gv1+16
12+ ;; stack_limit = gv2
13+ ;;
14+ ;; block0(v0: i64, v1: i64):
15+ ;; @001b v2 = iconst.i32 33
16+ ;; @001c jump block1
17+ ;;
18+ ;; block1:
19+ ;; @001c return
20+ ;; }
You can’t perform that action at this time.
0 commit comments