Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
members = [
"components/debug",
"components/recorder"
, "crates/dialog", "crates/trace"]
, "crates/dialog", "crates/libc-alloc", "crates/trace"]
[workspace.dependencies]
wit-bindgen = { version = "0.62.0", default-features = false, features = ["bitflags", "std", "macros"] }
serde = { version = "1.0.226", features = ["derive"] }
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ all: build-components build-cli
build-cli:
cargo build --all-features --release
build-components:
cargo build -p debug --target wasm32-wasip2 --release
cargo build -p recorder --target wasm32-wasip2 --release
RUSTFLAGS="-C link-arg=--page-size=1" cargo build -p debug --target wasm32-wasip2 --release
RUSTFLAGS="-C link-arg=--page-size=1" cargo build -p recorder --target wasm32-wasip2 --release
cp target/wasm32-wasip2/release/debug.wasm assets/debug.wasm
cp target/wasm32-wasip2/release/recorder.wasm assets/recorder.wasm

Expand All @@ -25,7 +25,7 @@ test-record:
$(MAKE) run-record WASM=tests/rust.wasm
# test the same trace with a different wasm replay
target/release/proxy-component instrument -m replay tests/rust.debug.wasm
wasmtime --invoke 'start()' composed.wasm < trace.out
wasmtime -W custom-page-sizes=y --invoke 'start()' composed.wasm < trace.out
# build-only test
target/release/proxy-component instrument -m record tests/calculator.wasm
target/release/proxy-component instrument -m replay tests/calculator.wasm
Expand All @@ -40,13 +40,13 @@ test-dialog:

run-fuzz:
target/release/proxy-component instrument -m fuzz $(WASM)
wasmtime --invoke 'start()' composed.wasm
wasmtime -W custom-page-sizes=y --invoke 'start()' composed.wasm

run-record:
target/release/proxy-component instrument -m record $(WASM)
$(MAKE) run-viceroy URL=localhost:7676
target/release/proxy-component instrument -m replay $(WASM)
wasmtime --invoke 'start()' composed.wasm < trace.out
wasmtime -W custom-page-sizes=y --invoke 'start()' composed.wasm < trace.out
# test host replay
target/release/proxy-component instrument -m replay --use-host-recorder $(WASM)
target/release/proxy-component run composed.wasm --invoke 'start()' --trace trace.out
Expand All @@ -64,4 +64,4 @@ run-viceroy:
done
curl $(URL)
kill $$(cat viceroy.pid) || true
rm viceroy.pid
rm viceroy.pid
Binary file modified assets/debug.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions assets/proj_cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ path = "lib.rs"
wit-bindgen.workspace = true
wasm-wave.workspace = true
arbitrary.workspace = true
talc.workspace = true
Binary file modified assets/recorder.wasm
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions assets/workspace_cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ wit-bindgen = { version = "0.62.0", default-features = false, features = ["bitfl
wasm-wave = { git = "https://github.com/chenyan2002/wasm-tools.git", branch = "extend-wave", version = "0.239.0", default-features = false }
#wasm-wave = { path = "/Users/chenyan/src/bytecodealliance/wasm-tools/crates/wasm-wave", default-features = false }
arbitrary = "1.4.2"
talc = "5.0.3"

[profile.release]
codegen-units = 1
Expand Down
4 changes: 3 additions & 1 deletion components/debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ crate-type = ["cdylib"]

[dependencies]
wit-bindgen.workspace = true
getrandom = "0.3"
getrandom = "0.3"
talc = "5.0.3"
libc-alloc = { path = "../../crates/libc-alloc" }
11 changes: 11 additions & 0 deletions components/debug/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
extern crate libc_alloc;

#[cfg(all(not(target_feature = "atomics"), target_family = "wasm"))]
#[global_allocator]
static TALC: talc::wasm::WasmArenaTalc = {
use core::mem::MaybeUninit;
static mut MEMORY: [MaybeUninit<u8>; 0x80000] = [MaybeUninit::uninit(); 0x80000];
// SAFETY: the memory for MEMORY is never modified externally. It's the allocator's.
unsafe { talc::wasm::new_wasm_arena_allocator(&raw mut MEMORY) }
};

mod bindings {
wit_bindgen::generate!({
path: "../../assets/util.wit",
Expand Down
2 changes: 2 additions & 0 deletions components/recorder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ crate-type = ["cdylib"]
trace = { path = "../../crates/trace" }
serde_json.workspace = true
wit-bindgen.workspace = true
talc = "5.0.3"
libc-alloc = { path = "../../crates/libc-alloc" }
11 changes: 11 additions & 0 deletions components/recorder/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
extern crate libc_alloc;

#[cfg(all(not(target_feature = "atomics"), target_family = "wasm"))]
#[global_allocator]
static TALC: talc::wasm::WasmArenaTalc = {
use core::mem::MaybeUninit;
static mut MEMORY: [MaybeUninit<u8>; 0x80000] = [MaybeUninit::uninit(); 0x80000];
// SAFETY: the memory for MEMORY is never modified externally. It's the allocator's.
unsafe { talc::wasm::new_wasm_arena_allocator(&raw mut MEMORY) }
};

mod bindings {
wit_bindgen::generate!({
path: "../../assets/recorder.wit",
Expand Down
6 changes: 6 additions & 0 deletions crates/libc-alloc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "libc-alloc"
version = "0.1.0"
edition = "2024"

[dependencies]
Loading
Loading