Repository: bytecodealliance/wasmtime
Pull request #7447 (2023-11-01 16:52:48)

Validate the status code in outgoing-response
Validate the `status-code` given to `outoging-reponse` in wasi-http. This forces two changes to the interface:

* The constructor can no longer take a `status-code` argument, as there's no way to indicate errors from a constructor. The solution here is to default the `status-code` to `200`, and use `outgoing-response.set-status-code` to change it when necessary.
* The `outgoing-response.set-status-code` method has become fallible, allowing us to indicate to the guest when an invalid `status-code` has been given.

Internally, the change to the wasmtime-wasi-http crate is that we're now storing an `http::StatusCode` instead of a raw `u16`.

cc @JakeChampion 
<!--
Please make sure you include the following information:

- If this work has been discussed elsewhere, please include a link to that
  conversation. If it was discussed in an issue, just mention "issue #...".

- Explain why this change is needed. If the details are in an issue already,
  this can be brief.

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->



Patch:
diff --git a/crates/cli-flags/src/lib.rs b/crates/cli-flags/src/lib.rs
index 0a496257c..03900707a 100644
--- a/crates/cli-flags/src/lib.rs
+++ b/crates/cli-flags/src/lib.rs
@@ -362,12 +362,10 @@ impl CommonOptions {
         } else {
             use std::io::IsTerminal;
             use tracing_subscriber::{EnvFilter, FmtSubscriber};
-            let mut b = FmtSubscriber::builder()
+            let b = FmtSubscriber::builder()
                 .with_writer(std::io::stderr)
-                .with_env_filter(EnvFilter::from_env("WASMTIME_LOG"));
-            if std::io::stderr().is_terminal() {
-                b = b.with_ansi(true);
-            }
+                .with_env_filter(EnvFilter::from_env("WASMTIME_LOG"))
+                .with_ansi(std::io::stderr().is_terminal());
             b.init();
         }
         #[cfg(not(feature = "logging"))]
diff --git a/crates/runtime/src/mpk/pkru.rs b/crates/runtime/src/mpk/pkru.rs
index 99dee74fa..9e36dd35a 100644
--- a/crates/runtime/src/mpk/pkru.rs
+++ b/crates/runtime/src/mpk/pkru.rs
@@ -56,6 +56,11 @@ pub fn write(pkru: u32) {
 /// Check the `ECX.PKU` flag (bit 3) of the `07h` `CPUID` leaf; see the
 /// Intel Software Development Manual, vol 3a, section 2.7.
 pub fn has_cpuid_bit_set() -> bool {
+    // TODO: disable MPK support until the following issue is resolved:
+    // https://github.com/bytecodealliance/wasmtime/issues/7445
+    if true {
+        return false;
+    }
     let result = unsafe { std::arch::x86_64::__cpuid(0x07) };
     (result.ecx & 0b100) != 0
 }
diff --git a/crates/wasi-http/src/types.rs b/crates/wasi-http/src/types.rs
index dc41a30c6..e962ff47c 100644
--- a/crates/wasi-http/src/types.rs
+++ b/crates/wasi-http/src/types.rs
@@ -289,7 +289,7 @@ pub struct HostIncomingResponse {
 }
 
 pub struct HostOutgoingResponse {
-    pub status: u16,
+    pub status: http::StatusCode,
     pub headers: FieldMap,
     pub body: Option<HyperOutgoingBody>,
 }
diff --git a/crates/wasi-http/src/types_impl.rs b/crates/wasi-http/src/types_impl.rs
index 2f7612af1..bce0384ab 100644
--- a/crates/wasi-http/src/types_impl.rs
+++ b/crates/wasi-http/src/types_impl.rs
@@ -632,13 +632,12 @@ impl<T: WasiHttpView> crate::bindings::http::types::HostIncomingBody for T {
 impl<T: WasiHttpView> crate::bindings::http::types::HostOutgoingResponse for T {
     fn new(
         &mut self,
-        status: StatusCode,
         headers: Resource<Headers>,
     ) -> wasmtime::Result<Resource<HostOutgoingResponse>> {
         let fields = move_fields(self.table(), headers)?;
 
         let id = self.table().push(HostOutgoingResponse {
-            status,
+            status: http::StatusCode::OK,
             headers: fields,
             body: None,
         })?;
@@ -669,16 +668,26 @@ impl<T: WasiHttpView> crate::bindings::http::types::HostOutgoingResponse for T {
         &mut self,
         id: Resource<HostOutgoingResponse>,
     ) -> wasmtime::Result<types::StatusCode> {
-        Ok(self.table().get(&id)?.status)
+        Ok(self.table().get(&id)?.status.into())
     }
 
     fn set_status_code(
         &mut self,
         id: Resource<HostOutgoingResponse>,
         status: types::StatusCode,
-    ) -> wasmtime::Result<()> {
-        self.table().get_mut(&id)?.status = status;
-        Ok(())
+    ) -> wasmtime::Result<Result<(), Error>> {
+        let resp = self.table().get_mut(&id)?;
+
+        match http::StatusCode::from_u16(status) {
+            Ok(status) => resp.status = status,
+            Err(_) => {
+                return Ok(Err(Error::UnexpectedError(
+                    "Invalid status code".to_string(),
+                )))
+            }
+        };
+
+        Ok(Ok(()))
     }
 
     fn headers(
diff --git a/crates/wasi-http/wit/deps/http/types.wit b/crates/wasi-http/wit/deps/http/types.wit
index 9a0c8956b..81166b011 100644
--- a/crates/wasi-http/wit/deps/http/types.wit
+++ b/crates/wasi-http/wit/deps/http/types.wit
@@ -351,16 +351,18 @@ interface types {
   /// Represents an outgoing HTTP Response.
   resource outgoing-response {
 
-    /// Construct an `outgoing-response`.
+    /// Construct an `outgoing-response`, with a default `status-code` of `200`.
+    /// If a different `status-code` is needed, it must be set via the
+    /// `set-status-code` method.
     ///
-    /// * `status-code` is the HTTP Status Code for the Response.
     /// * `headers` is the HTTP Headers for the Response.
-    constructor(status-code: status-code, headers: headers);
+    constructor(headers: headers);
 
     /// Get the HTTP Status Code for the Response.
     status-code: func() -> status-code;
+
     /// Set the HTTP Status Code for the Response.
-    set-status-code: func(status-code: status-code);
+    set-status-code: func(status-code: status-code) -> result<_, error>;
 
     /// Get the headers associated with the Request.
     ///
diff --git a/crates/wasi/wit/deps/http/types.wit b/crates/wasi/wit/deps/http/types.wit
index 9a0c8956b..81166b011 100644
--- a/crates/wasi/wit/deps/http/types.wit
+++ b/crates/wasi/wit/deps/http/types.wit
@@ -351,16 +351,18 @@ interface types {
   /// Represents an outgoing HTTP Response.
   resource outgoing-response {
 
-    /// Construct an `outgoing-response`.
+    /// Construct an `outgoing-response`, with a default `status-code` of `200`.
+    /// If a different `status-code` is needed, it must be set via the
+    /// `set-status-code` method.
     ///
-    /// * `status-code` is the HTTP Status Code for the Response.
     /// * `headers` is the HTTP Headers for the Response.
-    constructor(status-code: status-code, headers: headers);
+    constructor(headers: headers);
 
     /// Get the HTTP Status Code for the Response.
     status-code: func() -> status-code;
+
     /// Set the HTTP Status Code for the Response.
-    set-status-code: func(status-code: status-code);
+    set-status-code: func(status-code: status-code) -> result<_, error>;
 
     /// Get the headers associated with the Request.
     ///
diff --git a/src/commands/run.rs b/src/commands/run.rs
index 89fe35e85..6ca015ddd 100644
--- a/src/commands/run.rs
+++ b/src/commands/run.rs
@@ -504,8 +504,8 @@ impl RunCommand {
                 // parses base-10 representations.
                 ValType::I32 => Val::I32(val.parse()?),
                 ValType::I64 => Val::I64(val.parse()?),
-                ValType::F32 => Val::F32(val.parse()?),
-                ValType::F64 => Val::F64(val.parse()?),
+                ValType::F32 => Val::F32(val.parse::<f32>()?.to_bits()),
+                ValType::F64 => Val::F64(val.parse::<f64>()?.to_bits()),
                 t => bail!("unsupported argument type {:?}", t),
             });
         }
diff --git a/winch/codegen/src/frame/mod.rs b/winch/codegen/src/frame/mod.rs
index 9a0329856..3e555a912 100644
--- a/winch/codegen/src/frame/mod.rs
+++ b/winch/codegen/src/frame/mod.rs
@@ -108,7 +108,7 @@ impl Frame {
             locals_size,
             vmctx_slot: LocalSlot::i64(vmctx_offset),
             defined_locals_range: DefinedLocalsRange(
-                defined_locals_start..defined_locals.stack_size,
+                defined_locals_start..(defined_locals_start + defined_locals.stack_size),
             ),
         })
     }


Test patch:
diff --git a/crates/test-programs/src/bin/api_proxy.rs b/crates/test-programs/src/bin/api_proxy.rs
index 1bcdc783d..2170bdbbc 100644
--- a/crates/test-programs/src/bin/api_proxy.rs
+++ b/crates/test-programs/src/bin/api_proxy.rs
@@ -17,7 +17,7 @@ struct T;
 impl bindings::exports::wasi::http::incoming_handler::Guest for T {
     fn handle(_request: IncomingRequest, outparam: ResponseOutparam) {
         let hdrs = bindings::wasi::http::types::Headers::new();
-        let resp = bindings::wasi::http::types::OutgoingResponse::new(200, hdrs);
+        let resp = bindings::wasi::http::types::OutgoingResponse::new(hdrs);
         let body = resp.body().expect("outgoing response");
 
         bindings::wasi::http::types::ResponseOutparam::set(outparam, Ok(resp));
diff --git a/crates/test-programs/src/bin/api_proxy_streaming.rs b/crates/test-programs/src/bin/api_proxy_streaming.rs
index 5f1c0560c..730bef938 100644
--- a/crates/test-programs/src/bin/api_proxy_streaming.rs
+++ b/crates/test-programs/src/bin/api_proxy_streaming.rs
@@ -53,7 +53,6 @@ async fn handle_request(request: IncomingRequest, response_out: ResponseOutparam
             let mut results = stream::iter(results).buffer_unordered(MAX_CONCURRENCY);
 
             let response = OutgoingResponse::new(
-                200,
                 Fields::from_list(&[("content-type".to_string(), b"text/plain".to_vec())]).unwrap(),
             );
 
@@ -79,7 +78,6 @@ async fn handle_request(request: IncomingRequest, response_out: ResponseOutparam
             // Echo the request body without buffering it.
 
             let response = OutgoingResponse::new(
-                200,
                 Fields::from_list(
                     &headers
                         .into_iter()
@@ -129,7 +127,6 @@ async fn handle_request(request: IncomingRequest, response_out: ResponseOutparam
                         );
 
                         let response = OutgoingResponse::new(
-                            200,
                             Fields::from_list(
                                 &headers
                                     .into_iter()
@@ -242,7 +239,10 @@ fn method_not_allowed(response_out: ResponseOutparam) {
 }
 
 fn respond(status: u16, response_out: ResponseOutparam) {
-    let response = OutgoingResponse::new(status, Fields::new());
+    let response = OutgoingResponse::new(Fields::new());
+    response
+        .set_status_code(status)
+        .expect("setting status code");
 
     let body = response.body().expect("response should be writable");
 
diff --git a/crates/test-programs/src/bin/http_outbound_request_response_build.rs b/crates/test-programs/src/bin/http_outbound_request_response_build.rs
index 8a50ff6fa..c2360d299 100644
--- a/crates/test-programs/src/bin/http_outbound_request_response_build.rs
+++ b/crates/test-programs/src/bin/http_outbound_request_response_build.rs
@@ -27,7 +27,7 @@ fn main() {
             "application/text".to_string().into_bytes(),
         )])
         .unwrap();
-        let response = http_types::OutgoingResponse::new(200, headers);
+        let response = http_types::OutgoingResponse::new(headers);
         let outgoing_body = response.body().unwrap();
         let response_body = outgoing_body.write().unwrap();
         response_body
diff --git a/crates/test-programs/src/bin/preview2_tcp_bind.rs b/crates/test-programs/src/bin/preview2_tcp_bind.rs
index 0dadd114b..faea346a1 100644
--- a/crates/test-programs/src/bin/preview2_tcp_bind.rs
+++ b/crates/test-programs/src/bin/preview2_tcp_bind.rs
@@ -30,7 +30,9 @@ fn test_tcp_bind_specific_port(net: &Network, ip: IpAddress) {
             assert_eq!(bind_addr.ip(), bound_addr.ip());
             assert_eq!(bind_addr.port(), bound_addr.port());
         }
-        Err(ErrorCode::AddressInUse) => {}
+        // Concurrent invocations of this test can yield `AddressInUse` and that
+        // same error can show up on Windows as `AccessDenied`.
+        Err(ErrorCode::AddressInUse | ErrorCode::AccessDenied) => {}
         Err(e) => panic!("error: {e}"),
     }
 }
diff --git a/tests/all/cli_tests.rs b/tests/all/cli_tests.rs
index b4bc8c86c..a3113e2da 100644
--- a/tests/all/cli_tests.rs
+++ b/tests/all/cli_tests.rs
@@ -1176,6 +1176,25 @@ warning: this CLI invocation of Wasmtime is going to break in the future -- for
     Ok(())
 }
 
+#[test]
+fn float_args() -> Result<()> {
+    let result = run_wasmtime(&[
+        "--invoke",
+        "echo_f32",
+        "tests/all/cli_tests/simple.wat",
+        "1.0",
+    ])?;
+    assert_eq!(result, "1\n");
+    let result = run_wasmtime(&[
+        "--invoke",
+        "echo_f64",
+        "tests/all/cli_tests/simple.wat",
+        "1.1",
+    ])?;
+    assert_eq!(result, "1.1\n");
+    Ok(())
+}
+
 mod test_programs {
     use super::{get_wasmtime_command, run_wasmtime};
     use anyhow::Result;
diff --git a/tests/all/cli_tests/simple.wat b/tests/all/cli_tests/simple.wat
index a851dfa00..a62319c5e 100644
--- a/tests/all/cli_tests/simple.wat
+++ b/tests/all/cli_tests/simple.wat
@@ -4,4 +4,6 @@
     )
     (func (export "get_f32") (result f32) f32.const 100)
     (func (export "get_f64") (result f64) f64.const 100)
+    (func (export "echo_f32") (param f32) (result f32) local.get 0)
+    (func (export "echo_f64") (param f64) (result f64) local.get 0)
 )
diff --git a/winch/filetests/filetests/x64/br_if/as_local_set_value.wat b/winch/filetests/filetests/x64/br_if/as_local_set_value.wat
index 054e6a8b3..ee5f0ac87 100644
--- a/winch/filetests/filetests/x64/br_if/as_local_set_value.wat
+++ b/winch/filetests/filetests/x64/br_if/as_local_set_value.wat
@@ -12,13 +12,15 @@
 ;;    1:	 4889e5               	mov	rbp, rsp
 ;;    4:	 4883ec10             	sub	rsp, 0x10
 ;;    8:	 897c240c             	mov	dword ptr [rsp + 0xc], edi
-;;    c:	 4c893424             	mov	qword ptr [rsp], r14
-;;   10:	 8b4c240c             	mov	ecx, dword ptr [rsp + 0xc]
-;;   14:	 b811000000           	mov	eax, 0x11
-;;   19:	 85c9                 	test	ecx, ecx
-;;   1b:	 0f8509000000         	jne	0x2a
-;;   21:	 8944240c             	mov	dword ptr [rsp + 0xc], eax
-;;   25:	 b8ffffffff           	mov	eax, 0xffffffff
-;;   2a:	 4883c410             	add	rsp, 0x10
-;;   2e:	 5d                   	pop	rbp
-;;   2f:	 c3                   	ret	
+;;    c:	 c744240800000000     	mov	dword ptr [rsp + 8], 0
+;;   14:	 4531db               	xor	r11d, r11d
+;;   17:	 4c893424             	mov	qword ptr [rsp], r14
+;;   1b:	 8b4c240c             	mov	ecx, dword ptr [rsp + 0xc]
+;;   1f:	 b811000000           	mov	eax, 0x11
+;;   24:	 85c9                 	test	ecx, ecx
+;;   26:	 0f8509000000         	jne	0x35
+;;   2c:	 8944240c             	mov	dword ptr [rsp + 0xc], eax
+;;   30:	 b8ffffffff           	mov	eax, 0xffffffff
+;;   35:	 4883c410             	add	rsp, 0x10
+;;   39:	 5d                   	pop	rbp
+;;   3a:	 c3                   	ret	
diff --git a/winch/filetests/filetests/x64/loop/for.wat b/winch/filetests/filetests/x64/loop/for.wat
index cbeb993b6..2db94dd07 100644
--- a/winch/filetests/filetests/x64/loop/for.wat
+++ b/winch/filetests/filetests/x64/loop/for.wat
@@ -19,29 +19,30 @@
 ;;    1:	 4889e5               	mov	rbp, rsp
 ;;    4:	 4883ec20             	sub	rsp, 0x20
 ;;    8:	 48897c2418           	mov	qword ptr [rsp + 0x18], rdi
-;;    d:	 48c744241000000000   	
-;; 				mov	qword ptr [rsp + 0x10], 0
-;;   16:	 4c893424             	mov	qword ptr [rsp], r14
-;;   1a:	 48c7c001000000       	mov	rax, 1
-;;   21:	 4889442410           	mov	qword ptr [rsp + 0x10], rax
-;;   26:	 48c7c002000000       	mov	rax, 2
-;;   2d:	 4889442408           	mov	qword ptr [rsp + 8], rax
-;;   32:	 488b442418           	mov	rax, qword ptr [rsp + 0x18]
-;;   37:	 488b4c2408           	mov	rcx, qword ptr [rsp + 8]
-;;   3c:	 4839c1               	cmp	rcx, rax
-;;   3f:	 b900000000           	mov	ecx, 0
-;;   44:	 400f97c1             	seta	cl
-;;   48:	 85c9                 	test	ecx, ecx
-;;   4a:	 0f8526000000         	jne	0x76
-;;   50:	 488b442408           	mov	rax, qword ptr [rsp + 8]
-;;   55:	 488b4c2410           	mov	rcx, qword ptr [rsp + 0x10]
-;;   5a:	 480fafc8             	imul	rcx, rax
-;;   5e:	 48894c2410           	mov	qword ptr [rsp + 0x10], rcx
-;;   63:	 488b442408           	mov	rax, qword ptr [rsp + 8]
-;;   68:	 4883c001             	add	rax, 1
-;;   6c:	 4889442408           	mov	qword ptr [rsp + 8], rax
-;;   71:	 e9bcffffff           	jmp	0x32
-;;   76:	 488b442410           	mov	rax, qword ptr [rsp + 0x10]
-;;   7b:	 4883c420             	add	rsp, 0x20
-;;   7f:	 5d                   	pop	rbp
-;;   80:	 c3                   	ret	
+;;    d:	 4531db               	xor	r11d, r11d
+;;   10:	 4c895c2410           	mov	qword ptr [rsp + 0x10], r11
+;;   15:	 4c895c2408           	mov	qword ptr [rsp + 8], r11
+;;   1a:	 4c893424             	mov	qword ptr [rsp], r14
+;;   1e:	 48c7c001000000       	mov	rax, 1
+;;   25:	 4889442410           	mov	qword ptr [rsp + 0x10], rax
+;;   2a:	 48c7c002000000       	mov	rax, 2
+;;   31:	 4889442408           	mov	qword ptr [rsp + 8], rax
+;;   36:	 488b442418           	mov	rax, qword ptr [rsp + 0x18]
+;;   3b:	 488b4c2408           	mov	rcx, qword ptr [rsp + 8]
+;;   40:	 4839c1               	cmp	rcx, rax
+;;   43:	 b900000000           	mov	ecx, 0
+;;   48:	 400f97c1             	seta	cl
+;;   4c:	 85c9                 	test	ecx, ecx
+;;   4e:	 0f8526000000         	jne	0x7a
+;;   54:	 488b442408           	mov	rax, qword ptr [rsp + 8]
+;;   59:	 488b4c2410           	mov	rcx, qword ptr [rsp + 0x10]
+;;   5e:	 480fafc8             	imul	rcx, rax
+;;   62:	 48894c2410           	mov	qword ptr [rsp + 0x10], rcx
+;;   67:	 488b442408           	mov	rax, qword ptr [rsp + 8]
+;;   6c:	 4883c001             	add	rax, 1
+;;   70:	 4889442408           	mov	qword ptr [rsp + 8], rax
+;;   75:	 e9bcffffff           	jmp	0x36
+;;   7a:	 488b442410           	mov	rax, qword ptr [rsp + 0x10]
+;;   7f:	 4883c420             	add	rsp, 0x20
+;;   83:	 5d                   	pop	rbp
+;;   84:	 c3                   	ret	
diff --git a/winch/filetests/filetests/x64/loop/while.wat b/winch/filetests/filetests/x64/loop/while.wat
index e9773ab92..adef2ad06 100644
--- a/winch/filetests/filetests/x64/loop/while.wat
+++ b/winch/filetests/filetests/x64/loop/while.wat
@@ -18,24 +18,26 @@
 ;;    1:	 4889e5               	mov	rbp, rsp
 ;;    4:	 4883ec18             	sub	rsp, 0x18
 ;;    8:	 48897c2410           	mov	qword ptr [rsp + 0x10], rdi
-;;    d:	 4c893424             	mov	qword ptr [rsp], r14
-;;   11:	 48c7c001000000       	mov	rax, 1
-;;   18:	 4889442408           	mov	qword ptr [rsp + 8], rax
-;;   1d:	 488b442410           	mov	rax, qword ptr [rsp + 0x10]
-;;   22:	 4883f800             	cmp	rax, 0
-;;   26:	 b800000000           	mov	eax, 0
-;;   2b:	 400f94c0             	sete	al
-;;   2f:	 85c0                 	test	eax, eax
-;;   31:	 0f8526000000         	jne	0x5d
-;;   37:	 488b442408           	mov	rax, qword ptr [rsp + 8]
-;;   3c:	 488b4c2410           	mov	rcx, qword ptr [rsp + 0x10]
-;;   41:	 480fafc8             	imul	rcx, rax
-;;   45:	 48894c2408           	mov	qword ptr [rsp + 8], rcx
-;;   4a:	 488b442410           	mov	rax, qword ptr [rsp + 0x10]
-;;   4f:	 4883e801             	sub	rax, 1
-;;   53:	 4889442410           	mov	qword ptr [rsp + 0x10], rax
-;;   58:	 e9c0ffffff           	jmp	0x1d
-;;   5d:	 488b442408           	mov	rax, qword ptr [rsp + 8]
-;;   62:	 4883c418             	add	rsp, 0x18
-;;   66:	 5d                   	pop	rbp
-;;   67:	 c3                   	ret	
+;;    d:	 48c744240800000000   	
+;; 				mov	qword ptr [rsp + 8], 0
+;;   16:	 4c893424             	mov	qword ptr [rsp], r14
+;;   1a:	 48c7c001000000       	mov	rax, 1
+;;   21:	 4889442408           	mov	qword ptr [rsp + 8], rax
+;;   26:	 488b442410           	mov	rax, qword ptr [rsp + 0x10]
+;;   2b:	 4883f800             	cmp	rax, 0
+;;   2f:	 b800000000           	mov	eax, 0
+;;   34:	 400f94c0             	sete	al
+;;   38:	 85c0                 	test	eax, eax
+;;   3a:	 0f8526000000         	jne	0x66
+;;   40:	 488b442408           	mov	rax, qword ptr [rsp + 8]
+;;   45:	 488b4c2410           	mov	rcx, qword ptr [rsp + 0x10]
+;;   4a:	 480fafc8             	imul	rcx, rax
+;;   4e:	 48894c2408           	mov	qword ptr [rsp + 8], rcx
+;;   53:	 488b442410           	mov	rax, qword ptr [rsp + 0x10]
+;;   58:	 4883e801             	sub	rax, 1
+;;   5c:	 4889442410           	mov	qword ptr [rsp + 0x10], rax
+;;   61:	 e9c0ffffff           	jmp	0x26
+;;   66:	 488b442408           	mov	rax, qword ptr [rsp + 8]
+;;   6b:	 4883c418             	add	rsp, 0x18
+;;   6f:	 5d                   	pop	rbp
+;;   70:	 c3                   	ret	
diff --git a/winch/filetests/filetests/x64/table/fill.wat b/winch/filetests/filetests/x64/table/fill.wat
index 2a6121295..d811a646f 100644
--- a/winch/filetests/filetests/x64/table/fill.wat
+++ b/winch/filetests/filetests/x64/table/fill.wat
@@ -49,46 +49,49 @@
 ;;    8:	 897c241c             	mov	dword ptr [rsp + 0x1c], edi
 ;;    c:	 89742418             	mov	dword ptr [rsp + 0x18], esi
 ;;   10:	 89542414             	mov	dword ptr [rsp + 0x14], edx
-;;   14:	 4c89742404           	mov	qword ptr [rsp + 4], r14
-;;   19:	 8b4c2418             	mov	ecx, dword ptr [rsp + 0x18]
-;;   1d:	 4c89f2               	mov	rdx, r14
-;;   20:	 8b5a50               	mov	ebx, dword ptr [rdx + 0x50]
-;;   23:	 39d9                 	cmp	ecx, ebx
-;;   25:	 0f8381000000         	jae	0xac
-;;   2b:	 4189cb               	mov	r11d, ecx
-;;   2e:	 4d6bdb08             	imul	r11, r11, 8
-;;   32:	 488b5248             	mov	rdx, qword ptr [rdx + 0x48]
-;;   36:	 4889d6               	mov	rsi, rdx
-;;   39:	 4c01da               	add	rdx, r11
-;;   3c:	 39d9                 	cmp	ecx, ebx
-;;   3e:	 480f43d6             	cmovae	rdx, rsi
-;;   42:	 488b02               	mov	rax, qword ptr [rdx]
-;;   45:	 4885c0               	test	rax, rax
-;;   48:	 0f8523000000         	jne	0x71
-;;   4e:	 4d8b5e38             	mov	r11, qword ptr [r14 + 0x38]
-;;   52:	 498b5b48             	mov	rbx, qword ptr [r11 + 0x48]
-;;   56:	 4156                 	push	r14
-;;   58:	 51                   	push	rcx
-;;   59:	 488b7c2408           	mov	rdi, qword ptr [rsp + 8]
-;;   5e:	 be00000000           	mov	esi, 0
-;;   63:	 8b1424               	mov	edx, dword ptr [rsp]
-;;   66:	 ffd3                 	call	rbx
-;;   68:	 4883c410             	add	rsp, 0x10
-;;   6c:	 e904000000           	jmp	0x75
-;;   71:	 4883e0fe             	and	rax, 0xfffffffffffffffe
-;;   75:	 488944240c           	mov	qword ptr [rsp + 0xc], rax
-;;   7a:	 4d8b5e38             	mov	r11, qword ptr [r14 + 0x38]
-;;   7e:	 498b4368             	mov	rax, qword ptr [r11 + 0x68]
-;;   82:	 4156                 	push	r14
-;;   84:	 4883ec08             	sub	rsp, 8
-;;   88:	 488b7c2408           	mov	rdi, qword ptr [rsp + 8]
-;;   8d:	 be01000000           	mov	esi, 1
-;;   92:	 8b54242c             	mov	edx, dword ptr [rsp + 0x2c]
-;;   96:	 488b4c241c           	mov	rcx, qword ptr [rsp + 0x1c]
-;;   9b:	 448b442424           	mov	r8d, dword ptr [rsp + 0x24]
-;;   a0:	 ffd0                 	call	rax
-;;   a2:	 4883c410             	add	rsp, 0x10
-;;   a6:	 4883c420             	add	rsp, 0x20
-;;   aa:	 5d                   	pop	rbp
-;;   ab:	 c3                   	ret	
-;;   ac:	 0f0b                 	ud2	
+;;   14:	 c744241000000000     	mov	dword ptr [rsp + 0x10], 0
+;;   1c:	 48c744240800000000   	
+;; 				mov	qword ptr [rsp + 8], 0
+;;   25:	 4c89742404           	mov	qword ptr [rsp + 4], r14
+;;   2a:	 8b4c2418             	mov	ecx, dword ptr [rsp + 0x18]
+;;   2e:	 4c89f2               	mov	rdx, r14
+;;   31:	 8b5a50               	mov	ebx, dword ptr [rdx + 0x50]
+;;   34:	 39d9                 	cmp	ecx, ebx
+;;   36:	 0f8381000000         	jae	0xbd
+;;   3c:	 4189cb               	mov	r11d, ecx
+;;   3f:	 4d6bdb08             	imul	r11, r11, 8
+;;   43:	 488b5248             	mov	rdx, qword ptr [rdx + 0x48]
+;;   47:	 4889d6               	mov	rsi, rdx
+;;   4a:	 4c01da               	add	rdx, r11
+;;   4d:	 39d9                 	cmp	ecx, ebx
+;;   4f:	 480f43d6             	cmovae	rdx, rsi
+;;   53:	 488b02               	mov	rax, qword ptr [rdx]
+;;   56:	 4885c0               	test	rax, rax
+;;   59:	 0f8523000000         	jne	0x82
+;;   5f:	 4d8b5e38             	mov	r11, qword ptr [r14 + 0x38]
+;;   63:	 498b5b48             	mov	rbx, qword ptr [r11 + 0x48]
+;;   67:	 4156                 	push	r14
+;;   69:	 51                   	push	rcx
+;;   6a:	 488b7c2408           	mov	rdi, qword ptr [rsp + 8]
+;;   6f:	 be00000000           	mov	esi, 0
+;;   74:	 8b1424               	mov	edx, dword ptr [rsp]
+;;   77:	 ffd3                 	call	rbx
+;;   79:	 4883c410             	add	rsp, 0x10
+;;   7d:	 e904000000           	jmp	0x86
+;;   82:	 4883e0fe             	and	rax, 0xfffffffffffffffe
+;;   86:	 488944240c           	mov	qword ptr [rsp + 0xc], rax
+;;   8b:	 4d8b5e38             	mov	r11, qword ptr [r14 + 0x38]
+;;   8f:	 498b4368             	mov	rax, qword ptr [r11 + 0x68]
+;;   93:	 4156                 	push	r14
+;;   95:	 4883ec08             	sub	rsp, 8
+;;   99:	 488b7c2408           	mov	rdi, qword ptr [rsp + 8]
+;;   9e:	 be01000000           	mov	esi, 1
+;;   a3:	 8b54242c             	mov	edx, dword ptr [rsp + 0x2c]
+;;   a7:	 488b4c241c           	mov	rcx, qword ptr [rsp + 0x1c]
+;;   ac:	 448b442424           	mov	r8d, dword ptr [rsp + 0x24]
+;;   b1:	 ffd0                 	call	rax
+;;   b3:	 4883c410             	add	rsp, 0x10
+;;   b7:	 4883c420             	add	rsp, 0x20
+;;   bb:	 5d                   	pop	rbp
+;;   bc:	 c3                   	ret	
+;;   bd:	 0f0b                 	ud2