A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Skip clearing and restoring the may-leave flag when we don't call realloc (#15217)
Nick Fitzgerald83a0df59ba5b
diff --git a/crates/environ/src/component/types_builder.rs b/crates/environ/src/component/types_builder.rsindex 16594f0e90..3da4610bb6 100644--- a/crates/environ/src/component/types_builder.rs+++ b/crates/environ/src/component/types_builder.rs@@ -883,6 +883,12 @@ impl ComponentTypesBuilder {self.type_information(ty).has_string}+ /// Returns whether the type specified contains a `string`, `list`, or+ /// `map` within it, i.e. whether lowering it may call `realloc`.+ pub fn ty_needs_realloc(&self, ty: &InterfaceType) -> bool {+ self.type_information(ty).needs_realloc+ }+/// Returns whether the signature of `ty` mentions any handle, in either its/// parameters or its results.pub fn func_contains_any_handle(&self, ty: TypeFuncIndex) -> bool {@@ -943,6 +949,7 @@ impl ComponentTypesBuilder {static INFO: TypeInformation = {let mut info = TypeInformation::string();info.has_string = true;+ info.needs_realloc = true;info};&INFO@@ -1127,6 +1134,10 @@ struct TypeInformation {/// Whether this type transitively contains a `string`.has_string: bool,++ /// Whether lowering this type needs realloc because it transitively+ /// contains a `string`, `list`, or `map`.+ needs_realloc: bool,}impl TypeInformation {@@ -1135,6 +1146,7 @@ impl TypeInformation {flat: FlatTypesStorage::new(),handles: Handles::None,has_string: false,+ needs_realloc: false,}}@@ -1162,6 +1174,7 @@ impl TypeInformation {for info in types {self.handles = Handles::join(self.handles, info.handles);self.has_string |= info.has_string;+ self.needs_realloc |= info.needs_realloc;match info.flat.as_flat_types() {Some(types) => {for (t32, t64) in types.memory32.iter().zip(types.memory64) {@@ -1204,6 +1217,7 @@ impl TypeInformation {};self.handles = Handles::join(self.handles, info.handles);self.has_string |= info.has_string;+ self.needs_realloc |= info.needs_realloc;// If this variant is already unrepresentable in a flat// representation then this can be skipped.@@ -1270,6 +1284,7 @@ impl TypeInformation {let element_info = types.type_information(&ty.element);self.handles = element_info.handles;self.has_string = element_info.has_string;+ self.needs_realloc = element_info.needs_realloc;match element_info.flat.as_flat_types() {Some(types) => {'outer: for _ in 0..ty.size {@@ -1326,6 +1341,7 @@ impl TypeInformation {let info = types.type_information(&ty.element);self.handles = info.handles;self.has_string = info.has_string;+ self.needs_realloc = true;}fn maps(&mut self, types: &ComponentTypesBuilder, ty: &TypeMap) {@@ -1336,5 +1352,6 @@ impl TypeInformation {let value_info = types.type_information(&ty.value);self.handles = Handles::join(key_info.handles, value_info.handles);self.has_string = key_info.has_string || value_info.has_string;+ self.needs_realloc = true;}}diff --git a/crates/environ/src/fact/trampoline.rs b/crates/environ/src/fact/trampoline.rsindex 52db189f93..e98b809bfa 100644--- a/crates/environ/src/fact/trampoline.rs+++ b/crates/environ/src/fact/trampoline.rs@@ -573,9 +573,13 @@ impl<'a, 'b> Compiler<'a, 'b> {.map(|(i, ty)| (i as u32, *ty)).collect::<Vec<_>>();- let saved = self.clear_may_leave(adapter.lift.flags);+ let saved = self+ .translate_params_may_call_lift_realloc(adapter)+ .then(|| self.clear_may_leave(adapter.lift.flags));self.translate_params(adapter, ¶m_locals);- self.restore_may_leave(adapter.lift.flags, saved);+ if let Some(saved) = saved {+ self.restore_may_leave(adapter.lift.flags, saved);+ }self.finish();}@@ -599,7 +603,9 @@ impl<'a, 'b> Compiler<'a, 'b> {.map(|(i, ty)| (i as u32, *ty)).collect::<Vec<_>>();- let saved = self.clear_may_leave(adapter.lower.flags);+ let saved = self+ .translate_results_may_call_lower_realloc(adapter)+ .then(|| self.clear_may_leave(adapter.lower.flags));// Note that we pass `param_locals` as _both_ the `param_locals` and// `result_locals` parameters to `translate_results`. That's because// the _parameters_ to `task.return` are actually the _results_ that the@@ -611,7 +617,9 @@ impl<'a, 'b> Compiler<'a, 'b> {// the import is lowered async, in which case `translate_results` will// use that pointer to store the results.self.translate_results(adapter, ¶m_locals, ¶m_locals);- self.restore_may_leave(adapter.lower.flags, saved);+ if let Some(saved) = saved {+ self.restore_may_leave(adapter.lower.flags, saved);+ }self.finish()}@@ -717,7 +725,15 @@ impl<'a, 'b> Compiler<'a, 'b> {// more we can reuse locals to make this idempotency obvious, rather// than force Cranelift's optimizer to rediscover this information, the// better.- let saved_lift_may_leave = self.clear_may_leave(adapter.lift.flags);+ //+ // If translation can't call the callee's `realloc` then no callee code+ // runs while the flag is cleared, so the clear-and-restore is skipped+ // entirely. Cranelift can't always remove it on its own because host+ // libcalls made during translation (e.g. resource transfers) are+ // opaque.+ let saved_lift_may_leave = self+ .translate_params_may_call_lift_realloc(adapter)+ .then(|| self.clear_may_leave(adapter.lift.flags));let param_locals = lower_sig.params.iter()@@ -725,7 +741,9 @@ impl<'a, 'b> Compiler<'a, 'b> {.map(|(i, ty)| (i as u32, *ty)).collect::<Vec<_>>();self.translate_params(adapter, ¶m_locals);- self.restore_may_leave(adapter.lift.flags, saved_lift_may_leave);+ if let Some(saved) = saved_lift_may_leave {+ self.restore_may_leave(adapter.lift.flags, saved);+ }// With all the arguments on the stack the actual target function is// now invoked. The core wasm results of the function are then placed@@ -776,10 +794,16 @@ impl<'a, 'b> Compiler<'a, 'b> {// left (as we might invoke things like `realloc`). Again the precise// order of everything doesn't matter since intermediate states cannot// be witnessed, hence the setting of flags here to encapsulate both- // liftings and lowerings.- self.set_may_leave_false(adapter.lower.flags);- self.translate_results(adapter, ¶m_locals, &result_locals);- self.restore_may_leave(adapter.lower.flags, saved_lower_may_leave);+ // liftings and lowerings. As with parameters, this is skipped if+ // translation can't call the caller's `realloc`.+ if self.translate_results_may_call_lower_realloc(adapter) {+ self.set_may_leave_false(adapter.lower.flags);+ self.translate_results(adapter, ¶m_locals, &result_locals);+ self.restore_may_leave(adapter.lower.flags, saved_lower_may_leave);+ } else {+ self.translate_results(adapter, ¶m_locals, &result_locals);+ self.free_temp_local(saved_lower_may_leave);+ }// And finally post-return state is handled here once all results/etc// are all translated.@@ -810,6 +834,39 @@ impl<'a, 'b> Compiler<'a, 'b> {self.finish()}+ /// The maximum number of flat parameters a lifted function receives on the+ /// stack before they are spilled to memory allocated with its `realloc`.+ fn max_lift_flat_params(lift_opts: &Options) -> usize {+ match lift_opts.data_model {+ DataModel::Gc {} => usize::MAX,+ DataModel::LinearMemory(_) => MAX_FLAT_PARAMS,+ }+ }++ /// Whether `translate_params` might call the callee's `realloc`.+ fn translate_params_may_call_lift_realloc(&self, adapter: &AdapterData) -> bool {+ let lift_opts = &adapter.lift.options;+ let tys = &self.types[self.types[adapter.lift.ty].params].types;+ tys.iter().any(|ty| self.types.ty_needs_realloc(ty))+ || self+ .types+ .flatten_types(+ lift_opts,+ Self::max_lift_flat_params(lift_opts),+ tys.iter().copied(),+ )+ .is_none()+ }++ /// Whether `translate_results` might call the caller's `realloc`.+ ///+ /// Results that don't fit on the stack are written to a caller-provided+ /// return pointer, so only strings, lists, and maps allocate.+ fn translate_results_may_call_lower_realloc(&self, adapter: &AdapterData) -> bool {+ let tys = &self.types[self.types[adapter.lower.ty].results].types;+ tys.iter().any(|ty| self.types.ty_needs_realloc(ty))+ }+fn translate_params(&mut self, adapter: &AdapterData, param_locals: &[(u32, ValType)]) {let src_tys = self.types[adapter.lower.ty].params;let src_tys = self.types[src_tys]@@ -844,10 +901,7 @@ impl<'a, 'b> Compiler<'a, 'b> {let src_flat =self.types.flatten_types(lower_opts, max_flat_params, src_tys.iter().copied());- let max_dst_flat_params = match lift_opts.data_model {- DataModel::Gc {} => usize::MAX,- DataModel::LinearMemory(_) => MAX_FLAT_PARAMS,- };+ let max_dst_flat_params = Self::max_lift_flat_params(lift_opts);let dst_flat =self.types.flatten_types(lift_opts, max_dst_flat_params, dst_tys.iter().copied());diff --git a/tests/disas/component-model/compile-time-builtins-x64.wat b/tests/disas/component-model/compile-time-builtins-x64.watindex e4753ecdf8..bfc77df2a9 100644--- a/tests/disas/component-model/compile-time-builtins-x64.wat+++ b/tests/disas/component-model/compile-time-builtins-x64.wat@@ -176,33 +176,29 @@;; wasm[1]::function[3]:;; pushq %rbp;; movq %rsp, %rbp-;; movq 0x48(%rdi), %rcx-;; movq 0xe8(%rcx), %rax-;; movl (%rax), %edx-;; testl %edx, %edx-;; je 0x16d-;; 119: movq 0x48(%rcx), %rcx-;; movq 8(%rcx), %rcx-;; movq 0x68(%rcx), %rcx-;; movq 8(%rcx), %rdx-;; xorq %rsi, %rsi-;; cmpq %rdx, %rsi-;; jae 0x168-;; 135: movl (%rax), %edi-;; testl %edi, %edi-;; je 0x16f-;; 13f: movq 8(%rcx), %rdi-;; cmpq %rdi, %rsi-;; jae 0x171-;; 14c: movq (%rcx), %rdi-;; movzbq (%rdi, %rsi), %r8-;; addb $1, %r8b-;; movb %r8b, (%rdi, %rsi)-;; addq $1, %rsi+;; movq 0x48(%rdi), %rax+;; movq 0xe8(%rax), %rcx+;; movl (%rcx), %ecx+;; testl %ecx, %ecx+;; je 0x163+;; 119: movq 0x48(%rax), %rax+;; movq 8(%rax), %rax+;; movq 0x68(%rax), %rax+;; movq 8(%rax), %rcx+;; xorq %rdx, %rdx+;; cmpq %rcx, %rdx+;; jae 0x15e+;; 135: movq 8(%rax), %rsi+;; cmpq %rsi, %rdx+;; jae 0x165+;; 142: movq (%rax), %rsi+;; movzbq (%rsi, %rdx), %rdi+;; addb $1, %dil+;; movb %dil, (%rsi, %rdx)+;; addq $1, %rdx;; jmp 0x12c-;; 168: movq %rbp, %rsp+;; 15e: movq %rbp, %rsp;; popq %rbp;; retq-;; 16d: ud2-;; 16f: ud2-;; 171: ud2+;; 163: ud2+;; 165: ud2diff --git a/tests/disas/component-model/compile-time-builtins.wat b/tests/disas/component-model/compile-time-builtins.watindex 95b243622e..d859e6b7bd 100644--- a/tests/disas/component-model/compile-time-builtins.wat+++ b/tests/disas/component-model/compile-time-builtins.wat@@ -179,9 +179,8 @@;; region2 = 42 "";; region3 = 57 "";; region4 = 209 ""-;; region5 = 132 ""-;; region6 = 175 ""-;; region7 = 113 ""+;; region5 = 175 ""+;; region6 = 113 "";; gv0 = vmctx;; gv1 = load.i64 notrap aligned readonly can_move region0 gv0+8;; gv2 = load.i64 notrap aligned region1 gv1+24@@ -293,20 +292,18 @@;; jump block13;;;; block13:-;; v25 = load.i64 notrap aligned readonly can_move region3 v4+208-;; v26 = load.i32 notrap aligned region5 v25;; jump block16;;;; block16:;; jump block18;;;; block18:-;; v30 = load.i64 notrap aligned readonly can_move region2 v4+72-;; v32 = load.i64 notrap aligned readonly can_move region0 v30+8-;; v33 = load.i64 notrap aligned readonly can_move region6 v32+104-;; v34 = iconst.i64 8-;; v35 = iadd v33, v34 ; v34 = 8-;; v37 = load.i64 notrap aligned region7 v35+;; v25 = load.i64 notrap aligned readonly can_move region2 v4+72+;; v27 = load.i64 notrap aligned readonly can_move region0 v25+8+;; v28 = load.i64 notrap aligned readonly can_move region5 v27+104+;; v29 = iconst.i64 8+;; v30 = iadd v28, v29 ; v29 = 8+;; v32 = load.i64 notrap aligned region6 v30;; jump block19;;;; block19:@@ -332,12 +329,12 @@;;;; block21:;; @0573 v2 = iconst.i64 0-;; v127 = iconst.i8 1+;; v103 = iconst.i8 1;; @0595 v15 = iconst.i64 1;; @057d jump block2(v2) ; v2 = 0;;;; block2(v6: i64):-;; @0583 v8 = icmp uge v6, v37+;; @0583 v8 = icmp uge v6, v32;; @0584 brif v8, block4, block5;;;; block4:@@ -350,12 +347,9 @@;; jump block26;;;; block26:-;; v49 = load.i32 notrap aligned region4 v23-;; trapz v49, user26;; jump block29;;;; block29:-;; v51 = load.i32 notrap aligned region5 v25;; jump block32;;;; block32:@@ -365,16 +359,16 @@;; jump block39;;;; block39:-;; v131 = iadd.i64 v33, v34 ; v34 = 8-;; v62 = load.i64 notrap aligned region7 v131+;; v107 = iadd.i64 v28, v29 ; v29 = 8+;; v49 = load.i64 notrap aligned region6 v107;; jump block40;;;; block40:;; jump block41;;;; block41:-;; v63 = icmp.i64 ult v6, v62-;; trapz v63, user12+;; v50 = icmp.i64 ult v6, v49+;; trapz v50, user12;; jump block36;;;; block36:@@ -384,15 +378,15 @@;; jump block43;;;; block43:-;; v71 = load.i64 notrap aligned region7 v33+;; v58 = load.i64 notrap aligned region6 v28;; jump block44;;;; block44:;; jump block45;;;; block45:-;; v72 = iadd.i64 v71, v6-;; v74 = load.i8 notrap aligned region7 v72+;; v59 = iadd.i64 v58, v6+;; v61 = load.i8 notrap aligned region6 v59;; jump block33;;;; block33:@@ -450,9 +444,9 @@;; jump block70;;;; block70:-;; v132 = iconst.i8 1-;; v133 = iadd.i8 v74, v132 ; v132 = 1-;; store notrap aligned region7 v133, v72+;; v108 = iconst.i8 1+;; v109 = iadd.i8 v61, v108 ; v108 = 1+;; store notrap aligned region6 v109, v59;; jump block58;;;; block58:@@ -471,7 +465,7 @@;; jump block71;;;; block71:-;; @0595 v134 = iconst.i64 1-;; @0597 v135 = iadd.i64 v6, v134 ; v134 = 1-;; @059a jump block2(v135)+;; @0595 v110 = iconst.i64 1+;; @0597 v111 = iadd.i64 v6, v110 ; v110 = 1+;; @059a jump block2(v111);; }diff --git a/tests/disas/component-model/direct-adapter-calls-inlining.wat b/tests/disas/component-model/direct-adapter-calls-inlining.watindex c904a5f07d..f8df27ac87 100644--- a/tests/disas/component-model/direct-adapter-calls-inlining.wat+++ b/tests/disas/component-model/direct-adapter-calls-inlining.wat@@ -60,7 +60,6 @@;; region2 = 42 "";; region3 = 57 "";; region4 = 209 ""-;; region5 = 132 "";; gv0 = vmctx;; gv1 = load.i64 notrap aligned readonly can_move region0 gv0+8;; gv2 = load.i64 notrap aligned region1 gv1+24@@ -91,8 +90,6 @@;; jump block9;;;; block9:-;; v11 = load.i64 notrap aligned readonly can_move region3 v3+144-;; v12 = load.i32 notrap aligned region5 v11;; jump block12;;;; block12:@@ -117,6 +114,6 @@;; @00f0 jump block1;;;; block1:-;; v23 = iconst.i32 1276-;; @00f0 return v23 ; v23 = 1276+;; v15 = iconst.i32 1276+;; @00f0 return v15 ; v15 = 1276;; }diff --git a/tests/disas/component-model/direct-adapter-calls-x64.wat b/tests/disas/component-model/direct-adapter-calls-x64.watindex c93bf75cba..a6240eca18 100644--- a/tests/disas/component-model/direct-adapter-calls-x64.wat+++ b/tests/disas/component-model/direct-adapter-calls-x64.wat@@ -85,41 +85,36 @@;; movq %rsp, %rbp;; movq 8(%rdi), %r10;; movq 0x18(%r10), %r10-;; addq $0x60, %r10+;; addq $0x50, %r10;; cmpq %rsp, %r10-;; ja 0xfd-;; 79: subq $0x50, %rsp-;; movq %rbx, 0x20(%rsp)-;; movq %r12, 0x28(%rsp)-;; movq %r13, 0x30(%rsp)-;; movq %r14, 0x38(%rsp)-;; movq %r15, 0x40(%rsp)+;; ja 0xe6+;; 79: subq $0x40, %rsp+;; movq %rbx, 0x10(%rsp)+;; movq %r12, 0x18(%rsp)+;; movq %r13, 0x20(%rsp)+;; movq %r14, 0x28(%rsp)+;; movq %r15, 0x30(%rsp);; movq %rdi, (%rsp);; movq (%rsp), %rdi;; movq 0xa8(%rdi), %r10-;; movl (%r10), %r11d-;; movq %r10, 0x10(%rsp)-;; testl %r11d, %r11d-;; movq %r11, 8(%rsp)-;; je 0xff-;; bb: movq (%rsp), %rdi+;; movl (%r10), %r10d+;; testl %r10d, %r10d+;; je 0xe8+;; b1: movq (%rsp), %rdi;; movq 0x48(%rdi), %rdi;; movq (%rsp), %rsi;; callq 0-;; ├─╼ exception frame offset: SP = FP - 0x50-;; ╰─╼ exception handler: default handler, context at [SP+0x0], handler=0xfb-;; movq 0x10(%rsp), %r10-;; movq 8(%rsp), %r11-;; movl %r11d, (%r10)-;; movq 0x20(%rsp), %rbx-;; movq 0x28(%rsp), %r12-;; movq 0x30(%rsp), %r13-;; movq 0x38(%rsp), %r14-;; movq 0x40(%rsp), %r15-;; addq $0x50, %rsp+;; ├─╼ exception frame offset: SP = FP - 0x40+;; ╰─╼ exception handler: default handler, context at [SP+0x0], handler=0xe4+;; movq 0x10(%rsp), %rbx+;; movq 0x18(%rsp), %r12+;; movq 0x20(%rsp), %r13+;; movq 0x28(%rsp), %r14+;; movq 0x30(%rsp), %r15+;; addq $0x40, %rsp;; movq %rbp, %rsp;; popq %rbp;; retq-;; fb: ud2-;; fd: ud2-;; ff: ud2+;; e4: ud2+;; e6: ud2+;; e8: ud2diff --git a/tests/disas/component-model/direct-adapter-calls.wat b/tests/disas/component-model/direct-adapter-calls.watindex 8bcaf82afc..0454232650 100644--- a/tests/disas/component-model/direct-adapter-calls.wat+++ b/tests/disas/component-model/direct-adapter-calls.wat@@ -101,7 +101,6 @@;; region2 = 57 "";; region3 = 209 "";; region4 = 42 ""-;; region5 = 132 "";; gv0 = vmctx;; gv1 = load.i64 notrap aligned readonly can_move region0 gv0+8;; gv2 = load.i64 notrap aligned region1 gv1+24@@ -123,24 +122,21 @@;; @0098 jump block7;;;; block7:-;; @009e v9 = load.i64 notrap aligned readonly can_move region2 v0+144-;; @009e v10 = load.i32 notrap aligned region5 v9-;; @00ac v14 = load.i64 notrap aligned readonly can_move region4 v0+72-;; @00ac try_call fn0(v14, v0, v2), sig1, block9(ret0), [ context v0, default: block6(exn0) ]+;; @00a0 v9 = load.i64 notrap aligned readonly can_move region4 v0+72+;; @00a0 try_call fn0(v9, v0, v2), sig1, block9(ret0), [ context v0, default: block6(exn0) ];;-;; block9(v15: i32):-;; @00b8 store.i32 notrap aligned region3 v7, v6-;; @00ba jump block5+;; block9(v10: i32):+;; @00a6 jump block5;;;; block5:-;; @00bb jump block2+;; @00a7 jump block2;;;; block3:-;; @00be trap user52+;; @00aa trap user52;;;; block2:-;; @00c2 jump block1+;; @00ae jump block1;;;; block1:-;; @00c2 return v15+;; @00ae return v10;; }diff --git a/tests/disas/component-model/known-imported-adapter-memory.wat b/tests/disas/component-model/known-imported-adapter-memory.watindex 6d3ead81b3..40db491ae8 100644--- a/tests/disas/component-model/known-imported-adapter-memory.wat+++ b/tests/disas/component-model/known-imported-adapter-memory.wat@@ -152,12 +152,11 @@;; region2 = 57 "";; region3 = 209 "";; region4 = 42 ""-;; region5 = 132 ""-;; region6 = 75 ""-;; region7 = 215 ""-;; region8 = 105 ""-;; region9 = 171 ""-;; region10 = 184 ""+;; region5 = 75 ""+;; region6 = 215 ""+;; region7 = 105 ""+;; region8 = 171 ""+;; region9 = 184 "";; gv0 = vmctx;; gv1 = load.i64 notrap aligned readonly can_move region0 gv0+8;; gv2 = load.i64 notrap aligned region1 gv1+24@@ -179,89 +178,84 @@;; @00fd jump block7;;;; block7:-;; @0103 v10 = load.i64 notrap aligned readonly can_move region2 v0+320-;; @0103 v11 = load.i32 notrap aligned region5 v10-;; @0111 v15 = load.i64 notrap aligned readonly can_move region4 v0+120-;; @0111 try_call fn0(v15, v0, v2), sig1, block9(ret0), [ context v0, default: block6(exn0) ]+;; @0105 v10 = load.i64 notrap aligned readonly can_move region4 v0+120+;; @0105 try_call fn0(v10, v0, v2), sig1, block9(ret0), [ context v0, default: block6(exn0) ];;-;; block9(v16: i32):-;; @00ec v4 = iconst.i32 0-;; @0117 store notrap aligned region3 v4, v7 ; v4 = 0-;; @011b v19 = iconst.i32 3-;; @011d v20 = band v16, v19 ; v19 = 3-;; @011e trapnz v20, user36-;; @011e jump block11+;; block9(v11: i32):+;; @010b v12 = iconst.i32 3+;; @010d v13 = band v11, v12 ; v12 = 3+;; @010e trapnz v13, user36+;; @010e jump block11;;;; block11:-;; @0128 v22 = load.i64 notrap aligned readonly can_move region6 v0+48-;; @0128 v23 = load.i64 notrap aligned region8 v22+8-;; @0128 v24 = iconst.i64 16-;; @0128 v25 = ushr v23, v24 ; v24 = 16-;; @0128 v26 = ireduce.i32 v25-;; @012a v27 = uextend.i64 v26-;; @012d v29 = ishl v27, v24 ; v24 = 16-;; @0130 v30 = uextend.i64 v16-;; v79 = iconst.i64 8-;; @0134 v33 = iadd v30, v79 ; v79 = 8-;; @0135 v34 = icmp uge v29, v33-;; @0136 brif v34, block12, block14+;; @0118 v15 = load.i64 notrap aligned readonly can_move region5 v0+48+;; @0118 v16 = load.i64 notrap aligned region7 v15+8+;; @0118 v17 = iconst.i64 16+;; @0118 v18 = ushr v16, v17 ; v17 = 16+;; @0118 v19 = ireduce.i32 v18+;; @011a v20 = uextend.i64 v19+;; @011d v22 = ishl v20, v17 ; v17 = 16+;; @0120 v23 = uextend.i64 v11+;; v71 = iconst.i64 8+;; @0124 v26 = iadd v23, v71 ; v71 = 8+;; @0125 v27 = icmp uge v22, v26+;; @0126 brif v27, block12, block14;;;; block14:-;; @0138 jump block13+;; @0128 jump block13;;;; block13:-;; @0139 trap user4+;; @0129 trap user4;;;; block12:-;; @011b v80 = iconst.i32 3-;; @0141 v81 = band.i32 v3, v80 ; v80 = 3-;; @0142 trapnz v81, user36-;; @0142 jump block16+;; @010b v72 = iconst.i32 3+;; @0131 v73 = band.i32 v3, v72 ; v72 = 3+;; @0132 trapnz v73, user36+;; @0132 jump block16;;;; block16:-;; @014c v40 = load.i64 notrap aligned readonly can_move region6 v0+72-;; @014c v41 = load.i64 notrap aligned region8 v40+8-;; @0128 v82 = iconst.i64 16-;; @014c v83 = ushr v41, v82 ; v82 = 16-;; @014c v44 = ireduce.i32 v83-;; @014e v45 = uextend.i64 v44-;; @0151 v84 = ishl v45, v82 ; v82 = 16-;; @0154 v48 = uextend.i64 v3-;; v85 = iconst.i64 8-;; @0158 v86 = iadd v48, v85 ; v85 = 8-;; @0159 v52 = icmp uge v84, v86-;; @015a brif v52, block17, block19+;; @013c v33 = load.i64 notrap aligned readonly can_move region5 v0+72+;; @013c v34 = load.i64 notrap aligned region7 v33+8+;; @0118 v74 = iconst.i64 16+;; @013c v75 = ushr v34, v74 ; v74 = 16+;; @013c v37 = ireduce.i32 v75+;; @013e v38 = uextend.i64 v37+;; @0141 v76 = ishl v38, v74 ; v74 = 16+;; @0144 v41 = uextend.i64 v3+;; v77 = iconst.i64 8+;; @0148 v78 = iadd v41, v77 ; v77 = 8+;; @0149 v45 = icmp uge v76, v78+;; @014a brif v45, block17, block19;;;; block19:-;; @015c jump block18+;; @014c jump block18;;;; block18:-;; @015d trap user4+;; @014d trap user4;;;; block17:-;; @0165 v57 = load.i64 notrap aligned readonly can_move region7 v22-;; @0165 v58 = iadd v57, v30-;; @0165 v59 = load.i32 little region9 v58-;; @0168 v62 = load.i64 notrap aligned readonly can_move region7 v40-;; @0168 v63 = iadd v62, v48-;; @0168 store little region10 v59, v63-;; @0170 v68 = iconst.i64 4-;; @0170 v69 = iadd v58, v68 ; v68 = 4-;; @0170 v70 = load.i32 little region9 v69-;; @0173 v76 = iadd v63, v68 ; v68 = 4-;; @0173 store little region10 v70, v76-;; @0179 store.i32 notrap aligned region3 v8, v7-;; @017b jump block5+;; @0155 v50 = load.i64 notrap aligned readonly can_move region6 v15+;; @0155 v51 = iadd v50, v23+;; @0155 v52 = load.i32 little region8 v51+;; @0158 v55 = load.i64 notrap aligned readonly can_move region6 v33+;; @0158 v56 = iadd v55, v41+;; @0158 store little region9 v52, v56+;; @0160 v61 = iconst.i64 4+;; @0160 v62 = iadd v51, v61 ; v61 = 4+;; @0160 v63 = load.i32 little region8 v62+;; @0163 v69 = iadd v56, v61 ; v61 = 4+;; @0163 store little region9 v63, v69+;; @0167 jump block5;;;; block5:-;; @017c jump block2+;; @0168 jump block2;;;; block3:-;; @017f trap user52+;; @016b trap user52;;;; block2:-;; @0183 jump block1+;; @016f jump block1;;;; block1:-;; @0183 return+;; @016f return;; }diff --git a/tests/disas/component-model/sync-adapter-calls.wat b/tests/disas/component-model/sync-adapter-calls.watindex 42a8ea9965..c1c5c3276f 100644--- a/tests/disas/component-model/sync-adapter-calls.wat+++ b/tests/disas/component-model/sync-adapter-calls.wat@@ -57,7 +57,6 @@;; region2 = 42 "";; region3 = 57 "";; region4 = 209 ""-;; region5 = 132 "";; gv0 = vmctx;; gv1 = load.i64 notrap aligned readonly can_move region0 gv0+8;; gv2 = load.i64 notrap aligned region1 gv1+24@@ -88,8 +87,6 @@;; jump block9;;;; block9:-;; v11 = load.i64 notrap aligned readonly can_move region3 v3+144-;; v12 = load.i32 notrap aligned region5 v11;; jump block12;;;; block12:@@ -114,6 +111,6 @@;; @00f0 jump block1;;;; block1:-;; v23 = iconst.i32 1276-;; @00f0 return v23 ; v23 = 1276+;; v15 = iconst.i32 1276+;; @00f0 return v15 ; v15 = 1276;; }diff --git a/tests/disas/component-model/sync-adapter-lazy-lend.wat b/tests/disas/component-model/sync-adapter-lazy-lend.watindex aa81e938b3..2785ff461b 100644--- a/tests/disas/component-model/sync-adapter-lazy-lend.wat+++ b/tests/disas/component-model/sync-adapter-lazy-lend.wat@@ -72,16 +72,15 @@;; region12 = 93 "";; region13 = 30 "";; region14 = 184 ""-;; region15 = 132 ""-;; region16 = 108 ""-;; region17 = 8 ""-;; region18 = 218 ""-;; region19 = 252 ""-;; region20 = 13 ""-;; region21 = 34 ""-;; region22 = 195 ""-;; region23 = 158 ""-;; region24 = 174 ""+;; region15 = 108 ""+;; region16 = 8 ""+;; region17 = 218 ""+;; region18 = 252 ""+;; region19 = 13 ""+;; region20 = 34 ""+;; region21 = 195 ""+;; region22 = 158 ""+;; region23 = 174 "";; gv0 = vmctx;; gv1 = load.i64 notrap aligned readonly can_move region0 gv0+8;; gv2 = load.i64 notrap aligned region1 gv1+24@@ -121,107 +120,102 @@;; @00fc v19 = load.i64 notrap aligned region13 v13+152;; @00fc store notrap aligned region14 v19, v12+24;; @00fc store notrap aligned region5 v12, v13+136-;; @00fe v20 = load.i64 notrap aligned readonly can_move region2 v0+240-;; @00fe v21 = load.i32 notrap aligned region15 v20-;; @0104 store notrap aligned region15 v3, v20 ; v3 = 0-;; @0108 jump block11+;; @0100 jump block11;;;; block11:-;; @0108 v31 = iconst.i64 8-;; @0108 v32 = icmp.i64 ult v19, v31 ; v31 = 8-;; @0108 brif v32, block12, block9+;; @0100 v27 = iconst.i64 8+;; @0100 v28 = icmp.i64 ult v19, v27 ; v27 = 8+;; @0100 brif v28, block12, block9;;;; block12:;; @00f4 v8 = load.i64 notrap aligned readonly can_move region4 v0+104-;; @0108 v36 = load.i64 notrap aligned region16 v8+120-;; @0108 v33 = iconst.i32 -1-;; @0108 v34 = iadd.i32 v2, v33 ; v33 = -1-;; @0108 v35 = uextend.i64 v34-;; @0108 v37 = icmp ult v35, v36-;; @0108 brif v37, block13, block9+;; @0100 v32 = load.i64 notrap aligned region15 v8+120+;; @0100 v29 = iconst.i32 -1+;; @0100 v30 = iadd.i32 v2, v29 ; v29 = -1+;; @0100 v31 = uextend.i64 v30+;; @0100 v33 = icmp ult v31, v32+;; @0100 brif v33, block13, block9;;;; block13:-;; @0108 v38 = load.i64 notrap aligned region17 v8+112-;; @0108 v39 = iconst.i64 24-;; @0108 v40 = imul.i64 v35, v39 ; v39 = 24-;; @0108 v41 = iadd v38, v40-;; @0108 v42 = load.i32 notrap aligned region18 v41-;; @0108 v87 = iconst.i32 -1-;; @0108 v88 = iadd v42, v87 ; v87 = -1-;; @00fa v89 = iconst.i32 1-;; @0108 v90 = icmp ule v88, v89 ; v89 = 1-;; @0108 brif v90, block14, block9+;; @0100 v34 = load.i64 notrap aligned region16 v8+112+;; @0100 v35 = iconst.i64 24+;; @0100 v36 = imul.i64 v31, v35 ; v35 = 24+;; @0100 v37 = iadd v34, v36+;; @0100 v38 = load.i32 notrap aligned region17 v37+;; @0100 v74 = iconst.i32 -1+;; @0100 v75 = iadd v38, v74 ; v74 = -1+;; @00fa v76 = iconst.i32 1+;; @0100 v77 = icmp ule v75, v76 ; v76 = 1+;; @0100 brif v77, block14, block9;;;; block14:-;; @0108 v47 = load.i32 notrap aligned region19 v41+4-;; @0108 v48 = iconst.i32 2-;; @0108 v49 = icmp eq v47, v48 ; v48 = 2-;; @0108 brif v49, block15, block9+;; @0100 v43 = load.i32 notrap aligned region18 v37+4+;; @0100 v44 = iconst.i32 2+;; @0100 v45 = icmp eq v43, v44 ; v44 = 2+;; @0100 brif v45, block15, block9;;;; block15:-;; @0108 v50 = load.i32 notrap aligned region20 v41+8-;; @0108 v91 = iconst.i32 2-;; @0108 v51 = load.i64 notrap aligned readonly can_move region21 v13+144-;; v84 = iconst.i64 3-;; v85 = ishl.i64 v19, v84 ; v84 = 3-;; @0108 v54 = iadd v51, v85-;; @0108 store notrap aligned region22 v91, v54 ; v91 = 2-;; @0108 store.i32 notrap aligned region23 v2, v54+4-;; @0108 v56 = iconst.i64 1-;; @0108 v57 = iadd.i64 v19, v56 ; v56 = 1-;; @0108 store notrap aligned region13 v57, v13+152-;; @0108 jump block10(v50)+;; @0100 v46 = load.i32 notrap aligned region19 v37+8+;; @0100 v78 = iconst.i32 2+;; @0100 v47 = load.i64 notrap aligned readonly can_move region20 v13+144+;; v71 = iconst.i64 3+;; v72 = ishl.i64 v19, v71 ; v71 = 3+;; @0100 v50 = iadd v47, v72+;; @0100 store notrap aligned region21 v78, v50 ; v78 = 2+;; @0100 store.i32 notrap aligned region22 v2, v50+4+;; @0100 v52 = iconst.i64 1+;; @0100 v53 = iadd.i64 v19, v52 ; v52 = 1+;; @0100 store notrap aligned region13 v53, v13+152+;; @0100 jump block10(v46);;;; block9 cold:-;; @0108 v58 = load.i64 notrap aligned readonly can_move region24 v0+152-;; @00f4 v92 = load.i64 notrap aligned readonly can_move region4 v0+104-;; @0108 try_call_indirect v58(v92, v0, v2), sig2, block16(ret0), [ context v0, default: block6(exn0) ]+;; @0100 v54 = load.i64 notrap aligned readonly can_move region23 v0+152+;; @00f4 v79 = load.i64 notrap aligned readonly can_move region4 v0+104+;; @0100 try_call_indirect v54(v79, v0, v2), sig2, block16(ret0), [ context v0, default: block6(exn0) ];;-;; block16(v59: i32):-;; @0108 jump block10(v59)+;; block16(v55: i32):+;; @0100 jump block10(v55);;-;; block10(v27: i32):-;; @010c store.i32 notrap aligned region15 v21, v20-;; @010e v63 = load.i64 notrap aligned readonly can_move region4 v0+72-;; @010e try_call fn0(v63, v0, v27), sig2, block17(ret0), [ context v0, default: block6(exn0) ]+;; block10(v23: i32):+;; @0102 v56 = load.i64 notrap aligned readonly can_move region4 v0+72+;; @0102 try_call fn0(v56, v0, v23), sig2, block17(ret0), [ context v0, default: block6(exn0) ];;-;; block17(v64: i32):-;; @0112 v68 = load.i64 notrap aligned region5 v13+136-;; @0112 v69 = icmp eq v68, v12-;; @0112 brif v69, block18, block19+;; block17(v57: i32):+;; @0106 v61 = load.i64 notrap aligned region5 v13+136+;; @0106 v62 = icmp eq v61, v12+;; @0106 brif v62, block18, block19;;;; block18:-;; @0112 v70 = load.i64 notrap aligned region6 v12-;; @0112 store notrap aligned region5 v70, v13+136-;; @0112 v71 = load.i64 notrap aligned region14 v12+24-;; @0112 store notrap aligned region13 v71, v13+152-;; @0112 v72 = load.i32 notrap aligned region10 v12+16-;; @0112 store notrap aligned region9 v72, v13+128-;; @0112 v73 = load.i32 notrap aligned region12 v12+20-;; @0112 store notrap aligned region11 v73, v13+132-;; @0112 jump block20+;; @0106 v63 = load.i64 notrap aligned region6 v12+;; @0106 store notrap aligned region5 v63, v13+136+;; @0106 v64 = load.i64 notrap aligned region14 v12+24+;; @0106 store notrap aligned region13 v64, v13+152+;; @0106 v65 = load.i32 notrap aligned region10 v12+16+;; @0106 store notrap aligned region9 v65, v13+128+;; @0106 v66 = load.i32 notrap aligned region12 v12+20+;; @0106 store notrap aligned region11 v66, v13+132+;; @0106 jump block20;;;; block19 cold:-;; @0112 v74 = load.i64 notrap aligned readonly can_move region24 v0+184-;; @00f4 v93 = load.i64 notrap aligned readonly can_move region4 v0+104-;; @0112 try_call_indirect v74(v93, v0), sig0, block21, [ context v0, default: block6(exn0) ]+;; @0106 v67 = load.i64 notrap aligned readonly can_move region23 v0+184+;; @00f4 v80 = load.i64 notrap aligned readonly can_move region4 v0+104+;; @0106 try_call_indirect v67(v80, v0), sig0, block21, [ context v0, default: block6(exn0) ];;;; block21:-;; @0112 jump block20+;; @0106 jump block20;;;; block20:-;; @011c store.i32 notrap aligned region3 v7, v6-;; @011e jump block5+;; @010a jump block5;;;; block5:-;; @011f jump block2+;; @010b jump block2;;;; block3:-;; @0122 trap user52+;; @010e trap user52;;;; block2:-;; @0126 jump block1+;; @0112 jump block1;;;; block1:-;; @0126 return v64+;; @0112 return v57;; }diff --git a/tests/disas/component-model/thread-transparency/opaque.wat b/tests/disas/component-model/thread-transparency/opaque.watindex edb6503257..6be1f9ece3 100644--- a/tests/disas/component-model/thread-transparency/opaque.wat+++ b/tests/disas/component-model/thread-transparency/opaque.wat@@ -78,8 +78,7 @@;; region12 = 93 "";; region13 = 30 "";; region14 = 184 ""-;; region15 = 132 ""-;; region16 = 174 ""+;; region15 = 174 "";; gv0 = vmctx;; gv1 = load.i64 notrap aligned readonly can_move region0 gv0+8;; gv2 = load.i64 notrap aligned region1 gv1+24@@ -130,14 +129,12 @@;; v21 = load.i64 notrap aligned region13 v15+152;; store notrap aligned region14 v21, v14+24;; store notrap aligned region5 v14, v15+136-;; v22 = load.i64 notrap aligned readonly can_move region3 v3+208-;; v23 = load.i32 notrap aligned region15 v22;; jump block16;;;; block16:-;; v27 = load.i64 notrap aligned readonly can_move region2 v3+72-;; v29 = load.i64 notrap aligned readonly can_move region0 v27+8-;; v30 = load.i32 notrap aligned region9 v29+128+;; v22 = load.i64 notrap aligned readonly can_move region2 v3+72+;; v24 = load.i64 notrap aligned readonly can_move region0 v22+8+;; v25 = load.i32 notrap aligned region9 v24+128;; jump block17;;;; block17:@@ -153,7 +150,6 @@;; jump block14;;;; block14:-;; store.i32 notrap aligned region4 v10, v9;; jump block7;;;; block7:@@ -170,6 +166,6 @@;;;; block1:;; @0120 v2 = iconst.i32 1234-;; v48 = iadd.i32 v30, v2 ; v2 = 1234-;; @0125 return v48+;; v40 = iadd.i32 v25, v2 ; v2 = 1234+;; @0125 return v40;; }