Skip to content

Commit

Permalink
deps: update to Wasmtime@24 (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford authored Aug 20, 2024
1 parent 6a42bd7 commit d05a4ec
Show file tree
Hide file tree
Showing 24 changed files with 147 additions and 130 deletions.
165 changes: 82 additions & 83 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ log = "0.4.22"
semver = "1.0.23"
js-component-bindgen = { path = "./crates/js-component-bindgen" }
structopt = "0.3.26"
wasm-encoder = "0.212.0"
wasm-metadata = "0.212.0"
wasmparser = "0.212.0"
wasmprinter = "0.212.0"
wasmtime-environ = { version = "23.0.1", features = [
wasm-encoder = "0.215.0"
wasm-metadata = "0.215.0"
wasmparser = "0.215.0"
wasmprinter = "0.215.0"
wasmtime-environ = { version = "24.0.0", features = [
"component-model",
"compile",
] }
wat = "1.212.0"
wit-bindgen = "0.27.0"
wit-bindgen-core = "0.27.0"
wit-component = { version = "0.212.0", features = ["dummy-module"] }
wit-parser = "0.212.0"
wat = "1.215.0"
wit-bindgen = "0.30.0"
wit-bindgen-core = "0.30.0"
wit-component = { version = "0.215.0", features = ["dummy-module"] }
wit-parser = "0.215.0"
xshell = "0.2.6"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion crates/js-component-bindgen-component/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl Guest for JsComponentBindgenComponent {

let world_string = opts.world.map(|world| world.to_string());
let world = resolve
.select_world(&ids, world_string.as_deref())
.select_world(ids, world_string.as_deref())
.map_err(|e| e.to_string())?;

let opts = js_component_bindgen::TranspileOpts {
Expand Down
7 changes: 5 additions & 2 deletions crates/js-component-bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub fn transpile(component: &[u8], opts: TranspileOpts) -> Result<Transpiled, an
.context("failed to extract interface information from component")?;

let (resolve, world_id) = match decoded {
DecodedWasm::WitPackages(_, _) => bail!("unexpected wit package as input"),
DecodedWasm::WitPackage(_, _) => bail!("unexpected wit package as input"),
DecodedWasm::Component(resolve, world_id) => (resolve, world_id),
};

Expand Down Expand Up @@ -200,7 +200,10 @@ fn feature_gate_allowed(
// Stabilization (@since annotation) overrides features and deprecation
true
}
Stability::Unstable { feature } => {
Stability::Unstable {
feature,
deprecated: _,
} => {
// If a @unstable feature is present but the related feature was not enabled
// or all features was not selected, exclude
resolve.all_features || resolve.features.contains(feature)
Expand Down
6 changes: 3 additions & 3 deletions crates/wasm-tools-component/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ impl Guest for WasmToolsJs {
// let world = decode_world("component", &binary);

let doc = match &decoded {
DecodedWasm::WitPackages(_resolve, _pkg) => panic!("Unexpected wit package"),
DecodedWasm::WitPackage(_, _) => panic!("Unexpected wit package"),
DecodedWasm::Component(resolve, world) => resolve.worlds[*world].package.unwrap(),
};

let output = WitPrinter::default()
.print(decoded.resolve(), &[doc])
.print(decoded.resolve(), doc, &[])
.map_err(|e| format!("Unable to print wit\n${:?}", e))?;

Ok(output)
Expand Down Expand Up @@ -106,7 +106,7 @@ impl Guest for WasmToolsJs {
let world_string = embed_opts.world.as_ref().map(|world| world.to_string());

let world = resolve
.select_world(&ids, world_string.as_deref())
.select_world(ids, world_string.as_deref())
.map_err(|e| e.to_string())?;

let string_encoding = match &embed_opts.string_encoding {
Expand Down
Binary file modified lib/wasi_snapshot_preview1.command.wasm
Binary file not shown.
Binary file modified lib/wasi_snapshot_preview1.reactor.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 11 additions & 3 deletions packages/preview2-shim/lib/io/worker-socket-tcp.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import {
} from "./worker-sockets.js";
import { Socket, Server } from "node:net";

const winOrMac = process.platform === 'win32' || process.platform === 'darwin';

/**
* @typedef {import("../../types/interfaces/wasi-sockets-network.js").IpSocketAddress} IpSocketAddress
* @typedef {import("../../../types/interfaces/wasi-sockets-tcp.js").IpAddressFamily} IpAddressFamily
Expand All @@ -45,7 +47,7 @@ import { Socket, Server } from "node:net";
* @typedef {{
* state: number,
* future: number | null,
* socket: TcpSocket | null,
* tcpSocket: TcpSocket | null,
* listenBacklogSize: number,
* handle: TCP,
* pendingAccepts: PendingAccept[],
Expand All @@ -68,6 +70,7 @@ export function createTcpSocket() {
tcpSockets.set(++tcpSocketCnt, {
state: SOCKET_STATE_INIT,
future: null,
tcpSocket: null,
listenBacklogSize: 128,
handle,
pendingAccepts: [],
Expand Down Expand Up @@ -217,6 +220,7 @@ export function socketTcpAccept(id) {
tcpSockets.set(++tcpSocketCnt, {
state: SOCKET_STATE_CONNECTION,
future: null,
tcpSocket: accept.tcpSocket,
listenBacklogSize: 128,
handle: accept.tcpSocket._handle,
pendingAccepts: [],
Expand Down Expand Up @@ -265,8 +269,12 @@ export function socketTcpShutdown(id, shutdownType) {
const socket = tcpSockets.get(id);
if (socket.state !== SOCKET_STATE_CONNECTION) throw "invalid-state";
// Node.js only supports a write shutdown, which is triggered on end
if (shutdownType === "send" || shutdownType === "both")
socket.tcpSocket.end();
if (shutdownType === "send" || shutdownType === "both") {
if (winOrMac && socket.tcpSocket.destroySoon)
socket.tcpSocket.destroySoon();
else
socket.tcpSocket.destroy();
}
}

export function socketTcpSetKeepAlive(id, { keepAlive, keepAliveIdleTime }) {
Expand Down
2 changes: 1 addition & 1 deletion packages/preview2-shim/lib/io/worker-thread.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ function handle(call, id, payload) {
Math.min(stream.stream.readableLength, Number(payload))
);
if (res) return res;
if (stream.stream.readableEnded) return { tag: "closed" };
if (stream.stream.readableEnded) throw { tag: "closed" };
return new Uint8Array();
}
case INPUT_STREAM_BLOCKING_READ: {
Expand Down
4 changes: 0 additions & 4 deletions packages/preview2-shim/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,6 @@ suite("Node.js Preview2", () => {
}

tcpSocket.shutdown("both");
deepStrictEqual(
tcpSocket.remoteAddress().val.address,
googleIp.split(".").map((n) => Number(n))
);
}));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ export namespace WasiCliEnvironment {
* in the component model, this import function should return the same
* values each time it is called.
*/
export function getEnvironment(): [string, string][];
export function getEnvironment(): Array<[string, string]>;
/**
* Get the POSIX-style arguments to the program.
*/
export function getArguments(): string[];
export function getArguments(): Array<string>;
/**
* Return a path that programs should use as their initial current working
* directory, interpreting `.` as shorthand for this.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export namespace WasiFilesystemPreopens {
/**
* Return the set of preopened directories, and their path.
*/
export function getDirectories(): [Descriptor, string][];
export function getDirectories(): Array<[Descriptor, string]>;
}
import type { Descriptor } from './wasi-filesystem-types.js';
export { Descriptor };
8 changes: 4 additions & 4 deletions packages/preview2-shim/types/interfaces/wasi-http-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,14 @@ export class Fields {
* An error result will be returned if any header or value was
* syntactically invalid, or if a header was forbidden.
*/
static fromList(entries: [FieldKey, FieldValue][]): Fields;
static fromList(entries: Array<[FieldKey, FieldValue]>): Fields;
/**
* Get all of the values corresponding to a key. If the key is not present
* in this `fields`, an empty list is returned. However, if the key is
* present but empty, this is represented by a list with one or more
* empty field-values present.
*/
get(name: FieldKey): FieldValue[];
get(name: FieldKey): Array<FieldValue>;
/**
* Returns `true` when the key is present in this `fields`. If the key is
* syntactically invalid, `false` is returned.
Expand All @@ -343,7 +343,7 @@ export class Fields {
*
* Fails with `header-error.immutable` if the `fields` are immutable.
*/
set(name: FieldKey, value: FieldValue[]): void;
set(name: FieldKey, value: Array<FieldValue>): void;
/**
* Delete all values for a key. Does nothing if no values for the key
* exist.
Expand All @@ -366,7 +366,7 @@ export class Fields {
* which have multiple values are represented by multiple entries in this
* list with the same key.
*/
entries(): [FieldKey, FieldValue][];
entries(): Array<[FieldKey, FieldValue]>;
/**
* Make a deep copy of the Fields. Equivelant in behavior to calling the
* `fields` constructor on the return value of `entries`. The resulting
Expand Down
2 changes: 1 addition & 1 deletion packages/preview2-shim/types/interfaces/wasi-io-poll.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export namespace WasiIoPoll {
* the pollables has an error, it is indicated by marking the source as
* being reaedy for I/O.
*/
export function poll(in_: Pollable[]): Uint32Array;
export function poll(in_: Array<Pollable>): Uint32Array;
}

export class Pollable {
Expand Down
4 changes: 2 additions & 2 deletions packages/preview2-shim/types/interfaces/wasi-sockets-udp.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class IncomingDatagramStream {
* - <https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms741687(v=vs.85)>
* - <https://man.freebsd.org/cgi/man.cgi?query=recv&sektion=2>
*/
receive(maxResults: bigint): IncomingDatagram[];
receive(maxResults: bigint): Array<IncomingDatagram>;
/**
* Create a `pollable` which will resolve once the stream is ready to receive again.
*
Expand Down Expand Up @@ -139,7 +139,7 @@ export class OutgoingDatagramStream {
* - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasendmsg>
* - <https://man.freebsd.org/cgi/man.cgi?query=send&sektion=2>
*/
send(datagrams: OutgoingDatagram[]): bigint;
send(datagrams: Array<OutgoingDatagram>): bigint;
/**
* Create a `pollable` which will resolve once the stream is ready to send again.
*
Expand Down
2 changes: 1 addition & 1 deletion submodules/WASI-Virt
2 changes: 1 addition & 1 deletion submodules/wasm-tools
Submodule wasm-tools updated 1132 files
2 changes: 1 addition & 1 deletion submodules/wasmtime
Submodule wasmtime updated 1035 files
4 changes: 2 additions & 2 deletions test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export async function apiTest(fixtures) {
[
"processed-by",
[
["wit-component", "0.212.0"],
["wit-component", "0.215.0"],
["dummy-gen", "test"],
],
],
Expand Down Expand Up @@ -195,7 +195,7 @@ export async function apiTest(fixtures) {
[
"processed-by",
[
["wit-component", "0.212.0"],
["wit-component", "0.215.0"],
["dummy-gen", "test"],
],
],
Expand Down
2 changes: 1 addition & 1 deletion test/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ export async function cliTest(fixtures) {
[
"processed-by",
[
["wit-component", "0.212.0"],
["wit-component", "0.215.0"],
["dummy-gen", "test"],
],
],
Expand Down
17 changes: 14 additions & 3 deletions xtask/src/generate/preview2_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ const TRACE: bool = false;
const DENO: bool = true;
const TEST_FILTER: &[&str] = &[];

const TEST_IGNORE: &[&str] = &["preview2_file_read_write"];
const TEST_IGNORE: &[&str] = &[
// Wasmtime run supports a `wasmtime run --argv0=...` argument to customize the argv0
// which this test assumes is being used. We don't support this feature.
"cli_argv0",
];

// we don't currently support these subsystems, but if someone wants to work on them we
// can add these anytime!
const KEYWORD_IGNORE: &[&str] = &["nn_", "keyvalue", "runtime_config"];

const DENO_IGNORE: &[&str] = &[
"api_read_only",
Expand Down Expand Up @@ -51,6 +59,7 @@ const DENO_IGNORE: &[&str] = &[
"preview2_tcp_sample_application",
"preview2_tcp_sockopts",
"preview2_tcp_states",
"preview2_tcp_streams",
"preview2_udp_bind",
"preview2_udp_connect",
"preview2_udp_sample_application",
Expand Down Expand Up @@ -94,8 +103,10 @@ pub fn run() -> anyhow::Result<()> {
}
let file_name = String::from(entry.file_name().to_str().unwrap());
let test_name = String::from(&file_name[0..file_name.len() - 5]);
// ignore wasi-nn tests for now
if test_name.starts_with("nn_") {
if KEYWORD_IGNORE
.iter()
.any(|keyword_ignore| test_name.contains(keyword_ignore))
{
continue;
}
if TEST_IGNORE.contains(&test_name.as_ref()) {
Expand Down
2 changes: 1 addition & 1 deletion xtask/src/generate/wasi_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub(crate) fn run() -> Result<()> {
.unwrap()
.1;

let world = resolve.select_world(&[preview2], Some(world_name))?;
let world = resolve.select_world(preview2, Some(world_name))?;

let opts = js_component_bindgen::TranspileOpts {
name: "component".to_string(),
Expand Down

0 comments on commit d05a4ec

Please sign in to comment.