diff --git a/Cargo.lock b/Cargo.lock index a4c08b0e..d2f5114f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -407,7 +407,7 @@ dependencies = [ "itertools", "log", "smallvec", - "wasmparser 0.209.1", + "wasmparser", "wasmtime-types", ] @@ -1436,30 +1436,6 @@ dependencies = [ "thiserror-impl-no-std", ] -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser 0.207.0", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - [[package]] name = "tokio" version = "1.34.0" @@ -1590,19 +1566,6 @@ version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown 0.14.5", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin 0.9.8", - "tinywasm", -] - [[package]] name = "wasm-encoder" version = "0.209.1" @@ -1612,19 +1575,6 @@ dependencies = [ "leb128", ] -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags 2.6.0", - "hashbrown 0.14.5", - "indexmap", - "semver", -] - [[package]] name = "wasmparser" version = "0.209.1" @@ -1646,7 +1596,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ceca8ae6eaa8c7c87b33c25c53bdf299f8c2a764aee1179402ff7652ef3a6859" dependencies = [ "anyhow", - "wasmparser 0.209.1", + "wasmparser", ] [[package]] @@ -1679,7 +1629,7 @@ dependencies = [ "smallvec", "sptr", "target-lexicon", - "wasmparser 0.209.1", + "wasmparser", "wasmtime-asm-macros", "wasmtime-component-macro", "wasmtime-component-util", @@ -1741,7 +1691,7 @@ dependencies = [ "object 0.36.5", "target-lexicon", "thiserror", - "wasmparser 0.209.1", + "wasmparser", "wasmtime-environ", "wasmtime-versioned-export-macros", ] @@ -1763,7 +1713,7 @@ dependencies = [ "serde_derive", "target-lexicon", "wasm-encoder", - "wasmparser 0.209.1", + "wasmparser", "wasmprinter", "wasmtime-component-util", "wasmtime-types", @@ -1797,7 +1747,7 @@ dependencies = [ "serde", "serde_derive", "smallvec", - "wasmparser 0.209.1", + "wasmparser", ] [[package]] @@ -1822,7 +1772,7 @@ dependencies = [ "gimli 0.28.1", "object 0.36.5", "target-lexicon", - "wasmparser 0.209.1", + "wasmparser", "wasmtime-cranelift", "wasmtime-environ", "winch-codegen", @@ -1897,7 +1847,7 @@ dependencies = [ "regalloc2", "smallvec", "target-lexicon", - "wasmparser 0.209.1", + "wasmparser", "wasmtime-cranelift", "wasmtime-environ", ] @@ -2049,7 +1999,7 @@ dependencies = [ "serde_derive", "serde_json", "unicode-xid", - "wasmparser 0.209.1", + "wasmparser", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 6a75463e..1eab97ba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,6 @@ members = [ "ms_hostcall", "ms_std_proc_macro", "ms_std", - "wasi_api", "wasmtime_wasi_api", ] diff --git a/common_service/ruxfdtab/src/as_apis.rs b/common_service/ruxfdtab/src/as_apis.rs index 025e739a..7e9cdac8 100644 --- a/common_service/ruxfdtab/src/as_apis.rs +++ b/common_service/ruxfdtab/src/as_apis.rs @@ -1,4 +1,3 @@ - extern crate alloc; use std::path::PathBuf; @@ -13,7 +12,7 @@ use crate::{ }; use ms_hostcall::{ fdtab::{FdtabError, FdtabResult}, - types::{Fd, OpenFlags, OpenMode, Size, Stat, TimeSpec, DirEntry}, + types::{DirEntry, Fd, OpenFlags, OpenMode, Size, Stat, TimeSpec}, }; use ruxdriver::init_drivers; use ruxfdtable::{FileLike, RuxStat}; @@ -45,7 +44,7 @@ fn convert(ruxstat: RuxStat) -> Stat { tv_nsec: ruxstat.st_ctime.tv_nsec, }, __unused: ruxstat.__unused, - } + }; } fn get_fs_image_path() -> PathBuf { @@ -163,7 +162,7 @@ pub fn stat(fd: Fd) -> FdtabResult { let res = convert(stat); // #[cfg(feature = "log")] // println!("[DEBUG] stat fd: {:?}, stat: {:?}", fd, res); - + Ok(res) } @@ -181,7 +180,7 @@ pub fn readdir(path: &str) -> FdtabResult> { let entry = DirEntry { dir_path: item.path(), entry_name: item.file_name(), - entry_type: item.file_type() as u32 + entry_type: item.file_type() as u32, }; entries.push(entry); } diff --git a/common_service/signal/Cargo.toml b/common_service/signal/Cargo.toml index b2e6a64e..241f8280 100644 --- a/common_service/signal/Cargo.toml +++ b/common_service/signal/Cargo.toml @@ -10,8 +10,8 @@ crate-type = ["dylib"] [dependencies] nc = { version = "0.9.5", default-features = false } ms_std = { path = "../../ms_std", features = [] } -ms_hostcall = { path = "../../ms_hostcall", features = ["signal"]} +ms_hostcall = { path = "../../ms_hostcall", features = ["signal"] } [features] mpk = ["ms_std/mpk"] -default = [] \ No newline at end of file +default = [] diff --git a/common_service/socket/src/apis.rs b/common_service/socket/src/apis.rs index 94bd6fd6..1c00fc09 100644 --- a/common_service/socket/src/apis.rs +++ b/common_service/socket/src/apis.rs @@ -28,7 +28,7 @@ pub fn addrinfo(name: &str) -> SmoltcpResult { let mut iface = acquire_iface()?; let (dns_handle, query) = { - let servers = &[Ipv4Address::new(8, 8, 8, 8).into()]; + let servers = &[Ipv4Address::new(114, 114, 114, 114).into()]; let dns_socket = dns::Socket::new(servers, vec![]); let mut sockets = acquire_sockets()?; diff --git a/isol_config/tinywasm.json b/isol_config/tinywasm.json deleted file mode 100644 index 0c075bf3..00000000 --- a/isol_config/tinywasm.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "services": [ - [ - "fdtab", - "libfdtab.so" - ], - [ - "stdio", - "libstdio.so" - ] - ], - "apps": [ - [ - "tinywasm", - "libtinywasm_u.so" - ] - ], - "groups": [ - { - "list": [ - "tinywasm" - ], - "args": {} - } - ] -} \ No newline at end of file diff --git a/isol_config/tinywasm_c_printf.json b/isol_config/tinywasm_c_printf.json deleted file mode 100644 index bbb3fdf0..00000000 --- a/isol_config/tinywasm_c_printf.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "services": [ - [ - "fdtab", - "libfdtab.so" - ], - [ - "stdio", - "libstdio.so" - ] - ], - "apps": [ - [ - "tinywasm", - "libtinywasm_c_printf.so" - ] - ], - "groups": [ - { - "list": [ - "tinywasm" - ], - "args": {} - } - ] -} \ No newline at end of file diff --git a/isol_config/tinywasm_pass_args.json b/isol_config/tinywasm_pass_args.json deleted file mode 100644 index 7ff11d54..00000000 --- a/isol_config/tinywasm_pass_args.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "services": [ - [ - "fdtab", - "libfdtab.so" - ], - [ - "stdio", - "libstdio.so" - ], - [ - "mm", - "libmm.so" - ], - [ - "time", - "libtime.so" - ] - ], - "apps": [ - [ - "func_a", - "libtinywasm_pass_str.so" - ], - [ - "func_b", - "libtinywasm_recv_str.so" - ] - ] -} \ No newline at end of file diff --git a/isol_config/tinywasm_py.json b/isol_config/tinywasm_py.json deleted file mode 100755 index 40fd518e..00000000 --- a/isol_config/tinywasm_py.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "services": [ - [ - "fdtab", - "libfdtab.so" - ], - [ - "time", - "libtime.so" - ], - [ - "stdio", - "libstdio.so" - ] - ], - "apps": [ - [ - "tinywasm", - "libtinywasm_py.so" - ] - ], - "groups": [ - { - "list": [ - "tinywasm" - ], - "args": {} - } - ] -} diff --git a/isol_config/tinywasm_write.json b/isol_config/tinywasm_write.json deleted file mode 100644 index 80742009..00000000 --- a/isol_config/tinywasm_write.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "services": [ - [ - "fdtab", - "libfdtab.so" - ], - [ - "stdio", - "libstdio.so" - ] - ], - "apps": [ - [ - "tinywasm", - "libtinywasm_write.so" - ] - ], - "groups": [ - { - "list": [ - "tinywasm" - ], - "args": {} - } - ] -} \ No newline at end of file diff --git a/isol_config/wasmtime_cpython.json b/isol_config/wasmtime_cpython.json index 97ff06ef..ea290790 100755 --- a/isol_config/wasmtime_cpython.json +++ b/isol_config/wasmtime_cpython.json @@ -30,7 +30,7 @@ "cpython" ], "args": { - "pyfile_path": "/wasm_bench/alu.py" + "pyfile_path": "/wasm_bench/time.py" } } ] diff --git a/isol_config/tinywasm_cpython.json b/isol_config/wasmtime_cpython_alu.json similarity index 63% rename from isol_config/tinywasm_cpython.json rename to isol_config/wasmtime_cpython_alu.json index 6197177a..97ff06ef 100755 --- a/isol_config/tinywasm_cpython.json +++ b/isol_config/wasmtime_cpython_alu.json @@ -19,16 +19,19 @@ ], "apps": [ [ - "tinywasm", - "libtinywasm_cpython.so" + "cpython", + "libwasmtime_cpython.so" ] ], + "fs_image": "fs_images/fatfs.img", "groups": [ { "list": [ - "tinywasm" + "cpython" ], - "args": {} + "args": { + "pyfile_path": "/wasm_bench/alu.py" + } } ] } diff --git a/isol_config/wasmtime_cpython_functionchain.json b/isol_config/wasmtime_cpython_functionchain.json new file mode 100755 index 00000000..c8b56d4f --- /dev/null +++ b/isol_config/wasmtime_cpython_functionchain.json @@ -0,0 +1,132 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "mm", + "libmm.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "func", + "libwasmtime_cpython_func.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/wasmtime_func.py", + "func_num": "0" + } + }, + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/wasmtime_func.py", + "func_num": "1" + } + }, + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/wasmtime_func.py", + "func_num": "2" + } + }, + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/wasmtime_func.py", + "func_num": "3" + } + }, + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/wasmtime_func.py", + "func_num": "4" + } + }, + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/wasmtime_func.py", + "func_num": "5" + } + }, + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/wasmtime_func.py", + "func_num": "6" + } + }, + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/wasmtime_func.py", + "func_num": "7" + } + }, + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/wasmtime_func.py", + "func_num": "8" + } + }, + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/wasmtime_func.py", + "func_num": "9" + } + }, + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/wasmtime_func.py", + "func_num": "10" + } + } + ] +} diff --git a/isol_config/tinywasm_pass_args_cpython.json b/isol_config/wasmtime_cpython_functionchain_inner.json old mode 100644 new mode 100755 similarity index 59% rename from isol_config/tinywasm_pass_args_cpython.json rename to isol_config/wasmtime_cpython_functionchain_inner.json index 09e7e3bb..e0ab7eeb --- a/isol_config/tinywasm_pass_args_cpython.json +++ b/isol_config/wasmtime_cpython_functionchain_inner.json @@ -5,16 +5,16 @@ "libruxfdtab.so" ], [ - "stdio", - "libstdio.so" + "time", + "libtime.so" ], [ "mm", "libmm.so" ], [ - "time", - "libtime.so" + "stdio", + "libstdio.so" ], [ "fatfs", @@ -23,26 +23,20 @@ ], "apps": [ [ - "func_a", - "libtinywasm_pass_str_cpython.so" - ], - [ - "func_b", - "libtinywasm_recv_str_cpython.so" + "func", + "libwasmtime_cpython_func.so" ] ], + "fs_image": "fs_images/fatfs.img", "groups": [ { "list": [ - "func_a" - ], - "args": {} - }, - { - "list": [ - "func_b" + "func" ], - "args": {} + "args": { + "pyfile_path": "/wasm_bench/functionchain.py", + "func_num": "10" + } } ] -} \ No newline at end of file +} diff --git a/isol_config/read_wrie.json b/isol_config/wasmtime_cpython_functionchain_n10.json old mode 100644 new mode 100755 similarity index 51% rename from isol_config/read_wrie.json rename to isol_config/wasmtime_cpython_functionchain_n10.json index e170c3b0..e0ab7eeb --- a/isol_config/read_wrie.json +++ b/isol_config/wasmtime_cpython_functionchain_n10.json @@ -2,19 +2,19 @@ "services": [ [ "fdtab", - "libfdtab.so" + "libruxfdtab.so" ], [ - "stdio", - "libstdio.so" + "time", + "libtime.so" ], [ "mm", "libmm.so" ], [ - "time", - "libtime.so" + "stdio", + "libstdio.so" ], [ "fatfs", @@ -23,23 +23,20 @@ ], "apps": [ [ - "file_reader", - "libfile_reader.so" + "func", + "libwasmtime_cpython_func.so" ] ], - "fs_image": "fs_images/new_image.img", + "fs_image": "fs_images/fatfs.img", "groups": [ { "list": [ - { - "name": "file_reader", - "args": { - "slot_name": "input-part-0", - "input_file": "fake_data_0.txt" - } - } + "func" ], - "args": {} + "args": { + "pyfile_path": "/wasm_bench/functionchain.py", + "func_num": "10" + } } ] -} \ No newline at end of file +} diff --git a/isol_config/wasmtime_cpython_functionchain_n15.json b/isol_config/wasmtime_cpython_functionchain_n15.json new file mode 100755 index 00000000..3c230781 --- /dev/null +++ b/isol_config/wasmtime_cpython_functionchain_n15.json @@ -0,0 +1,42 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "mm", + "libmm.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "func", + "libwasmtime_cpython_func.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/functionchain.py", + "func_num": "15" + } + } + ] +} diff --git a/isol_config/wasmtime_cpython_functionchain_n5.json b/isol_config/wasmtime_cpython_functionchain_n5.json new file mode 100755 index 00000000..e77bc68d --- /dev/null +++ b/isol_config/wasmtime_cpython_functionchain_n5.json @@ -0,0 +1,42 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "mm", + "libmm.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "func", + "libwasmtime_cpython_func.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/functionchain.py", + "func_num": "5" + } + } + ] +} diff --git a/isol_config/tinywasm_parallel_sort.json b/isol_config/wasmtime_cpython_parallel_sort.json old mode 100644 new mode 100755 similarity index 58% rename from isol_config/tinywasm_parallel_sort.json rename to isol_config/wasmtime_cpython_parallel_sort.json index 7c79939a..b7df50ee --- a/isol_config/tinywasm_parallel_sort.json +++ b/isol_config/wasmtime_cpython_parallel_sort.json @@ -5,13 +5,17 @@ "libruxfdtab.so" ], [ - "stdio", - "libstdio.so" + "time", + "libtime.so" ], [ "mm", "libmm.so" ], + [ + "stdio", + "libstdio.so" + ], [ "fatfs", "libfatfs.so" @@ -19,64 +23,57 @@ ], "apps": [ [ - "sorter", - "libtinywasm_sorter.so" - ], - [ - "spliter", - "libtinywasm_spliter.so" - ], - [ - "merger", - "libtinywasm_merger.so" - ], - [ - "checker", - "libtinywasm_checker.so" + "func", + "libwasmtime_cpython_parallel_sort.so" ] ], + "fs_image": "fs_images/fatfs.img", "groups": [ { "list": [ - "sorter", - "sorter" + "func", + "func" ], "args": { + "pyfile_path": "/wasm_bench/wasmtime_sorter.py", "sorter_num": "2", "merger_num": "5" } }, { "list": [ - "spliter", - "spliter" + "func", + "func" ], "args": { + "pyfile_path": "/wasm_bench/wasmtime_spliter.py", "sorter_num": "2", "merger_num": "5" } }, { "list": [ - "merger", - "merger", - "merger", - "merger", - "merger" + "func", + "func", + "func", + "func", + "func" ], "args": { + "pyfile_path": "/wasm_bench/wasmtime_merger.py", "sorter_num": "2", "merger_num": "5" } }, { "list": [ - "checker" + "func" ], "args": { + "pyfile_path": "/wasm_bench/wasmtime_checker.py", "sorter_num": "2", "merger_num": "5" } } ] -} \ No newline at end of file +} diff --git a/isol_config/wasmtime_cpython_parallel_sort_c1.json b/isol_config/wasmtime_cpython_parallel_sort_c1.json new file mode 100755 index 00000000..79bb3165 --- /dev/null +++ b/isol_config/wasmtime_cpython_parallel_sort_c1.json @@ -0,0 +1,43 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "mm", + "libmm.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "func", + "libwasmtime_cpython_parallel_sort.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/parallel_sort.py", + "sorter_num": "1", + "merger_num": "1" + } + } + ] +} diff --git a/isol_config/wasmtime_cpython_parallel_sort_c3.json b/isol_config/wasmtime_cpython_parallel_sort_c3.json new file mode 100755 index 00000000..2f79d983 --- /dev/null +++ b/isol_config/wasmtime_cpython_parallel_sort_c3.json @@ -0,0 +1,45 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "mm", + "libmm.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "func", + "libwasmtime_cpython_parallel_sort.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "func", + "func", + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/parallel_sort.py", + "sorter_num": "3", + "merger_num": "3" + } + } + ] +} diff --git a/isol_config/wasmtime_cpython_parallel_sort_c5.json b/isol_config/wasmtime_cpython_parallel_sort_c5.json new file mode 100755 index 00000000..84877b4a --- /dev/null +++ b/isol_config/wasmtime_cpython_parallel_sort_c5.json @@ -0,0 +1,47 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "mm", + "libmm.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "func", + "libwasmtime_cpython_parallel_sort.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "func", + "func", + "func", + "func", + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/parallel_sort.py", + "sorter_num": "5", + "merger_num": "5" + } + } + ] +} diff --git a/isol_config/wasmtime_cpython_parallel_sort_inner.json b/isol_config/wasmtime_cpython_parallel_sort_inner.json new file mode 100755 index 00000000..2f79d983 --- /dev/null +++ b/isol_config/wasmtime_cpython_parallel_sort_inner.json @@ -0,0 +1,45 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "mm", + "libmm.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "func", + "libwasmtime_cpython_parallel_sort.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "func", + "func", + "func" + ], + "args": { + "pyfile_path": "/wasm_bench/parallel_sort.py", + "sorter_num": "3", + "merger_num": "3" + } + } + ] +} diff --git a/isol_config/wasmtime_cpython_pass_args.json b/isol_config/wasmtime_cpython_pass_args.json new file mode 100755 index 00000000..ee09ea76 --- /dev/null +++ b/isol_config/wasmtime_cpython_pass_args.json @@ -0,0 +1,49 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "mm", + "libmm.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "cpython", + "libwasmtime_cpython.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "cpython" + ], + "args": { + "pyfile_path": "/wasm_bench/pass_str.py" + } + }, + { + "list": [ + "cpython" + ], + "args": { + "pyfile_path": "/wasm_bench/recv_str.py" + } + } + ] +} diff --git a/isol_config/wasmtime_cpython_pass_args_inner.json b/isol_config/wasmtime_cpython_pass_args_inner.json new file mode 100755 index 00000000..be064f38 --- /dev/null +++ b/isol_config/wasmtime_cpython_pass_args_inner.json @@ -0,0 +1,41 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "mm", + "libmm.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "cpython", + "libwasmtime_cpython.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "cpython" + ], + "args": { + "pyfile_path": "/wasm_bench/pass_inner.py" + } + } + ] +} diff --git a/isol_config/wasmtime_cpython_time.json b/isol_config/wasmtime_cpython_time.json new file mode 100755 index 00000000..ea290790 --- /dev/null +++ b/isol_config/wasmtime_cpython_time.json @@ -0,0 +1,37 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "cpython", + "libwasmtime_cpython.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "cpython" + ], + "args": { + "pyfile_path": "/wasm_bench/time.py" + } + } + ] +} diff --git a/isol_config/tinywasm_wordcount.json b/isol_config/wasmtime_cpython_wordcount.json old mode 100644 new mode 100755 similarity index 64% rename from isol_config/tinywasm_wordcount.json rename to isol_config/wasmtime_cpython_wordcount.json index 324aa05f..f540b9ae --- a/isol_config/tinywasm_wordcount.json +++ b/isol_config/wasmtime_cpython_wordcount.json @@ -5,13 +5,17 @@ "libruxfdtab.so" ], [ - "stdio", - "libstdio.so" + "time", + "libtime.so" ], [ "mm", "libmm.so" ], + [ + "stdio", + "libstdio.so" + ], [ "fatfs", "libfatfs.so" @@ -20,14 +24,14 @@ "apps": [ [ "mapper", - "libtinywasm_mapper.so" + "libwasmtime_cpython_mapper.so" ], [ "reducer", - "libtinywasm_reducer.so" + "libwasmtime_cpython_reducer.so" ] ], - "fs_image": "fs_images/fatfs_wasm.img", + "fs_image": "fs_images/fatfs.img", "groups": [ { "list": [ @@ -36,25 +40,20 @@ "mapper" ], "args": { - "reducer_num": "10" + "pyfile_path": "/wasm_bench/wasmtime_mapper.py", + "reducer_num": "3" } }, { "list": [ - "reducer", - "reducer", - "reducer", - "reducer", - "reducer", - "reducer", - "reducer", "reducer", "reducer", "reducer" ], "args": { + "pyfile_path": "/wasm_bench/wasmtime_reducer.py", "mapper_num": "3" } } ] -} \ No newline at end of file +} diff --git a/isol_config/wasmtime_cpython_wordcount_c1.json b/isol_config/wasmtime_cpython_wordcount_c1.json new file mode 100755 index 00000000..a1e30c44 --- /dev/null +++ b/isol_config/wasmtime_cpython_wordcount_c1.json @@ -0,0 +1,43 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "mm", + "libmm.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "wordcount", + "libwasmtime_cpython_wordcount.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "wordcount" + ], + "args": { + "pyfile_path": "/wasm_bench/wordcount.py", + "reducer_num": "1", + "mapper_num": "1" + } + } + ] +} diff --git a/isol_config/wasmtime_cpython_wordcount_c3.json b/isol_config/wasmtime_cpython_wordcount_c3.json new file mode 100755 index 00000000..0586f1d1 --- /dev/null +++ b/isol_config/wasmtime_cpython_wordcount_c3.json @@ -0,0 +1,45 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "mm", + "libmm.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "wordcount", + "libwasmtime_cpython_wordcount.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "wordcount", + "wordcount", + "wordcount" + ], + "args": { + "pyfile_path": "/wasm_bench/wordcount.py", + "reducer_num": "3", + "mapper_num": "3" + } + } + ] +} diff --git a/isol_config/wasmtime_cpython_wordcount_c5.json b/isol_config/wasmtime_cpython_wordcount_c5.json new file mode 100755 index 00000000..49b73156 --- /dev/null +++ b/isol_config/wasmtime_cpython_wordcount_c5.json @@ -0,0 +1,47 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "mm", + "libmm.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "wordcount", + "libwasmtime_cpython_wordcount.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "wordcount", + "wordcount", + "wordcount", + "wordcount", + "wordcount" + ], + "args": { + "pyfile_path": "/wasm_bench/wordcount.py", + "reducer_num": "5", + "mapper_num": "5" + } + } + ] +} diff --git a/isol_config/wasmtime_cpython_wordcount_inner.json b/isol_config/wasmtime_cpython_wordcount_inner.json new file mode 100755 index 00000000..0586f1d1 --- /dev/null +++ b/isol_config/wasmtime_cpython_wordcount_inner.json @@ -0,0 +1,45 @@ +{ + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "time", + "libtime.so" + ], + [ + "mm", + "libmm.so" + ], + [ + "stdio", + "libstdio.so" + ], + [ + "fatfs", + "libfatfs.so" + ] + ], + "apps": [ + [ + "wordcount", + "libwasmtime_cpython_wordcount.so" + ] + ], + "fs_image": "fs_images/fatfs.img", + "groups": [ + { + "list": [ + "wordcount", + "wordcount", + "wordcount" + ], + "args": { + "pyfile_path": "/wasm_bench/wordcount.py", + "reducer_num": "3", + "mapper_num": "3" + } + } + ] +} diff --git a/isol_config/wasmtime_longchain_n10.json b/isol_config/wasmtime_longchain_n10.json deleted file mode 100644 index dc97a18c..00000000 --- a/isol_config/wasmtime_longchain_n10.json +++ /dev/null @@ -1,148 +0,0 @@ -{ - "services": [ - [ - "fdtab", - "libruxfdtab.so" - ], - [ - "stdio", - "libstdio.so" - ], - [ - "mm", - "libmm.so" - ], - [ - "time", - "libtime.so" - ], - [ - "fatfs", - "libfatfs.so" - ] - ], - "apps": [ - [ - "func1", - "libwasmtime_func.so" - ], - [ - "func2", - "libwasmtime_func.so" - ], - [ - "func3", - "libwasmtime_func.so" - ], - [ - "func4", - "libwasmtime_func.so" - ], - [ - "func5", - "libwasmtime_func.so" - ], - [ - "func6", - "libwasmtime_func.so" - ], - [ - "func7", - "libwasmtime_func.so" - ], - [ - "func8", - "libwasmtime_func.so" - ], - [ - "func9", - "libwasmtime_func.so" - ], - [ - "func10", - "libwasmtime_func.so" - ] - ], - "groups": [ - { - "list": [ - "func1" - ], - "args": { - "func_num": "0" - } - }, - { - "list": [ - "func2" - ], - "args": { - "func_num": "1" - } - }, - { - "list": [ - "func3" - ], - "args": { - "func_num": "2" - } - }, - { - "list": [ - "func4" - ], - "args": { - "func_num": "3" - } - }, - { - "list": [ - "func5" - ], - "args": { - "func_num": "4" - } - }, - { - "list": [ - "func6" - ], - "args": { - "func_num": "5" - } - }, - { - "list": [ - "func7" - ], - "args": { - "func_num": "6" - } - }, - { - "list": [ - "func8" - ], - "args": { - "func_num": "7" - } - }, - { - "list": [ - "func9" - ], - "args": { - "func_num": "8" - } - }, - { - "list": [ - "func10" - ], - "args": { - "func_num": "9" - } - } - ] - } \ No newline at end of file diff --git a/isol_config/wasmtime_longchain_n15.json b/isol_config/wasmtime_longchain_n15.json deleted file mode 100644 index 7b3b67c5..00000000 --- a/isol_config/wasmtime_longchain_n15.json +++ /dev/null @@ -1,208 +0,0 @@ -{ - "services": [ - [ - "fdtab", - "libruxfdtab.so" - ], - [ - "stdio", - "libstdio.so" - ], - [ - "mm", - "libmm.so" - ], - [ - "time", - "libtime.so" - ], - [ - "fatfs", - "libfatfs.so" - ] - ], - "apps": [ - [ - "func1", - "libwasmtime_func.so" - ], - [ - "func2", - "libwasmtime_func.so" - ], - [ - "func3", - "libwasmtime_func.so" - ], - [ - "func4", - "libwasmtime_func.so" - ], - [ - "func5", - "libwasmtime_func.so" - ], - [ - "func6", - "libwasmtime_func.so" - ], - [ - "func7", - "libwasmtime_func.so" - ], - [ - "func8", - "libwasmtime_func.so" - ], - [ - "func9", - "libwasmtime_func.so" - ], - [ - "func10", - "libwasmtime_func.so" - ], - [ - "func11", - "libwasmtime_func.so" - ], - [ - "func12", - "libwasmtime_func.so" - ], - [ - "func13", - "libwasmtime_func.so" - ], - [ - "func14", - "libwasmtime_func.so" - ], - [ - "func15", - "libwasmtime_func.so" - ] - ], - "groups": [ - { - "list": [ - "func1" - ], - "args": { - "func_num": "0" - } - }, - { - "list": [ - "func2" - ], - "args": { - "func_num": "1" - } - }, - { - "list": [ - "func3" - ], - "args": { - "func_num": "2" - } - }, - { - "list": [ - "func4" - ], - "args": { - "func_num": "3" - } - }, - { - "list": [ - "func5" - ], - "args": { - "func_num": "4" - } - }, - { - "list": [ - "func6" - ], - "args": { - "func_num": "5" - } - }, - { - "list": [ - "func7" - ], - "args": { - "func_num": "6" - } - }, - { - "list": [ - "func8" - ], - "args": { - "func_num": "7" - } - }, - { - "list": [ - "func9" - ], - "args": { - "func_num": "8" - } - }, - { - "list": [ - "func10" - ], - "args": { - "func_num": "9" - } - }, - { - "list": [ - "func11" - ], - "args": { - "func_num": "10" - } - }, - { - "list": [ - "func12" - ], - "args": { - "func_num": "11" - } - }, - { - "list": [ - "func13" - ], - "args": { - "func_num": "12" - } - }, - { - "list": [ - "func14" - ], - "args": { - "func_num": "13" - } - }, - { - "list": [ - "func15" - ], - "args": { - "func_num": "14" - } - } - ] - } \ No newline at end of file diff --git a/isol_config/wasmtime_longchain_n5.json b/isol_config/wasmtime_longchain_n5.json deleted file mode 100644 index ab0362c8..00000000 --- a/isol_config/wasmtime_longchain_n5.json +++ /dev/null @@ -1,88 +0,0 @@ -{ - "services": [ - [ - "fdtab", - "libruxfdtab.so" - ], - [ - "stdio", - "libstdio.so" - ], - [ - "mm", - "libmm.so" - ], - [ - "time", - "libtime.so" - ], - [ - "fatfs", - "libfatfs.so" - ] - ], - "apps": [ - [ - "func1", - "libwasmtime_func.so" - ], - [ - "func2", - "libwasmtime_func.so" - ], - [ - "func3", - "libwasmtime_func.so" - ], - [ - "func4", - "libwasmtime_func.so" - ], - [ - "func5", - "libwasmtime_func.so" - ] - ], - "groups": [ - { - "list": [ - "func1" - ], - "args": { - "func_num": "0" - } - }, - { - "list": [ - "func2" - ], - "args": { - "func_num": "1" - } - }, - { - "list": [ - "func3" - ], - "args": { - "func_num": "2" - } - }, - { - "list": [ - "func4" - ], - "args": { - "func_num": "3" - } - }, - { - "list": [ - "func5" - ], - "args": { - "func_num": "4" - } - } - ] - } \ No newline at end of file diff --git a/isol_config/wasmtime_parallel_sort.json b/isol_config/wasmtime_parallel_sort.json deleted file mode 100644 index 32e7d8ac..00000000 --- a/isol_config/wasmtime_parallel_sort.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "services": [ - [ - "fdtab", - "libruxfdtab.so" - ], - [ - "stdio", - "libstdio.so" - ], - [ - "mm", - "libmm.so" - ], - [ - "time", - "libtime.so" - ], - [ - "fatfs", - "libfatfs.so" - ] - ], - "apps": [ - [ - "sorter", - "libwasmtime_sorter.so" - ], - [ - "spliter", - "libwasmtime_spliter.so" - ], - [ - "merger", - "libwasmtime_merger.so" - ], - [ - "checker", - "libwasmtime_checker.so" - ] - ], - "fs_image": "fs_images/new_image.img", - "groups": [ - { - "list": [ - "sorter" - ], - "args": { - "sorter_num": "1", - "merger_num": "1" - } - }, - { - "list": [ - "spliter" - ], - "args": { - "sorter_num": "1", - "merger_num": "1" - } - } - ] - } \ No newline at end of file diff --git a/isol_config/wasmtime_parallel_sort_c1.json b/isol_config/wasmtime_parallel_sort_c1.json index e8bb75a2..d6a4b853 100644 --- a/isol_config/wasmtime_parallel_sort_c1.json +++ b/isol_config/wasmtime_parallel_sort_c1.json @@ -39,7 +39,7 @@ "libwasmtime_checker.so" ] ], - "fs_image": "fs_images/new_image.img", + "fs_image": "fs_images/fatfs.img", "groups": [ { "list": [ diff --git a/isol_config/wasmtime_parallel_sort_c3.json b/isol_config/wasmtime_parallel_sort_c3.json index fe4a553d..c7bf1304 100644 --- a/isol_config/wasmtime_parallel_sort_c3.json +++ b/isol_config/wasmtime_parallel_sort_c3.json @@ -12,13 +12,13 @@ "mm", "libmm.so" ], - [ - "time", - "libtime.so" - ], [ "fatfs", "libfatfs.so" + ], + [ + "time", + "libtime.so" ] ], "apps": [ @@ -39,7 +39,7 @@ "libwasmtime_checker.so" ] ], - "fs_image": "fs_images/new_image.img", + "fs_image": "fs_images/fatfs.img", "groups": [ { "list": [ @@ -84,4 +84,4 @@ } } ] - } \ No newline at end of file + } diff --git a/isol_config/wasmtime_parallel_sort_c5.json b/isol_config/wasmtime_parallel_sort_c5.json index 3aa27e47..f5783a79 100644 --- a/isol_config/wasmtime_parallel_sort_c5.json +++ b/isol_config/wasmtime_parallel_sort_c5.json @@ -12,10 +12,6 @@ "mm", "libmm.so" ], - [ - "time", - "libtime.so" - ], [ "fatfs", "libfatfs.so" @@ -39,7 +35,7 @@ "libwasmtime_checker.so" ] ], - "fs_image": "fs_images/new_image.img", + "fs_image": "fs_images/fatfs.img", "groups": [ { "list": [ diff --git a/isol_config/wasmtime_wordcount.json b/isol_config/wasmtime_wordcount.json index 6d95f27b..09b63bb1 100644 --- a/isol_config/wasmtime_wordcount.json +++ b/isol_config/wasmtime_wordcount.json @@ -1,45 +1,61 @@ { - "services": [ - [ - "fdtab", - "libruxfdtab.so" - ], - [ - "stdio", - "libstdio.so" - ], - [ - "mm", - "libmm.so" - ], - [ - "time", - "libtime.so" - ], - [ - "fatfs", - "libfatfs.so" - ] + "services": [ + [ + "fdtab", + "libruxfdtab.so" + ], + [ + "stdio", + "libstdio.so" ], - "apps": [ - [ + [ + "mm", + "libmm.so" + ], + [ + "fatfs", + "libfatfs.so" + ], + [ + "signal", + "libsignal.so" + ], + [ + "time", + "libtime.so" + ] + ], + "apps": [ + [ + "mapper", + "libwasmtime_mapper.so" + ], + [ + "reducer", + "libwasmtime_reducer.so" + ] + ], + "fs_image": "fs_images/fatfs_wasm.img", + "groups": [ + { + "list": [ "mapper", - "libwasmtime_mapper.so" + "mapper", + "mapper" ], - [ + "args": { + "reducer_num": "3" + } + }, + { + "list": [ "reducer", - "libwasmtime_reducer.so" - ] - ], - "fs_image": "fs_images/fatfs_large.img", - "groups": [ - { - "list": [ - "mapper" - ], - "args": { - "reducer_num": "1" - } + "reducer", + "reducer" + ], + "args": { + "mapper_num": "3" } - ] - } \ No newline at end of file + } + ] +} \ No newline at end of file diff --git a/isol_config/wasmtime_wordcount_c1.json b/isol_config/wasmtime_wordcount_c1.json index 40d1a3c9..7d51b881 100644 --- a/isol_config/wasmtime_wordcount_c1.json +++ b/isol_config/wasmtime_wordcount_c1.json @@ -4,6 +4,10 @@ "fdtab", "libruxfdtab.so" ], + [ + "time", + "libtime.so" + ], [ "stdio", "libstdio.so" @@ -12,10 +16,6 @@ "mm", "libmm.so" ], - [ - "time", - "libtime.so" - ], [ "fatfs", "libfatfs.so" @@ -31,7 +31,7 @@ "libwasmtime_reducer.so" ] ], - "fs_image": "fs_images/new_image.img", + "fs_image": "fs_images/fatfs.img", "groups": [ { "list": [ diff --git a/isol_config/wasmtime_wordcount_c3.json b/isol_config/wasmtime_wordcount_c3.json index 86403831..2a597fc3 100644 --- a/isol_config/wasmtime_wordcount_c3.json +++ b/isol_config/wasmtime_wordcount_c3.json @@ -4,6 +4,10 @@ "fdtab", "libruxfdtab.so" ], + [ + "time", + "libtime.so" + ], [ "stdio", "libstdio.so" @@ -12,10 +16,6 @@ "mm", "libmm.so" ], - [ - "time", - "libtime.so" - ], [ "fatfs", "libfatfs.so" @@ -31,7 +31,7 @@ "libwasmtime_reducer.so" ] ], - "fs_image": "fs_images/new_image.img", + "fs_image": "fs_images/fatfs.img", "groups": [ { "list": [ diff --git a/isol_config/wasmtime_wordcount_c5.json b/isol_config/wasmtime_wordcount_c5.json index 61f11e2b..c1d5ded4 100644 --- a/isol_config/wasmtime_wordcount_c5.json +++ b/isol_config/wasmtime_wordcount_c5.json @@ -12,10 +12,6 @@ "mm", "libmm.so" ], - [ - "time", - "libtime.so" - ], [ "fatfs", "libfatfs.so" @@ -31,7 +27,7 @@ "libwasmtime_reducer.so" ] ], - "fs_image": "fs_images/new_image.img", + "fs_image": "fs_images/fatfs.img", "groups": [ { "list": [ diff --git a/justfile b/justfile new file mode 100644 index 00000000..6afbdf8f --- /dev/null +++ b/justfile @@ -0,0 +1,113 @@ +all_rust: + ./scripts/build_user.sh + +cc_flags_p1 := "-Wl,--gc-sections -nostdlib -Wl,--whole-archive" +cc_flags_p2 := "-Wl,--no-whole-archive -shared" +target := "x86_64-unknown-none" + +c_mapper_so: + @echo "c_mapper.so" + cd user/wasmtime_mapper \ + && cargo build --target {{target}} \ + && cc {{cc_flags_p1}} \ + target/{{target}}/debug/libwasmtime_mapper.a \ + {{cc_flags_p2}} \ + -o target/{{target}}/debug/libwasmtime_mapper.so + +c_reducer_so: + @echo "c_reducer.so" + cd user/wasmtime_reducer \ + && cargo build --target {{target}} \ + && cc {{cc_flags_p1}} \ + target/{{target}}/debug/libwasmtime_reducer.a \ + {{cc_flags_p2}} \ + -o target/{{target}}/debug/libwasmtime_reducer.so + +wasmtime_wordcount: c_mapper_so c_reducer_so + @echo "make symbol link: wasmtime_wordcount" + @-rm target/debug/libwasmtime_mapper.so + @-rm target/debug/libwasmtime_reducer.so + @ln -s $(pwd)/user/wasmtime_mapper/target/{{target}}/debug/libwasmtime_mapper.so target/debug/ + @ln -s $(pwd)/user/wasmtime_reducer/target/{{target}}/debug/libwasmtime_reducer.so target/debug/ + +c_sorter_so: + @echo "c_sorter.so" + cd user/wasmtime_sorter \ + && cargo build --target {{target}} \ + && cc {{cc_flags_p1}} \ + target/{{target}}/debug/libwasmtime_sorter.a \ + {{cc_flags_p2}} \ + -o target/{{target}}/debug/libwasmtime_sorter.so + +c_spliter_so: + @echo "c_spliter.so" + cd user/wasmtime_spliter \ + && cargo build --target {{target}} \ + && cc {{cc_flags_p1}} \ + target/{{target}}/debug/libwasmtime_spliter.a \ + {{cc_flags_p2}} \ + -o target/{{target}}/debug/libwasmtime_spliter.so + +c_merger_so: + @echo "c_merger.so" + cd user/wasmtime_merger \ + && cargo build --target {{target}} \ + && cc {{cc_flags_p1}} \ + target/{{target}}/debug/libwasmtime_merger.a \ + {{cc_flags_p2}} \ + -o target/{{target}}/debug/libwasmtime_merger.so + +c_checker_so: + @echo "c_checker.so" + cd user/wasmtime_checker \ + && cargo build --target {{target}} \ + && cc {{cc_flags_p1}} \ + target/{{target}}/debug/libwasmtime_checker.a \ + {{cc_flags_p2}} \ + -o target/{{target}}/debug/libwasmtime_checker.so + +wasmtime_parallel_sort: c_sorter_so c_spliter_so c_merger_so c_checker_so + @echo "make symbol link: wasmtime_parallel_sort" + @-rm target/debug/libwasmtime_sorter.so + @-rm target/debug/libwasmtime_spliter.so + @-rm target/debug/libwasmtime_merger.so + @-rm target/debug/libwasmtime_checker.so + @ln -s $(pwd)/user/wasmtime_sorter/target/{{target}}/debug/libwasmtime_sorter.so target/debug/ + @ln -s $(pwd)/user/wasmtime_spliter/target/{{target}}/debug/libwasmtime_spliter.so target/debug/ + @ln -s $(pwd)/user/wasmtime_merger/target/{{target}}/debug/libwasmtime_merger.so target/debug/ + @ln -s $(pwd)/user/wasmtime_checker/target/{{target}}/debug/libwasmtime_checker.so target/debug/ + + +all_c_wasm: wasmtime_wordcount wasmtime_parallel_sort + +cpython_wordcount_so: + @echo "cpython_wordcount.so" + cd user/wasmtime_cpython_wordcount \ + && cargo build --target {{target}} \ + && cc {{cc_flags_p1}} \ + target/{{target}}/debug/libwasmtime_cpython_wordcount.a \ + {{cc_flags_p2}} \ + -o target/{{target}}/debug/libwasmtime_cpython_wordcount.so + +cpython_wordcount: cpython_wordcount_so + @echo "make symbol link: cpython_wordcount" + @-rm target/debug/libwasmtime_cpython_wordcount.so + @ln -s $(pwd)/user/wasmtime_cpython_wordcount/target/x86_64-unknown-none/debug/libwasmtime_cpython_wordcount.so target/debug + +cpython_parallel_sort_so: + @echo "cpython_parallel_sort.so" + cd user/wasmtime_cpython_parallel_sort \ + && cargo build --target {{target}} \ + && cc {{cc_flags_p1}} \ + target/{{target}}/debug/libwasmtime_cpython_parallel_sort.a \ + {{cc_flags_p2}} \ + -o target/{{target}}/debug/libwasmtime_cpython_parallel_sort.so + +cpython_parallel_sort: cpython_parallel_sort_so + @echo "make symbol link: cpython_parallel_sort" + @-rm target/debug/libwasmtime_cpython_parallel_sort.so + @ln -s $(pwd)/user/wasmtime_cpython_parallel_sort/target/{{target}}/debug/libwasmtime_cpython_parallel_sort.so target/debug/ + +all_py_wasm: cpython_wordcount cpython_parallel_sort + +all_wasm: all_c_wasm all_py_wasm diff --git a/ms_std/src/agent.rs b/ms_std/src/agent.rs index 07c8ad4e..0ba728ae 100644 --- a/ms_std/src/agent.rs +++ b/ms_std/src/agent.rs @@ -7,12 +7,7 @@ use alloc::{ }; use ms_hostcall::Verify; -use crate::{libos::libos, println, time::{SystemTime, UNIX_EPOCH},}; - -pub static mut PHASE31: u128 = 0; -pub static mut PHASE32: u128 = 0; -pub static mut PHASE33: u128 = 0; -pub static mut PHASE34: u128 = 0; +use crate::{libos::libos, println}; pub type FaaSFuncResult = Result, FaaSFuncError>; @@ -92,29 +87,19 @@ where } pub fn from_buffer_slot(slot: String) -> Option { - unsafe { - PHASE31 = SystemTime::now().duration_since(UNIX_EPOCH).as_nanos(); - } let buffer_meta: Option<(usize, u64)> = libos!(access_buffer(&slot)); - unsafe { - PHASE32 = SystemTime::now().duration_since(UNIX_EPOCH).as_nanos(); - } + buffer_meta.map(|(raw_ptr, fingerprint)| { if fingerprint != T::__fingerprint() { println!("wrong data type, {}, {}", fingerprint, T::__fingerprint()); panic!(""); }; - unsafe { - PHASE33 = SystemTime::now().duration_since(UNIX_EPOCH).as_nanos(); - } let inner = unsafe { Box::from_raw(raw_ptr as *mut T) }; - unsafe { - PHASE34 = SystemTime::now().duration_since(UNIX_EPOCH).as_nanos(); - } + Self { inner: ManuallyDrop::new(inner), - used: true, + used: false, } }) } diff --git a/scripts/c_end_to_end.sh b/scripts/c_end_to_end.sh deleted file mode 100644 index e69de29b..00000000 diff --git a/scripts/gen_data.py b/scripts/gen_data.py index b672816b..b17fc352 100755 --- a/scripts/gen_data.py +++ b/scripts/gen_data.py @@ -2,18 +2,18 @@ import os +workdir = "/home/wyj/dyx_workplace/mount" def gen_word_count(file_num: int, total_size: int): from faker import Faker fake = Faker() - # 设置种子 - Faker.seed(42) # 使用固定的种子值 + Faker.seed(42) one_size = int(total_size / file_num) for i in range(file_num): - file_name = f'./image_content/fake_data_{i}.txt' - with open(file_name, 'w') as f: + file_name = f'{workdir}/fake_data_{i}.txt' + with open(file_name, 'w', encoding='utf-8') as f: while True: f.write(fake.text(10_000)) @@ -23,28 +23,18 @@ def gen_word_count(file_num: int, total_size: int): def gen_parallel_sort(file_num: int, total_size: int): import random - random.seed(42) one_size = int(total_size / file_num) for i in range(file_num): - file_name = f'./image_content/sort_data_{i}.txt' - first = True - - with open(file_name, 'w') as f: - while True: - text = ','.join([str(random.randint(0, 1000000)) - for i in range(200)]) - if not first: - text = ',' + text - else: - first = False - + file_name = f'{workdir}/sort_data_{i}.txt' + current_size = 0 + with open(file_name, 'w', encoding='utf-8') as f: + while current_size < one_size: + text = ' '.join(str(random.randint(0, 1000000)) for i in range(10)) + text += '\n' f.write(text) - - if os.stat(file_name).st_size > one_size: - break + current_size += len(text.encode('utf-8')) # 更新当前文件大小 if __name__ == "__main__": - # gen_word_count(3, 10 * 1024 * 1024) gen_parallel_sort(3, 25 * 1024 * 1024) diff --git a/scripts/make_fs_img.sh b/scripts/make_fs_img.sh index fe24b9ca..2b3a3342 100755 --- a/scripts/make_fs_img.sh +++ b/scripts/make_fs_img.sh @@ -11,5 +11,5 @@ if [ -f "$image" ]; then rm "$image" fi -dd if=/dev/zero of="$image" bs=1M seek=200 count=0 && \ +dd if=/dev/zero of="$image" bs=1M seek=400 count=0 && \ mkfs.fat "$image" diff --git a/scripts/python_cold_start.sh b/scripts/python_cold_start.sh new file mode 100755 index 00000000..6bf3a200 --- /dev/null +++ b/scripts/python_cold_start.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +WORKDIR="/home/wyj/dyx_workplace/mslibos" + +# 定义执行次数 +EXECUTIONS=100 + +cd $WORKDIR/user/wasmtime_cpython +if [ -f "./Cargo.toml" ]; then + cargo clean +fi + +cargo build --release --target x86_64-unknown-none && cc \ + -Wl,--gc-sections -nostdlib \ + -Wl,--whole-archive \ + target/x86_64-unknown-none/release/libwasmtime_cpython.a \ + -Wl,--no-whole-archive \ + -shared \ + -o target/x86_64-unknown-none/release/libwasmtime_cpython.so + +cd $WORKDIR +ln -s $WORKDIR/user/wasmtime_cpython/target/x86_64-unknown-none/release/libwasmtime_cpython.so target/release/libwasmtime_cpython.so + +# 初始化变量来累加 total_cold 的值 +total_cold_sum=0 + +# 循环执行十次 +for (( i=1; i<=EXECUTIONS; i++ )) +do + echo "Running iteration $i..." + + # 运行项目并提取 "total_dur(ms)" 的值 + start_time=$(date '+%s.%N') + end_time=$(cargo run --release -- --files ./isol_config/wasmtime_cpython_time.json) + + # 提取 cold start time + cold_start_time=$(echo "$end_time * 1000 - $start_time * 1000" | bc) + total_cold_sum=$(echo "$total_cold_sum + $cold_start_time" | bc) + + # 打印结果 + echo "$i: $cold_start_time ms" +done + +# 计算平均值 +average_total_cold=$(echo "scale=3; $total_cold_sum / $EXECUTIONS" | bc) +echo "Average Total Cold (ms): $average_total_cold" diff --git a/scripts/python_data_trans.sh b/scripts/python_data_trans.sh new file mode 100755 index 00000000..bf0d6b3a --- /dev/null +++ b/scripts/python_data_trans.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +WORKDIR="/home/wyj/dyx_workplace/mslibos" + +# 定义执行次数 +EXECUTIONS=10 + +cd $WORKDIR/user/wasmtime_cpython +if [ -f "./Cargo.toml" ]; then + cargo clean +fi + +cargo build --release --target x86_64-unknown-none && cc \ + -Wl,--gc-sections -nostdlib \ + -Wl,--whole-archive \ + target/x86_64-unknown-none/release/libwasmtime_cpython.a \ + -Wl,--no-whole-archive \ + -shared \ + -o target/x86_64-unknown-none/release/libwasmtime_cpython.so + +cd $WORKDIR +ln -s $WORKDIR/user/wasmtime_cpython/target/x86_64-unknown-none/release/libwasmtime_cpython.so target/release/libwasmtime_cpython.so + +# 初始化变量来累加 total_dur 的值 +total_dur_sum=0 +total_trans_time=0 + +total_register_time=0 +total_access_time=0 + +# 循环执行十次 +for (( i=1; i<=EXECUTIONS; i++ )) +do + echo "Running iteration $i..." + + # 运行项目并提取 "total_dur(ms)" 的值 + # output=$(cargo run --release -- --preload --metrics all --files ./isol_config/wasmtime_cpython_pass_args.json 2>&1) + output=$(cargo run --release -- --preload --metrics all --files ./isol_config/wasmtime_cpython_pass_args_inner.json 2>&1) + total_dur=$(echo "$output" | grep -o '"total_dur(ms)": [0-9.]*' | awk -F': ' '{print $2}') + start_time=$(echo "$output" | grep -o 'start time: [0-9.]*' | awk -F': ' '{print $2}') + end_time=$(echo "$output" | grep -o 'end time: [0-9.]*' | awk -F': ' '{print $2}') + total_size=$(echo "$output" | grep -o 'buffer_size: [0-9]*' | awk -F': ' '{print $2 / 1024}') + + start_time1=$(echo "$output" | grep -o 'start1: [0-9.]*' | awk -F': ' '{print $2}') + end_time1=$(echo "$output" | grep -o 'end1: [0-9.]*' | awk -F': ' '{print $2}') + + start_time2=$(echo "$output" | grep -o 'start2: [0-9.]*' | awk -F': ' '{print $2}') + end_time2=$(echo "$output" | grep -o 'end2: [0-9.]*' | awk -F': ' '{print $2}') + + + # 提取 trans data time + trans_data_time=$(echo "$end_time * 1000 - $start_time * 1000" | bc) + # register time + trans_data_time1=$(echo "$end_time1 * 1000 - $start_time1 * 1000" | bc) + # access time + trans_data_time2=$(echo "$end_time2 * 1000 - $start_time2 * 1000" | bc) + + total_dur_sum=$(echo "$total_dur_sum + $total_dur" | bc) + total_trans_time=$(echo "$total_trans_time + $trans_data_time" | bc) + total_register_time=$(echo "$total_register_time + $trans_data_time1" | bc) + total_access_time=$(echo "$total_access_time + $trans_data_time2" | bc) + + + # 打印结果 + echo "$i: trans time: $trans_data_time ms register time: $trans_data_time1 ms access time: $trans_data_time2 ms buffer size: $total_size KB" +done + +# 计算平均值 +average_total_dur=$(echo "scale=3; $total_dur_sum / $EXECUTIONS" | bc) +echo "Average Total Dur (ms): $average_total_dur" +average_total_trans=$(echo "scale=3; $total_trans_time / $EXECUTIONS" | bc) +echo "Average Total Trans (ms): $average_total_trans" +average_total_register=$(echo "scale=3; $total_register_time / $EXECUTIONS" | bc) +echo "Average Total Register (ms): $average_total_register" +average_total_access=$(echo "scale=3; $total_access_time / $EXECUTIONS" | bc) +echo "Average Total Access (ms): $average_total_access" \ No newline at end of file diff --git a/scripts/python_end_to_end.sh b/scripts/python_end_to_end.sh new file mode 100755 index 00000000..63afe644 --- /dev/null +++ b/scripts/python_end_to_end.sh @@ -0,0 +1,193 @@ +#!/bin/bash + +WORKDIR="/home/wyj/dyx_workplace/mslibos" + +# 定义执行次数 +EXECUTIONS=10 + +# 初始化变量来累加 total_dur 的值 +total_dur_sum=0 + +# 检查是否有参数传递 +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +# 根据第一个参数决定执行哪个命令 +case $1 in + "long_chain") + echo "Executing long_chain" + cd $WORKDIR/user/wasmtime_cpython_func + if [ -f "./Cargo.toml" ]; then + cargo clean + fi + cargo build --release --target x86_64-unknown-none && cc \ + -Wl,--gc-sections -nostdlib \ + -Wl,--whole-archive \ + target/x86_64-unknown-none/release/libwasmtime_cpython_func.a \ + -Wl,--no-whole-archive \ + -shared \ + -o target/x86_64-unknown-none/release/libwasmtime_cpython_func.so + + cd $WORKDIR + ln -s $WORKDIR/user/wasmtime_cpython_func/target/x86_64-unknown-none/release/libwasmtime_cpython_func.so target/release/libwasmtime_cpython_func.so + + # 循环执行十次 + for (( i=1; i<=EXECUTIONS; i++ )) + do + echo "Running iteration $i..." + + # 运行项目并提取 "total_dur(ms)" 的值 + case $2 in + "n5") + echo "Executing n5" + output=$(cargo run --release -- --metrics all --files ./isol_config/wasmtime_cpython_functionchain_n5.json 2>&1) + ;; + "n10") + echo "Executing n10" + output=$(cargo run --release -- --metrics all --files ./isol_config/wasmtime_cpython_functionchain_n10.json 2>&1) + ;; + "n15") + echo "Executing n15" + output=$(cargo run --release -- --metrics all --files ./isol_config/wasmtime_cpython_functionchain_n15.json 2>&1) + ;; + *) + echo "Unknown command: $2" + exit 1 + ;; + esac + total_dur=$(echo "$output" | grep -o '"total_dur(ms)": [0-9.]*' | awk -F': ' '{print $2}') + + # 保留三位小数,并进行四舍五入 + total_dur_rounded=$(printf "%.3f\n" "$total_dur") + + # 累加 total_dur 的值 + total_dur_sum=$(echo "$total_dur_sum + $total_dur_rounded" | bc) + + # 打印结果 + echo "Total Dur (ms): $total_dur_rounded" + done + # 计算平均值 + average_total_dur=$(echo "scale=3; $total_dur_sum / $EXECUTIONS" | bc) + echo "Average Total Dur (ms): $average_total_dur" + ;; + "map_reduce") + echo "Executing map_reduce" + cd $WORKDIR/user/wasmtime_cpython_wordcount + if [ -f "./Cargo.toml" ]; then + cargo clean + fi + cargo build --release --target x86_64-unknown-none && cc \ + -Wl,--gc-sections -nostdlib \ + -Wl,--whole-archive \ + target/x86_64-unknown-none/release/libwasmtime_cpython_wordcount.a \ + -Wl,--no-whole-archive \ + -shared \ + -o target/x86_64-unknown-none/release/libwasmtime_cpython_wordcount.so + + cd $WORKDIR + ln -s $WORKDIR/user/wasmtime_cpython_wordcount/target/x86_64-unknown-none/release/libwasmtime_cpython_wordcount.so target/release/libwasmtime_cpython_wordcount.so + + # 循环执行十次 + for (( i=1; i<=EXECUTIONS; i++ )) + do + echo "Running iteration $i..." + + # 运行项目并提取 "total_dur(ms)" 的值 + case $2 in + "c1") + echo "Executing c1" + output=$(cargo run --release -- --metrics all --files ./isol_config/wasmtime_cpython_wordcount_c1.json 2>&1) + ;; + "c3") + echo "Executing c3" + output=$(cargo run --release -- --metrics all --files ./isol_config/wasmtime_cpython_wordcount_c3.json 2>&1) + ;; + "c5") + echo "Executing c5" + output=$(cargo run --release -- --metrics all --files ./isol_config/wasmtime_cpython_wordcount_c5.json 2>&1) + ;; + *) + echo "Unknown command: $2" + exit 1 + ;; + esac + total_dur=$(echo "$output" | grep -o '"total_dur(ms)": [0-9.]*' | awk -F': ' '{print $2}') + + # 保留三位小数,并进行四舍五入 + total_dur_rounded=$(printf "%.3f\n" "$total_dur") + + # 累加 total_dur 的值 + total_dur_sum=$(echo "$total_dur_sum + $total_dur_rounded" | bc) + + # 打印结果 + echo "Total Dur (ms): $total_dur_rounded" + done + # 计算平均值 + average_total_dur=$(echo "scale=3; $total_dur_sum / $EXECUTIONS" | bc) + echo "Average Total Dur (ms): $average_total_dur" + ;; + "parallel_sort") + echo "Executing parallel_sort" + cd $WORKDIR/user/wasmtime_cpython_parallel_sort + if [ -f "./Cargo.toml" ]; then + cargo clean + fi + cargo build --release --target x86_64-unknown-none && cc \ + -Wl,--gc-sections -nostdlib \ + -Wl,--whole-archive \ + target/x86_64-unknown-none/release/libwasmtime_cpython_parallel_sort.a \ + -Wl,--no-whole-archive \ + -shared \ + -o target/x86_64-unknown-none/release/libwasmtime_cpython_parallel_sort.so + + cd $WORKDIR + ln -s $WORKDIR/user/wasmtime_cpython_parallel_sort/target/x86_64-unknown-none/release/libwasmtime_cpython_parallel_sort.so target/release/libwasmtime_cpython_parallel_sort.so + + # 循环执行十次 + for (( i=1; i<=EXECUTIONS; i++ )) + do + echo "Running iteration $i..." + + # 运行项目并提取 "total_dur(ms)" 的值 + + case $2 in + "c1") + echo "Executing c1" + output=$(cargo run --release -- --metrics all --files ./isol_config/wasmtime_cpython_parallel_sort_c1.json 2>&1) + ;; + "c3") + echo "Executing c3" + output=$(cargo run --release -- --metrics all --files ./isol_config/wasmtime_cpython_parallel_sort_c3.json 2>&1) + ;; + "c5") + echo "Executing c5" + output=$(cargo run --release -- --metrics all --files ./isol_config/wasmtime_cpython_parallel_sort_c5.json 2>&1) + ;; + *) + echo "Unknown command: $2" + exit 1 + ;; + esac + total_dur=$(echo "$output" | grep -o '"total_dur(ms)": [0-9.]*' | awk -F': ' '{print $2}') + + # 保留三位小数,并进行四舍五入 + total_dur_rounded=$(printf "%.3f\n" "$total_dur") + + # 累加 total_dur 的值 + total_dur_sum=$(echo "$total_dur_sum + $total_dur_rounded" | bc) + + # 打印结果 + echo "Total Dur (ms): $total_dur_rounded" + done + # 计算平均值 + average_total_dur=$(echo "scale=3; $total_dur_sum / $EXECUTIONS" | bc) + echo "Average Total Dur (ms): $average_total_dur" + ;; + *) + echo "Unknown command: $1" + exit 1 + ;; +esac + diff --git a/scripts/python_wordcount_trash.sh b/scripts/python_wordcount_trash.sh new file mode 100755 index 00000000..378d81ce --- /dev/null +++ b/scripts/python_wordcount_trash.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +WORKDIR="/home/wyj/dyx_workplace/mslibos" + +# 定义执行次数 +EXECUTIONS=10 + +cd $WORKDIR/user/wasmtime_cpython_mapper +if [ -f "./Cargo.toml" ]; then + cargo clean +fi +cargo build --release --target x86_64-unknown-none && cc \ + -Wl,--gc-sections -nostdlib \ + -Wl,--whole-archive \ + target/x86_64-unknown-none/release/libwasmtime_cpython_mapper.a \ + -Wl,--no-whole-archive \ + -shared \ + -o target/x86_64-unknown-none/release/libwasmtime_cpython_mapper.so + +cd $WORKDIR/user/wasmtime_cpython_reducer +if [ -f "./Cargo.toml" ]; then + cargo clean +fi +cargo build --release --target x86_64-unknown-none && cc \ + -Wl,--gc-sections -nostdlib \ + -Wl,--whole-archive \ + target/x86_64-unknown-none/release/libwasmtime_cpython_reducer.a \ + -Wl,--no-whole-archive \ + -shared \ + -o target/x86_64-unknown-none/release/libwasmtime_cpython_reducer.so + +cd $WORKDIR +ln -s $WORKDIR/user/wasmtime_cpython_mapper/target/x86_64-unknown-none/release/libwasmtime_cpython_mapper.so target/release/libwasmtime_cpython_mapper.so +ln -s $WORKDIR/user/wasmtime_cpython_reducer/target/x86_64-unknown-none/release/libwasmtime_cpython_reducer.so target/release/libwasmtime_cpython_reducer.so + +# 初始化变量来累加 total_phase 的值 +total_phase1=0 +total_phase2=0 +total_phase3=0 +total_phase4=0 + +# 循环执行十次 +for (( i=1; i<=EXECUTIONS; i++ )) +do + echo "Running iteration $i..." + + # 运行项目并提取 'phase' 的值 + output=$(cargo run --release -- --metrics all --files ./isol_config/wasmtime_cpython_wordcount_c3.json 2>&1) + phase0=$(echo "$output" | grep -o 'phase0: [0-9.]*' | awk -F': ' '{print $2}' | sort | head -n 1) + phase1=$(echo "$output" | grep -o 'phase1: [0-9.]*' | awk -F': ' '{print $2}' | sort | head -n 1) + phase2=$(echo "$output" | grep -o 'phase2: [0-9.]*' | awk -F': ' '{print $2}' | sort | head -n 1) + phase3=$(echo "$output" | grep -o 'phase2: [0-9.]*' | awk -F': ' '{print $2}' | sort -r | head -n 1) + phase4=$(echo "$output" | grep -o 'phase3: [0-9.]*' | awk -F': ' '{print $2}' | sort -r | head -n 1) + + # 提取 time + p1=$(echo "$phase1 - $phase0" | bc) + p2=$(echo "$phase2 - $phase1" | bc) + p3=$(echo "$phase3 - $phase2" | bc) + p4=$(echo "$phase4 - $phase3" | bc) + + total_phase1=$(echo "$total_phase1 + $p1" | bc) + total_phase2=$(echo "$total_phase2 + $p2" | bc) + total_phase3=$(echo "$total_phase3 + $p3" | bc) + total_phase4=$(echo "$total_phase4 + $p4" | bc) + + # 打印结果 + echo "$i: $p1 s $p2 s $p3 s $p4 s" +done + +# 计算平均值 +average_total_phase1=$(echo "scale=6; $total_phase1 / $EXECUTIONS" | bc) +echo "Average Total Phase1 (s): $average_total_phase1" +average_total_phase2=$(echo "scale=6; $total_phase2 / $EXECUTIONS" | bc) +echo "Average Total Phase2 (s): $average_total_phase2" +average_total_phase3=$(echo "scale=6; $total_phase3 / $EXECUTIONS" | bc) +echo "Average Total Phase3 (s): $average_total_phase3" +average_total_phase4=$(echo "scale=6; $total_phase4 / $EXECUTIONS" | bc) +echo "Average Total Phase4 (s): $average_total_phase4" diff --git a/scripts/run_wasm_tests.sh b/scripts/run_wasm_tests.sh new file mode 100755 index 00000000..b586fd44 --- /dev/null +++ b/scripts/run_wasm_tests.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +declare -A test_groups=( + [wasm_c]="wasmtime_wordcount wasmtime_parallel_sort_c3" + [wasm_py]="wasmtime_cpython wasmtime_cpython_wordcount_c3 wasmtime_cpython_parallel_sort_c3" +) + +passed_count=0 +declare -A results + +# 获取脚本参数(feature) +feature_arg="" +if [ $# -gt 0 ]; then + feature_arg="--features $1" +fi + +for group in "${!test_groups[@]}"; do + names=${test_groups[$group]} + + for name in $names; do + output=$(RUST_LOG=info cargo run $feature_arg -- --files "isol_config/$name.json") + if [ $? -eq 0 ]; then + results[$name]="passed" + ((passed_count++)) # 增加通过计数 + else + echo -e "===== \033[31mCommand failed for $name\033[0m =====" + results[$name]="failed" + fi + done +done + +# 输出所有测试结果 +echo "Test Results:" +for name in "${!results[@]}"; do + status=${results[$name]} + if [ "$status" == "passed" ]; then + echo -e "\033[32m$name: $status\033[0m" + else + echo -e "\033[31m$name: $status\033[0m" + fi +done + +total_tests=${#results[@]} + +# 检查通过计数与总测试数量是否相等 +if [ "$passed_count" -ne "$total_tests" ]; then + echo "Error: Not all tests passed!" + exit 1 # 返回失败状态 +fi diff --git a/scripts/rust_cold_start.sh b/scripts/rust_cold_start.sh index e3753818..10d1dc25 100755 --- a/scripts/rust_cold_start.sh +++ b/scripts/rust_cold_start.sh @@ -1,7 +1,7 @@ #!/bin/bash # 定义执行次数 -EXECUTIONS=10 +EXECUTIONS=100 # 初始化变量来累加 total_dur 的值 total_dur_sum=0 @@ -10,7 +10,7 @@ if [ -f "./user/hello_world/Cargo.toml" ]; then cargo clean --manifest-path ./user/hello_world/Cargo.toml fi -cargo build --manifest-path ./user/hello_world/Cargo.toml --release +cargo build --features mpk --manifest-path ./user/hello_world/Cargo.toml --release # 循环执行十次 for (( i=1; i<=EXECUTIONS; i++ )) @@ -18,8 +18,7 @@ do echo "Running iteration $i..." # 运行项目并提取 "total_dur(ms)" 的值 - output=$(cargo run --release -- --metrics all --files ./isol_config/base_config.json 2>&1) - # output=$(cargo run --release -- --preload --metrics all --files ./isol_config/base_config.json 2>&1) + output=$(cargo run --release --features mpk -- --metrics all --files ./isol_config/base_config.json 2>&1) total_dur=$(echo "$output" | grep -o '"total_dur(ms)": [0-9.]*' | awk -F': ' '{print $2}') # 保留三位小数,并进行四舍五入 diff --git a/scripts/rust_data_trans.sh b/scripts/rust_data_trans.sh index d1e818ff..e784322c 100755 --- a/scripts/rust_data_trans.sh +++ b/scripts/rust_data_trans.sh @@ -7,10 +7,16 @@ if [ -f "./user/func_a/Cargo.toml" ]; then cargo clean --manifest-path ./user/func_a/Cargo.toml fi -cargo build --manifest-path ./user/func_a/Cargo.toml --release +if [ -f "./user/func_b/Cargo.toml" ]; then + cargo clean --manifest-path ./user/func_b/Cargo.toml +fi + +cargo build --features mpk --manifest-path ./user/func_a/Cargo.toml --release +cargo build --features mpk --manifest-path ./user/func_b/Cargo.toml --release # 初始化变量来累加 total_dur 的值 total_dur_sum=0 +total_rate_sum=0 # 循环执行十次 for (( i=1; i<=EXECUTIONS; i++ )) @@ -18,18 +24,35 @@ do echo "Running iteration $i..." # 运行项目并提取 "total_dur(ms)" 的值 - # output=$(cargo run --release -- --preload --metrics all --files ./isol_config/pass_complex_args.json 2>&1) - output=$(cargo run --release -- --preload --files ./isol_config/pass_complex_args.json 2>&1) - - total_dur=$(echo "$output" | grep 'opt_dur=' | cut -d'=' -f2) + # output=$(cargo run --release --features mpk -- --preload --metrics all --files ./isol_config/pass_complex_args.json 2>&1) + output=$(cargo run --release --features mpk -- --metrics all --files ./isol_config/pass_complex_args.json 2>&1) + total_dur=$(echo "$output" | grep -o '"total_dur(ms)": [0-9.]*' | awk -F': ' '{print $2}') + + # 提取 trans data time、total_size 和 transfer rate + # trans_data_time=$(echo "$output" | grep -o 'trans data time: [0-9.]*µs' | awk -F': ' '{print $2}' | awk -F'µs' '{print $1}') + trans_data_time=$(echo "$output" | grep -o 'trans data time: [0-9.]*[µm]s' | awk -F': ' '{print $2}' | awk '{ + if ($1 ~ /µs$/) { + print $1 + } else if ($1 ~ /ms$/) { + gsub(/ms$/, "", $1) + print $1 * 1000 "µs" + } + }' | awk -F'µs' '{print $1}') + total_size=$(echo "$output" | grep -o 'total_size: [0-9]* Bytes' | awk -F': ' '{print $2}' | awk -F' Bytes' '{print $1}') + transfer_rate=$(echo "$output" | grep -o 'transfer rate: [0-9]* MB/s' | awk -F': ' '{print $2}' | awk -F' MB/s' '{print $1}') + # 累加 total_dur 的值 - total_dur_sum=$(echo "$total_dur_sum + $total_dur" | bc) + total_dur_sum=$(echo "$total_dur_sum + $trans_data_time" | bc) + + # 累加 total_rate 的值 + total_rate_sum=$(echo "$total_rate_sum + $transfer_rate" | bc) # 打印结果 - echo "$total_dur" + echo "$trans_data_time $total_size $transfer_rate" done - # 计算平均值 -average_total_dur=$(echo "scale=6; $total_dur_sum / $EXECUTIONS / 1000" | bc) -echo "Average Total Dur (ms): $average_total_dur" \ No newline at end of file +average_total_dur=$(echo "scale=3; $total_dur_sum / $EXECUTIONS" | bc) +echo "Average Total Dur (us): $average_total_dur" +average_total_rate=$(echo "scale=3; $total_rate_sum / $EXECUTIONS" | bc) +echo "Average Total Dur (MB/s): $average_total_rate" diff --git a/scripts/wasmtime_data_trans.sh b/scripts/wasmtime_data_trans.sh index 7f0bcb08..f663a4e9 100755 --- a/scripts/wasmtime_data_trans.sh +++ b/scripts/wasmtime_data_trans.sh @@ -4,6 +4,9 @@ EXECUTIONS=10 # 初始化变量来累加 total_dur 的值 +total_dur_sum1=0 +total_dur_sum2=0 +total_dur_sum34=0 total_dur_sum=0 # 循环执行十次 @@ -16,20 +19,34 @@ do numbers=($(echo "$output" | grep -o '[0-9]\+\.[0-9]\+')) # 获取最后两个数字 - num1=${numbers[-2]} - num2=${numbers[-1]} + num0=${numbers[-4]} + num1=${numbers[-3]} + num2=${numbers[-2]} + num3=${numbers[-1]} # 计算差值 - difference=$(echo "$num2 - $num1" | bc) + phase1=$(echo "$num1 * 1000 - $num0 * 1000" | bc) + phase2=$(echo "$num2 * 1000 - $num1 * 1000" | bc) + phase34=$(echo "$num3 * 1000 - $num2 * 1000" | bc) + total=$(echo "$num3 * 1000 - $num0 * 1000" | bc) # 累加 total_dur 的值 - total_dur_sum=$(echo "$total_dur_sum + $difference" | bc) + total_dur_sum1=$(echo "$total_dur_sum1 + $phase1" | bc) + total_dur_sum2=$(echo "$total_dur_sum2 + $phase2" | bc) + total_dur_sum34=$(echo "$total_dur_sum34 + $phase34" | bc) + total_dur_sum=$(echo "$total_dur_sum + $total" | bc) # 打印结果 - echo "Difference: $difference" + echo "$i: phase1: $phase1 ms phase2: $phase2 ms phase3+4: $phase34 ms" done # 计算平均值 -average_total_dur=$(echo "scale=3; $total_dur_sum * 1000 / $EXECUTIONS" | bc) -echo "Average Total Dur (ms): $average_total_dur" \ No newline at end of file +average_total_dur1=$(echo "scale=3; $total_dur_sum1 / $EXECUTIONS" | bc) +echo "Average Phase1 (ms): $average_total_dur1" +average_total_dur2=$(echo "scale=3; $total_dur_sum2 / $EXECUTIONS" | bc) +echo "Average Phase2 (ms): $average_total_dur2" +average_total_dur34=$(echo "scale=3; $total_dur_sum34 / $EXECUTIONS" | bc) +echo "Average Phase3+4 (ms): $average_total_dur34" +average_total_dur=$(echo "scale=3; $total_dur_sum / $EXECUTIONS" | bc) +echo "Average Total (ms): $average_total_dur" \ No newline at end of file diff --git a/user/hello_world/Cargo.lock b/user/hello_world/Cargo.lock index 719a4934..26c8f98d 100644 --- a/user/hello_world/Cargo.lock +++ b/user/hello_world/Cargo.lock @@ -2,6 +2,24 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + [[package]] name = "autocfg" version = "1.1.0" @@ -45,6 +63,12 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "gimli" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" + [[package]] name = "hash32" version = "0.3.1" @@ -54,6 +78,16 @@ dependencies = [ "byteorder", ] +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + [[package]] name = "heapless" version = "0.8.0" @@ -69,10 +103,17 @@ name = "hello_world" version = "0.1.0" dependencies = [ "cfg-if", + "hashbrown", "ms_hostcall", "ms_std", ] +[[package]] +name = "libc" +version = "0.2.158" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" + [[package]] name = "linked_list_allocator" version = "0.10.5" @@ -112,6 +153,7 @@ dependencies = [ "ms_std_proc_macro", "spin", "thiserror-no-std", + "unwinding", ] [[package]] @@ -123,6 +165,12 @@ dependencies = [ "syn 2.0.39", ] +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + [[package]] name = "proc-macro2" version = "1.0.70" @@ -233,3 +281,39 @@ name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "unwinding" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" +dependencies = [ + "gimli", + "libc", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.39", +] diff --git a/user/load_all/Cargo.toml b/user/load_all/Cargo.toml index a296d7ee..45faf71e 100644 --- a/user/load_all/Cargo.toml +++ b/user/load_all/Cargo.toml @@ -19,5 +19,5 @@ cfg-if = "1.0.0" [features] with_libos = ["ms_std", "ms_hostcall"] measure_mem = ["with_libos"] -# mpk = ["ms_std/mpk"] +mpk = ["ms_std/mpk"] default = ["measure_mem"] diff --git a/user/load_all/src/lib.rs b/user/load_all/src/lib.rs index f26d1dd9..d61e349c 100644 --- a/user/load_all/src/lib.rs +++ b/user/load_all/src/lib.rs @@ -16,7 +16,7 @@ cfg_if::cfg_if! { pub fn main() -> Result<()> { println!("Hello, world! id: {}", args::get("id").unwrap()); - libos!(addrinfo("www.baidu.com")).unwrap(); + libos!(addrinfo("localhost")).unwrap(); if let Err(e) = File::open(".") { println!("{:#?}", e); } diff --git a/user/tinywasm_c_printf/Cargo.lock b/user/tinywasm_c_printf/Cargo.lock deleted file mode 100644 index 9ed6dd20..00000000 --- a/user/tinywasm_c_printf/Cargo.lock +++ /dev/null @@ -1,394 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_c_printf" -version = "0.1.0" -dependencies = [ - "cfg-if", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] diff --git a/user/tinywasm_c_printf/Cargo.toml b/user/tinywasm_c_printf/Cargo.toml deleted file mode 100644 index 6aeffc39..00000000 --- a/user/tinywasm_c_printf/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "tinywasm_c_printf" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api" } - -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] -mpk = ["ms_std/mpk"] -default = ["with_libos"] \ No newline at end of file diff --git a/user/tinywasm_c_printf/src/lib.rs b/user/tinywasm_c_printf/src/lib.rs deleted file mode 100644 index eb6b2f0a..00000000 --- a/user/tinywasm_c_printf/src/lib.rs +++ /dev/null @@ -1,37 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -cfg_if::cfg_if! { - if #[cfg(feature = "with_libos")] { - use ms_std::{agent::FaaSFuncResult as Result}; - extern crate alloc; - } else { - type Result = core::result::Result; - } -} - -use alloc::format; -use ms_std::println; - -use wasi_api::tinywasm::{Module, Store, ModuleInstance}; - -const WASM: &[u8] = include_bytes!("../write.wasm"); - -#[no_mangle] -pub fn main() -> Result<()> { - let module = Module::parse_bytes(WASM)?; - let mut store = Store::default(); - let imports = wasi_api::import_all()?; - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - let main = instance.exported_func::<(), ()>(&store, "_start")?; - - if let Err(e) = unwinding::panic::catch_unwind(|| main.call(&mut store, ()).unwrap()) { - let msg = format!("{:?}", e); - println!("err msg: {}", msg); - if msg != "normally exit" { - // return Err(); - } - }; - - Ok(().into()) -} diff --git a/user/tinywasm_c_printf/write.c b/user/tinywasm_c_printf/write.c deleted file mode 100644 index 17257881..00000000 --- a/user/tinywasm_c_printf/write.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -#include -#include -#include -int main() -{ - char input_file [20]; - sprintf(input_file, "fake_data_%d.txt", 1); - printf("input file: %s\n", input_file); - return 0; -} \ No newline at end of file diff --git a/user/tinywasm_c_printf/write.wasm b/user/tinywasm_c_printf/write.wasm deleted file mode 100755 index af49fff2..00000000 Binary files a/user/tinywasm_c_printf/write.wasm and /dev/null differ diff --git a/user/tinywasm_checker/Cargo.lock b/user/tinywasm_checker/Cargo.lock deleted file mode 100644 index 214c01a4..00000000 --- a/user/tinywasm_checker/Cargo.lock +++ /dev/null @@ -1,395 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_checker" -version = "0.1.0" -dependencies = [ - "cfg-if", - "lazy_static", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] diff --git a/user/tinywasm_checker/Cargo.toml b/user/tinywasm_checker/Cargo.toml deleted file mode 100644 index d81163af..00000000 --- a/user/tinywasm_checker/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "tinywasm_checker" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api" } - -lazy_static = { version = "1.5.0", features = ["spin_no_std"] } -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] -mpk = ["ms_std/mpk"] -default = ["with_libos"] \ No newline at end of file diff --git a/user/tinywasm_checker/checker.c b/user/tinywasm_checker/checker.c deleted file mode 100644 index 59bcff87..00000000 --- a/user/tinywasm_checker/checker.c +++ /dev/null @@ -1,56 +0,0 @@ -#include -#include -#include - -__attribute__((import_module("env"), import_name("access_buffer"))) void access_buffer(void *slot_name, int name_size, void *buffer, int buffer_size); - -#define MAX_ARRAY_LENGTH 100 - -int main(int argc, char* argv[]) { - int id = atoi(argv[1]); - int sorter_num = atoi(argv[2]); - int merger_num = atoi(argv[3]); - printf("checker_%d start!\n", id); - int result[MAX_ARRAY_LENGTH]; - int index = 0; - for (int i = 0; i < merger_num; i++) { - char slot_name[20]; - sprintf(slot_name, "checker_%d", i); - // printf("pivotname: %s\n", slot_name); - int bufferSize = 1000; - char *buffer; - buffer = (char *)malloc(bufferSize * sizeof(char)); - if (buffer == NULL) { - perror("malloc error"); - return 1; - } - memset(buffer, 0, bufferSize * sizeof(char)); - buffer[0] = '\0'; // 初始化为空字符串 - access_buffer(slot_name, strlen(slot_name), buffer, bufferSize); - char *ptr = buffer; - int num; - while (sscanf(ptr, "%d", &num) == 1) { - result[index] = num; - index++; - // 移动指针到下一个数字 - while (*ptr && *ptr != ' ') { - ptr++; - } - if (*ptr == ' ') { - ptr++; - } - } - free(buffer); - } - printf("result_array: "); - for (int i = 0; i < index-1; i++) { - if (result[i] > result[i+1]) { - printf("sort error!\n"); - return 0; - } - printf("%d ", result[i]); - } - printf("%d\n", result[index-1]); - printf("checker_%d all finished!\n", id); - return 0; -} \ No newline at end of file diff --git a/user/tinywasm_checker/checker.wasm b/user/tinywasm_checker/checker.wasm deleted file mode 100755 index 6a2f26ca..00000000 Binary files a/user/tinywasm_checker/checker.wasm and /dev/null differ diff --git a/user/tinywasm_checker/src/lib.rs b/user/tinywasm_checker/src/lib.rs deleted file mode 100644 index c189811d..00000000 --- a/user/tinywasm_checker/src/lib.rs +++ /dev/null @@ -1,74 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -cfg_if::cfg_if! { - if #[cfg(feature = "with_libos")] { - use ms_std::{agent::FaaSFuncResult as Result}; - extern crate alloc; - } else { - type Result = core::result::Result; - use std::collections::BTreeMap; - } -} - -use alloc::{collections::BTreeMap, format, string::{String, ToString}, vec::Vec}; -use ms_std::{args, println, libos::libos}; -use ms_hostcall::types::{OpenFlags, OpenMode}; - -use tinywasm::{Module, Store, ModuleInstance}; -use wasi_api::tinywasm; - -const WASM: &[u8] = include_bytes!("../checker.wasm"); - -lazy_static::lazy_static! { - static ref MUST_OPEN_ROOT: bool = { - libos!(open("/", OpenFlags::empty(), OpenMode::RD)).unwrap(); - true - }; -} - -fn func_body(my_id: &str, sorter_num: u64, merger_num: u64) -> Result<()> { - #[cfg(feature = "log")] - println!("rust: my_id: {:?}, reducer_num: {:?}", my_id, reducer_num); - - let mut wasi_args: Vec = Vec::new(); - wasi_args.push("fake system path!".to_string()); // c语言main第一个参数是系统路径 - wasi_args.push(my_id.to_string()); - wasi_args.push(sorter_num.to_string()); - wasi_args.push(merger_num.to_string()); - - let _open_root = *MUST_OPEN_ROOT; - - let module = Module::parse_bytes(WASM)?; - let mut store = Store::default(); - let imports = wasi_api::import_all()?; - - wasi_api::set_wasi_args(store.id(), wasi_args); - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - let main = instance.exported_func::<(), ()>(&store, "_start")?; - - if let Err(e) = unwinding::panic::catch_unwind(|| main.call(&mut store, ()).unwrap()) { - let msg = format!("{:?}", e); - println!("err msg: {}", msg); - if msg != "normally exit" { - // return Err(); - } - }; - - Ok(().into()) -} - -#[no_mangle] -pub fn main() -> Result<()> { - let my_id = args::get("id").unwrap(); - let sorter_num: u64 = args::get("sorter_num") - .expect("missing arg sorter_num") - .parse() - .unwrap_or_else(|_| panic!("bad arg, sorter_num={}", args::get("sorter_num").unwrap())); - let merger_num: u64 = args::get("merger_num") - .expect("missing arg merger_num") - .parse() - .unwrap_or_else(|_| panic!("bad arg, merger_num={}", args::get("merger_num").unwrap())); - - func_body(my_id, sorter_num, merger_num) -} \ No newline at end of file diff --git a/user/tinywasm_cpython/Cargo.lock b/user/tinywasm_cpython/Cargo.lock deleted file mode 100644 index 3316b7b4..00000000 --- a/user/tinywasm_cpython/Cargo.lock +++ /dev/null @@ -1,394 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 2.0.77", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.77", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_cpython" -version = "0.1.0" -dependencies = [ - "cfg-if", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.77", -] diff --git a/user/tinywasm_cpython/Cargo.toml b/user/tinywasm_cpython/Cargo.toml deleted file mode 100755 index 3c815248..00000000 --- a/user/tinywasm_cpython/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "tinywasm_cpython" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api" } - -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] - -default = ["with_libos"] diff --git a/user/tinywasm_cpython/src/lib.rs b/user/tinywasm_cpython/src/lib.rs deleted file mode 100755 index 7fb18816..00000000 --- a/user/tinywasm_cpython/src/lib.rs +++ /dev/null @@ -1,45 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -cfg_if::cfg_if! { - if #[cfg(feature = "with_libos")] { - use ms_std::{agent::FaaSFuncResult as Result}; - extern crate alloc; - use alloc::{collections::BTreeMap, string::String}; - } else { - type Result = core::result::Result; - use std::collections::BTreeMap; - } -} - -use alloc::{string::ToString, vec::Vec}; -use ms_std::{ - libos::libos, - println, - time::{SystemTime, UNIX_EPOCH}, -}; -use tinywasm::{Module, Store}; -use wasi_api::tinywasm::{self, ModuleInstance}; -use ms_hostcall::types::{OpenFlags, OpenMode}; - -const WASM: &[u8] = include_bytes!("../python.wasm"); - -#[no_mangle] -pub fn main(_args: &BTreeMap) -> Result<()> { - libos!(open("/", OpenFlags::empty(), OpenMode::RD))?; - let mut wasi_args: Vec = Vec::new(); - wasi_args.push("python.wasm".to_string()); - wasi_args.push("/wasm_bench/alu.py".to_string()); - let module = Module::parse_bytes(WASM)?; - let mut store = Store::default(); - let imports = wasi_api::import_all()?; - - wasi_api::set_wasi_args(store.id(), wasi_args); - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - let main = instance.exported_func::<(), ()>(&store, "_start")?; - - let result = unwinding::panic::catch_unwind(|| main.call(&mut store, ()).unwrap()); - println!("result: {:?}", result); - - Ok(().into()) -} diff --git a/user/tinywasm_mapper/Cargo.lock b/user/tinywasm_mapper/Cargo.lock deleted file mode 100644 index 3cb988c0..00000000 --- a/user/tinywasm_mapper/Cargo.lock +++ /dev/null @@ -1,395 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_mapper" -version = "0.1.0" -dependencies = [ - "cfg-if", - "lazy_static", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] diff --git a/user/tinywasm_mapper/Cargo.toml b/user/tinywasm_mapper/Cargo.toml deleted file mode 100644 index f1a3b15c..00000000 --- a/user/tinywasm_mapper/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "tinywasm_mapper" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api" } - -lazy_static = { version = "1.5.0", features = ["spin_no_std"] } -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] -mpk = ["ms_std/mpk"] -default = ["with_libos"] diff --git a/user/tinywasm_mapper/mapper.c b/user/tinywasm_mapper/mapper.c deleted file mode 100644 index dc9a35e8..00000000 --- a/user/tinywasm_mapper/mapper.c +++ /dev/null @@ -1,104 +0,0 @@ -#include -#include -#include -#include - -__attribute__((import_module("env"), import_name("buffer_register"))) void buffer_register(void *slot_name, int name_size, void *buffer, int buffer_size); - -#define MAX_WORD_LENGTH 100 -#define MAX_WORDS 8000 -#define MAX_SLOT_NUM 100 -#define MAX_BUFFER_SIZE 8000 - -void to_lowercase(char *str) { - for (int i = 0; str[i]; i++) { - str[i] = tolower(str[i]); - } -} -int main(int argc, char* argv[]) { - int id = atoi(argv[1]); - int reducer_num = atoi(argv[2]); - printf("mapper.c recieve: id: %d, reducer_num: %d\n", id, reducer_num); - - char input_file[30]; - sprintf(input_file, "fake_data_%d.txt", id); - FILE *file = fopen(input_file, "r"); - if (!file) { - perror("Failed to open input file\n"); - exit(EXIT_FAILURE); - } - - printf("mapper_%d input file: %s\n", id, input_file); - - int count[MAX_WORDS] = {0}; - char *words[MAX_WORDS]; - char word[MAX_WORD_LENGTH]; - int word_index = 0; - while (fscanf(file, "%s", word) != EOF) { - to_lowercase(word); - - int found = 0; - for (int i = 0; i < word_index; i++) { - if (strcmp(words[i], word) == 0) { - count[i]++; - found = 1; - break; - } - } - - if (!found) { - words[word_index] = strdup(word); - count[word_index]++; - word_index++; - } - } - fclose(file); - - printf("mapper_%d read success!\n", id); - - char *slot_name[MAX_SLOT_NUM]; - char *buffer[MAX_SLOT_NUM]; - char slot[20]; - int bufferSize = MAX_BUFFER_SIZE; - int slot_index = 0; - - for (int i = 0; i < word_index; i++) { - int partition_index = i % reducer_num; - sprintf(slot, "buffer_%d_%d", partition_index, id); - int found = 0; - for (int j = 0; j < slot_index; j++) { - if (strcmp(slot_name[j], slot) == 0) { - found = 1; - sprintf(buffer[j] + strlen(buffer[j]), "%s: %d\n", words[i], count[i]); - break; - } - } - - if (!found) { - slot_name[slot_index] = strdup(slot); - buffer[slot_index] = (char *)malloc(bufferSize * sizeof(char)); - if (buffer == NULL) { - printf("alloc mem failed\n"); - return 1; - } - memset(buffer[slot_index], 0, bufferSize * sizeof(char)); - sprintf(buffer[slot_index], "%s: %d\n", words[i], count[i]); - // printf("slot: %s; buffer: %s\n", slot_name[slot_index], buffer[slot_index]); - slot_index++; - } - // printf("found: %d; word: %s; count: %d; slot_name: %s; buffer: %s\n", found, words[i], count[i], slot, buffer[slot_index]); - free(words[i]); - } - - for (int i = 0; i < slot_index; i++) { - buffer_register(slot_name[i], strlen(slot_name[i]), buffer[i], bufferSize); - } - - for (int i = 0; i < slot_index; i++) { - free(slot_name[i]); // 释放 strdup 分配的内存 - free(buffer[i]); // 释放 buffer - } - - printf("mapper_%d finished!\n", id); - return 0; -} \ No newline at end of file diff --git a/user/tinywasm_mapper/mapper.wasm b/user/tinywasm_mapper/mapper.wasm deleted file mode 100755 index 50e8aa33..00000000 Binary files a/user/tinywasm_mapper/mapper.wasm and /dev/null differ diff --git a/user/tinywasm_mapper/src/lib.rs b/user/tinywasm_mapper/src/lib.rs deleted file mode 100644 index d643e820..00000000 --- a/user/tinywasm_mapper/src/lib.rs +++ /dev/null @@ -1,80 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -cfg_if::cfg_if! { - if #[cfg(feature = "with_libos")] { - use ms_std::{agent::FaaSFuncResult as Result}; - extern crate alloc; - } else { - type Result = core::result::Result; - use std::collections::BTreeMap; - } -} - -use alloc::{ - format, - string::{String, ToString}, - vec::Vec, -}; -use ms_hostcall::types::{OpenFlags, OpenMode}; -use ms_std::{args, libos::libos, println}; - -use tinywasm::{Module, ModuleInstance, Store}; -use wasi_api::tinywasm; - -const WASM: &[u8] = include_bytes!("../mapper.wasm"); - -lazy_static::lazy_static! { - static ref MUST_OPEN_ROOT: bool = { - libos!(open("/", OpenFlags::empty(), OpenMode::RD)).unwrap(); - true - }; -} - -fn func_body(my_id: &str, reducer_num: u64) -> Result<()> { - #[cfg(feature = "log")] - println!("rust: my_id: {:?}, reducer_num: {:?}", my_id, reducer_num); - - let wasi_args: Vec = Vec::from([ - "fake system path!".to_string(), - my_id.to_string(), - reducer_num.to_string(), - ]); - - let _open_root = *MUST_OPEN_ROOT; - - // let data_fd = libos!(open(&format!("little_fake_data_{}.txt", my_id), OpenFlags::O_CREAT, OpenMode::RDWR))? as u32; - // println!("mapper_{} data_fd: {}", my_id, data_fd); - // libos!(write(data_fd, b"hello hello hello hello name name name name world world world world\n"))?; - // libos!(write(data_fd, b"you you you you like like like like potato potato potato potato\n"))?; - // libos!(close(data_fd))?; - - let module = Module::parse_bytes(WASM)?; - let mut store = Store::default(); - let imports = wasi_api::import_all()?; - - wasi_api::set_wasi_args(store.id(), wasi_args); - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - let main = instance.exported_func::<(), ()>(&store, "_start")?; - - if let Err(e) = unwinding::panic::catch_unwind(|| main.call(&mut store, ()).unwrap()) { - let msg = format!("{:?}", e); - println!("err msg: {}", msg); - if msg != "normally exit" { - // return Err(); - } - }; - - Ok(().into()) -} - -#[no_mangle] -pub fn main() -> Result<()> { - let my_id = args::get("id").unwrap(); - let reducer_num: u64 = args::get("reducer_num") - .expect("missing arg reducer_num") - .parse() - .unwrap_or_else(|_| panic!("bad arg, reducer_num={}", args::get("reducer_num").unwrap())); - - func_body(my_id, reducer_num) -} diff --git a/user/tinywasm_merger/Cargo.lock b/user/tinywasm_merger/Cargo.lock deleted file mode 100644 index 59ceb608..00000000 --- a/user/tinywasm_merger/Cargo.lock +++ /dev/null @@ -1,395 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_merger" -version = "0.1.0" -dependencies = [ - "cfg-if", - "lazy_static", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] diff --git a/user/tinywasm_merger/Cargo.toml b/user/tinywasm_merger/Cargo.toml deleted file mode 100644 index 5c84cae1..00000000 --- a/user/tinywasm_merger/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "tinywasm_merger" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api" } - -lazy_static = { version = "1.5.0", features = ["spin_no_std"] } -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] -mpk = ["ms_std/mpk"] -default = ["with_libos"] \ No newline at end of file diff --git a/user/tinywasm_merger/merger.c b/user/tinywasm_merger/merger.c deleted file mode 100644 index 7b66afca..00000000 --- a/user/tinywasm_merger/merger.c +++ /dev/null @@ -1,153 +0,0 @@ -#include -#include -#include - -__attribute__((import_module("env"), import_name("buffer_register"))) void buffer_register(void *slot_name, int name_size, void *buffer, int buffer_size); -__attribute__((import_module("env"), import_name("access_buffer"))) void access_buffer(void *slot_name, int name_size, void *buffer, int buffer_size); - -#define MAX_ARRAY_LENGTH 100 - -typedef struct { - int value; // 存储的值 - int arrayIndex; // 数组索引 - int elementIndex; // 元素索引 -} HeapNode; - -// 最小堆的比较函数 -int compare(const void *a, const void *b) { - return ((HeapNode *)a)->value - ((HeapNode *)b)->value; -} - -void heapifyDown(HeapNode *minHeap, int heapSize, int index) { - int smallest = index; - int left = 2 * index + 1; - int right = 2 * index + 2; - - // 比较当前节点与其左子节点 - if (left < heapSize && minHeap[left].value < minHeap[smallest].value) { - smallest = left; - } - - // 比较当前节点与其右子节点 - if (right < heapSize && minHeap[right].value < minHeap[smallest].value) { - smallest = right; - } - - // 如果最小值不是当前节点,则交换并继续下沉 - if (smallest != index) { - HeapNode temp = minHeap[index]; - minHeap[index] = minHeap[smallest]; - minHeap[smallest] = temp; - - // 递归调用下沉操作 - heapifyDown(minHeap, heapSize, smallest); - } -} - -int main(int argc, char* argv[]) { - int id = atoi(argv[1]); - int sorter_num = atoi(argv[2]); - int merger_num = atoi(argv[3]); - printf("merger_%d start!\n", id); - - // access buffer - int array[sorter_num][MAX_ARRAY_LENGTH]; - int index[sorter_num]; - memset(index, 0, sizeof(index)); - for (int i = 0; i < sorter_num; i++) { - char slot_name[20]; - sprintf(slot_name, "merger_%d_%d", i, id); - char *buffer; - int bufferSize = 1000; - buffer = (char *)malloc(bufferSize * sizeof(char)); - if (buffer == NULL) { - perror("malloc error"); - return 1; - } - memset(buffer, 0, bufferSize * sizeof(char)); - buffer[0] = '\0'; // 初始化为空字符串 - access_buffer(slot_name, strlen(slot_name), buffer, bufferSize); - char *ptr = buffer; - int num; - while (sscanf(ptr, "%d", &num) == 1) { - array[i][index[i]] = num; - index[i]++; - // 移动指针到下一个数字 - while (*ptr && *ptr != ' ') { - ptr++; - } - if (*ptr == ' ') { - ptr++; - } - } - free(buffer); - } - - // merge - int result[MAX_ARRAY_LENGTH]; - int resultIndex = 0; - HeapNode *minHeap = (HeapNode *)malloc(sorter_num * sizeof(HeapNode)); - int heapSize = 0; - // 初始化最小堆 - for (int i = 0; i < sorter_num; i++) { - if (index[i] > 0) { // 确保数组非空 - minHeap[heapSize].value = array[i][0]; - minHeap[heapSize].arrayIndex = i; - minHeap[heapSize].elementIndex = 0; - heapSize++; - } - } - // 构建初始最小堆 - // qsort(minHeap, heapSize, sizeof(HeapNode), compare); - // 使用下沉操作调整整个堆以确保最小堆性质 - for (int i = (heapSize - 2) / 2; i >= 0; i--) { - heapifyDown(minHeap, heapSize, i); - } - while (heapSize > 0) { - // 获取最小元素 - HeapNode minNode = minHeap[0]; - result[resultIndex++] = minNode.value; - - // 替换最小值的元素 - if (minNode.elementIndex + 1 < index[minNode.arrayIndex]) { - minNode.elementIndex++; - minNode.value = array[minNode.arrayIndex][minNode.elementIndex]; - // 更新堆 - minHeap[0] = minNode; - // qsort(minHeap, heapSize, sizeof(HeapNode), compare); // 重新构建堆 - } else { - // 如果该数组没有更多元素,则用最后一个元素替换掉 - minHeap[0] = minHeap[--heapSize]; - } - // 执行下沉操作以恢复堆的性质 - heapifyDown(minHeap, heapSize, 0); - } - free(minHeap); - - // rigister mergered array - - char slot_name[20]; - sprintf(slot_name, "checker_%d", id); - int bufferSize = 1000; - char *buffer; - buffer = (char *)malloc(bufferSize * sizeof(char)); - if (buffer == NULL) { - perror("malloc error"); - return 1; - } - memset(buffer, 0, bufferSize * sizeof(char)); - buffer[0] = '\0'; // 初始化为空字符串 - for (int i = 0; i < resultIndex; i++) { - char temp[12]; // 临时缓冲区,注意要足够大以容纳最大整数和一个空格 - snprintf(temp, sizeof(temp), "%d ", result[i]); // 将整数转换为字符串,并加上空格 - strcat(buffer, temp); // 追加到 buffer - } - // 去掉最后一个多余的空格 - buffer[strlen(buffer) - 1] = '\0'; - buffer_register(slot_name, strlen(slot_name), buffer, bufferSize); - free(buffer); - - - printf("merger_%d all finished!\n", id); - return 0; -} \ No newline at end of file diff --git a/user/tinywasm_merger/merger.wasm b/user/tinywasm_merger/merger.wasm deleted file mode 100755 index c6fcf1d9..00000000 Binary files a/user/tinywasm_merger/merger.wasm and /dev/null differ diff --git a/user/tinywasm_merger/src/lib.rs b/user/tinywasm_merger/src/lib.rs deleted file mode 100644 index db0c088e..00000000 --- a/user/tinywasm_merger/src/lib.rs +++ /dev/null @@ -1,74 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -cfg_if::cfg_if! { - if #[cfg(feature = "with_libos")] { - use ms_std::{agent::FaaSFuncResult as Result}; - extern crate alloc; - } else { - type Result = core::result::Result; - use std::collections::BTreeMap; - } -} - -use alloc::{collections::BTreeMap, format, string::{String, ToString}, vec::Vec}; -use ms_std::{args, println, libos::libos}; -use ms_hostcall::types::{OpenFlags, OpenMode}; - -use tinywasm::{Module, Store, ModuleInstance}; -use wasi_api::tinywasm; - -const WASM: &[u8] = include_bytes!("../merger.wasm"); - -lazy_static::lazy_static! { - static ref MUST_OPEN_ROOT: bool = { - libos!(open("/", OpenFlags::empty(), OpenMode::RD)).unwrap(); - true - }; -} - -fn func_body(my_id: &str, sorter_num: u64, merger_num: u64) -> Result<()> { - #[cfg(feature = "log")] - println!("rust: my_id: {:?}, reducer_num: {:?}", my_id, reducer_num); - - let mut wasi_args: Vec = Vec::new(); - wasi_args.push("fake system path!".to_string()); // c语言main第一个参数是系统路径 - wasi_args.push(my_id.to_string()); - wasi_args.push(sorter_num.to_string()); - wasi_args.push(merger_num.to_string()); - - let _open_root = *MUST_OPEN_ROOT; - - let module = Module::parse_bytes(WASM)?; - let mut store = Store::default(); - let imports = wasi_api::import_all()?; - - wasi_api::set_wasi_args(store.id(), wasi_args); - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - let main = instance.exported_func::<(), ()>(&store, "_start")?; - - if let Err(e) = unwinding::panic::catch_unwind(|| main.call(&mut store, ()).unwrap()) { - let msg = format!("{:?}", e); - println!("err msg: {}", msg); - if msg != "normally exit" { - // return Err(); - } - }; - - Ok(().into()) -} - -#[no_mangle] -pub fn main() -> Result<()> { - let my_id = args::get("id").unwrap(); - let sorter_num: u64 = args::get("sorter_num") - .expect("missing arg sorter_num") - .parse() - .unwrap_or_else(|_| panic!("bad arg, sorter_num={}", args::get("sorter_num").unwrap())); - let merger_num: u64 = args::get("merger_num") - .expect("missing arg merger_num") - .parse() - .unwrap_or_else(|_| panic!("bad arg, merger_num={}", args::get("merger_num").unwrap())); - - func_body(my_id, sorter_num, merger_num) -} \ No newline at end of file diff --git a/user/tinywasm_pass_str/Cargo.lock b/user/tinywasm_pass_str/Cargo.lock deleted file mode 100644 index a8a06560..00000000 --- a/user/tinywasm_pass_str/Cargo.lock +++ /dev/null @@ -1,394 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.159" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_pass_str" -version = "0.1.0" -dependencies = [ - "cfg-if", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] diff --git a/user/tinywasm_pass_str/Cargo.toml b/user/tinywasm_pass_str/Cargo.toml deleted file mode 100644 index 64a7352c..00000000 --- a/user/tinywasm_pass_str/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "tinywasm_pass_str" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api", features = [] } - -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] -mpk = ["ms_std/mpk"] - -default = ["with_libos"] diff --git a/user/tinywasm_pass_str/c_app/main.c b/user/tinywasm_pass_str/c_app/main.c deleted file mode 100644 index b738b157..00000000 --- a/user/tinywasm_pass_str/c_app/main.c +++ /dev/null @@ -1,38 +0,0 @@ -#include -#include -#include - -__attribute__((import_module("env"), import_name("buffer_register"))) void buffer_register(void *slot_name, int name_size, void *buffer, int buffer_size); - -int main() -{ - int bufferSize = 10; - char *buffer; - - buffer = (char *)malloc(bufferSize * sizeof(char)); - - if (buffer == NULL) - { - printf("alloc mem failed\n"); - return 1; - } - - // printf("alloc mem.\n"); - for (int i = 0; i < bufferSize; i++) - { - buffer[i] = 'A' + i; - } - - char *slot_name = "slot_1"; - - buffer_register(slot_name, strlen(slot_name), buffer, bufferSize); - - // printf("c_app pass_str buffer: "); - // for (int i = 0; i < bufferSize; i++) - // { - // printf("%c ", buffer[i]); - // } - // printf("\n"); - - // free(buffer); -} \ No newline at end of file diff --git a/user/tinywasm_pass_str/main.wasm b/user/tinywasm_pass_str/main.wasm deleted file mode 100755 index d7b2a9ec..00000000 Binary files a/user/tinywasm_pass_str/main.wasm and /dev/null differ diff --git a/user/tinywasm_pass_str/src/lib.rs b/user/tinywasm_pass_str/src/lib.rs deleted file mode 100644 index 5c68f3c7..00000000 --- a/user/tinywasm_pass_str/src/lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -use alloc::format; -use ms_std::agent::FaaSFuncResult as Result; -extern crate alloc; -use wasi_api::tinywasm::{Module, ModuleInstance, Store}; - -#[no_mangle] -pub fn main() -> Result<()> { - let module = Module::parse_bytes(include_bytes!("../main.wasm"))?; - - let mut store = Store::default(); - let imports = wasi_api::import_all().map_err(|e| format!("import func err: {e}"))?; - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - // assert_eq!(add.call(&mut store, (20))?, 3); - let _result = instance.start(&mut store); - // println!("{:?}", unwinding::panic::catch_unwind(|| result)); - - Ok(().into()) -} diff --git a/user/tinywasm_pass_str_cpython/Cargo.lock b/user/tinywasm_pass_str_cpython/Cargo.lock deleted file mode 100644 index d0f9720e..00000000 --- a/user/tinywasm_pass_str_cpython/Cargo.lock +++ /dev/null @@ -1,394 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 2.0.77", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.77", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_pass_str_cpython" -version = "0.1.0" -dependencies = [ - "cfg-if", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.77", -] diff --git a/user/tinywasm_pass_str_cpython/Cargo.toml b/user/tinywasm_pass_str_cpython/Cargo.toml deleted file mode 100755 index 59cc84af..00000000 --- a/user/tinywasm_pass_str_cpython/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "tinywasm_pass_str_cpython" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api" } - -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] - -default = ["with_libos"] diff --git a/user/tinywasm_pass_str_cpython/src/lib.rs b/user/tinywasm_pass_str_cpython/src/lib.rs deleted file mode 100755 index 29f096cb..00000000 --- a/user/tinywasm_pass_str_cpython/src/lib.rs +++ /dev/null @@ -1,52 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -cfg_if::cfg_if! { - if #[cfg(feature = "with_libos")] { - use ms_std::{agent::FaaSFuncResult as Result}; - extern crate alloc; - use alloc::{collections::BTreeMap, string::String}; - } else { - type Result = core::result::Result; - use std::collections::BTreeMap; - } -} - -use alloc::{string::ToString, vec::Vec}; -use ms_std::{ - libos::libos, - println, - time::{SystemTime, UNIX_EPOCH}, -}; -use tinywasm::{Module, Store}; -use wasi_api::tinywasm::{self, ModuleInstance}; -use ms_hostcall::types::{OpenFlags, OpenMode}; - -const WASM: &[u8] = include_bytes!("../python.wasm"); - -#[no_mangle] -pub fn main(_args: &BTreeMap) -> Result<()> { - libos!(open("/", OpenFlags::empty(), OpenMode::RD))?; - let mut wasi_args: Vec = Vec::new(); - wasi_args.push("python.wasm".to_string()); - wasi_args.push("/wasm_bench/pass_str.py".to_string()); - - let module = Module::parse_bytes(WASM)?; - let mut store = Store::default(); - let imports = wasi_api::import_all()?; - - wasi_api::set_wasi_args(store.id(), wasi_args); - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - - let _result = unwinding::panic::catch_unwind(|| instance.start(&mut store)); - - // println!("before _start"); - - // let main = instance.exported_func::<(), ()>(&store, "_start")?; - - // let _result = unwinding::panic::catch_unwind(|| main.call(&mut store, ()).unwrap()); - println!("pass.rs: result: {:?}", _result); - - core::mem::forget(store); - Ok(().into()) -} diff --git a/user/tinywasm_py/Cargo.lock b/user/tinywasm_py/Cargo.lock deleted file mode 100644 index d87cde34..00000000 --- a/user/tinywasm_py/Cargo.lock +++ /dev/null @@ -1,394 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 2.0.77", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.77", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_py" -version = "0.1.0" -dependencies = [ - "cfg-if", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.77", -] diff --git a/user/tinywasm_py/Cargo.toml b/user/tinywasm_py/Cargo.toml deleted file mode 100755 index f041da60..00000000 --- a/user/tinywasm_py/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "tinywasm_py" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api" } - -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] -mpk = ["ms_std/mpk"] - -default = ["with_libos"] diff --git a/user/tinywasm_py/src/lib.rs b/user/tinywasm_py/src/lib.rs deleted file mode 100755 index 26a2b291..00000000 --- a/user/tinywasm_py/src/lib.rs +++ /dev/null @@ -1,40 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -cfg_if::cfg_if! { - if #[cfg(feature = "with_libos")] { - use ms_std::{agent::FaaSFuncResult as Result}; - extern crate alloc; - use alloc::{string::{ToString, String}, vec::Vec}; - } else { - type Result = core::result::Result; - } -} - -use ms_std::{ - println, - time::{SystemTime, UNIX_EPOCH}, -}; -use tinywasm::{Module, ModuleInstance, Store}; -use wasi_api::tinywasm; - -const WASM: &[u8] = include_bytes!("../rustpython.wasm"); - -#[no_mangle] -pub fn main() -> Result<()> { - let module = Module::parse_bytes(WASM)?; - let mut store = Store::default(); - let imports = wasi_api::import_all()?; - - let wasi_args: Vec = Vec::from(["fake system path!".to_string()]); - wasi_api::set_wasi_args(store.id(), wasi_args); - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - let main = instance.exported_func::<(), ()>(&store, "_start")?; - - let _start_time = SystemTime::now().duration_since(UNIX_EPOCH).as_millis(); - - let result = unwinding::panic::catch_unwind(|| main.call(&mut store, ()).unwrap()); - println!("result: {:?}", result); - - Ok(().into()) -} diff --git a/user/tinywasm_recv_str/Cargo.lock b/user/tinywasm_recv_str/Cargo.lock deleted file mode 100644 index 34a9c62d..00000000 --- a/user/tinywasm_recv_str/Cargo.lock +++ /dev/null @@ -1,394 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.159" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_recv_str" -version = "0.1.0" -dependencies = [ - "cfg-if", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] diff --git a/user/tinywasm_recv_str/Cargo.toml b/user/tinywasm_recv_str/Cargo.toml deleted file mode 100644 index f9452738..00000000 --- a/user/tinywasm_recv_str/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "tinywasm_recv_str" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api", features = [] } - -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] -mpk = ["ms_std/mpk"] - -default = ["with_libos"] diff --git a/user/tinywasm_recv_str/c_app/main.c b/user/tinywasm_recv_str/c_app/main.c deleted file mode 100644 index 9e76f1c5..00000000 --- a/user/tinywasm_recv_str/c_app/main.c +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include -#include - -__attribute__((import_module("env"), import_name("access_buffer"))) void access_buffer(void *slot_name, int name_size, void *buffer, int buffer_size); - -int main() -{ - int bufferSize = 10; - char *buffer; - - buffer = (char *)malloc(bufferSize * sizeof(char)); - - if (buffer == NULL) - { - printf("alloc mem failed\n"); - return 1; - } - - printf("alloc mem\n"); - char *slot_name = "slot_1"; - access_buffer(slot_name, strlen(slot_name), buffer, bufferSize); - - // for (int i = 0; i < bufferSize; i++) - // { - // buffer[i] = 'A' + i; - // } - - printf("c_app recv_str buffer: "); - for (int i = 0; i < bufferSize; i++) - { - printf("%c ", buffer[i]); - } - printf("\n"); - - // free(buffer); -} \ No newline at end of file diff --git a/user/tinywasm_recv_str/main.wasm b/user/tinywasm_recv_str/main.wasm deleted file mode 100755 index 88be33da..00000000 Binary files a/user/tinywasm_recv_str/main.wasm and /dev/null differ diff --git a/user/tinywasm_recv_str/src/lib.rs b/user/tinywasm_recv_str/src/lib.rs deleted file mode 100644 index b8f6c6f9..00000000 --- a/user/tinywasm_recv_str/src/lib.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -use alloc::format; -use ms_std::agent::FaaSFuncResult as Result; -extern crate alloc; -use wasi_api::tinywasm::{Module, ModuleInstance, Store}; - -#[no_mangle] -pub fn main() -> Result<()> { - let module = Module::parse_bytes(include_bytes!("../main.wasm"))?; - - let mut store = Store::default(); - let imports = wasi_api::import_all().map_err(|e| format!("import func err: {e}"))?; - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - // assert_eq!(add.call(&mut store, (20))?, 3); - let _result = unwinding::panic::catch_unwind(|| instance.start(&mut store)); - // println!("{:?}", result); - - Ok(().into()) -} diff --git a/user/tinywasm_recv_str_cpython/Cargo.lock b/user/tinywasm_recv_str_cpython/Cargo.lock deleted file mode 100644 index fce022fc..00000000 --- a/user/tinywasm_recv_str_cpython/Cargo.lock +++ /dev/null @@ -1,394 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 2.0.77", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.77", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.86" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.37" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.77" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_recv_str_cpython" -version = "0.1.0" -dependencies = [ - "cfg-if", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.77", -] diff --git a/user/tinywasm_recv_str_cpython/Cargo.toml b/user/tinywasm_recv_str_cpython/Cargo.toml deleted file mode 100755 index 2d49038b..00000000 --- a/user/tinywasm_recv_str_cpython/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "tinywasm_recv_str_cpython" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api" } - -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] - -default = ["with_libos"] diff --git a/user/tinywasm_recv_str_cpython/src/lib.rs b/user/tinywasm_recv_str_cpython/src/lib.rs deleted file mode 100755 index cdbcce29..00000000 --- a/user/tinywasm_recv_str_cpython/src/lib.rs +++ /dev/null @@ -1,47 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -cfg_if::cfg_if! { - if #[cfg(feature = "with_libos")] { - use ms_std::{agent::FaaSFuncResult as Result}; - extern crate alloc; - use alloc::{collections::BTreeMap, string::String}; - } else { - type Result = core::result::Result; - use std::collections::BTreeMap; - } -} - -use alloc::{string::ToString, vec::Vec}; -use ms_std::{ - libos::libos, - println, - time::{SystemTime, UNIX_EPOCH}, -}; -use tinywasm::{Module, Store}; -use wasi_api::tinywasm::{self, ModuleInstance}; -use ms_hostcall::types::{OpenFlags, OpenMode}; - -const WASM: &[u8] = include_bytes!("../python.wasm"); - -#[no_mangle] -pub fn main(_args: &BTreeMap) -> Result<()> { - libos!(open("/", OpenFlags::empty(), OpenMode::RD))?; - let mut wasi_args: Vec = Vec::new(); - wasi_args.push("python.wasm".to_string()); - wasi_args.push("/wasm_bench/recv_str.py".to_string()); - let module = Module::parse_bytes(WASM)?; - let mut store = Store::default(); - let imports = wasi_api::import_all()?; - - wasi_api::set_wasi_args(store.id(), wasi_args); - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - let _result = unwinding::panic::catch_unwind(|| instance.start(&mut store)); - - // let main = instance.exported_func::<(), ()>(&store, "_start")?; - - // let _result = unwinding::panic::catch_unwind(|| main.call(&mut store, ()).unwrap()); - println!("recv.rs: result: {:?}", _result); - - Ok(().into()) -} diff --git a/user/tinywasm_reducer/Cargo.lock b/user/tinywasm_reducer/Cargo.lock deleted file mode 100644 index 23416dde..00000000 --- a/user/tinywasm_reducer/Cargo.lock +++ /dev/null @@ -1,395 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_reducer" -version = "0.1.0" -dependencies = [ - "cfg-if", - "lazy_static", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] diff --git a/user/tinywasm_reducer/Cargo.toml b/user/tinywasm_reducer/Cargo.toml deleted file mode 100644 index b63f8ab1..00000000 --- a/user/tinywasm_reducer/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "tinywasm_reducer" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api" } - -lazy_static = { version = "1.5.0", features = ["spin_no_std"] } -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] -mpk = ["ms_std/mpk"] -default = ["with_libos"] diff --git a/user/tinywasm_reducer/reducer.c b/user/tinywasm_reducer/reducer.c deleted file mode 100644 index aaba50c7..00000000 --- a/user/tinywasm_reducer/reducer.c +++ /dev/null @@ -1,83 +0,0 @@ -#include -#include -#include -#include -#define MAX_WORD_LENGTH 100 -#define MAX_WORDS 1000 -#define MAX_SLOT_NUM 100 -#define MAX_BUFFER_SIZE 8000 - -__attribute__((import_module("env"), import_name("access_buffer"))) void access_buffer(void *slot_name, int name_size, void *buffer, int buffer_size); - -void to_lowercase(char *str) { - for (int i = 0; str[i]; i++) { - str[i] = tolower(str[i]); - } -} -int main(int argc, char* argv[]) { - int id = atoi(argv[1]); - int mapper_num = atoi(argv[2]); - printf("reducer.c recieve: id: %d, mapper_num: %d\n", id, mapper_num); - - char *slot_name[MAX_SLOT_NUM]; - char *buffer[MAX_SLOT_NUM]; - char slot[20]; - int bufferSize = MAX_BUFFER_SIZE; - int slot_num = mapper_num; - - printf("access start!\n"); - - for (int i = 0; i < slot_num; ++i) { - sprintf(slot, "buffer_%d_%d", id, i); - slot_name[i] = strdup(slot); - buffer[i] = (char *)malloc(bufferSize * sizeof(char)); - if (buffer == NULL) { - printf("alloc mem failed\n"); - return 1; - } - access_buffer(slot_name[i], strlen(slot_name[i]), buffer[i], bufferSize); - } - printf("access success!\n"); - - int count[MAX_WORDS] = {0}; - char *words[MAX_WORDS]; - char word[MAX_WORD_LENGTH]; - int word_index = 0; - - for (int i = 0; i < slot_num; i++) { - char *line = strtok(buffer[i], "\n"); - while (line != NULL) { - int num = 0; - sscanf(line, "%[^:]: %d", word, &num); // 解析每一行 - to_lowercase(word); - int found = 0; - for (int i = 0; i < word_index; i++) { - if (strcmp(words[i], word) == 0) { - found = 1; - count[i] += num; - break; - } - } - if (!found) { - words[word_index] = strdup(word); - count[word_index] += num; - word_index++; - } - line = strtok(NULL, "\n"); - } - } - - printf("reducer_%d read success!\n", id); - - char output_file[30]; - sprintf(output_file, "reducer_%d.txt", id); - FILE *output = fopen(output_file, "w"); - for (int i = 0; i < word_index; i++) { - fprintf(output, "%s %d\n", words[i], count[i]); - free(words[i]); - } - fclose(output); - - printf("reducer_%d finished!\n", id); - return 0; -} \ No newline at end of file diff --git a/user/tinywasm_reducer/reducer.wasm b/user/tinywasm_reducer/reducer.wasm deleted file mode 100755 index 5b09bfb6..00000000 Binary files a/user/tinywasm_reducer/reducer.wasm and /dev/null differ diff --git a/user/tinywasm_reducer/src/lib.rs b/user/tinywasm_reducer/src/lib.rs deleted file mode 100644 index 87bff5c8..00000000 --- a/user/tinywasm_reducer/src/lib.rs +++ /dev/null @@ -1,76 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -cfg_if::cfg_if! { - if #[cfg(feature = "with_libos")] { - use ms_std::{agent::FaaSFuncResult as Result}; - extern crate alloc; - use alloc::{string::String}; - } else { - type Result = core::result::Result; - use std::collections::BTreeMap; - } -} - -use alloc::{format, string::ToString, vec::Vec}; -use ms_hostcall::types::{OpenFlags, OpenMode}; -use ms_std::{args, libos::libos, println}; - -use tinywasm::{Module, ModuleInstance, Store}; -use wasi_api::tinywasm; - -const WASM: &[u8] = include_bytes!("../reducer.wasm"); - -lazy_static::lazy_static! { - static ref MUST_OPEN_ROOT: bool = { - libos!(open("/", OpenFlags::empty(), OpenMode::RD)).unwrap(); - true - }; -} - -fn func_body(my_id: &str, mapper_num: u64) -> Result<()> { - #[cfg(feature = "log")] - println!("rust: my_id: {:?}, mapper_num: {:?}", my_id, mapper_num); - - let wasi_args: Vec = Vec::from([ - "fake system path!".to_string(), - my_id.to_string(), - mapper_num.to_string(), - ]); - - let _open_root = *MUST_OPEN_ROOT; - - let module = Module::parse_bytes(WASM)?; - let mut store = Store::default(); - let imports = wasi_api::import_all()?; - - wasi_api::set_wasi_args(store.id(), wasi_args); - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - - let mut mem = instance.exported_memory_mut(&mut store, "memory")?; - mem.grow(3000); - drop(mem); - - let main = instance.exported_func::<(), ()>(&store, "_start")?; - - if let Err(e) = unwinding::panic::catch_unwind(|| main.call(&mut store, ()).unwrap()) { - let msg = format!("{:?}", e); - println!("err msg: {}", msg); - if msg != "normally exit" { - // return Err(); - } - }; - - Ok(().into()) -} - -#[no_mangle] -pub fn main() -> Result<()> { - let my_id = args::get("id").unwrap(); - let mapper_num: u64 = args::get("mapper_num") - .expect("missing arg mapper_num") - .parse() - .unwrap_or_else(|_| panic!("bad arg, mapper_num={}", args::get("mapper_num").unwrap())); - - func_body(my_id, mapper_num) -} diff --git a/user/tinywasm_sorter/Cargo.lock b/user/tinywasm_sorter/Cargo.lock deleted file mode 100644 index 7a946b0c..00000000 --- a/user/tinywasm_sorter/Cargo.lock +++ /dev/null @@ -1,395 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_sorter" -version = "0.1.0" -dependencies = [ - "cfg-if", - "lazy_static", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] diff --git a/user/tinywasm_sorter/Cargo.toml b/user/tinywasm_sorter/Cargo.toml deleted file mode 100644 index 6007669f..00000000 --- a/user/tinywasm_sorter/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "tinywasm_sorter" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api" } - -lazy_static = { version = "1.5.0", features = ["spin_no_std"] } -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] -mpk = ["ms_std/mpk"] -default = ["with_libos"] \ No newline at end of file diff --git a/user/tinywasm_sorter/sorter.c b/user/tinywasm_sorter/sorter.c deleted file mode 100644 index 4f88932e..00000000 --- a/user/tinywasm_sorter/sorter.c +++ /dev/null @@ -1,121 +0,0 @@ -#include -#include -#include - -__attribute__((import_module("env"), import_name("buffer_register"))) void buffer_register(void *slot_name, int name_size, void *buffer, int buffer_size); - -#define MAX_ARRAY_LENGTH 100 - -// 比较函数,用于 qsort -int compare(const void *a, const void *b) { - return (*(int *)a - *(int *)b); // 升序排序 -} - -int main(int argc, char* argv[]) { - int id = atoi(argv[1]); - int sorter_num = atoi(argv[2]); - int merger_num = atoi(argv[3]); - printf("sorter_%d start!\n", id); - - char input_file[30]; - printf("sorter_%d file define!\n", id); - sprintf(input_file, "sort_data_%d.txt", id); - printf("sorter_%d fopen start!\n", id); - FILE *file = fopen(input_file, "r"); - if (!file) { - perror("Failed to open input file\n"); - exit(EXIT_FAILURE); - } - printf("sorter_%d fopen finished!\n", id); - int array[MAX_ARRAY_LENGTH]; - // char number[20]; - int index = 0; - // while (fscanf(file, "%s", number) != EOF) { - // array[index] = atoi(number); - // // printf("array[%d]: %d\n", index, array[index]); - // index++; - // } - int ch = fgetc(file), x = 0; - for (; ch != '\n' && ch != EOF; ch = fgetc(file)) { - if (ch == ',') array[index++] = x, x = 0; - else x = x * 10 + ch - '0'; - } - array[index++] = x; - - - // while (~fscanf(file, "%d,", &array[index])) { - // index++; - // if (index >= MAX_ARRAY_LENGTH) { - // break; - // } - // int ch = fgetc(file); - // if (ch != ',') { - // ungetc(ch, file); // 如果不是逗号,放回字符流,跳出循环 - // break; - // } - // } - printf("sorter_%d read finished!\n", id); - // printf("index: %d\n", index); - fclose(file); - qsort(array, index, sizeof(int), compare); - - printf("sorter_%d sort finished!\n", id); - - if (id == 0) { - int pivot[merger_num-1]; - for (int i = 0; i < merger_num-1; i++) { - int idx = (i+1) * index / merger_num; - pivot[i] = array[idx]; - } - for (int k = 0; k < sorter_num; k++) { - char slot_name[20]; - sprintf(slot_name, "pivot_%d", k); - // printf("pivotname: %s\n", slot_name); - int bufferSize = 1000; - char *buffer; - buffer = (char *)malloc(bufferSize * sizeof(char)); - if (buffer == NULL) { - perror("malloc error"); - return 1; - } - memset(buffer, 0, bufferSize * sizeof(char)); - buffer[0] = '\0'; // 初始化为空字符串 - for (int i = 0; i < merger_num-1; i++) { - char temp[12]; // 临时缓冲区,注意要足够大以容纳最大整数和一个空格 - snprintf(temp, sizeof(temp), "%d ", pivot[i]); // 将整数转换为字符串,并加上空格 - strcat(buffer, temp); // 追加到 buffer - } - // 去掉最后一个多余的空格 - buffer[strlen(buffer) - 1] = '\0'; - buffer_register(slot_name, strlen(slot_name), buffer, bufferSize); - free(buffer); - } - } - - // printf("sorter_%d pivot finished!\n", id); - - char slot_name[20]; - sprintf(slot_name, "sorter_%d", id); - char *buffer; - int bufferSize = 1000; - // printf("buffersize: %d\n", bufferSize); - buffer = (char *)malloc(bufferSize * sizeof(char)); - if (buffer == NULL) { - perror("malloc error"); - return 1; - } - memset(buffer, 0, bufferSize * sizeof(char)); - buffer[0] = '\0'; // 初始化为空字符串 - for (int i = 0; i < index; i++) { - char temp[12]; // 临时缓冲区,注意要足够大以容纳最大整数和一个空格 - snprintf(temp, sizeof(temp), "%d ", array[i]); // 将整数转换为字符串,并加上空格 - strcat(buffer, temp); // 追加到 buffer - } - // 去掉最后一个多余的空格 - buffer[strlen(buffer) - 1] = '\0'; - - buffer_register(slot_name, strlen(slot_name), buffer, bufferSize); - free(buffer); - printf("sorter_%d all finished!\n", id); - return 0; -} \ No newline at end of file diff --git a/user/tinywasm_sorter/sorter.wasm b/user/tinywasm_sorter/sorter.wasm deleted file mode 100755 index 37d9974d..00000000 Binary files a/user/tinywasm_sorter/sorter.wasm and /dev/null differ diff --git a/user/tinywasm_sorter/src/lib.rs b/user/tinywasm_sorter/src/lib.rs deleted file mode 100644 index 07a06d4c..00000000 --- a/user/tinywasm_sorter/src/lib.rs +++ /dev/null @@ -1,94 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -cfg_if::cfg_if! { - if #[cfg(feature = "with_libos")] { - use ms_std::{agent::FaaSFuncResult as Result}; - extern crate alloc; - } else { - type Result = core::result::Result; - use std::collections::BTreeMap; - } -} - -use alloc::{collections::BTreeMap, format, string::{String, ToString}, vec::Vec}; -use ms_std::{args, println, libos::libos}; -use ms_hostcall::types::{OpenFlags, OpenMode}; - -use tinywasm::{Module, Store, ModuleInstance}; -use wasi_api::tinywasm; - -const WASM: &[u8] = include_bytes!("../sorter.wasm"); - -lazy_static::lazy_static! { - static ref MUST_OPEN_ROOT: bool = { - libos!(open("/", OpenFlags::empty(), OpenMode::RD)).unwrap(); - true - }; -} - -fn func_body(my_id: &str, sorter_num: u64, merger_num: u64) -> Result<()> { - #[cfg(feature = "log")] - println!("rust: my_id: {:?}, reducer_num: {:?}", my_id, reducer_num); - - let mut wasi_args: Vec = Vec::new(); - wasi_args.push("fake system path!".to_string()); // c语言main第一个参数是系统路径 - wasi_args.push(my_id.to_string()); - wasi_args.push(sorter_num.to_string()); - wasi_args.push(merger_num.to_string()); - - let _open_root = *MUST_OPEN_ROOT; - - // let data_fd = libos!(open(&format!("little_fake_data_{}.txt", my_id), OpenFlags::O_CREAT, OpenMode::RDWR))? as u32; - // match my_id { - // "0" => { - // libos!(write(data_fd, b"34 12 7 26 1 19 30 3 38 9\n"))?; - // }, - // "1" => { - // libos!(write(data_fd, b"0 24 22 14 36 17 15 32 6 4\n"))?; - // }, - // "2" => { - // libos!(write(data_fd, b"20 37 8 35 31 29 25 5 10 11\n"))?; - // }, - // "3" => { - // libos!(write(data_fd, b"18 33 2 16 39 13 28 27 21 23\n"))?; - // }, - // _ => { - // libos!(write(data_fd, b"7 4 8 5 1 3 9 6 2\n"))?; - // } - // } - // libos!(close(data_fd))?; - - let module = Module::parse_bytes(WASM)?; - let mut store = Store::default(); - let imports = wasi_api::import_all()?; - - wasi_api::set_wasi_args(store.id(), wasi_args); - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - let main = instance.exported_func::<(), ()>(&store, "_start")?; - - if let Err(e) = unwinding::panic::catch_unwind(|| main.call(&mut store, ()).unwrap()) { - let msg = format!("{:?}", e); - println!("err msg: {}", msg); - if msg != "normally exit" { - // return Err(); - } - }; - - Ok(().into()) -} - -#[no_mangle] -pub fn main() -> Result<()> { - let my_id = args::get("id").unwrap(); - let sorter_num: u64 = args::get("sorter_num") - .expect("missing arg sorter_num") - .parse() - .unwrap_or_else(|_| panic!("bad arg, sorter_num={}", args::get("sorter_num").unwrap())); - let merger_num: u64 = args::get("merger_num") - .expect("missing arg merger_num") - .parse() - .unwrap_or_else(|_| panic!("bad arg, merger_num={}", args::get("merger_num").unwrap())); - - func_body(my_id, sorter_num, merger_num) -} \ No newline at end of file diff --git a/user/tinywasm_spliter/Cargo.lock b/user/tinywasm_spliter/Cargo.lock deleted file mode 100644 index 90554a47..00000000 --- a/user/tinywasm_spliter/Cargo.lock +++ /dev/null @@ -1,395 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_spliter" -version = "0.1.0" -dependencies = [ - "cfg-if", - "lazy_static", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] diff --git a/user/tinywasm_spliter/Cargo.toml b/user/tinywasm_spliter/Cargo.toml deleted file mode 100644 index 1ddff1d2..00000000 --- a/user/tinywasm_spliter/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "tinywasm_spliter" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api" } - -lazy_static = { version = "1.5.0", features = ["spin_no_std"] } -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] -mpk = ["ms_std/mpk"] -default = ["with_libos"] \ No newline at end of file diff --git a/user/tinywasm_spliter/spliter.c b/user/tinywasm_spliter/spliter.c deleted file mode 100644 index 7e36f7fb..00000000 --- a/user/tinywasm_spliter/spliter.c +++ /dev/null @@ -1,120 +0,0 @@ -#include -#include -#include - -__attribute__((import_module("env"), import_name("buffer_register"))) void buffer_register(void *slot_name, int name_size, void *buffer, int buffer_size); -__attribute__((import_module("env"), import_name("access_buffer"))) void access_buffer(void *slot_name, int name_size, void *buffer, int buffer_size); - -#define MAX_ARRAY_LENGTH 100 - -int main(int argc, char* argv[]) { - int id = atoi(argv[1]); - int sorter_num = atoi(argv[2]); - int merger_num = atoi(argv[3]); - printf("spliter_%d start!\n", id); - char slot_name[20]; - int bufferSize = 1000; - char *ptr; - int num; - - // access pivot buffer - sprintf(slot_name, "pivot_%d", id); - char *pivot_buffer; - pivot_buffer = (char *)malloc(bufferSize * sizeof(char)); - if (pivot_buffer == NULL) { - perror("malloc error"); - return 1; - } - memset(pivot_buffer, 0, bufferSize * sizeof(char)); - pivot_buffer[0] = '\0'; // 初始化为空字符串 - access_buffer(slot_name, strlen(slot_name), pivot_buffer, bufferSize); - int pivot_array[merger_num-1]; - int pivot_index = 0; - ptr = pivot_buffer; - printf("pivot_buffer: %s", pivot_buffer); - while (sscanf(ptr, "%d", &num) == 1) { - pivot_array[pivot_index] = num; - pivot_index++; - // 移动指针到下一个数字 - while (*ptr && *ptr != ' ') { - ptr++; - } - if (*ptr == ' ') { - ptr++; - } - } - free(pivot_buffer); - printf("spliter_%d pivot access finished!\n", id); - - // access sorter buffer - sprintf(slot_name, "sorter_%d", id); - char *sorter_buffer; - sorter_buffer = (char *)malloc(bufferSize * sizeof(char)); - if (sorter_buffer == NULL) { - perror("malloc error"); - return 1; - } - memset(sorter_buffer, 0, bufferSize * sizeof(char)); - sorter_buffer[0] = '\0'; // 初始化为空字符串 - access_buffer(slot_name, strlen(slot_name), sorter_buffer, bufferSize); - int sorter_array[MAX_ARRAY_LENGTH]; - int sorter_index = 0; - ptr = sorter_buffer; - while (sscanf(ptr, "%d", &num) == 1) { - sorter_array[sorter_index] = num; - sorter_index++; - // 移动指针到下一个数字 - while (*ptr && *ptr != ' ') { - ptr++; - } - if (*ptr == ' ') { - ptr++; - } - } - free(sorter_buffer); - printf("spliter_%d sorter access finished!\n", id); - - // trans to merger - int array[merger_num][MAX_ARRAY_LENGTH]; - int index[merger_num]; - memset(index, 0, sizeof(index)); - for (int i = 0; i < sorter_index; i++) { - int row = 0; - for (int j = 0; j < pivot_index; j++) { - if (sorter_array[i] >= pivot_array[j]) { - row++; - } else { - break; - } - } - array[row][index[row]] = sorter_array[i]; - index[row]++; - } - - for (int i = 0; i < merger_num; i++) { - char slot_name[20]; - sprintf(slot_name, "merger_%d_%d", id, i); - char *buffer; - int bufferSize = 1000; - // printf("buffersize: %d\n", bufferSize); - buffer = (char *)malloc(bufferSize * sizeof(char)); - if (buffer == NULL) { - perror("malloc error"); - return 1; - } - memset(buffer, 0, bufferSize * sizeof(char)); - buffer[0] = '\0'; // 初始化为空字符串 - for (int j = 0; j < index[i]; j++) { - char temp[12]; // 临时缓冲区,注意要足够大以容纳最大整数和一个空格 - snprintf(temp, sizeof(temp), "%d ", array[i][j]); // 将整数转换为字符串,并加上空格 - strcat(buffer, temp); // 追加到 buffer - } - // 去掉最后一个多余的空格 - buffer[strlen(buffer) - 1] = '\0'; - buffer_register(slot_name, strlen(slot_name), buffer, bufferSize); - free(buffer); - } - - printf("spliter_%d all finished!\n", id); - return 0; -} \ No newline at end of file diff --git a/user/tinywasm_spliter/spliter.wasm b/user/tinywasm_spliter/spliter.wasm deleted file mode 100755 index 44169f0a..00000000 Binary files a/user/tinywasm_spliter/spliter.wasm and /dev/null differ diff --git a/user/tinywasm_spliter/src/lib.rs b/user/tinywasm_spliter/src/lib.rs deleted file mode 100644 index 600b7df9..00000000 --- a/user/tinywasm_spliter/src/lib.rs +++ /dev/null @@ -1,74 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -cfg_if::cfg_if! { - if #[cfg(feature = "with_libos")] { - use ms_std::{agent::FaaSFuncResult as Result}; - extern crate alloc; - } else { - type Result = core::result::Result; - use std::collections::BTreeMap; - } -} - -use alloc::{collections::BTreeMap, format, string::{String, ToString}, vec::Vec}; -use ms_std::{args, println, libos::libos}; -use ms_hostcall::types::{OpenFlags, OpenMode}; - -use tinywasm::{Module, Store, ModuleInstance}; -use wasi_api::tinywasm; - -const WASM: &[u8] = include_bytes!("../spliter.wasm"); - -lazy_static::lazy_static! { - static ref MUST_OPEN_ROOT: bool = { - libos!(open("/", OpenFlags::empty(), OpenMode::RD)).unwrap(); - true - }; -} - -fn func_body(my_id: &str, sorter_num: u64, merger_num: u64) -> Result<()> { - #[cfg(feature = "log")] - println!("rust: my_id: {:?}, reducer_num: {:?}", my_id, reducer_num); - - let mut wasi_args: Vec = Vec::new(); - wasi_args.push("fake system path!".to_string()); // c语言main第一个参数是系统路径 - wasi_args.push(my_id.to_string()); - wasi_args.push(sorter_num.to_string()); - wasi_args.push(merger_num.to_string()); - - let _open_root = *MUST_OPEN_ROOT; - - let module = Module::parse_bytes(WASM)?; - let mut store = Store::default(); - let imports = wasi_api::import_all()?; - - wasi_api::set_wasi_args(store.id(), wasi_args); - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - let main = instance.exported_func::<(), ()>(&store, "_start")?; - - if let Err(e) = unwinding::panic::catch_unwind(|| main.call(&mut store, ()).unwrap()) { - let msg = format!("{:?}", e); - println!("err msg: {}", msg); - if msg != "normally exit" { - // return Err(); - } - }; - - Ok(().into()) -} - -#[no_mangle] -pub fn main() -> Result<()> { - let my_id = args::get("id").unwrap(); - let sorter_num: u64 = args::get("sorter_num") - .expect("missing arg sorter_num") - .parse() - .unwrap_or_else(|_| panic!("bad arg, sorter_num={}", args::get("sorter_num").unwrap())); - let merger_num: u64 = args::get("merger_num") - .expect("missing arg merger_num") - .parse() - .unwrap_or_else(|_| panic!("bad arg, merger_num={}", args::get("merger_num").unwrap())); - - func_body(my_id, sorter_num, merger_num) -} \ No newline at end of file diff --git a/user/tinywasm_u/Cargo.lock b/user/tinywasm_u/Cargo.lock deleted file mode 100644 index 50b27b2c..00000000 --- a/user/tinywasm_u/Cargo.lock +++ /dev/null @@ -1,370 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_u" -version = "0.1.0" -dependencies = [ - "cfg-if", - "ms_hostcall", - "ms_std", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] diff --git a/user/tinywasm_u/Cargo.toml b/user/tinywasm_u/Cargo.toml deleted file mode 100644 index 492418bd..00000000 --- a/user/tinywasm_u/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "tinywasm_u" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "panic_def", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api" } - -cfg-if = "1.0.0" -# wat = { version = "=1.0.88" } - - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] -mpk = ["ms_std/mpk"] - -default = ["with_libos"] diff --git a/user/tinywasm_u/add.wasm b/user/tinywasm_u/add.wasm deleted file mode 100644 index 92e34327..00000000 Binary files a/user/tinywasm_u/add.wasm and /dev/null differ diff --git a/user/tinywasm_u/fibonacci.wasm b/user/tinywasm_u/fibonacci.wasm deleted file mode 100755 index 5297f10a..00000000 Binary files a/user/tinywasm_u/fibonacci.wasm and /dev/null differ diff --git a/user/tinywasm_u/src/lib.rs b/user/tinywasm_u/src/lib.rs deleted file mode 100644 index ee142ff3..00000000 --- a/user/tinywasm_u/src/lib.rs +++ /dev/null @@ -1,27 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -cfg_if::cfg_if! { - if #[cfg(feature = "with_libos")] { - use ms_std::{agent::FaaSFuncResult as Result, println}; - extern crate alloc; - } else { - type Result = core::result::Result; - use std::collections::BTreeMap; - } -} - -use wasi_api::tinywasm::{Module, Store, ModuleInstance}; - -const WASM: &[u8] = include_bytes!("../fibonacci.wasm"); - -#[no_mangle] -pub fn main() -> Result<()> { - let module = Module::parse_bytes(WASM)?; - let mut store = Store::default(); - let instance = ModuleInstance::instantiate(&mut store, module, None)?; - let fib = instance.exported_func::(&store, "fibonacci_recursive")?; - // assert_eq!(add.call(&mut store, (20))?, 3); - println!("fib(20)={}", fib.call(&mut store, 20)?); - - Ok(().into()) -} diff --git a/user/tinywasm_write/Cargo.lock b/user/tinywasm_write/Cargo.lock deleted file mode 100644 index 0cf9c926..00000000 --- a/user/tinywasm_write/Cargo.lock +++ /dev/null @@ -1,394 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "2.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "convert_case" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" - -[[package]] -name = "derive_more" -version = "0.99.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "rustc_version", - "syn 1.0.109", -] - -[[package]] -name = "equivalent" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" - -[[package]] -name = "gimli" -version = "0.26.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" - -[[package]] -name = "hash32" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" -dependencies = [ - "byteorder", -] - -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" -dependencies = [ - "ahash", -] - -[[package]] -name = "heapless" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" -dependencies = [ - "hash32", - "stable_deref_trait", -] - -[[package]] -name = "indexmap" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" -dependencies = [ - "equivalent", - "hashbrown", -] - -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin", -] - -[[package]] -name = "libc" -version = "0.2.158" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" - -[[package]] -name = "libm" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" - -[[package]] -name = "linked_list_allocator" -version = "0.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" -dependencies = [ - "spinning_top", -] - -[[package]] -name = "lock_api" -version = "0.4.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" -dependencies = [ - "autocfg", - "scopeguard", -] - -[[package]] -name = "ms_hostcall" -version = "0.1.0" -dependencies = [ - "bitflags", - "derive_more", - "thiserror-no-std", -] - -[[package]] -name = "ms_std" -version = "0.1.0" -dependencies = [ - "cfg-if", - "heapless", - "linked_list_allocator", - "ms_hostcall", - "ms_std_proc_macro", - "spin", - "thiserror-no-std", - "unwinding", -] - -[[package]] -name = "ms_std_proc_macro" -version = "0.1.0" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rustc_version" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" -dependencies = [ - "semver", -] - -[[package]] -name = "scopeguard" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" - -[[package]] -name = "semver" -version = "1.0.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" - -[[package]] -name = "spin" -version = "0.9.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -dependencies = [ - "lock_api", -] - -[[package]] -name = "spinning_top" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" -dependencies = [ - "lock_api", -] - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror-impl-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - -[[package]] -name = "thiserror-no-std" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" -dependencies = [ - "thiserror-impl-no-std", -] - -[[package]] -name = "tinywasm" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "libm", - "tinywasm-parser", - "tinywasm-types", -] - -[[package]] -name = "tinywasm-parser" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" -dependencies = [ - "tinywasm-types", - "wasmparser", -] - -[[package]] -name = "tinywasm-types" -version = "0.7.0" -source = "git+https://github.com/anti-entropy123/tinywasm?branch=master#31b2d363cd2f1ae36754fd4934acf02f333af95a" - -[[package]] -name = "tinywasm_write" -version = "0.1.0" -dependencies = [ - "cfg-if", - "ms_hostcall", - "ms_std", - "unwinding", - "wasi_api", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "unwinding" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ee215fc0991fb587275819562685254302112d0b7c8d25e635655526c0ecdc6" -dependencies = [ - "gimli", - "libc", -] - -[[package]] -name = "version_check" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" - -[[package]] -name = "wasi_api" -version = "0.1.0" -dependencies = [ - "hashbrown", - "lazy_static", - "ms_hostcall", - "ms_std", - "ms_std_proc_macro", - "spin", - "tinywasm", -] - -[[package]] -name = "wasmparser" -version = "0.207.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e19bb9f8ab07616da582ef8adb24c54f1424c7ec876720b7da9db8ec0626c92c" -dependencies = [ - "ahash", - "bitflags", - "hashbrown", - "indexmap", - "semver", -] - -[[package]] -name = "zerocopy" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.39", -] diff --git a/user/tinywasm_write/Cargo.toml b/user/tinywasm_write/Cargo.toml deleted file mode 100644 index 4ac3b56c..00000000 --- a/user/tinywasm_write/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "tinywasm_write" -version = "0.1.0" -edition = "2021" -build = "../../build_user.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["dylib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = [ - "alloc_def", - "unwinding", -], optional = true } -ms_hostcall = { path = "../../ms_hostcall", optional = true } -wasi_api = { path = "../../wasi_api" } - -cfg-if = "1.0.0" -unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -# wat = { version = "=1.0.88" } - - -[features] -with_libos = ["ms_std", "ms_hostcall"] -measure_mem = ["with_libos"] -mpk = ["ms_std/mpk"] - -default = ["with_libos"] diff --git a/user/tinywasm_write/src/lib.rs b/user/tinywasm_write/src/lib.rs deleted file mode 100644 index 8bee6769..00000000 --- a/user/tinywasm_write/src/lib.rs +++ /dev/null @@ -1,53 +0,0 @@ -#![cfg_attr(feature = "with_libos", no_std)] - -cfg_if::cfg_if! { - if #[cfg(feature = "with_libos")] { - use ms_std::{agent::FaaSFuncResult as Result}; - extern crate alloc; - } else { - type Result = core::result::Result; - use std::collections::BTreeMap; - } -} - -use ms_std::{agent::FaaSFuncError, println}; - -use tinywasm::{Module, Store, ModuleInstance}; -use wasi_api::tinywasm; - -const WASM: &[u8] = include_bytes!("../write.wasm"); - -pub fn run_wasm_app(wasm: &[u8]) -> core::result::Result<(), FaaSFuncError> { - let module = Module::parse_bytes(wasm)?; - let mut store = Store::default(); - let imports = wasi_api::import_all()?; - - let instance = ModuleInstance::instantiate(&mut store, module, Some(imports))?; - let main = instance.exported_func::<(), ()>(&store, "_start")?; - main.call(&mut store, ())?; - - Ok(()) -} - -#[no_mangle] -pub fn main() -> Result<()> { - // assert_eq!(add.call(&mut store, (20))?, 3); - // println!("fib(20)={}", fib.call(&mut store, 20)?); - let result = unwinding::panic::catch_unwind(|| run_wasm_app(WASM)); - // println!("result = {:#?}", result); - if let Ok(val) = result { - val? - } else { - println!("run wasm ok.") - } - - // if let Err(e) = { - // let msg = format!("{:?}", e); - // println!("err msg: {}", msg); - // if msg != "normally exit" { - // // return Err(); - // } - // }; - - Ok(().into()) -} diff --git a/user/tinywasm_write/write.c b/user/tinywasm_write/write.c deleted file mode 100644 index bb5e5932..00000000 --- a/user/tinywasm_write/write.c +++ /dev/null @@ -1,7 +0,0 @@ -#include - -int main() -{ - write(1, "Hello World!\n", sizeof("Hello World!\n")); - return 0; -} \ No newline at end of file diff --git a/user/tinywasm_write/write.wasm b/user/tinywasm_write/write.wasm deleted file mode 100644 index 7f0080dc..00000000 Binary files a/user/tinywasm_write/write.wasm and /dev/null differ diff --git a/user/wasmtime_checker/build.sh b/user/wasmtime_checker/build.sh index 6d929791..03f89ec6 100755 --- a/user/wasmtime_checker/build.sh +++ b/user/wasmtime_checker/build.sh @@ -2,7 +2,6 @@ $CPP checker_ori.cpp -o checker.wasm -fno-exceptions -fno-rtti -ffast-math -funroll-loops -fomit-frame-pointer -Ofast # $CC checker.c -o checker.wasm wasmtime compile --target x86_64-unknown-none -W threads=n,tail-call=n checker.wasm -# wasmtime compile --target x86_64-unknown-none -W simd=y,threads=n,tail-call=n checker.wasm cargo build --target x86_64-unknown-none --release && cc \ -Wl,--gc-sections -nostdlib \ @@ -12,5 +11,5 @@ cargo build --target x86_64-unknown-none --release && cc \ -shared \ -o target/x86_64-unknown-none/release/libwasmtime_checker.so -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_checker/target/x86_64-unknown-none/release/libwasmtime_checker.so /home/wyj/alloy_stack/mslibos/target/release/libwasmtime_checker.so +ln -s /home/wyj/dyx_workplace/mslibos/user/wasmtime_checker/target/x86_64-unknown-none/release/libwasmtime_checker.so /home/wyj/dyx_workplace/mslibos/target/release/libwasmtime_checker.so diff --git a/user/wasmtime_checker/checker.cwasm b/user/wasmtime_checker/checker.cwasm index 5c560725..8b9daccf 100644 Binary files a/user/wasmtime_checker/checker.cwasm and b/user/wasmtime_checker/checker.cwasm differ diff --git a/user/wasmtime_checker/checker.wasm b/user/wasmtime_checker/checker.wasm index 35c5cab7..cd9ea684 100755 Binary files a/user/wasmtime_checker/checker.wasm and b/user/wasmtime_checker/checker.wasm differ diff --git a/user/wasmtime_checker/checker_ori.cpp b/user/wasmtime_checker/checker_ori.cpp index 8251687d..5babc84d 100644 --- a/user/wasmtime_checker/checker_ori.cpp +++ b/user/wasmtime_checker/checker_ori.cpp @@ -8,29 +8,28 @@ __attribute__((import_module("env"), import_name("access_buffer"))) void access_ // #define MAX_ARRAY_LENGTH 152221 // #define MAX_BUFFER_SIZE 1024*1024+152221 -#define MAX_ARRAY_LENGTH 3805441 -#define MAX_BUFFER_SIZE 25*1024*1024+3805441 - // #define MAX_ARRAY_LENGTH 7611001 // #define MAX_BUFFER_SIZE 50*1024*1024+7611001 +#define MAX_ARRAY_LENGTH 3805441 +#define MAX_BUFFER_SIZE 25*1024*1024+3805441 + int result[MAX_ARRAY_LENGTH]; -void get_time(int num, int phase) { +void get_time() { timeval tv{}; gettimeofday(&tv, nullptr); - printf("%lld.%06lld--%d--%d\n", tv.tv_sec, tv.tv_usec, num, phase); + printf("%lld.%06lld\n", tv.tv_sec, tv.tv_usec); } int main(int argc, char* argv[]) { - // get_time(); + get_time(); int id = atoi(argv[1]); int sorter_num = atoi(argv[2]); int merger_num = atoi(argv[3]); // printf("checker_%d start!\n", id); int bufferSize = MAX_BUFFER_SIZE; int index = 0; - int time_num = 16; for (int i = 0; i < merger_num; i++) { char slot_name[20]; sprintf(slot_name, "checker_%d", i); @@ -39,12 +38,7 @@ int main(int argc, char* argv[]) { buffer = (char *)malloc(bufferSize * sizeof(char)); memset(buffer, 0, bufferSize * sizeof(char)); buffer[0] = '\0'; // 初始化为空字符串 - if (id == 0) - get_time(time_num, 0); access_buffer(slot_name, strlen(slot_name), buffer, bufferSize); - if (id == 0) - get_time(time_num, 1); - time_num++; char *ptr = buffer; int num; while (sscanf(ptr, "%d", &num) == 1) { @@ -70,6 +64,6 @@ int main(int argc, char* argv[]) { // } // printf("%d\n", result[index-1]); // printf("checker_%d all finished!\n", id); - // get_time(); + get_time(); return 0; } \ No newline at end of file diff --git a/user/wasmtime_checker/src/lib.rs b/user/wasmtime_checker/src/lib.rs index 0ea90e53..6bb05484 100644 --- a/user/wasmtime_checker/src/lib.rs +++ b/user/wasmtime_checker/src/lib.rs @@ -44,14 +44,13 @@ fn func_body(my_id: &str, sorter_num: u64, merger_num: u64) -> Result<()> { let mut store = Store::new(&engine, LibosCtx{id: my_id.to_string()}); let instance = linker.instantiate(&mut store, &module)?; - let mut memory = instance.get_memory(&mut store, "memory").unwrap(); - let pages = memory.grow(&mut store, 20000).unwrap(); + let memory = instance.get_memory(&mut store, "memory").unwrap(); + let _pages = memory.grow(&mut store, 20000).unwrap(); let main = instance .get_typed_func::<(), ()>(&mut store, "_start") .map_err(|e| e.to_string())?; - // main.call(store, ()).map_err(|e| e.to_string())?; main.call(&mut store, ()).map_err(|e| e.to_string())?; forget(store); let end_time = SystemTime::now().duration_since(UNIX_EPOCH).as_millis(); diff --git a/user/wasmtime_cpython/Cargo.lock b/user/wasmtime_cpython/Cargo.lock index 5e1bcd12..87fcbc8f 100644 --- a/user/wasmtime_cpython/Cargo.lock +++ b/user/wasmtime_cpython/Cargo.lock @@ -396,6 +396,12 @@ dependencies = [ "spinning_top", ] +[[package]] +name = "linux-raw-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1ad52afd8f9448cbbe722ae722849cc41f1d365e285cca386896352bc08e1a9" + [[package]] name = "linux-raw-sys" version = "0.4.14" @@ -482,6 +488,27 @@ dependencies = [ "syn 2.0.79", ] +[[package]] +name = "naked-function" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b8d5fca6ab1e6215b010aefd3b9ac5aae369dae0faea3a7f34f296cc9f719ac" +dependencies = [ + "cfg-if", + "naked-function-macro", +] + +[[package]] +name = "naked-function-macro" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b4123e70df5fe0bb370cff166ae453b9c5324a2cfc932c0f7e55498147a0475" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + [[package]] name = "object" version = "0.36.5" @@ -582,7 +609,7 @@ dependencies = [ "bitflags", "errno", "libc", - "linux-raw-sys", + "linux-raw-sys 0.4.14", "windows-sys", ] @@ -592,6 +619,12 @@ version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" +[[package]] +name = "sc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "010e18bd3bfd1d45a7e666b236c78720df0d9a7698ebaa9c1c559961eb60a38b" + [[package]] name = "scopeguard" version = "1.2.0" @@ -642,6 +675,17 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +[[package]] +name = "sjlj" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9b43efc387069aabdc27124a294337c7032a3cb62df0108d2578eff7f08e39" +dependencies = [ + "linux-raw-sys 0.2.2", + "naked-function", + "sc", +] + [[package]] name = "slice-group-by" version = "0.3.1" @@ -809,8 +853,7 @@ dependencies = [ [[package]] name = "wasmtime" version = "22.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "786d8b5e7a4d54917c5ebe555b9667337e5f93383f49bddaaeec2eba68093b45" +source = "git+https://gitee.com/tju-cloud-computing/wasmtime-as-lib?branch=master#fb45fb8dde6d068abb3ae78bfab78253c9654af5" dependencies = [ "anyhow", "bumpalo", @@ -1005,6 +1048,7 @@ dependencies = [ "lazy_static", "ms_hostcall", "ms_std", + "sjlj", "spin", "wasmtime_wasi_api", ] @@ -1018,6 +1062,7 @@ dependencies = [ "ms_hostcall", "ms_std", "ms_std_proc_macro", + "sjlj", "spin", "wasmtime", ] diff --git a/user/wasmtime_cpython/Cargo.toml b/user/wasmtime_cpython/Cargo.toml index 9c43bdf7..77820e92 100755 --- a/user/wasmtime_cpython/Cargo.toml +++ b/user/wasmtime_cpython/Cargo.toml @@ -17,7 +17,7 @@ wasmtime_wasi_api = { path = "../../wasmtime_wasi_api" } lazy_static = { version = "1.5.0", features = ["spin_no_std"] } spin = "0.9.8" +sjlj = "0.1.3" [features] mpk = ["ms_std/mpk"] -log = ["wasmtime_wasi_api/log"] diff --git a/user/wasmtime_cpython/python.cwasm b/user/wasmtime_cpython/python.cwasm index 998e1f6e..a38faac4 100644 Binary files a/user/wasmtime_cpython/python.cwasm and b/user/wasmtime_cpython/python.cwasm differ diff --git a/user/wasmtime_cpython/python.wasm b/user/wasmtime_cpython/python.wasm old mode 100755 new mode 100644 index b9ce0324..1d2b20b4 Binary files a/user/wasmtime_cpython/python.wasm and b/user/wasmtime_cpython/python.wasm differ diff --git a/user/wasmtime_cpython/src/lib.rs b/user/wasmtime_cpython/src/lib.rs index f70f3094..859fd58c 100755 --- a/user/wasmtime_cpython/src/lib.rs +++ b/user/wasmtime_cpython/src/lib.rs @@ -2,8 +2,10 @@ extern crate alloc; +use alloc::sync::Arc; use alloc::{string::{String, ToString}, vec::Vec}; use spin::Mutex; +use core::mem::forget; use ms_hostcall::types::{OpenFlags, OpenMode}; use ms_std::{agent::FaaSFuncResult as Result, args, libos::libos, println, time::{SystemTime, UNIX_EPOCH},}; @@ -26,8 +28,18 @@ fn func_body(my_id: &str, pyfile_path: &str) -> Result<()> { #[cfg(feature = "log")] println!("rust: my_id: {:?}, pyfile_path: {:?}", my_id, pyfile_path); + let mut jmpbuf = sjlj::JumpBuf::new(); + let if_panic = unsafe { sjlj::setjmp(&mut jmpbuf) }; + if if_panic != 0 { + #[cfg(feature = "log")] + println!("[Info] normal exit. if_panic: {:?}", if_panic); + return Ok(().into()); + } else { + wasmtime_wasi_api::JMP_BUF_MAP.lock().insert(my_id.to_string(), Arc::new(jmpbuf)); + } + let wasi_args: Vec = Vec::from([ - "fake system path!".to_string(), + "python.wasm".to_string(), pyfile_path.to_string(), ]); wasmtime_wasi_api::set_wasi_args(my_id, wasi_args); @@ -45,8 +57,9 @@ fn func_body(my_id: &str, pyfile_path: &str) -> Result<()> { .get_typed_func::<(), ()>(&mut store, "_start") .map_err(|e| e.to_string())?; - println!("{}", SystemTime::now().duration_since(UNIX_EPOCH).as_nanos()); - main.call(store, ()).map_err(|e| e.to_string())?; + // println!("{}", SystemTime::now().duration_since(UNIX_EPOCH).as_nanos()); + main.call(&mut store, ()).map_err(|e| e.to_string())?; + forget(store); #[cfg(feature = "log")] println!("rust: wasmtime_cpython_{:?} finished!", my_id); diff --git a/user/wasmtime_func_a/Cargo.lock b/user/wasmtime_cpython_func/Cargo.lock similarity index 99% rename from user/wasmtime_func_a/Cargo.lock rename to user/wasmtime_cpython_func/Cargo.lock index cab80106..26c0f7c0 100644 --- a/user/wasmtime_func_a/Cargo.lock +++ b/user/wasmtime_cpython_func/Cargo.lock @@ -547,9 +547,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1042,12 +1042,13 @@ dependencies = [ ] [[package]] -name = "wasmtime_mapper" +name = "wasmtime_cpython_func" version = "0.1.0" dependencies = [ "lazy_static", "ms_hostcall", "ms_std", + "sjlj", "spin", "wasmtime_wasi_api", ] diff --git a/user/wasmtime_func_b/Cargo.toml b/user/wasmtime_cpython_func/Cargo.toml similarity index 75% rename from user/wasmtime_func_b/Cargo.toml rename to user/wasmtime_cpython_func/Cargo.toml index 73966ea7..23b704c9 100644 --- a/user/wasmtime_func_b/Cargo.toml +++ b/user/wasmtime_cpython_func/Cargo.toml @@ -1,22 +1,23 @@ -[package] -name = "wasmtime_mapper" -version = "0.1.0" -edition = "2021" -build = "build.rs" -# build = "../../build_wasm.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["staticlib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = ["panic_def", "alloc_def"] } -ms_hostcall = { path = "../../ms_hostcall", features = ["signal"] } - -wasmtime_wasi_api = { path = "../../wasmtime_wasi_api" } - -lazy_static = { version = "1.5.0", features = ["spin_no_std"] } -spin = "0.9.8" - -[features] -mpk = ["ms_std/mpk"] +[package] +name = "wasmtime_cpython_func" +version = "0.1.0" +edition = "2021" +build = "build.rs" +# build = "../../build_user.rs" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +# crate-type = ["dylib"] +crate-type = ["staticlib"] + +[dependencies] +ms_std = { path = "../../ms_std", features = ["panic_def", "alloc_def"] } +ms_hostcall = { path = "../../ms_hostcall" } +wasmtime_wasi_api = { path = "../../wasmtime_wasi_api" } + +lazy_static = { version = "1.5.0", features = ["spin_no_std"] } +spin = "0.9.8" +sjlj = "0.1.3" + +[features] +mpk = ["ms_std/mpk"] diff --git a/user/wasmtime_func_a/build.rs b/user/wasmtime_cpython_func/build.rs similarity index 100% rename from user/wasmtime_func_a/build.rs rename to user/wasmtime_cpython_func/build.rs diff --git a/user/wasmtime_func_a/libwasmtime-platform.a b/user/wasmtime_cpython_func/libwasmtime-platform.a similarity index 100% rename from user/wasmtime_func_a/libwasmtime-platform.a rename to user/wasmtime_cpython_func/libwasmtime-platform.a diff --git a/user/wasmtime_func_a/libwasmtime-platform.o b/user/wasmtime_cpython_func/libwasmtime-platform.o similarity index 100% rename from user/wasmtime_func_a/libwasmtime-platform.o rename to user/wasmtime_cpython_func/libwasmtime-platform.o diff --git a/user/wasmtime_cpython_func/python.cwasm b/user/wasmtime_cpython_func/python.cwasm new file mode 100644 index 00000000..a38faac4 Binary files /dev/null and b/user/wasmtime_cpython_func/python.cwasm differ diff --git a/user/tinywasm_cpython/python.wasm b/user/wasmtime_cpython_func/python.wasm old mode 100755 new mode 100644 similarity index 57% rename from user/tinywasm_cpython/python.wasm rename to user/wasmtime_cpython_func/python.wasm index b9ce0324..1d2b20b4 Binary files a/user/tinywasm_cpython/python.wasm and b/user/wasmtime_cpython_func/python.wasm differ diff --git a/user/wasmtime_cpython_func/src/lib.rs b/user/wasmtime_cpython_func/src/lib.rs new file mode 100755 index 00000000..25b8989b --- /dev/null +++ b/user/wasmtime_cpython_func/src/lib.rs @@ -0,0 +1,82 @@ +#![no_std] + +extern crate alloc; + +use alloc::sync::Arc; +use alloc::{format, string::{String, ToString}, vec::Vec}; +use spin::Mutex; +use core::mem::forget; + +use ms_hostcall::types::{OpenFlags, OpenMode}; +use ms_std::{agent::FaaSFuncResult as Result, args, libos::libos, println, time::{SystemTime, UNIX_EPOCH},}; + +use wasmtime_wasi_api::{wasmtime, LibosCtx}; +use wasmtime::Store; + +const CWASM: &[u8] = include_bytes!("../python.cwasm"); + +static INIT_LOCK: Mutex<()> = Mutex::new(()); + +lazy_static::lazy_static! { + static ref MUST_OPEN_ROOT: bool = { + libos!(open("/", OpenFlags::empty(), OpenMode::RD)).unwrap(); + true + }; +} + +fn func_body(pyfile_path: &str, func_num: u64) -> Result<()> { + let my_map_id = &format!("func_{}", func_num); + + let mut jmpbuf = sjlj::JumpBuf::new(); + let if_panic = unsafe { sjlj::setjmp(&mut jmpbuf) }; + if if_panic != 0 { + #[cfg(feature = "log")] + println!("[Info] normal exit. if_panic: {:?}", if_panic); + return Ok(().into()); + } else { + wasmtime_wasi_api::JMP_BUF_MAP.lock().insert(my_map_id.to_string(), Arc::new(jmpbuf)); + } + + #[cfg(feature = "log")] + println!("rust: pyfile_path: {:?}, func_num: {:?}", pyfile_path, func_num); + + let wasi_args: Vec = Vec::from([ + "python.wasm".to_string(), + pyfile_path.to_string(), + func_num.to_string(), + ]); + wasmtime_wasi_api::set_wasi_args(my_map_id, wasi_args); + + let _open_root = *MUST_OPEN_ROOT; + + let lock = INIT_LOCK.lock(); + let (engine, module, linker) = wasmtime_wasi_api::build_wasm(CWASM); + drop(lock); + + let mut store = Store::new(&engine, LibosCtx{id: my_map_id.to_string()}); + let instance = linker.instantiate(&mut store, &module)?; + + let main = instance + .get_typed_func::<(), ()>(&mut store, "_start") + .map_err(|e| e.to_string())?; + + // println!("phase0: {}", SystemTime::now().duration_since(UNIX_EPOCH).as_micros() as f64 / 1000000f64); + main.call(store, ()).map_err(|e| e.to_string())?; + + #[cfg(feature = "log")] + println!("rust: wasmtime_cpython_func_{:?} finished!", my_id); + + Ok(().into()) +} + + +#[no_mangle] +pub fn main() -> Result<()> { + let pyfile_path = args::get("pyfile_path").unwrap(); + let func_num: u64 = args::get("func_num") + .expect("missing arg func_num") + .parse() + .unwrap_or_else(|_| panic!("bad arg, func_num={}", args::get("func_num").unwrap())); + + func_body(pyfile_path, func_num) +} diff --git a/user/wasmtime_func_b/Cargo.lock b/user/wasmtime_cpython_mapper/Cargo.lock similarity index 99% rename from user/wasmtime_func_b/Cargo.lock rename to user/wasmtime_cpython_mapper/Cargo.lock index cab80106..1335cc85 100644 --- a/user/wasmtime_func_b/Cargo.lock +++ b/user/wasmtime_cpython_mapper/Cargo.lock @@ -547,9 +547,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" dependencies = [ "unicode-ident", ] @@ -1042,12 +1042,13 @@ dependencies = [ ] [[package]] -name = "wasmtime_mapper" +name = "wasmtime_cpython_mapper" version = "0.1.0" dependencies = [ "lazy_static", "ms_hostcall", "ms_std", + "sjlj", "spin", "wasmtime_wasi_api", ] diff --git a/user/wasmtime_cpython_mapper/Cargo.toml b/user/wasmtime_cpython_mapper/Cargo.toml new file mode 100644 index 00000000..1ae3af2e --- /dev/null +++ b/user/wasmtime_cpython_mapper/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "wasmtime_cpython_mapper" +version = "0.1.0" +edition = "2021" +build = "build.rs" +# build = "../../build_user.rs" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +# crate-type = ["dylib"] +crate-type = ["staticlib"] + +[dependencies] +ms_std = { path = "../../ms_std", features = ["panic_def", "alloc_def"] } +ms_hostcall = { path = "../../ms_hostcall" } +wasmtime_wasi_api = { path = "../../wasmtime_wasi_api" } + +lazy_static = { version = "1.5.0", features = ["spin_no_std"] } +spin = "0.9.8" +sjlj = "0.1.3" + +[features] +mpk = ["ms_std/mpk"] diff --git a/user/wasmtime_func_b/build.rs b/user/wasmtime_cpython_mapper/build.rs similarity index 100% rename from user/wasmtime_func_b/build.rs rename to user/wasmtime_cpython_mapper/build.rs diff --git a/user/wasmtime_func_b/libwasmtime-platform.a b/user/wasmtime_cpython_mapper/libwasmtime-platform.a similarity index 100% rename from user/wasmtime_func_b/libwasmtime-platform.a rename to user/wasmtime_cpython_mapper/libwasmtime-platform.a diff --git a/user/wasmtime_func_b/libwasmtime-platform.o b/user/wasmtime_cpython_mapper/libwasmtime-platform.o similarity index 100% rename from user/wasmtime_func_b/libwasmtime-platform.o rename to user/wasmtime_cpython_mapper/libwasmtime-platform.o diff --git a/user/wasmtime_cpython_mapper/python.cwasm b/user/wasmtime_cpython_mapper/python.cwasm new file mode 100644 index 00000000..a38faac4 Binary files /dev/null and b/user/wasmtime_cpython_mapper/python.cwasm differ diff --git a/user/tinywasm_pass_str_cpython/python.wasm b/user/wasmtime_cpython_mapper/python.wasm old mode 100755 new mode 100644 similarity index 57% rename from user/tinywasm_pass_str_cpython/python.wasm rename to user/wasmtime_cpython_mapper/python.wasm index 153c849b..1d2b20b4 Binary files a/user/tinywasm_pass_str_cpython/python.wasm and b/user/wasmtime_cpython_mapper/python.wasm differ diff --git a/user/wasmtime_cpython_mapper/src/lib.rs b/user/wasmtime_cpython_mapper/src/lib.rs new file mode 100755 index 00000000..dacba5c3 --- /dev/null +++ b/user/wasmtime_cpython_mapper/src/lib.rs @@ -0,0 +1,85 @@ +#![no_std] + +extern crate alloc; + +use alloc::sync::Arc; +use alloc::{format, string::{String, ToString}, vec::Vec}; +use spin::Mutex; +use core::mem::forget; + +use ms_hostcall::types::{OpenFlags, OpenMode}; +use ms_std::{agent::FaaSFuncResult as Result, args, libos::libos, println, time::{SystemTime, UNIX_EPOCH},}; + +use wasmtime_wasi_api::{wasmtime, LibosCtx}; +use wasmtime::Store; + +const CWASM: &[u8] = include_bytes!("../python.cwasm"); + +static INIT_LOCK: Mutex<()> = Mutex::new(()); + +lazy_static::lazy_static! { + static ref MUST_OPEN_ROOT: bool = { + libos!(open("/", OpenFlags::empty(), OpenMode::RD)).unwrap(); + true + }; +} + +fn func_body(my_id: &str, pyfile_path: &str, reducer_num: u64) -> Result<()> { + let my_map_id = &format!("mapper_{}", my_id); + + let mut jmpbuf = sjlj::JumpBuf::new(); + let if_panic = unsafe { sjlj::setjmp(&mut jmpbuf) }; + if if_panic != 0 { + #[cfg(feature = "log")] + println!("[Info] normal exit. if_panic: {:?}", if_panic); + return Ok(().into()); + } else { + wasmtime_wasi_api::JMP_BUF_MAP.lock().insert(my_map_id.to_string(), Arc::new(jmpbuf)); + } + + #[cfg(feature = "log")] + println!("rust: my_id: {:?}, pyfile_path: {:?}, reducer_num: {:?}", my_id, pyfile_path, reducer_num); + + let wasi_args: Vec = Vec::from([ + "python.wasm".to_string(), + pyfile_path.to_string(), + my_id.to_string(), + reducer_num.to_string(), + ]); + wasmtime_wasi_api::set_wasi_args(my_map_id, wasi_args); + + let _open_root = *MUST_OPEN_ROOT; + + let lock = INIT_LOCK.lock(); + let (engine, module, linker) = wasmtime_wasi_api::build_wasm(CWASM); + drop(lock); + + let mut store = Store::new(&engine, LibosCtx{id: my_map_id.to_string()}); + let instance = linker.instantiate(&mut store, &module)?; + + let main = instance + .get_typed_func::<(), ()>(&mut store, "_start") + .map_err(|e| e.to_string())?; + + // println!("phase0: {}", SystemTime::now().duration_since(UNIX_EPOCH).as_micros() as f64 / 1000000f64); + main.call(&mut store, ()).map_err(|e| e.to_string())?; + forget(store); + + #[cfg(feature = "log")] + println!("rust: wasmtime_cpython_mapper_{:?} finished!", my_id); + + Ok(().into()) +} + + +#[no_mangle] +pub fn main() -> Result<()> { + let my_id = args::get("id").unwrap(); + let pyfile_path = args::get("pyfile_path").unwrap(); + let reducer_num: u64 = args::get("reducer_num") + .expect("missing arg reducer_num") + .parse() + .unwrap_or_else(|_| panic!("bad arg, reducer_num={}", args::get("reducer_num").unwrap())); + + func_body(my_id, pyfile_path, reducer_num) +} diff --git a/user/wasmtime_cpython_parallel_sort/Cargo.lock b/user/wasmtime_cpython_parallel_sort/Cargo.lock new file mode 100644 index 00000000..df901b80 --- /dev/null +++ b/user/wasmtime_cpython_parallel_sort/Cargo.lock @@ -0,0 +1,1196 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "anyhow" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" + +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cobs" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cranelift-bforest" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6b33d7e757a887989eb18b35712b2a67d96171ec3149d1bfb657b29b7b367c" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9acf15cb22be42d07c3b57d7856329cb228b7315d385346149df2566ad5e4aa" +dependencies = [ + "bumpalo", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-control", + "cranelift-entity", + "cranelift-isle", + "gimli", + "hashbrown 0.14.5", + "log", + "regalloc2", + "rustc-hash", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e934d301392b73b3f8b0540391fb82465a0f179a3cee7c726482ac4727efcc97" +dependencies = [ + "cranelift-codegen-shared", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb2a2566b3d54b854dfb288b3b187f6d3d17d6f762c92898207eba302931da" + +[[package]] +name = "cranelift-control" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0100f33b704cdacd01ad66ff41f8c5030d57cbff078e2a4e49ab1822591299fa" +dependencies = [ + "arbitrary", +] + +[[package]] +name = "cranelift-entity" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8cfdc315e5d18997093e040a8d234bea1ac1e118a716d3e30f40d449e78207b" +dependencies = [ + "serde", + "serde_derive", +] + +[[package]] +name = "cranelift-frontend" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f74b84f16af2e982b0c0c72233503d9d55cbfe3865dbe807ca28dc6642a28b5" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adf306d3dde705fb94bd48082f01d38c4ededc74293a4c007805f610bf08bc6e" + +[[package]] +name = "cranelift-native" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ea0ebdef7aff4a79bcbc8b6495f31315f16b3bf311152f472eaa8d679352581" +dependencies = [ + "cranelift-codegen", + "libc", + "target-lexicon", +] + +[[package]] +name = "cranelift-wasm" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d549108a1942065cdbac3bb96c2952afa0e1b9a3beff4b08c4308ac72257576d" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "itertools", + "log", + "smallvec", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "derive_more" +version = "0.99.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.79", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + +[[package]] +name = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "serde", +] + +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +dependencies = [ + "foldhash", +] + +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "hash32", + "stable_deref_trait", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + +[[package]] +name = "indexmap" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +dependencies = [ + "equivalent", + "hashbrown 0.15.0", + "serde", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "libc" +version = "0.2.159" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "linked_list_allocator" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" +dependencies = [ + "spinning_top", +] + +[[package]] +name = "linux-raw-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1ad52afd8f9448cbbe722ae722849cc41f1d365e285cca386896352bc08e1a9" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memfd" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" +dependencies = [ + "rustix", +] + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "ms_hostcall" +version = "0.1.0" +dependencies = [ + "bitflags", + "derive_more", + "thiserror-no-std", +] + +[[package]] +name = "ms_std" +version = "0.1.0" +dependencies = [ + "cfg-if", + "heapless", + "linked_list_allocator", + "ms_hostcall", + "ms_std_proc_macro", + "spin", + "thiserror-no-std", +] + +[[package]] +name = "ms_std_proc_macro" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "naked-function" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b8d5fca6ab1e6215b010aefd3b9ac5aae369dae0faea3a7f34f296cc9f719ac" +dependencies = [ + "cfg-if", + "naked-function-macro", +] + +[[package]] +name = "naked-function-macro" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b4123e70df5fe0bb370cff166ae453b9c5324a2cfc932c0f7e55498147a0475" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "object" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +dependencies = [ + "crc32fast", + "hashbrown 0.15.0", + "indexmap", + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "postcard" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f7f0a8d620d71c457dd1d47df76bb18960378da56af4527aaa10f515eee732e" +dependencies = [ + "cobs", + "embedded-io 0.4.0", + "embedded-io 0.6.1", + "serde", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205" +dependencies = [ + "cc", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regalloc2" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad156d539c879b7a24a363a2016d77961786e71f48f2e2fc8302a92abd2429a6" +dependencies = [ + "hashbrown 0.13.2", + "log", + "rustc-hash", + "slice-group-by", + "smallvec", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys 0.4.14", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "sc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "010e18bd3bfd1d45a7e666b236c78720df0d9a7698ebaa9c1c559961eb60a38b" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "serde_json" +version = "1.0.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "sjlj" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9b43efc387069aabdc27124a294337c7032a3cb62df0108d2578eff7f08e39" +dependencies = [ + "linux-raw-sys 0.2.2", + "naked-function", + "sc", +] + +[[package]] +name = "slice-group-by" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +dependencies = [ + "serde", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spinning_top" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" +dependencies = [ + "lock_api", +] + +[[package]] +name = "sptr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + +[[package]] +name = "thiserror" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "thiserror-impl-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "thiserror-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" +dependencies = [ + "thiserror-impl-no-std", +] + +[[package]] +name = "unicode-ident" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasm-encoder" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4a05336882dae732ce6bd48b7e11fe597293cb72c13da4f35d7d5f8d53b2a7" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasmparser" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07035cc9a9b41e62d3bb3a3815a66ab87c993c06fe1cf6b2a3f2a18499d937db" +dependencies = [ + "ahash", + "bitflags", + "hashbrown 0.14.5", + "indexmap", + "semver", + "serde", +] + +[[package]] +name = "wasmprinter" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceca8ae6eaa8c7c87b33c25c53bdf299f8c2a764aee1179402ff7652ef3a6859" +dependencies = [ + "anyhow", + "wasmparser", +] + +[[package]] +name = "wasmtime" +version = "22.0.0" +source = "git+https://gitee.com/tju-cloud-computing/wasmtime-as-lib?branch=master#fb45fb8dde6d068abb3ae78bfab78253c9654af5" +dependencies = [ + "anyhow", + "bumpalo", + "cc", + "cfg-if", + "encoding_rs", + "hashbrown 0.14.5", + "indexmap", + "libc", + "libm", + "log", + "mach2", + "memfd", + "memoffset", + "object", + "once_cell", + "paste", + "postcard", + "psm", + "rustix", + "semver", + "serde", + "serde_derive", + "smallvec", + "sptr", + "target-lexicon", + "wasmparser", + "wasmtime-asm-macros", + "wasmtime-component-macro", + "wasmtime-component-util", + "wasmtime-cranelift", + "wasmtime-environ", + "wasmtime-jit-icache-coherence", + "wasmtime-slab", + "wasmtime-versioned-export-macros", + "wasmtime-winch", + "windows-sys", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d697d99c341d4a9ffb72f3af7a02124d233eeb59aee010f36d88e97cca553d5e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-component-macro" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b29b462b068e73b5b27fae092a27f47e5937cabf6b26be2779c978698a52feca" +dependencies = [ + "anyhow", + "proc-macro2", + "quote", + "syn 2.0.79", + "wasmtime-component-util", + "wasmtime-wit-bindgen", + "wit-parser", +] + +[[package]] +name = "wasmtime-component-util" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d2912c53d9054984b380dfbd7579f9c3681b2a73b903a56bd71a1c4f175f1e" + +[[package]] +name = "wasmtime-cranelift" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3975deafea000457ba84355c7c0fce0372937204f77026510b7b454f28a3a65" +dependencies = [ + "anyhow", + "cfg-if", + "cranelift-codegen", + "cranelift-control", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "cranelift-wasm", + "gimli", + "log", + "object", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-environ", + "wasmtime-versioned-export-macros", +] + +[[package]] +name = "wasmtime-environ" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f444e900e848b884d8a8a2949b6f5b92af642a3e663ff8fbe78731143a55be61" +dependencies = [ + "anyhow", + "cranelift-entity", + "gimli", + "indexmap", + "log", + "object", + "postcard", + "serde", + "serde_derive", + "target-lexicon", + "wasm-encoder", + "wasmparser", + "wasmprinter", + "wasmtime-component-util", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5afe2f0499542f9a4bcfa1b55bfdda803b6ade4e7c93c6b99e0f39dba44b0a91" +dependencies = [ + "anyhow", + "cfg-if", + "libc", + "windows-sys", +] + +[[package]] +name = "wasmtime-slab" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a7de1f2bec5bbb35d532e61c85c049dc84ae671df60492f90b954ecf21169e7" + +[[package]] +name = "wasmtime-types" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "412463e9000e14cf6856be48628d2213c20c153e29ffc22b036980c892ea6964" +dependencies = [ + "cranelift-entity", + "serde", + "serde_derive", + "smallvec", + "wasmparser", +] + +[[package]] +name = "wasmtime-versioned-export-macros" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de5a9bc4f44ceeb168e9e8e3be4e0b4beb9095b468479663a9e24c667e36826f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "wasmtime-winch" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed4db238a0241df2d15f79ad17b3a37a27f2ea6cb885894d81b42ae107544466" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "object", + "target-lexicon", + "wasmparser", + "wasmtime-cranelift", + "wasmtime-environ", + "winch-codegen", +] + +[[package]] +name = "wasmtime-wit-bindgen" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc077306b38288262e5ba01d4b21532a6987416cdc0aedf04bb06c22a68fdc" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "wit-parser", +] + +[[package]] +name = "wasmtime_cpython_parallel_sort" +version = "0.1.0" +dependencies = [ + "lazy_static", + "ms_hostcall", + "ms_std", + "sjlj", + "spin", + "wasmtime_wasi_api", +] + +[[package]] +name = "wasmtime_wasi_api" +version = "0.1.0" +dependencies = [ + "hashbrown 0.14.5", + "lazy_static", + "ms_hostcall", + "ms_std", + "ms_std_proc_macro", + "sjlj", + "spin", + "wasmtime", +] + +[[package]] +name = "winch-codegen" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c6915884e731b2db0d8cf08cb64474cb69221a161675fd3c135f91febc3daa" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "regalloc2", + "smallvec", + "target-lexicon", + "wasmparser", + "wasmtime-cranelift", + "wasmtime-environ", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-parser" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e79b9e3c0b6bb589dec46317e645851e0db2734c44e2be5e251b03ff4a51269" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] diff --git a/user/wasmtime_cpython_parallel_sort/Cargo.toml b/user/wasmtime_cpython_parallel_sort/Cargo.toml new file mode 100644 index 00000000..d4fd38f9 --- /dev/null +++ b/user/wasmtime_cpython_parallel_sort/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "wasmtime_cpython_parallel_sort" +version = "0.1.0" +edition = "2021" +build = "build.rs" +# build = "../../build_user.rs" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +# crate-type = ["dylib"] +crate-type = ["staticlib"] + +[dependencies] +ms_std = { path = "../../ms_std", features = ["panic_def", "alloc_def"] } +ms_hostcall = { path = "../../ms_hostcall" } +wasmtime_wasi_api = { path = "../../wasmtime_wasi_api" } + +lazy_static = { version = "1.5.0", features = ["spin_no_std"] } +spin = "0.9.8" +sjlj = "0.1.3" + +[features] +mpk = ["ms_std/mpk"] diff --git a/user/wasmtime_cpython_parallel_sort/build.rs b/user/wasmtime_cpython_parallel_sort/build.rs new file mode 100644 index 00000000..9fc09ddf --- /dev/null +++ b/user/wasmtime_cpython_parallel_sort/build.rs @@ -0,0 +1,4 @@ +fn main() { + println!("cargo:rustc-link-lib=static={}", "wasmtime-platform"); + println!("cargo:rustc-link-search=native={}", "./"); +} diff --git a/user/wasmtime_cpython_parallel_sort/libwasmtime-platform.a b/user/wasmtime_cpython_parallel_sort/libwasmtime-platform.a new file mode 100644 index 00000000..beebf570 Binary files /dev/null and b/user/wasmtime_cpython_parallel_sort/libwasmtime-platform.a differ diff --git a/user/wasmtime_cpython_parallel_sort/libwasmtime-platform.o b/user/wasmtime_cpython_parallel_sort/libwasmtime-platform.o new file mode 100644 index 00000000..90bbf6dd Binary files /dev/null and b/user/wasmtime_cpython_parallel_sort/libwasmtime-platform.o differ diff --git a/user/wasmtime_cpython_parallel_sort/python.cwasm b/user/wasmtime_cpython_parallel_sort/python.cwasm new file mode 100644 index 00000000..a38faac4 Binary files /dev/null and b/user/wasmtime_cpython_parallel_sort/python.cwasm differ diff --git a/user/tinywasm_recv_str_cpython/python.wasm b/user/wasmtime_cpython_parallel_sort/python.wasm old mode 100755 new mode 100644 similarity index 57% rename from user/tinywasm_recv_str_cpython/python.wasm rename to user/wasmtime_cpython_parallel_sort/python.wasm index 153c849b..1d2b20b4 Binary files a/user/tinywasm_recv_str_cpython/python.wasm and b/user/wasmtime_cpython_parallel_sort/python.wasm differ diff --git a/user/wasmtime_cpython_parallel_sort/src/lib.rs b/user/wasmtime_cpython_parallel_sort/src/lib.rs new file mode 100755 index 00000000..08515be3 --- /dev/null +++ b/user/wasmtime_cpython_parallel_sort/src/lib.rs @@ -0,0 +1,90 @@ +#![no_std] + +extern crate alloc; + +use alloc::sync::Arc; +use alloc::{format, string::{String, ToString}, vec::Vec}; +use spin::Mutex; +use core::mem::forget; + +use ms_hostcall::types::{OpenFlags, OpenMode}; +use ms_std::{agent::FaaSFuncResult as Result, args, libos::libos, println, time::{SystemTime, UNIX_EPOCH},}; + +use wasmtime_wasi_api::{wasmtime, LibosCtx}; +use wasmtime::Store; + +const CWASM: &[u8] = include_bytes!("../python.cwasm"); + +static INIT_LOCK: Mutex<()> = Mutex::new(()); + +lazy_static::lazy_static! { + static ref MUST_OPEN_ROOT: bool = { + libos!(open("/", OpenFlags::empty(), OpenMode::RD)).unwrap(); + true + }; +} + +fn func_body(my_id: &str, pyfile_path: &str, sorter_num: u64, merger_num: u64) -> Result<()> { + let my_map_id = &format!("func_{}", my_id); + + let mut jmpbuf = sjlj::JumpBuf::new(); + let if_panic = unsafe { sjlj::setjmp(&mut jmpbuf) }; + if if_panic != 0 { + #[cfg(feature = "log")] + println!("[Info] normal exit. if_panic: {:?}", if_panic); + return Ok(().into()); + } else { + wasmtime_wasi_api::JMP_BUF_MAP.lock().insert(my_map_id.to_string(), Arc::new(jmpbuf)); + } + + #[cfg(feature = "log")] + println!("rust: my_id: {:?}, pyfile_path: {:?}, sorter_num: {:?}, merger_num: {:?}", my_id, pyfile_path, sorter_num, merger_num); + + let wasi_args: Vec = Vec::from([ + "python.wasm".to_string(), + pyfile_path.to_string(), + my_id.to_string(), + sorter_num.to_string(), + merger_num.to_string(), + ]); + wasmtime_wasi_api::set_wasi_args(my_map_id, wasi_args); + + let _open_root = *MUST_OPEN_ROOT; + + let lock = INIT_LOCK.lock(); + let (engine, module, linker) = wasmtime_wasi_api::build_wasm(CWASM); + drop(lock); + + let mut store = Store::new(&engine, LibosCtx{id: my_map_id.to_string()}); + let instance = linker.instantiate(&mut store, &module)?; + + let main = instance + .get_typed_func::<(), ()>(&mut store, "_start") + .map_err(|e| e.to_string())?; + + println!("start: {}", SystemTime::now().duration_since(UNIX_EPOCH).as_micros() as f64 / 1000000f64); + main.call(&mut store, ()).map_err(|e| e.to_string())?; + forget(store); + + #[cfg(feature = "log")] + println!("rust: wasmtime_cpython_func_{:?} finished!", my_id); + + Ok(().into()) +} + + +#[no_mangle] +pub fn main() -> Result<()> { + let my_id = args::get("id").unwrap(); + let pyfile_path = args::get("pyfile_path").unwrap(); + let sorter_num: u64 = args::get("sorter_num") + .expect("missing arg sorter_num") + .parse() + .unwrap_or_else(|_| panic!("bad arg, sorter_num={}", args::get("sorter_num").unwrap())); + let merger_num: u64 = args::get("merger_num") + .expect("missing arg merger_num") + .parse() + .unwrap_or_else(|_| panic!("bad arg, merger_num={}", args::get("merger_num").unwrap())); + + func_body(my_id, pyfile_path, sorter_num, merger_num) +} diff --git a/user/wasmtime_cpython_reducer/Cargo.lock b/user/wasmtime_cpython_reducer/Cargo.lock new file mode 100644 index 00000000..f95f04fc --- /dev/null +++ b/user/wasmtime_cpython_reducer/Cargo.lock @@ -0,0 +1,1196 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "anyhow" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" + +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cobs" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cranelift-bforest" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6b33d7e757a887989eb18b35712b2a67d96171ec3149d1bfb657b29b7b367c" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9acf15cb22be42d07c3b57d7856329cb228b7315d385346149df2566ad5e4aa" +dependencies = [ + "bumpalo", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-control", + "cranelift-entity", + "cranelift-isle", + "gimli", + "hashbrown 0.14.5", + "log", + "regalloc2", + "rustc-hash", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e934d301392b73b3f8b0540391fb82465a0f179a3cee7c726482ac4727efcc97" +dependencies = [ + "cranelift-codegen-shared", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb2a2566b3d54b854dfb288b3b187f6d3d17d6f762c92898207eba302931da" + +[[package]] +name = "cranelift-control" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0100f33b704cdacd01ad66ff41f8c5030d57cbff078e2a4e49ab1822591299fa" +dependencies = [ + "arbitrary", +] + +[[package]] +name = "cranelift-entity" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8cfdc315e5d18997093e040a8d234bea1ac1e118a716d3e30f40d449e78207b" +dependencies = [ + "serde", + "serde_derive", +] + +[[package]] +name = "cranelift-frontend" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f74b84f16af2e982b0c0c72233503d9d55cbfe3865dbe807ca28dc6642a28b5" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adf306d3dde705fb94bd48082f01d38c4ededc74293a4c007805f610bf08bc6e" + +[[package]] +name = "cranelift-native" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ea0ebdef7aff4a79bcbc8b6495f31315f16b3bf311152f472eaa8d679352581" +dependencies = [ + "cranelift-codegen", + "libc", + "target-lexicon", +] + +[[package]] +name = "cranelift-wasm" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d549108a1942065cdbac3bb96c2952afa0e1b9a3beff4b08c4308ac72257576d" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "itertools", + "log", + "smallvec", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "derive_more" +version = "0.99.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.79", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + +[[package]] +name = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "serde", +] + +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +dependencies = [ + "foldhash", +] + +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "hash32", + "stable_deref_trait", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + +[[package]] +name = "indexmap" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +dependencies = [ + "equivalent", + "hashbrown 0.15.0", + "serde", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "libc" +version = "0.2.159" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "linked_list_allocator" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" +dependencies = [ + "spinning_top", +] + +[[package]] +name = "linux-raw-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1ad52afd8f9448cbbe722ae722849cc41f1d365e285cca386896352bc08e1a9" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memfd" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" +dependencies = [ + "rustix", +] + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "ms_hostcall" +version = "0.1.0" +dependencies = [ + "bitflags", + "derive_more", + "thiserror-no-std", +] + +[[package]] +name = "ms_std" +version = "0.1.0" +dependencies = [ + "cfg-if", + "heapless", + "linked_list_allocator", + "ms_hostcall", + "ms_std_proc_macro", + "spin", + "thiserror-no-std", +] + +[[package]] +name = "ms_std_proc_macro" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "naked-function" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b8d5fca6ab1e6215b010aefd3b9ac5aae369dae0faea3a7f34f296cc9f719ac" +dependencies = [ + "cfg-if", + "naked-function-macro", +] + +[[package]] +name = "naked-function-macro" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b4123e70df5fe0bb370cff166ae453b9c5324a2cfc932c0f7e55498147a0475" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "object" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +dependencies = [ + "crc32fast", + "hashbrown 0.15.0", + "indexmap", + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "postcard" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f7f0a8d620d71c457dd1d47df76bb18960378da56af4527aaa10f515eee732e" +dependencies = [ + "cobs", + "embedded-io 0.4.0", + "embedded-io 0.6.1", + "serde", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205" +dependencies = [ + "cc", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regalloc2" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad156d539c879b7a24a363a2016d77961786e71f48f2e2fc8302a92abd2429a6" +dependencies = [ + "hashbrown 0.13.2", + "log", + "rustc-hash", + "slice-group-by", + "smallvec", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys 0.4.14", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "sc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "010e18bd3bfd1d45a7e666b236c78720df0d9a7698ebaa9c1c559961eb60a38b" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "serde_json" +version = "1.0.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "sjlj" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9b43efc387069aabdc27124a294337c7032a3cb62df0108d2578eff7f08e39" +dependencies = [ + "linux-raw-sys 0.2.2", + "naked-function", + "sc", +] + +[[package]] +name = "slice-group-by" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +dependencies = [ + "serde", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spinning_top" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" +dependencies = [ + "lock_api", +] + +[[package]] +name = "sptr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + +[[package]] +name = "thiserror" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "thiserror-impl-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "thiserror-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" +dependencies = [ + "thiserror-impl-no-std", +] + +[[package]] +name = "unicode-ident" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasm-encoder" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4a05336882dae732ce6bd48b7e11fe597293cb72c13da4f35d7d5f8d53b2a7" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasmparser" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07035cc9a9b41e62d3bb3a3815a66ab87c993c06fe1cf6b2a3f2a18499d937db" +dependencies = [ + "ahash", + "bitflags", + "hashbrown 0.14.5", + "indexmap", + "semver", + "serde", +] + +[[package]] +name = "wasmprinter" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceca8ae6eaa8c7c87b33c25c53bdf299f8c2a764aee1179402ff7652ef3a6859" +dependencies = [ + "anyhow", + "wasmparser", +] + +[[package]] +name = "wasmtime" +version = "22.0.0" +source = "git+https://gitee.com/tju-cloud-computing/wasmtime-as-lib?branch=master#fb45fb8dde6d068abb3ae78bfab78253c9654af5" +dependencies = [ + "anyhow", + "bumpalo", + "cc", + "cfg-if", + "encoding_rs", + "hashbrown 0.14.5", + "indexmap", + "libc", + "libm", + "log", + "mach2", + "memfd", + "memoffset", + "object", + "once_cell", + "paste", + "postcard", + "psm", + "rustix", + "semver", + "serde", + "serde_derive", + "smallvec", + "sptr", + "target-lexicon", + "wasmparser", + "wasmtime-asm-macros", + "wasmtime-component-macro", + "wasmtime-component-util", + "wasmtime-cranelift", + "wasmtime-environ", + "wasmtime-jit-icache-coherence", + "wasmtime-slab", + "wasmtime-versioned-export-macros", + "wasmtime-winch", + "windows-sys", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d697d99c341d4a9ffb72f3af7a02124d233eeb59aee010f36d88e97cca553d5e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-component-macro" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b29b462b068e73b5b27fae092a27f47e5937cabf6b26be2779c978698a52feca" +dependencies = [ + "anyhow", + "proc-macro2", + "quote", + "syn 2.0.79", + "wasmtime-component-util", + "wasmtime-wit-bindgen", + "wit-parser", +] + +[[package]] +name = "wasmtime-component-util" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d2912c53d9054984b380dfbd7579f9c3681b2a73b903a56bd71a1c4f175f1e" + +[[package]] +name = "wasmtime-cranelift" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3975deafea000457ba84355c7c0fce0372937204f77026510b7b454f28a3a65" +dependencies = [ + "anyhow", + "cfg-if", + "cranelift-codegen", + "cranelift-control", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "cranelift-wasm", + "gimli", + "log", + "object", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-environ", + "wasmtime-versioned-export-macros", +] + +[[package]] +name = "wasmtime-environ" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f444e900e848b884d8a8a2949b6f5b92af642a3e663ff8fbe78731143a55be61" +dependencies = [ + "anyhow", + "cranelift-entity", + "gimli", + "indexmap", + "log", + "object", + "postcard", + "serde", + "serde_derive", + "target-lexicon", + "wasm-encoder", + "wasmparser", + "wasmprinter", + "wasmtime-component-util", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5afe2f0499542f9a4bcfa1b55bfdda803b6ade4e7c93c6b99e0f39dba44b0a91" +dependencies = [ + "anyhow", + "cfg-if", + "libc", + "windows-sys", +] + +[[package]] +name = "wasmtime-slab" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a7de1f2bec5bbb35d532e61c85c049dc84ae671df60492f90b954ecf21169e7" + +[[package]] +name = "wasmtime-types" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "412463e9000e14cf6856be48628d2213c20c153e29ffc22b036980c892ea6964" +dependencies = [ + "cranelift-entity", + "serde", + "serde_derive", + "smallvec", + "wasmparser", +] + +[[package]] +name = "wasmtime-versioned-export-macros" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de5a9bc4f44ceeb168e9e8e3be4e0b4beb9095b468479663a9e24c667e36826f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "wasmtime-winch" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed4db238a0241df2d15f79ad17b3a37a27f2ea6cb885894d81b42ae107544466" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "object", + "target-lexicon", + "wasmparser", + "wasmtime-cranelift", + "wasmtime-environ", + "winch-codegen", +] + +[[package]] +name = "wasmtime-wit-bindgen" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc077306b38288262e5ba01d4b21532a6987416cdc0aedf04bb06c22a68fdc" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "wit-parser", +] + +[[package]] +name = "wasmtime_cpython_reducer" +version = "0.1.0" +dependencies = [ + "lazy_static", + "ms_hostcall", + "ms_std", + "sjlj", + "spin", + "wasmtime_wasi_api", +] + +[[package]] +name = "wasmtime_wasi_api" +version = "0.1.0" +dependencies = [ + "hashbrown 0.14.5", + "lazy_static", + "ms_hostcall", + "ms_std", + "ms_std_proc_macro", + "sjlj", + "spin", + "wasmtime", +] + +[[package]] +name = "winch-codegen" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c6915884e731b2db0d8cf08cb64474cb69221a161675fd3c135f91febc3daa" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "regalloc2", + "smallvec", + "target-lexicon", + "wasmparser", + "wasmtime-cranelift", + "wasmtime-environ", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-parser" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e79b9e3c0b6bb589dec46317e645851e0db2734c44e2be5e251b03ff4a51269" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] diff --git a/user/wasmtime_cpython_reducer/Cargo.toml b/user/wasmtime_cpython_reducer/Cargo.toml new file mode 100755 index 00000000..9872a749 --- /dev/null +++ b/user/wasmtime_cpython_reducer/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "wasmtime_cpython_reducer" +version = "0.1.0" +edition = "2021" +build = "build.rs" +# build = "../../build_user.rs" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +# crate-type = ["dylib"] +crate-type = ["staticlib"] + +[dependencies] +ms_std = { path = "../../ms_std", features = ["panic_def", "alloc_def"] } +ms_hostcall = { path = "../../ms_hostcall" } +wasmtime_wasi_api = { path = "../../wasmtime_wasi_api" } + +lazy_static = { version = "1.5.0", features = ["spin_no_std"] } +spin = "0.9.8" +sjlj = "0.1.3" + +[features] +mpk = ["ms_std/mpk"] diff --git a/user/wasmtime_cpython_reducer/build.rs b/user/wasmtime_cpython_reducer/build.rs new file mode 100644 index 00000000..9fc09ddf --- /dev/null +++ b/user/wasmtime_cpython_reducer/build.rs @@ -0,0 +1,4 @@ +fn main() { + println!("cargo:rustc-link-lib=static={}", "wasmtime-platform"); + println!("cargo:rustc-link-search=native={}", "./"); +} diff --git a/user/wasmtime_cpython_reducer/libwasmtime-platform.a b/user/wasmtime_cpython_reducer/libwasmtime-platform.a new file mode 100644 index 00000000..beebf570 Binary files /dev/null and b/user/wasmtime_cpython_reducer/libwasmtime-platform.a differ diff --git a/user/wasmtime_cpython_reducer/libwasmtime-platform.o b/user/wasmtime_cpython_reducer/libwasmtime-platform.o new file mode 100644 index 00000000..90bbf6dd Binary files /dev/null and b/user/wasmtime_cpython_reducer/libwasmtime-platform.o differ diff --git a/user/wasmtime_cpython_reducer/python.cwasm b/user/wasmtime_cpython_reducer/python.cwasm new file mode 100644 index 00000000..a38faac4 Binary files /dev/null and b/user/wasmtime_cpython_reducer/python.cwasm differ diff --git a/user/tinywasm_py/rustpython.wasm b/user/wasmtime_cpython_reducer/python.wasm old mode 100755 new mode 100644 similarity index 56% rename from user/tinywasm_py/rustpython.wasm rename to user/wasmtime_cpython_reducer/python.wasm index ae43912b..1d2b20b4 Binary files a/user/tinywasm_py/rustpython.wasm and b/user/wasmtime_cpython_reducer/python.wasm differ diff --git a/user/wasmtime_cpython_reducer/src/lib.rs b/user/wasmtime_cpython_reducer/src/lib.rs new file mode 100755 index 00000000..91b6e6b4 --- /dev/null +++ b/user/wasmtime_cpython_reducer/src/lib.rs @@ -0,0 +1,86 @@ +#![no_std] + +extern crate alloc; + +use alloc::sync::Arc; +use alloc::{format, string::{String, ToString}, vec::Vec}; +use spin::Mutex; +use core::mem::forget; + +use ms_hostcall::types::{OpenFlags, OpenMode}; +use ms_std::{agent::FaaSFuncResult as Result, args, libos::libos, println, time::{SystemTime, UNIX_EPOCH},}; + +use wasmtime_wasi_api::{wasmtime, LibosCtx}; +use wasmtime::Store; + +const CWASM: &[u8] = include_bytes!("../python.cwasm"); + +static INIT_LOCK: Mutex<()> = Mutex::new(()); + +lazy_static::lazy_static! { + static ref MUST_OPEN_ROOT: bool = { + libos!(open("/", OpenFlags::empty(), OpenMode::RD)).unwrap(); + true + }; +} + +fn func_body(my_id: &str, pyfile_path: &str, mapper_num: u64) -> Result<()> { + let my_map_id = &format!("reducer_{}", my_id); + + let mut jmpbuf = sjlj::JumpBuf::new(); + let if_panic = unsafe { sjlj::setjmp(&mut jmpbuf) }; + if if_panic != 0 { + #[cfg(feature = "log")] + println!("[Info] normal exit. if_panic: {:?}", if_panic); + // println!("phase3: {}", SystemTime::now().duration_since(UNIX_EPOCH).as_micros() as f64 / 1000000f64); + return Ok(().into()); + } else { + wasmtime_wasi_api::JMP_BUF_MAP.lock().insert(my_map_id.to_string(), Arc::new(jmpbuf)); + } + + #[cfg(feature = "log")] + println!("rust: my_id: {:?}, pyfile_path: {:?}, mapper_num: {:?}", my_id, pyfile_path, mapper_num); + + let wasi_args: Vec = Vec::from([ + "python.wasm".to_string(), + pyfile_path.to_string(), + my_id.to_string(), + mapper_num.to_string(), + ]); + wasmtime_wasi_api::set_wasi_args(my_map_id, wasi_args); + + let _open_root = *MUST_OPEN_ROOT; + + let lock = INIT_LOCK.lock(); + let (engine, module, linker) = wasmtime_wasi_api::build_wasm(CWASM); + drop(lock); + + let mut store = Store::new(&engine, LibosCtx{id: my_map_id.to_string()}); + let instance = linker.instantiate(&mut store, &module)?; + + let main = instance + .get_typed_func::<(), ()>(&mut store, "_start") + .map_err(|e| e.to_string())?; + + // println!("{}", SystemTime::now().duration_since(UNIX_EPOCH).as_nanos()); + main.call(&mut store, ()).map_err(|e| e.to_string())?; + forget(store); + + #[cfg(feature = "log")] + println!("rust: wasmtime_cpython_reducer_{:?} finished!", my_id); + + Ok(().into()) +} + + +#[no_mangle] +pub fn main() -> Result<()> { + let my_id = args::get("id").unwrap(); + let pyfile_path = args::get("pyfile_path").unwrap(); + let mapper_num: u64 = args::get("mapper_num") + .expect("missing arg mapper_num") + .parse() + .unwrap_or_else(|_| panic!("bad arg, mapper_num={}", args::get("mapper_num").unwrap())); + + func_body(my_id, pyfile_path, mapper_num) +} diff --git a/user/wasmtime_cpython_wordcount/Cargo.lock b/user/wasmtime_cpython_wordcount/Cargo.lock new file mode 100644 index 00000000..ff660e51 --- /dev/null +++ b/user/wasmtime_cpython_wordcount/Cargo.lock @@ -0,0 +1,1196 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "anyhow" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" + +[[package]] +name = "arbitrary" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d5a26814d8dcb93b0e5a0ff3c6d80a8843bafb21b39e8e18a6f05471870e110" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cobs" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67ba02a97a2bd10f4b59b25c7973101c79642302776489e030cd13cdab09ed15" + +[[package]] +name = "convert_case" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" + +[[package]] +name = "cranelift-bforest" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b6b33d7e757a887989eb18b35712b2a67d96171ec3149d1bfb657b29b7b367c" +dependencies = [ + "cranelift-entity", +] + +[[package]] +name = "cranelift-codegen" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9acf15cb22be42d07c3b57d7856329cb228b7315d385346149df2566ad5e4aa" +dependencies = [ + "bumpalo", + "cranelift-bforest", + "cranelift-codegen-meta", + "cranelift-codegen-shared", + "cranelift-control", + "cranelift-entity", + "cranelift-isle", + "gimli", + "hashbrown 0.14.5", + "log", + "regalloc2", + "rustc-hash", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-codegen-meta" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e934d301392b73b3f8b0540391fb82465a0f179a3cee7c726482ac4727efcc97" +dependencies = [ + "cranelift-codegen-shared", +] + +[[package]] +name = "cranelift-codegen-shared" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb2a2566b3d54b854dfb288b3b187f6d3d17d6f762c92898207eba302931da" + +[[package]] +name = "cranelift-control" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0100f33b704cdacd01ad66ff41f8c5030d57cbff078e2a4e49ab1822591299fa" +dependencies = [ + "arbitrary", +] + +[[package]] +name = "cranelift-entity" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8cfdc315e5d18997093e040a8d234bea1ac1e118a716d3e30f40d449e78207b" +dependencies = [ + "serde", + "serde_derive", +] + +[[package]] +name = "cranelift-frontend" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f74b84f16af2e982b0c0c72233503d9d55cbfe3865dbe807ca28dc6642a28b5" +dependencies = [ + "cranelift-codegen", + "log", + "smallvec", + "target-lexicon", +] + +[[package]] +name = "cranelift-isle" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adf306d3dde705fb94bd48082f01d38c4ededc74293a4c007805f610bf08bc6e" + +[[package]] +name = "cranelift-native" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ea0ebdef7aff4a79bcbc8b6495f31315f16b3bf311152f472eaa8d679352581" +dependencies = [ + "cranelift-codegen", + "libc", + "target-lexicon", +] + +[[package]] +name = "cranelift-wasm" +version = "0.109.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d549108a1942065cdbac3bb96c2952afa0e1b9a3beff4b08c4308ac72257576d" +dependencies = [ + "cranelift-codegen", + "cranelift-entity", + "cranelift-frontend", + "itertools", + "log", + "smallvec", + "wasmparser", + "wasmtime-types", +] + +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "derive_more" +version = "0.99.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f33878137e4dafd7fa914ad4e259e18a4e8e532b9617a2d0150262bf53abfce" +dependencies = [ + "convert_case", + "proc-macro2", + "quote", + "rustc_version", + "syn 2.0.79", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + +[[package]] +name = "encoding_rs" +version = "0.8.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" +dependencies = [ + "fallible-iterator", + "indexmap", + "stable_deref_trait", +] + +[[package]] +name = "hash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606" +dependencies = [ + "byteorder", +] + +[[package]] +name = "hashbrown" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "serde", +] + +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +dependencies = [ + "foldhash", +] + +[[package]] +name = "heapless" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad" +dependencies = [ + "hash32", + "stable_deref_trait", +] + +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + +[[package]] +name = "indexmap" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" +dependencies = [ + "equivalent", + "hashbrown 0.15.0", + "serde", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +dependencies = [ + "spin", +] + +[[package]] +name = "leb128" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "884e2677b40cc8c339eaefcb701c32ef1fd2493d71118dc0ca4b6a736c93bd67" + +[[package]] +name = "libc" +version = "0.2.159" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "linked_list_allocator" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afa463f5405ee81cdb9cc2baf37e08ec7e4c8209442b5d72c04cfb2cd6e6286" +dependencies = [ + "spinning_top", +] + +[[package]] +name = "linux-raw-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1ad52afd8f9448cbbe722ae722849cc41f1d365e285cca386896352bc08e1a9" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "mach2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b955cdeb2a02b9117f121ce63aa52d08ade45de53e48fe6a38b39c10f6f709" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "memfd" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2cffa4ad52c6f791f4f8b15f0c05f9824b2ced1160e88cc393d64fff9a8ac64" +dependencies = [ + "rustix", +] + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "ms_hostcall" +version = "0.1.0" +dependencies = [ + "bitflags", + "derive_more", + "thiserror-no-std", +] + +[[package]] +name = "ms_std" +version = "0.1.0" +dependencies = [ + "cfg-if", + "heapless", + "linked_list_allocator", + "ms_hostcall", + "ms_std_proc_macro", + "spin", + "thiserror-no-std", +] + +[[package]] +name = "ms_std_proc_macro" +version = "0.1.0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "naked-function" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b8d5fca6ab1e6215b010aefd3b9ac5aae369dae0faea3a7f34f296cc9f719ac" +dependencies = [ + "cfg-if", + "naked-function-macro", +] + +[[package]] +name = "naked-function-macro" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b4123e70df5fe0bb370cff166ae453b9c5324a2cfc932c0f7e55498147a0475" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "object" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +dependencies = [ + "crc32fast", + "hashbrown 0.15.0", + "indexmap", + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "postcard" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f7f0a8d620d71c457dd1d47df76bb18960378da56af4527aaa10f515eee732e" +dependencies = [ + "cobs", + "embedded-io 0.4.0", + "embedded-io 0.6.1", + "serde", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "psm" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa37f80ca58604976033fae9515a8a2989fc13797d953f7c04fb8fa36a11f205" +dependencies = [ + "cc", +] + +[[package]] +name = "quote" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regalloc2" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad156d539c879b7a24a363a2016d77961786e71f48f2e2fc8302a92abd2429a6" +dependencies = [ + "hashbrown 0.13.2", + "log", + "rustc-hash", + "slice-group-by", + "smallvec", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys 0.4.14", + "windows-sys", +] + +[[package]] +name = "ryu" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" + +[[package]] +name = "sc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "010e18bd3bfd1d45a7e666b236c78720df0d9a7698ebaa9c1c559961eb60a38b" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b" + +[[package]] +name = "serde" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.210" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "serde_json" +version = "1.0.128" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "sjlj" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9b43efc387069aabdc27124a294337c7032a3cb62df0108d2578eff7f08e39" +dependencies = [ + "linux-raw-sys 0.2.2", + "naked-function", + "sc", +] + +[[package]] +name = "slice-group-by" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "826167069c09b99d56f31e9ae5c99049e932a98c9dc2dac47645b08dbbf76ba7" + +[[package]] +name = "smallvec" +version = "1.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" +dependencies = [ + "serde", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" +dependencies = [ + "lock_api", +] + +[[package]] +name = "spinning_top" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9eb1a2f4c41445a3a0ff9abc5221c5fcd28e1f13cd7c0397706f9ac938ddb0" +dependencies = [ + "lock_api", +] + +[[package]] +name = "sptr" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b9b39299b249ad65f3b7e96443bad61c02ca5cd3589f46cb6d610a0fd6c0d6a" + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + +[[package]] +name = "thiserror" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.64" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "thiserror-impl-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58e6318948b519ba6dc2b442a6d0b904ebfb8d411a3ad3e07843615a72249758" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "thiserror-no-std" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3ad459d94dd517257cc96add8a43190ee620011bb6e6cdc82dafd97dfafafea" +dependencies = [ + "thiserror-impl-no-std", +] + +[[package]] +name = "unicode-ident" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" + +[[package]] +name = "unicode-xid" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasm-encoder" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b4a05336882dae732ce6bd48b7e11fe597293cb72c13da4f35d7d5f8d53b2a7" +dependencies = [ + "leb128", +] + +[[package]] +name = "wasmparser" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07035cc9a9b41e62d3bb3a3815a66ab87c993c06fe1cf6b2a3f2a18499d937db" +dependencies = [ + "ahash", + "bitflags", + "hashbrown 0.14.5", + "indexmap", + "semver", + "serde", +] + +[[package]] +name = "wasmprinter" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceca8ae6eaa8c7c87b33c25c53bdf299f8c2a764aee1179402ff7652ef3a6859" +dependencies = [ + "anyhow", + "wasmparser", +] + +[[package]] +name = "wasmtime" +version = "22.0.0" +source = "git+https://gitee.com/tju-cloud-computing/wasmtime-as-lib?branch=master#fb45fb8dde6d068abb3ae78bfab78253c9654af5" +dependencies = [ + "anyhow", + "bumpalo", + "cc", + "cfg-if", + "encoding_rs", + "hashbrown 0.14.5", + "indexmap", + "libc", + "libm", + "log", + "mach2", + "memfd", + "memoffset", + "object", + "once_cell", + "paste", + "postcard", + "psm", + "rustix", + "semver", + "serde", + "serde_derive", + "smallvec", + "sptr", + "target-lexicon", + "wasmparser", + "wasmtime-asm-macros", + "wasmtime-component-macro", + "wasmtime-component-util", + "wasmtime-cranelift", + "wasmtime-environ", + "wasmtime-jit-icache-coherence", + "wasmtime-slab", + "wasmtime-versioned-export-macros", + "wasmtime-winch", + "windows-sys", +] + +[[package]] +name = "wasmtime-asm-macros" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d697d99c341d4a9ffb72f3af7a02124d233eeb59aee010f36d88e97cca553d5e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "wasmtime-component-macro" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b29b462b068e73b5b27fae092a27f47e5937cabf6b26be2779c978698a52feca" +dependencies = [ + "anyhow", + "proc-macro2", + "quote", + "syn 2.0.79", + "wasmtime-component-util", + "wasmtime-wit-bindgen", + "wit-parser", +] + +[[package]] +name = "wasmtime-component-util" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d2912c53d9054984b380dfbd7579f9c3681b2a73b903a56bd71a1c4f175f1e" + +[[package]] +name = "wasmtime-cranelift" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3975deafea000457ba84355c7c0fce0372937204f77026510b7b454f28a3a65" +dependencies = [ + "anyhow", + "cfg-if", + "cranelift-codegen", + "cranelift-control", + "cranelift-entity", + "cranelift-frontend", + "cranelift-native", + "cranelift-wasm", + "gimli", + "log", + "object", + "target-lexicon", + "thiserror", + "wasmparser", + "wasmtime-environ", + "wasmtime-versioned-export-macros", +] + +[[package]] +name = "wasmtime-environ" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f444e900e848b884d8a8a2949b6f5b92af642a3e663ff8fbe78731143a55be61" +dependencies = [ + "anyhow", + "cranelift-entity", + "gimli", + "indexmap", + "log", + "object", + "postcard", + "serde", + "serde_derive", + "target-lexicon", + "wasm-encoder", + "wasmparser", + "wasmprinter", + "wasmtime-component-util", + "wasmtime-types", +] + +[[package]] +name = "wasmtime-jit-icache-coherence" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5afe2f0499542f9a4bcfa1b55bfdda803b6ade4e7c93c6b99e0f39dba44b0a91" +dependencies = [ + "anyhow", + "cfg-if", + "libc", + "windows-sys", +] + +[[package]] +name = "wasmtime-slab" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a7de1f2bec5bbb35d532e61c85c049dc84ae671df60492f90b954ecf21169e7" + +[[package]] +name = "wasmtime-types" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "412463e9000e14cf6856be48628d2213c20c153e29ffc22b036980c892ea6964" +dependencies = [ + "cranelift-entity", + "serde", + "serde_derive", + "smallvec", + "wasmparser", +] + +[[package]] +name = "wasmtime-versioned-export-macros" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de5a9bc4f44ceeb168e9e8e3be4e0b4beb9095b468479663a9e24c667e36826f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] + +[[package]] +name = "wasmtime-winch" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed4db238a0241df2d15f79ad17b3a37a27f2ea6cb885894d81b42ae107544466" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "object", + "target-lexicon", + "wasmparser", + "wasmtime-cranelift", + "wasmtime-environ", + "winch-codegen", +] + +[[package]] +name = "wasmtime-wit-bindgen" +version = "22.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc077306b38288262e5ba01d4b21532a6987416cdc0aedf04bb06c22a68fdc" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "wit-parser", +] + +[[package]] +name = "wasmtime_cpython_wordcount" +version = "0.1.0" +dependencies = [ + "lazy_static", + "ms_hostcall", + "ms_std", + "sjlj", + "spin", + "wasmtime_wasi_api", +] + +[[package]] +name = "wasmtime_wasi_api" +version = "0.1.0" +dependencies = [ + "hashbrown 0.14.5", + "lazy_static", + "ms_hostcall", + "ms_std", + "ms_std_proc_macro", + "sjlj", + "spin", + "wasmtime", +] + +[[package]] +name = "winch-codegen" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85c6915884e731b2db0d8cf08cb64474cb69221a161675fd3c135f91febc3daa" +dependencies = [ + "anyhow", + "cranelift-codegen", + "gimli", + "regalloc2", + "smallvec", + "target-lexicon", + "wasmparser", + "wasmtime-cranelift", + "wasmtime-environ", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-parser" +version = "0.209.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e79b9e3c0b6bb589dec46317e645851e0db2734c44e2be5e251b03ff4a51269" +dependencies = [ + "anyhow", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-xid", + "wasmparser", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.79", +] diff --git a/user/wasmtime_cpython_wordcount/Cargo.toml b/user/wasmtime_cpython_wordcount/Cargo.toml new file mode 100644 index 00000000..36736488 --- /dev/null +++ b/user/wasmtime_cpython_wordcount/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "wasmtime_cpython_wordcount" +version = "0.1.0" +edition = "2021" +build = "build.rs" +# build = "../../build_user.rs" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +# crate-type = ["dylib"] +crate-type = ["staticlib"] + +[dependencies] +ms_std = { path = "../../ms_std", features = ["panic_def", "alloc_def"] } +ms_hostcall = { path = "../../ms_hostcall" } +wasmtime_wasi_api = { path = "../../wasmtime_wasi_api" } + +lazy_static = { version = "1.5.0", features = ["spin_no_std"] } +spin = "0.9.8" +sjlj = "0.1.3" + +[features] +mpk = ["ms_std/mpk"] diff --git a/user/wasmtime_cpython_wordcount/build.rs b/user/wasmtime_cpython_wordcount/build.rs new file mode 100644 index 00000000..9fc09ddf --- /dev/null +++ b/user/wasmtime_cpython_wordcount/build.rs @@ -0,0 +1,4 @@ +fn main() { + println!("cargo:rustc-link-lib=static={}", "wasmtime-platform"); + println!("cargo:rustc-link-search=native={}", "./"); +} diff --git a/user/wasmtime_cpython_wordcount/libwasmtime-platform.a b/user/wasmtime_cpython_wordcount/libwasmtime-platform.a new file mode 100644 index 00000000..beebf570 Binary files /dev/null and b/user/wasmtime_cpython_wordcount/libwasmtime-platform.a differ diff --git a/user/wasmtime_cpython_wordcount/libwasmtime-platform.o b/user/wasmtime_cpython_wordcount/libwasmtime-platform.o new file mode 100644 index 00000000..90bbf6dd Binary files /dev/null and b/user/wasmtime_cpython_wordcount/libwasmtime-platform.o differ diff --git a/user/wasmtime_cpython_wordcount/python.cwasm b/user/wasmtime_cpython_wordcount/python.cwasm new file mode 100644 index 00000000..a38faac4 Binary files /dev/null and b/user/wasmtime_cpython_wordcount/python.cwasm differ diff --git a/user/wasmtime_cpython_wordcount/python.wasm b/user/wasmtime_cpython_wordcount/python.wasm new file mode 100644 index 00000000..1d2b20b4 Binary files /dev/null and b/user/wasmtime_cpython_wordcount/python.wasm differ diff --git a/user/wasmtime_cpython_wordcount/src/lib.rs b/user/wasmtime_cpython_wordcount/src/lib.rs new file mode 100755 index 00000000..fece0101 --- /dev/null +++ b/user/wasmtime_cpython_wordcount/src/lib.rs @@ -0,0 +1,102 @@ +#![no_std] + +extern crate alloc; + +use alloc::sync::Arc; +use alloc::{ + format, + string::{String, ToString}, + vec::Vec, +}; +use core::mem::forget; +use spin::Mutex; + +use ms_hostcall::types::{OpenFlags, OpenMode}; +use ms_std::{agent::FaaSFuncResult as Result, args, libos::libos}; + +use wasmtime::Store; +use wasmtime_wasi_api::{wasmtime, LibosCtx}; + +const CWASM: &[u8] = include_bytes!("../python.cwasm"); + +static INIT_LOCK: Mutex<()> = Mutex::new(()); + +lazy_static::lazy_static! { + static ref MUST_OPEN_ROOT: bool = { + libos!(open("/", OpenFlags::empty(), OpenMode::RD)).unwrap(); + true + }; +} + +fn func_body(my_id: &str, pyfile_path: &str, reducer_num: u64, mapper_num: u64) -> Result<()> { + let my_map_id = &format!("wordcount_{}", my_id); + + let mut jmpbuf = sjlj::JumpBuf::new(); + let if_panic = unsafe { sjlj::setjmp(&mut jmpbuf) }; + if if_panic != 0 { + #[cfg(feature = "log")] + println!("[Info] normal exit. if_panic: {:?}", if_panic); + return Ok(().into()); + } else { + wasmtime_wasi_api::JMP_BUF_MAP + .lock() + .insert(my_map_id.to_string(), Arc::new(jmpbuf)); + } + + #[cfg(feature = "log")] + println!( + "rust: my_id: {:?}, pyfile_path: {:?}, reducer_num: {:?}, mapper_num: {:?}", + my_id, pyfile_path, reducer_num, mapper_num + ); + + let wasi_args: Vec = Vec::from([ + "python.wasm".to_string(), + pyfile_path.to_string(), + my_id.to_string(), + reducer_num.to_string(), + mapper_num.to_string(), + ]); + wasmtime_wasi_api::set_wasi_args(my_map_id, wasi_args); + + let _open_root = *MUST_OPEN_ROOT; + + let lock = INIT_LOCK.lock(); + let (engine, module, linker) = wasmtime_wasi_api::build_wasm(CWASM); + drop(lock); + + let mut store = Store::new( + &engine, + LibosCtx { + id: my_map_id.to_string(), + }, + ); + let instance = linker.instantiate(&mut store, &module)?; + + let main = instance + .get_typed_func::<(), ()>(&mut store, "_start") + .map_err(|e| e.to_string())?; + + main.call(&mut store, ()).map_err(|e| e.to_string())?; + forget(store); + + #[cfg(feature = "log")] + println!("rust: wasmtime_cpython_wordcount_{:?} finished!", my_id); + + Ok(().into()) +} + +#[no_mangle] +pub fn main() -> Result<()> { + let my_id = args::get("id").unwrap(); + let pyfile_path = args::get("pyfile_path").unwrap(); + let reducer_num: u64 = args::get("reducer_num") + .expect("missing arg reducer_num") + .parse() + .unwrap_or_else(|_| panic!("bad arg, reducer_num={}", args::get("reducer_num").unwrap())); + let mapper_num: u64 = args::get("mapper_num") + .expect("missing arg mapper_num") + .parse() + .unwrap_or_else(|_| panic!("bad arg, mapper_num={}", args::get("mapper_num").unwrap())); + + func_body(my_id, pyfile_path, reducer_num, mapper_num) +} diff --git a/user/wasmtime_func_a/build.sh b/user/wasmtime_func_a/build.sh deleted file mode 100755 index 0c6cecb6..00000000 --- a/user/wasmtime_func_a/build.sh +++ /dev/null @@ -1,15 +0,0 @@ -$CPP mapper.cpp -o mapper.wasm -fno-exceptions -fno-rtti -ffast-math -funroll-loops -fomit-frame-pointer -Ofast -# $CC mapper.c -o mapper.wasm -O3 - -wasmtime compile --target x86_64-unknown-none -W threads=n,tail-call=n mapper.wasm - -cargo build --target x86_64-unknown-none --release && cc \ - -Wl,--gc-sections -nostdlib \ - -Wl,--whole-archive \ - target/x86_64-unknown-none/release/libwasmtime_mapper.a \ - -Wl,--no-whole-archive \ - -shared \ - -o target/x86_64-unknown-none/release/libwasmtime_mapper.so - -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_mapper/target/x86_64-unknown-none/release/libwasmtime_mapper.so /home/wyj/alloy_stack/mslibos/target/release/libwasmtime_mapper.so - diff --git a/user/wasmtime_func_a/func_a.cpp b/user/wasmtime_func_a/func_a.cpp deleted file mode 100644 index c41965d8..00000000 --- a/user/wasmtime_func_a/func_a.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -#define MAX_SLOT_NUM 10 -#define MAX_WORDS 20000000 -#define MAX_BUFFER_SIZE 500000 - -string words[MAX_WORDS]; -int counts[MAX_WORDS]; - -__attribute__((import_module("env"), import_name("buffer_register"))) void buffer_register(void *slot_name, int name_size, void *buffer, int buffer_size); - -void get_time() { - timeval tv{}; - gettimeofday(&tv, nullptr); - printf("%lld.%lld\n", tv.tv_sec, tv.tv_usec); -} - -int main(int argc, char* argv[]) { - int id = atoi(argv[1]); - int reducer_num = atoi(argv[2]); - cout << "mapper_" << id << " start!" << endl; - - string input_file = "fake_data_" + to_string(id) + ".txt"; - ifstream file(input_file); - - int word_index = 0; - - string word; - // vector words; - // vector counts; - - - printf("start reading file\n"); - get_time(); - while (file >> word) { - transform(word.begin(), word.end(), word.begin(), - [](unsigned char c) { return std::tolower(c); }); - int found = 0; - for (int i = 0; i < word_index; i++) { - if (words[i] == word) { - counts[i]++; - found = 1; - break; - } - } - if (!found) { - words[word_index] = word; - counts[word_index] = 1; - // words.push_back(word); - // counts.push_back(1); - // words.emplace_back(word); - // count.emplace_back(1); - word_index++; - } - } - printf("finish reading file\n"); - get_time(); - // return 0; - file.close(); - - cout << "mapper_" << id << " read success!" << endl; - - string buffer[MAX_SLOT_NUM]; - string slot_name[MAX_SLOT_NUM]; - int slot_index = 0; - - for (int i = 0; i < word_index; i++) { - int partition_index = i % reducer_num; - string slot = "buffer_" + to_string(partition_index) + "_" + to_string(id); - int found = 0; - for (int j = 0; j < slot_index; j++) { - if (slot_name[j] == slot) { - found = 1; - buffer[j].append(words[i] + ": " + to_string(counts[i]) + "\n"); - break; - } - } - - if (!found) { - slot_name[slot_index] = slot; - buffer[slot_index] = words[i] + ": " + to_string(counts[i]) + "\n"; - slot_index++; - } - } - - for (int i = 0; i < MAX_SLOT_NUM; i++) { - buffer[i].resize(MAX_BUFFER_SIZE, '\0'); - } - - - cout << "mapper_" << id << " solved " << word_index << " words!" << endl; - for (int i = 0; i < slot_index; i++) { - buffer_register((void*)slot_name[i].c_str(), slot_name[i].length(), (void*)buffer[i].c_str(), buffer[i].size()); - // cout << "buffersize" << i << ": " << buffer[i].size() << endl; - } - cout << "mapper_" << id << " write finished!" << endl; - - return 0; -} \ No newline at end of file diff --git a/user/wasmtime_func_a/src/lib.rs b/user/wasmtime_func_a/src/lib.rs deleted file mode 100644 index fd2abb4e..00000000 --- a/user/wasmtime_func_a/src/lib.rs +++ /dev/null @@ -1,76 +0,0 @@ -#![no_std] - -extern crate alloc; -use core::mem::forget; - -use alloc::{string::{String, ToString}, vec::Vec}; -use spin::Mutex; - -use ms_hostcall::types::{OpenFlags, OpenMode}; -use ms_std::{agent::FaaSFuncResult as Result, args, println, libos::libos, time::{SystemTime, UNIX_EPOCH}}; - - -use wasmtime_wasi_api::{wasmtime, LibosCtx}; -use wasmtime::Store; - -static CWASM: &[u8] = include_bytes!("../mapper.cwasm"); - -static INIT_LOCK: Mutex<()> = Mutex::new(()); - -lazy_static::lazy_static! { - static ref MUST_OPEN_ROOT: bool = { - libos!(open("/", OpenFlags::empty(), OpenMode::RD)).unwrap(); - true - }; -} - -fn func_body(my_id: &str, reducer_num: u64) -> Result<()> { - #[cfg(feature = "log")] - - println!("rust: my_id: {:?}, reducer_num: {:?}", my_id, reducer_num); - - let wasi_args: Vec = Vec::from([ - "fake system path!".to_string(), - my_id.to_string(), - reducer_num.to_string(), - ]); - wasmtime_wasi_api::set_wasi_args(my_id, wasi_args); - - let _open_root = *MUST_OPEN_ROOT; - - let lock = INIT_LOCK.lock(); - let (engine, module, linker) = wasmtime_wasi_api::build_wasm(CWASM); - drop(lock); - - let mut store = Store::new(&engine, LibosCtx{id: my_id.to_string()}); - let instance = linker.instantiate(&mut store, &module)?; - - let mut memory = instance.get_memory(&mut store, "memory").unwrap(); - let pages = memory.grow(&mut store, 20000).unwrap(); - println!("rust: pages: {}", pages); - - let main = instance - .get_typed_func::<(), ()>(&mut store, "_start") - .map_err(|e| e.to_string())?; - - let start_time = SystemTime::now().duration_since(UNIX_EPOCH).as_millis(); - println!("start_time: {:?}", start_time); - main.call(store, ()).map_err(|e| e.to_string())?; - - #[cfg(feature = "log")] - println!("rust: wasmtime_mapper_{:?} finished!", my_id); - let end_time = SystemTime::now().duration_since(UNIX_EPOCH).as_millis(); - println!("end_time: {:?}", end_time); - Ok(().into()) -} - -#[no_mangle] -pub fn main() -> Result<()> { - let my_id = args::get("id").unwrap(); - let reducer_num: u64 = args::get("reducer_num") - .expect("missing arg reducer_num") - .parse() - .unwrap_or_else(|_| panic!("bad arg, reducer_num={}", args::get("reducer_num").unwrap())); - - func_body(my_id, reducer_num) -} diff --git a/user/wasmtime_func_b/build.sh b/user/wasmtime_func_b/build.sh deleted file mode 100755 index 0c6cecb6..00000000 --- a/user/wasmtime_func_b/build.sh +++ /dev/null @@ -1,15 +0,0 @@ -$CPP mapper.cpp -o mapper.wasm -fno-exceptions -fno-rtti -ffast-math -funroll-loops -fomit-frame-pointer -Ofast -# $CC mapper.c -o mapper.wasm -O3 - -wasmtime compile --target x86_64-unknown-none -W threads=n,tail-call=n mapper.wasm - -cargo build --target x86_64-unknown-none --release && cc \ - -Wl,--gc-sections -nostdlib \ - -Wl,--whole-archive \ - target/x86_64-unknown-none/release/libwasmtime_mapper.a \ - -Wl,--no-whole-archive \ - -shared \ - -o target/x86_64-unknown-none/release/libwasmtime_mapper.so - -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_mapper/target/x86_64-unknown-none/release/libwasmtime_mapper.so /home/wyj/alloy_stack/mslibos/target/release/libwasmtime_mapper.so - diff --git a/user/wasmtime_func_b/func_a.cpp b/user/wasmtime_func_b/func_a.cpp deleted file mode 100644 index c41965d8..00000000 --- a/user/wasmtime_func_b/func_a.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -#define MAX_SLOT_NUM 10 -#define MAX_WORDS 20000000 -#define MAX_BUFFER_SIZE 500000 - -string words[MAX_WORDS]; -int counts[MAX_WORDS]; - -__attribute__((import_module("env"), import_name("buffer_register"))) void buffer_register(void *slot_name, int name_size, void *buffer, int buffer_size); - -void get_time() { - timeval tv{}; - gettimeofday(&tv, nullptr); - printf("%lld.%lld\n", tv.tv_sec, tv.tv_usec); -} - -int main(int argc, char* argv[]) { - int id = atoi(argv[1]); - int reducer_num = atoi(argv[2]); - cout << "mapper_" << id << " start!" << endl; - - string input_file = "fake_data_" + to_string(id) + ".txt"; - ifstream file(input_file); - - int word_index = 0; - - string word; - // vector words; - // vector counts; - - - printf("start reading file\n"); - get_time(); - while (file >> word) { - transform(word.begin(), word.end(), word.begin(), - [](unsigned char c) { return std::tolower(c); }); - int found = 0; - for (int i = 0; i < word_index; i++) { - if (words[i] == word) { - counts[i]++; - found = 1; - break; - } - } - if (!found) { - words[word_index] = word; - counts[word_index] = 1; - // words.push_back(word); - // counts.push_back(1); - // words.emplace_back(word); - // count.emplace_back(1); - word_index++; - } - } - printf("finish reading file\n"); - get_time(); - // return 0; - file.close(); - - cout << "mapper_" << id << " read success!" << endl; - - string buffer[MAX_SLOT_NUM]; - string slot_name[MAX_SLOT_NUM]; - int slot_index = 0; - - for (int i = 0; i < word_index; i++) { - int partition_index = i % reducer_num; - string slot = "buffer_" + to_string(partition_index) + "_" + to_string(id); - int found = 0; - for (int j = 0; j < slot_index; j++) { - if (slot_name[j] == slot) { - found = 1; - buffer[j].append(words[i] + ": " + to_string(counts[i]) + "\n"); - break; - } - } - - if (!found) { - slot_name[slot_index] = slot; - buffer[slot_index] = words[i] + ": " + to_string(counts[i]) + "\n"; - slot_index++; - } - } - - for (int i = 0; i < MAX_SLOT_NUM; i++) { - buffer[i].resize(MAX_BUFFER_SIZE, '\0'); - } - - - cout << "mapper_" << id << " solved " << word_index << " words!" << endl; - for (int i = 0; i < slot_index; i++) { - buffer_register((void*)slot_name[i].c_str(), slot_name[i].length(), (void*)buffer[i].c_str(), buffer[i].size()); - // cout << "buffersize" << i << ": " << buffer[i].size() << endl; - } - cout << "mapper_" << id << " write finished!" << endl; - - return 0; -} \ No newline at end of file diff --git a/user/wasmtime_func_b/src/lib.rs b/user/wasmtime_func_b/src/lib.rs deleted file mode 100644 index fd2abb4e..00000000 --- a/user/wasmtime_func_b/src/lib.rs +++ /dev/null @@ -1,76 +0,0 @@ -#![no_std] - -extern crate alloc; -use core::mem::forget; - -use alloc::{string::{String, ToString}, vec::Vec}; -use spin::Mutex; - -use ms_hostcall::types::{OpenFlags, OpenMode}; -use ms_std::{agent::FaaSFuncResult as Result, args, println, libos::libos, time::{SystemTime, UNIX_EPOCH}}; - - -use wasmtime_wasi_api::{wasmtime, LibosCtx}; -use wasmtime::Store; - -static CWASM: &[u8] = include_bytes!("../mapper.cwasm"); - -static INIT_LOCK: Mutex<()> = Mutex::new(()); - -lazy_static::lazy_static! { - static ref MUST_OPEN_ROOT: bool = { - libos!(open("/", OpenFlags::empty(), OpenMode::RD)).unwrap(); - true - }; -} - -fn func_body(my_id: &str, reducer_num: u64) -> Result<()> { - #[cfg(feature = "log")] - - println!("rust: my_id: {:?}, reducer_num: {:?}", my_id, reducer_num); - - let wasi_args: Vec = Vec::from([ - "fake system path!".to_string(), - my_id.to_string(), - reducer_num.to_string(), - ]); - wasmtime_wasi_api::set_wasi_args(my_id, wasi_args); - - let _open_root = *MUST_OPEN_ROOT; - - let lock = INIT_LOCK.lock(); - let (engine, module, linker) = wasmtime_wasi_api::build_wasm(CWASM); - drop(lock); - - let mut store = Store::new(&engine, LibosCtx{id: my_id.to_string()}); - let instance = linker.instantiate(&mut store, &module)?; - - let mut memory = instance.get_memory(&mut store, "memory").unwrap(); - let pages = memory.grow(&mut store, 20000).unwrap(); - println!("rust: pages: {}", pages); - - let main = instance - .get_typed_func::<(), ()>(&mut store, "_start") - .map_err(|e| e.to_string())?; - - let start_time = SystemTime::now().duration_since(UNIX_EPOCH).as_millis(); - println!("start_time: {:?}", start_time); - main.call(store, ()).map_err(|e| e.to_string())?; - - #[cfg(feature = "log")] - println!("rust: wasmtime_mapper_{:?} finished!", my_id); - let end_time = SystemTime::now().duration_since(UNIX_EPOCH).as_millis(); - println!("end_time: {:?}", end_time); - Ok(().into()) -} - -#[no_mangle] -pub fn main() -> Result<()> { - let my_id = args::get("id").unwrap(); - let reducer_num: u64 = args::get("reducer_num") - .expect("missing arg reducer_num") - .parse() - .unwrap_or_else(|_| panic!("bad arg, reducer_num={}", args::get("reducer_num").unwrap())); - - func_body(my_id, reducer_num) -} diff --git a/user/wasmtime_hello/command.sh b/user/wasmtime_hello/command.sh deleted file mode 100755 index 1bb1dcc7..00000000 --- a/user/wasmtime_hello/command.sh +++ /dev/null @@ -1,49 +0,0 @@ -cargo build --target x86_64-unknown-none --release && cc \ - -Wl,--gc-sections -nostdlib \ - -Wl,--whole-archive \ - target/x86_64-unknown-none/release/libwasmtime_mapper.a \ - -Wl,--no-whole-archive \ - -shared \ - -o target/x86_64-unknown-none/release/libwasmtime_mapper.so - -cargo run -- --files ./isol_config/wasmtime_wordcount.json - -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_mapper/target/x86_64-unknown-none/debug/libwasmtime_mapper.so target/debug/libwasmtime_mapper.so -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_mapper/target/x86_64-unknown-none/release/libwasmtime_mapper.so target/release/libwasmtime_mapper.so - -wasmtime compile --target x86_64-unknown-none -W threads=n,tail-call=n mapper.wasm - - - - -cargo build --target x86_64-unknown-none --release && cc \ - -Wl,--gc-sections -nostdlib \ - -Wl,--whole-archive \ - target/x86_64-unknown-none/release/libwasmtime_reducer.a \ - -Wl,--no-whole-archive \ - -shared \ - -o target/x86_64-unknown-none/release/libwasmtime_reducer.so - -cargo run -- --files ./isol_config/wasmtime_wordcount.json - -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_reducer/target/x86_64-unknown-none/debug/libwasmtime_reducer.so target/debug/libwasmtime_reducer.so -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_reducer/target/x86_64-unknown-none/release/libwasmtime_reducer.so target/release/libwasmtime_reducer.so - -wasmtime compile --target x86_64-unknown-none -W threads=n,tail-call=n reducer.wasm - - - - -cargo build --target x86_64-unknown-none && cc \ - -Wl,--gc-sections -nostdlib \ - -Wl,--whole-archive \ - target/x86_64-unknown-none/debug/libwasmtime_func.a \ - -Wl,--no-whole-archive \ - -shared \ - -o target/x86_64-unknown-none/debug/libwasmtime_func.so - -cargo run -- --files ./isol_config/wasmtime_longchain.json - -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_longchain/target/x86_64-unknown-none/debug/libwasmtime_func.so target/debug/libwasmtime_func.so - -wasmtime compile --target x86_64-unknown-none -W threads=n func.wasm diff --git a/user/wasmtime_hello/ta b/user/wasmtime_hello/ta deleted file mode 120000 index 04591154..00000000 --- a/user/wasmtime_hello/ta +++ /dev/null @@ -1 +0,0 @@ -/home/dyx/workplace/mslibos/user/wasmtime_write/target/x86_64-unknown-none/debug/libwasmtime_write.so \ No newline at end of file diff --git a/user/wasmtime_longchain/build.sh b/user/wasmtime_longchain/build.sh deleted file mode 100755 index 2d7121ce..00000000 --- a/user/wasmtime_longchain/build.sh +++ /dev/null @@ -1,26 +0,0 @@ -$CC func.c -o func.wasm -fno-exceptions -fno-rtti -ffast-math -funroll-loops -fomit-frame-pointer -Ofast -# $CC func.c -o func.wasm -wasmtime compile --target x86_64-unknown-none -W threads=n,tail-call=n func.wasm - -cargo build --target x86_64-unknown-none --release && cc \ - -Wl,--gc-sections -nostdlib \ - -Wl,--whole-archive \ - target/x86_64-unknown-none/release/libwasmtime_func.a \ - -Wl,--no-whole-archive \ - -shared \ - -o target/x86_64-unknown-none/release/libwasmtime_func.so - - -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_longchain/target/x86_64-unknown-none/release/libwasmtime_func.so /home/wyj/alloy_stack/mslibos/target/release/libwasmtime_func.so - - - -# cargo build --target x86_64-unknown-none && cc \ -# -Wl,--gc-sections -nostdlib \ -# -Wl,--whole-archive \ -# target/x86_64-unknown-none/debug/libwasmtime_func.a \ -# -Wl,--no-whole-archive \ -# -shared \ -# -o target/x86_64-unknown-none/debug/libwasmtime_func.so - -# ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_func/target/x86_64-unknown-none/debug/libwasmtime_func.so /home/wyj/alloy_stack/mslibos/target/debug/libwasmtime_func.so diff --git a/user/wasmtime_longchain/func.c b/user/wasmtime_longchain/func.c index ba5d5f12..43bd228f 100644 --- a/user/wasmtime_longchain/func.c +++ b/user/wasmtime_longchain/func.c @@ -11,21 +11,20 @@ int main(int argc, char* argv[]) { int func_num = atoi(argv[2]); printf("func.c recieve: id: %d, func_num: %d\n", id, func_num); - char slot_name[20] = "buffer"; - int bufferSize = 1024 * 1024 * 256; + char slot_name[20]; + int bufferSize = 2; char *buffer = (char *)malloc(bufferSize * sizeof(char)); + if (func_num == 0) { - // sprintf(slot_name, "buffer_%d_%d", func_num, id); - memset(buffer, 0, bufferSize * sizeof(char)); + sprintf(slot_name, "buffer_%d_%d", func_num, id); + buffer[0] = '0'; + buffer[1] = '\0'; buffer_register(slot_name, strlen(slot_name), buffer, bufferSize); - } else if (func_num == 14) { + } else { + sprintf(slot_name, "buffer_%d_%d", func_num-1, id); access_buffer(slot_name, strlen(slot_name), buffer, bufferSize); - } - else { - // sprintf(slot_name, "buffer_%d_%d", func_num-1, id); - access_buffer(slot_name, strlen(slot_name), buffer, bufferSize); - // sprintf(slot_name, "buffer_%d_%d", func_num, id); - // buffer[0] += 1; + sprintf(slot_name, "buffer_%d_%d", func_num, id); + buffer[0] += 1; buffer_register(slot_name, strlen(slot_name), buffer, bufferSize); } free(buffer); diff --git a/user/wasmtime_longchain/func.cwasm b/user/wasmtime_longchain/func.cwasm deleted file mode 100644 index a53d7c9c..00000000 Binary files a/user/wasmtime_longchain/func.cwasm and /dev/null differ diff --git a/user/wasmtime_longchain/func.wasm b/user/wasmtime_longchain/func.wasm deleted file mode 100755 index 5dde85eb..00000000 Binary files a/user/wasmtime_longchain/func.wasm and /dev/null differ diff --git a/user/wasmtime_longchain/src/lib.rs b/user/wasmtime_longchain/src/lib.rs index 5b4d06d4..414b895b 100644 --- a/user/wasmtime_longchain/src/lib.rs +++ b/user/wasmtime_longchain/src/lib.rs @@ -61,11 +61,10 @@ fn func_body(my_id: &str, func_num: u64) -> Result<()> { .get_typed_func::<(), ()>(&mut store, "_start") .map_err(|e| e.to_string())?; - // main.call(store, ()).map_err(|e| e.to_string())?; - main.call(&mut store, ()).map_err(|e| e.to_string())?; - forget(store); + main.call(store, ()).map_err(|e| e.to_string())?; + - if func_num == 14 { + if func_num == 9 { let data = DataBuffer::::from_buffer_slot("Conference".to_owned()); if let Some(buffer) = data { let dur = buffer.current_time.elapsed(); diff --git a/user/wasmtime_mapper/Cargo.toml b/user/wasmtime_mapper/Cargo.toml index 16069c69..d5e5a8e2 100644 --- a/user/wasmtime_mapper/Cargo.toml +++ b/user/wasmtime_mapper/Cargo.toml @@ -3,7 +3,7 @@ name = "wasmtime_mapper" version = "0.1.0" edition = "2021" build = "build.rs" -# build = "../../build_wasm.rs" +#build = "../../build_wasm.rs" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [lib] @@ -11,8 +11,7 @@ crate-type = ["staticlib"] [dependencies] ms_std = { path = "../../ms_std", features = ["panic_def", "alloc_def"] } -# ms_hostcall = { path = "../../ms_hostcall", features = ["signal"] } -ms_hostcall = { path = "../../ms_hostcall"} +ms_hostcall = { path = "../../ms_hostcall", features = ["signal"] } wasmtime_wasi_api = { path = "../../wasmtime_wasi_api" } diff --git a/user/wasmtime_mapper/build.sh b/user/wasmtime_mapper/build.sh index 683fb8d7..3e4d4025 100755 --- a/user/wasmtime_mapper/build.sh +++ b/user/wasmtime_mapper/build.sh @@ -11,7 +11,7 @@ cargo build --target x86_64-unknown-none --release && cc \ -shared \ -o target/x86_64-unknown-none/release/libwasmtime_mapper.so -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_mapper/target/x86_64-unknown-none/release/libwasmtime_mapper.so /home/wyj/alloy_stack/mslibos/target/release/libwasmtime_mapper.so +ln -s /home/wyj/dyx_workplace/mslibos/user/wasmtime_mapper/target/x86_64-unknown-none/release/libwasmtime_mapper.so /home/wyj/dyx_workplace/mslibos/target/release/libwasmtime_mapper.so # cargo build --target x86_64-unknown-none && cc \ # -Wl,--gc-sections -nostdlib \ @@ -21,4 +21,4 @@ ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_mapper/target/x86_64-unknown-n # -shared \ # -o target/x86_64-unknown-none/debug/libwasmtime_mapper.so -# ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_mapper/target/x86_64-unknown-none/debug/libwasmtime_mapper.so /home/wyj/alloy_stack/mslibos/target/debug/libwasmtime_mapper.so +# ln -s /home/wyj/dyx_workplace/mslibos/user/wasmtime_mapper/target/x86_64-unknown-none/debug/libwasmtime_mapper.so /home/wyj/dyx_workplace/mslibos/target/debug/libwasmtime_mapper.so diff --git a/user/wasmtime_mapper/mapper b/user/wasmtime_mapper/mapper deleted file mode 100755 index d50be828..00000000 Binary files a/user/wasmtime_mapper/mapper and /dev/null differ diff --git a/user/wasmtime_mapper/mapper.c b/user/wasmtime_mapper/mapper.c index 0a4fca59..f0731498 100644 --- a/user/wasmtime_mapper/mapper.c +++ b/user/wasmtime_mapper/mapper.c @@ -3,48 +3,20 @@ #include #include #include -#include __attribute__((import_module("env"), import_name("buffer_register"))) void buffer_register(void *slot_name, int name_size, void *buffer, int buffer_size); -#define MAX_WORD_LENGTH 50 -#define MAX_WORDS 18000000 -#define MAX_SLOT_NUM 5 -#define MAX_BUFFER_SIZE 500000 +#define MAX_WORD_LENGTH 100 +#define MAX_WORDS 8000 +#define MAX_SLOT_NUM 100 +#define MAX_BUFFER_SIZE 8000 -int count[MAX_WORDS]; -char *words[MAX_WORDS]; void to_lowercase(char *str) { for (int i = 0; str[i]; i++) { str[i] = tolower(str[i]); } } - -char nc(FILE *stream) { - static char buf[1<<27], *p1 = buf, *p2 = buf; - return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 27, stream), p1 == p2) ? EOF : *p1 ++; -} - -char* readfile(FILE *stream) { - int cnt = 0; - char *buffer = (char *)malloc(MAX_WORD_LENGTH * sizeof(char)); - while (buffer[cnt] = nc(stream)) { - if (buffer[cnt] == ' ' || buffer[cnt] == '\n' || buffer[cnt] == EOF) { - buffer[cnt] = 0; - break; - } - cnt++; - } - return cnt > 0 ? buffer : 0; -} - -void get_now() { - struct timeval tv; - gettimeofday(&tv, NULL); - printf("%lld.%lld\n", tv.tv_sec, tv.tv_usec); -} - int main(int argc, char* argv[]) { int id = atoi(argv[1]); int reducer_num = atoi(argv[2]); @@ -60,56 +32,49 @@ int main(int argc, char* argv[]) { printf("mapper_%d input file: %s\n", id, input_file); - char* word; + int count[MAX_WORDS] = {0}; + char *words[MAX_WORDS]; + char word[MAX_WORD_LENGTH]; int word_index = 0; - // int test_num = 0; - get_now(); - while(word = readfile(file)) { - to_lowercase(word); - int found = 0; - - for (int i = 0; i < word_index; i++) { - if (strcmp(words[i], word) == 0) { - count[i]++; - found = 1; - break; + + char line[1024]; + while (fgets(line, sizeof(line), file)) { + char *token = strtok(line, " \n"); // 以空格和换行作为分隔符 + while (token != NULL) { + char word[MAX_WORD_LENGTH]; + strncpy(word, token, MAX_WORD_LENGTH); + word[MAX_WORD_LENGTH - 1] = '\0'; // 确保字符串以 null 结尾 + + to_lowercase(word); + int found = 0; + + for (int i = 0; i < word_index; i++) { + if (strcmp(words[i], word) == 0) { + count[i]++; + found = 1; + break; + } + } + + if (!found) { + words[word_index] = strdup(word); + count[word_index]++; + word_index++; } + token = strtok(NULL, " \n"); //读取下一个单词 } - - if (!found) { - words[word_index] = strdup(word); - count[word_index]++; - word_index++; - } - } - get_now(); fclose(file); - // return 0; printf("mapper_%d_index: %d\n", id, word_index); - - char **slot_name = (char **)malloc(MAX_SLOT_NUM * sizeof(char*)); - for (int i = 0; i < MAX_SLOT_NUM; i++) { - slot_name[i] = (char *)malloc(20 * sizeof(char)); - } - // char *slot_name[MAX_SLOT_NUM]; - char **buffer = (char **)malloc(MAX_SLOT_NUM * sizeof(char*)); - for (int i = 0; i < MAX_SLOT_NUM; i++) { - buffer[i] = (char *)malloc(MAX_BUFFER_SIZE * sizeof(char)); - } - // char *buffer[MAX_SLOT_NUM]; + char *slot_name[MAX_SLOT_NUM]; + char *buffer[MAX_SLOT_NUM]; char slot[20]; int bufferSize = MAX_BUFFER_SIZE; int slot_index = 0; - char *ptr[MAX_SLOT_NUM]; - for (int i = 0; i < reducer_num; i++) { - ptr[i] = buffer[i]; - } - for (int i = 0; i < word_index; i++) { int partition_index = i % reducer_num; sprintf(slot, "buffer_%d_%d", partition_index, id); @@ -117,28 +82,20 @@ int main(int argc, char* argv[]) { for (int j = 0; j < slot_index; j++) { if (strcmp(slot_name[j], slot) == 0) { found = 1; - // sprintf(buffer[j] + total_len[j], "%s: %d\n", words[i], count[i]); - char temp[100]; - snprintf(temp, sizeof(temp), "%s: %d\n", words[i], count[i]); - strncpy(ptr[j], temp, strlen(temp)); - ptr[j] += strlen(temp); + sprintf(buffer[j] + strlen(buffer[j]), "%s: %d\n", words[i], count[i]); break; } } if (!found) { slot_name[slot_index] = strdup(slot); - // buffer[slot_index] = (char *)malloc(bufferSize * sizeof(char)); - // if (buffer[slot_index] == NULL) { - // printf("alloc mem failed\n"); - // return 1; - // } + buffer[slot_index] = (char *)malloc(bufferSize * sizeof(char)); + if (buffer[slot_index] == NULL) { + printf("alloc mem failed\n"); + return 1; + } memset(buffer[slot_index], 0, bufferSize * sizeof(char)); - char temp[100]; - snprintf(temp, sizeof(temp), "%s: %d\n", words[i], count[i]); - strncpy(ptr[slot_index], temp, strlen(temp)); - ptr[slot_index] += strlen(temp); - // sprintf(buffer[slot_index], "%s: %d\n", words[i], count[i]); + sprintf(buffer[slot_index], "%s: %d\n", words[i], count[i]); // printf("slot: %s; buffer: %s\n", slot_name[slot_index], buffer[slot_index]); slot_index++; } @@ -146,12 +103,6 @@ int main(int argc, char* argv[]) { free(words[i]); } - for (int i = 0; i < reducer_num; i++) { - *ptr[i] = '\0'; - } - - // printf("buffer: %s\n", buffer[0]); - for (int i = 0; i < slot_index; i++) { buffer_register(slot_name[i], strlen(slot_name[i]), buffer[i], bufferSize); } @@ -160,7 +111,7 @@ int main(int argc, char* argv[]) { free(slot_name[i]); // 释放 strdup 分配的内存 free(buffer[i]); // 释放 buffer } - // write(1, "mapper end!\n", sizeof("mapper end!\n")); + write(1, "mapper end!\n", sizeof("mapper end!\n")); // printf("mapper_%d finished!\n", id); return 0; } \ No newline at end of file diff --git a/user/wasmtime_mapper/mapper.cpp b/user/wasmtime_mapper/mapper.cpp deleted file mode 100644 index c41965d8..00000000 --- a/user/wasmtime_mapper/mapper.cpp +++ /dev/null @@ -1,109 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; - -#define MAX_SLOT_NUM 10 -#define MAX_WORDS 20000000 -#define MAX_BUFFER_SIZE 500000 - -string words[MAX_WORDS]; -int counts[MAX_WORDS]; - -__attribute__((import_module("env"), import_name("buffer_register"))) void buffer_register(void *slot_name, int name_size, void *buffer, int buffer_size); - -void get_time() { - timeval tv{}; - gettimeofday(&tv, nullptr); - printf("%lld.%lld\n", tv.tv_sec, tv.tv_usec); -} - -int main(int argc, char* argv[]) { - int id = atoi(argv[1]); - int reducer_num = atoi(argv[2]); - cout << "mapper_" << id << " start!" << endl; - - string input_file = "fake_data_" + to_string(id) + ".txt"; - ifstream file(input_file); - - int word_index = 0; - - string word; - // vector words; - // vector counts; - - - printf("start reading file\n"); - get_time(); - while (file >> word) { - transform(word.begin(), word.end(), word.begin(), - [](unsigned char c) { return std::tolower(c); }); - int found = 0; - for (int i = 0; i < word_index; i++) { - if (words[i] == word) { - counts[i]++; - found = 1; - break; - } - } - if (!found) { - words[word_index] = word; - counts[word_index] = 1; - // words.push_back(word); - // counts.push_back(1); - // words.emplace_back(word); - // count.emplace_back(1); - word_index++; - } - } - printf("finish reading file\n"); - get_time(); - // return 0; - file.close(); - - cout << "mapper_" << id << " read success!" << endl; - - string buffer[MAX_SLOT_NUM]; - string slot_name[MAX_SLOT_NUM]; - int slot_index = 0; - - for (int i = 0; i < word_index; i++) { - int partition_index = i % reducer_num; - string slot = "buffer_" + to_string(partition_index) + "_" + to_string(id); - int found = 0; - for (int j = 0; j < slot_index; j++) { - if (slot_name[j] == slot) { - found = 1; - buffer[j].append(words[i] + ": " + to_string(counts[i]) + "\n"); - break; - } - } - - if (!found) { - slot_name[slot_index] = slot; - buffer[slot_index] = words[i] + ": " + to_string(counts[i]) + "\n"; - slot_index++; - } - } - - for (int i = 0; i < MAX_SLOT_NUM; i++) { - buffer[i].resize(MAX_BUFFER_SIZE, '\0'); - } - - - cout << "mapper_" << id << " solved " << word_index << " words!" << endl; - for (int i = 0; i < slot_index; i++) { - buffer_register((void*)slot_name[i].c_str(), slot_name[i].length(), (void*)buffer[i].c_str(), buffer[i].size()); - // cout << "buffersize" << i << ": " << buffer[i].size() << endl; - } - cout << "mapper_" << id << " write finished!" << endl; - - return 0; -} \ No newline at end of file diff --git a/user/wasmtime_mapper/mapper.cwasm b/user/wasmtime_mapper/mapper.cwasm index 6b32b55b..aac27a41 100644 Binary files a/user/wasmtime_mapper/mapper.cwasm and b/user/wasmtime_mapper/mapper.cwasm differ diff --git a/user/wasmtime_mapper/mapper.wasm b/user/wasmtime_mapper/mapper.wasm index e75b2748..502d4cb7 100755 Binary files a/user/wasmtime_mapper/mapper.wasm and b/user/wasmtime_mapper/mapper.wasm differ diff --git a/user/wasmtime_mapper/mapper_new.cpp b/user/wasmtime_mapper/mapper_new.cpp index 227b2ed6..bdd827df 100644 --- a/user/wasmtime_mapper/mapper_new.cpp +++ b/user/wasmtime_mapper/mapper_new.cpp @@ -5,17 +5,12 @@ #include #include #include -#include #include -#include #include #include -#include -#include using namespace std; -#define MAX_WORD_LENGTH 50 #define MAX_SLOT_NUM 10 #define MAX_WORDS 18000000 #define MAX_BUFFER_SIZE 500000 @@ -31,101 +26,30 @@ void get_time() { printf("%lld.%06lld\n", tv.tv_sec, tv.tv_usec); } -long long get_time2() { - timeval tv{}; - gettimeofday(&tv, nullptr); - // printf("%lld.%06lld\n", (long long)tv.tv_sec, tv.tv_usec); - return (long long)tv.tv_sec * 1000000 + tv.tv_usec; -} - -void to_lowercase(std::string& s) { - for (char& c : s) { - c = std::tolower(c); - } -} - -char nc(FILE *stream) { - static char buf[1<<27], *p1 = buf, *p2 = buf; - return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 27, stream), p1 == p2) ? EOF : *p1 ++; -} - -char* readfile(FILE *stream) { - int cnt = 0; - char *buffer = (char *)malloc(MAX_WORD_LENGTH * sizeof(char)); - while (buffer[cnt] = nc(stream)) { - if (buffer[cnt] == ' ' || buffer[cnt] == '\n' || buffer[cnt] == EOF) { - buffer[cnt] = 0; - break; - } - cnt++; - } - return cnt > 0 ? buffer : 0; -} - int main(int argc, char* argv[]) { int id = atoi(argv[1]); int reducer_num = atoi(argv[2]); cout << "mapper_" << id << " start!" << endl; + string input_file = "fake_data_" + to_string(id) + ".txt"; + ifstream file(input_file); + string word; unordered_map word_map; - string input_file = "fake_data_" + to_string(id) + ".txt"; - // c 快读 - // FILE *file = fopen(input_file.c_str(), "r"); - // printf("start reading file\n"); - // get_time(); - // while(true) { - // word = readfile(file); - // if (word.empty()) { - // break; // 假设空字符串表示没有更多的单词可以读取 - // } - // to_lowercase(word); - // ++word_map[word]; - // } - // printf("finish reading file\n"); - // get_time(); - - // 一次性读 printf("start reading file\n"); get_time(); - ifstream file(input_file); - string content((std::istreambuf_iterator(file)), istreambuf_iterator()); - printf("finish reading file\n"); - get_time(); - printf("start com\n"); - get_time(); - transform(content.begin(), content.end(), content.begin(), - [](unsigned char c) { return std::tolower(c); }); - // 使用 istringstream 分割单词 - istringstream sfile(content); - while (sfile >> word) { + while (file >> word) { + transform(word.begin(), word.end(), word.begin(), + [](unsigned char c) { return std::tolower(c); }); ++word_map[word]; } + printf("finish reading file\n"); + get_time(); + // return 0; file.close(); - // 逐个word读 - // printf("start reading file\n"); - // get_time(); - // ifstream file(input_file); - // while (file >> word) { - - // } - // file.close(); - // printf("finish reading file\n"); - // get_time(); - // printf("start com\n"); - // get_time(); - // ifstream file2(input_file); - // while (file2 >> word) { - // transform(word.begin(), word.end(), word.begin(), - // [](unsigned char c) { return std::tolower(c); }); - // ++word_map[word]; - // } - // file2.close(); - cout << "mapper_" << id << " read success!" << endl; - cout << word_map.size() << endl; string buffer[MAX_SLOT_NUM]; string slot_name[MAX_SLOT_NUM]; @@ -142,15 +66,12 @@ int main(int argc, char* argv[]) { int word_index = word_map.size(); cout << "mapper_" << id << " solved " << word_index << " words!" << endl; - - printf("finish com\n"); - get_time(); + for (int i = 0; i < reducer_num; i++) { buffer_register((void*)slot_name[i].c_str(), slot_name[i].length(), (void*)buffer[i].c_str(), buffer[i].size()); // cout << "buffersize" << i << ": " << buffer[i].size() << endl; } cout << "mapper_" << id << " write finished!" << endl; - printf("finish data_trans\n"); - get_time(); + return 0; } \ No newline at end of file diff --git a/user/wasmtime_mapper/mapper_ori.cpp b/user/wasmtime_mapper/mapper_ori.cpp deleted file mode 100644 index 0a4fca59..00000000 --- a/user/wasmtime_mapper/mapper_ori.cpp +++ /dev/null @@ -1,166 +0,0 @@ -#include -#include -#include -#include -#include -#include - -__attribute__((import_module("env"), import_name("buffer_register"))) void buffer_register(void *slot_name, int name_size, void *buffer, int buffer_size); - -#define MAX_WORD_LENGTH 50 -#define MAX_WORDS 18000000 -#define MAX_SLOT_NUM 5 -#define MAX_BUFFER_SIZE 500000 - -int count[MAX_WORDS]; -char *words[MAX_WORDS]; - -void to_lowercase(char *str) { - for (int i = 0; str[i]; i++) { - str[i] = tolower(str[i]); - } -} - -char nc(FILE *stream) { - static char buf[1<<27], *p1 = buf, *p2 = buf; - return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 27, stream), p1 == p2) ? EOF : *p1 ++; -} - -char* readfile(FILE *stream) { - int cnt = 0; - char *buffer = (char *)malloc(MAX_WORD_LENGTH * sizeof(char)); - while (buffer[cnt] = nc(stream)) { - if (buffer[cnt] == ' ' || buffer[cnt] == '\n' || buffer[cnt] == EOF) { - buffer[cnt] = 0; - break; - } - cnt++; - } - return cnt > 0 ? buffer : 0; -} - -void get_now() { - struct timeval tv; - gettimeofday(&tv, NULL); - printf("%lld.%lld\n", tv.tv_sec, tv.tv_usec); -} - -int main(int argc, char* argv[]) { - int id = atoi(argv[1]); - int reducer_num = atoi(argv[2]); - printf("mapper.c recieve: id: %d, reducer_num: %d\n", id, reducer_num); - - char input_file[30]; - sprintf(input_file, "fake_data_%d.txt", id); - FILE *file = fopen(input_file, "r"); - if (!file) { - perror("Failed to open input file\n"); - exit(EXIT_FAILURE); - } - - printf("mapper_%d input file: %s\n", id, input_file); - - char* word; - int word_index = 0; - // int test_num = 0; - get_now(); - while(word = readfile(file)) { - to_lowercase(word); - int found = 0; - - for (int i = 0; i < word_index; i++) { - if (strcmp(words[i], word) == 0) { - count[i]++; - found = 1; - break; - } - - } - - if (!found) { - words[word_index] = strdup(word); - count[word_index]++; - word_index++; - } - - } - get_now(); - - fclose(file); - // return 0; - printf("mapper_%d_index: %d\n", id, word_index); - - - char **slot_name = (char **)malloc(MAX_SLOT_NUM * sizeof(char*)); - for (int i = 0; i < MAX_SLOT_NUM; i++) { - slot_name[i] = (char *)malloc(20 * sizeof(char)); - } - // char *slot_name[MAX_SLOT_NUM]; - char **buffer = (char **)malloc(MAX_SLOT_NUM * sizeof(char*)); - for (int i = 0; i < MAX_SLOT_NUM; i++) { - buffer[i] = (char *)malloc(MAX_BUFFER_SIZE * sizeof(char)); - } - // char *buffer[MAX_SLOT_NUM]; - char slot[20]; - int bufferSize = MAX_BUFFER_SIZE; - int slot_index = 0; - - char *ptr[MAX_SLOT_NUM]; - for (int i = 0; i < reducer_num; i++) { - ptr[i] = buffer[i]; - } - - for (int i = 0; i < word_index; i++) { - int partition_index = i % reducer_num; - sprintf(slot, "buffer_%d_%d", partition_index, id); - int found = 0; - for (int j = 0; j < slot_index; j++) { - if (strcmp(slot_name[j], slot) == 0) { - found = 1; - // sprintf(buffer[j] + total_len[j], "%s: %d\n", words[i], count[i]); - char temp[100]; - snprintf(temp, sizeof(temp), "%s: %d\n", words[i], count[i]); - strncpy(ptr[j], temp, strlen(temp)); - ptr[j] += strlen(temp); - break; - } - } - - if (!found) { - slot_name[slot_index] = strdup(slot); - // buffer[slot_index] = (char *)malloc(bufferSize * sizeof(char)); - // if (buffer[slot_index] == NULL) { - // printf("alloc mem failed\n"); - // return 1; - // } - memset(buffer[slot_index], 0, bufferSize * sizeof(char)); - char temp[100]; - snprintf(temp, sizeof(temp), "%s: %d\n", words[i], count[i]); - strncpy(ptr[slot_index], temp, strlen(temp)); - ptr[slot_index] += strlen(temp); - // sprintf(buffer[slot_index], "%s: %d\n", words[i], count[i]); - // printf("slot: %s; buffer: %s\n", slot_name[slot_index], buffer[slot_index]); - slot_index++; - } - // printf("found: %d; word: %s; count: %d; slot_name: %s; buffer: %s\n", found, words[i], count[i], slot, buffer[slot_index]); - free(words[i]); - } - - for (int i = 0; i < reducer_num; i++) { - *ptr[i] = '\0'; - } - - // printf("buffer: %s\n", buffer[0]); - - for (int i = 0; i < slot_index; i++) { - buffer_register(slot_name[i], strlen(slot_name[i]), buffer[i], bufferSize); - } - - for (int i = 0; i < slot_index; i++) { - free(slot_name[i]); // 释放 strdup 分配的内存 - free(buffer[i]); // 释放 buffer - } - // write(1, "mapper end!\n", sizeof("mapper end!\n")); - // printf("mapper_%d finished!\n", id); - return 0; -} \ No newline at end of file diff --git a/user/wasmtime_mapper/src/lib.rs b/user/wasmtime_mapper/src/lib.rs index 22121311..66b1ee96 100644 --- a/user/wasmtime_mapper/src/lib.rs +++ b/user/wasmtime_mapper/src/lib.rs @@ -7,7 +7,7 @@ use alloc::{string::{String, ToString}, vec::Vec}; use spin::Mutex; use ms_hostcall::types::{OpenFlags, OpenMode}; -use ms_std::{agent::FaaSFuncResult as Result, args, libos::libos, println, time::{SystemTime, UNIX_EPOCH}}; +use ms_std::{agent::FaaSFuncResult as Result, args, libos::libos}; use wasmtime_wasi_api::{wasmtime, LibosCtx}; @@ -26,6 +26,7 @@ lazy_static::lazy_static! { fn func_body(my_id: &str, reducer_num: u64) -> Result<()> { #[cfg(feature = "log")] + println!("rust: my_id: {:?}, reducer_num: {:?}", my_id, reducer_num); let wasi_args: Vec = Vec::from([ @@ -44,41 +45,28 @@ fn func_body(my_id: &str, reducer_num: u64) -> Result<()> { let mut store = Store::new(&engine, LibosCtx{id: my_id.to_string()}); let instance = linker.instantiate(&mut store, &module)?; - // let memory_grow_start_time = SystemTime::now().duration_since(UNIX_EPOCH).as_millis(); - // println!("memory_grow_start_time: {:?}", memory_grow_start_time); - let mut memory = instance.get_memory(&mut store, "memory").unwrap(); - let pages = memory.grow(&mut store, 20000).unwrap(); - // println!("rust: pages: {}", pages); + let memory = instance.get_memory(&mut store, "memory").unwrap(); + let _pages = memory.grow(&mut store, 20000).unwrap(); let main = instance .get_typed_func::<(), ()>(&mut store, "_start") .map_err(|e| e.to_string())?; - - // let start_time = SystemTime::now().duration_since(UNIX_EPOCH).as_millis(); - // println!("start_time: {:?}", start_time); - // main.call(store, ()).map_err(|e| e.to_string())?; + main.call(&mut store, ()).map_err(|e| e.to_string())?; forget(store); - #[cfg(feature = "log")] println!("rust: wasmtime_mapper_{:?} finished!", my_id); - let end_time = SystemTime::now().duration_since(UNIX_EPOCH).as_millis(); - // println!("end_time: {:?}", end_time); + Ok(().into()) } #[no_mangle] pub fn main() -> Result<()> { - // let main_start_time = SystemTime::now().duration_since(UNIX_EPOCH).as_millis(); - // println!("main_start_time: {:?}", main_start_time); let my_id = args::get("id").unwrap(); - let get_id = SystemTime::now().duration_since(UNIX_EPOCH).as_millis(); - // println!("get_id: {:?}", get_id); let reducer_num: u64 = args::get("reducer_num") .expect("missing arg reducer_num") .parse() .unwrap_or_else(|_| panic!("bad arg, reducer_num={}", args::get("reducer_num").unwrap())); - // let after_get_args = SystemTime::now().duration_since(UNIX_EPOCH).as_millis(); - // println!("after_get_args: {:?}", after_get_args); + func_body(my_id, reducer_num) } diff --git a/user/wasmtime_merger/build.sh b/user/wasmtime_merger/build.sh index 487d3949..496e87ec 100755 --- a/user/wasmtime_merger/build.sh +++ b/user/wasmtime_merger/build.sh @@ -2,7 +2,6 @@ $CPP merger_ori.cpp -o merger.wasm -fno-exceptions -fno-rtti -ffast-math -funroll-loops -fomit-frame-pointer -Ofast # $CC merger.c -o merger.wasm wasmtime compile --target x86_64-unknown-none -W threads=n,tail-call=n merger.wasm -# wasmtime compile --target x86_64-unknown-none -W simd=y,threads=n,tail-call=n merger.wasm cargo build --target x86_64-unknown-none --release && cc \ -Wl,--gc-sections -nostdlib \ @@ -12,5 +11,5 @@ cargo build --target x86_64-unknown-none --release && cc \ -shared \ -o target/x86_64-unknown-none/release/libwasmtime_merger.so -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_merger/target/x86_64-unknown-none/release/libwasmtime_merger.so /home/wyj/alloy_stack/mslibos/target/release/libwasmtime_merger.so +ln -s /home/wyj/dyx_workplace/mslibos/user/wasmtime_merger/target/x86_64-unknown-none/release/libwasmtime_merger.so /home/wyj/dyx_workplace/mslibos/target/release/libwasmtime_merger.so diff --git a/user/wasmtime_merger/merger.cwasm b/user/wasmtime_merger/merger.cwasm index fd9622b3..34a956b9 100644 Binary files a/user/wasmtime_merger/merger.cwasm and b/user/wasmtime_merger/merger.cwasm differ diff --git a/user/wasmtime_merger/merger.wasm b/user/wasmtime_merger/merger.wasm index 372160be..aadad419 100755 Binary files a/user/wasmtime_merger/merger.wasm and b/user/wasmtime_merger/merger.wasm differ diff --git a/user/wasmtime_merger/merger_ori.cpp b/user/wasmtime_merger/merger_ori.cpp index 69939819..575b4666 100644 --- a/user/wasmtime_merger/merger_ori.cpp +++ b/user/wasmtime_merger/merger_ori.cpp @@ -9,12 +9,12 @@ __attribute__((import_module("env"), import_name("access_buffer"))) void access_ // #define MAX_ARRAY_LENGTH 152221 // #define MAX_BUFFER_SIZE 1024*1024+152221 -#define MAX_ARRAY_LENGTH 3805441 -#define MAX_BUFFER_SIZE 25*1024*1024+3805441 - // #define MAX_ARRAY_LENGTH 7611001 // #define MAX_BUFFER_SIZE 50*1024*1024+7611001 +#define MAX_ARRAY_LENGTH 3805441 +#define MAX_BUFFER_SIZE 25*1024*1024+3805441 + int result[MAX_ARRAY_LENGTH]; typedef struct { @@ -23,10 +23,10 @@ typedef struct { int elementIndex; // 元素索引 } HeapNode; -void get_time(int num, int phase) { +void get_time() { timeval tv{}; gettimeofday(&tv, nullptr); - printf("%lld.%06lld--%d--%d\n", tv.tv_sec, tv.tv_usec, num, phase); + printf("%lld.%06lld\n", tv.tv_sec, tv.tv_usec); } // 最小堆的比较函数 @@ -61,7 +61,7 @@ void heapifyDown(HeapNode *minHeap, int heapSize, int index) { } int main(int argc, char* argv[]) { - // get_time(); + get_time(); int id = atoi(argv[1]); int sorter_num = atoi(argv[2]); int merger_num = atoi(argv[3]); @@ -77,7 +77,6 @@ int main(int argc, char* argv[]) { int index[sorter_num]; // int *index = (int *)malloc(sorter_num * sizeof(int)); memset(index, 0, sizeof(index)); - int time_num = 12; for (int i = 0; i < sorter_num; i++) { char slot_name[20]; sprintf(slot_name, "merger_%d_%d", i, id); @@ -85,12 +84,7 @@ int main(int argc, char* argv[]) { buffer = (char *)malloc(MAX_BUFFER_SIZE * sizeof(char)); memset(buffer, 0, MAX_BUFFER_SIZE * sizeof(char)); buffer[0] = '\0'; // 初始化为空字符串 - if (id == 0) - get_time(time_num, 0); access_buffer(slot_name, strlen(slot_name), buffer, MAX_BUFFER_SIZE); - if (id == 0) - get_time(time_num, 1); - time_num++; char *ptr = buffer; int num; while (sscanf(ptr, "%d", &num) == 1) { @@ -168,15 +162,11 @@ int main(int argc, char* argv[]) { // buffer[strlen(buffer) - 1] = '\0'; *ptr++ = '\0'; printf("result_index: %d\n", resultIndex); - if (id == 0) - get_time(15, 0); buffer_register(slot_name, strlen(slot_name), buffer, MAX_BUFFER_SIZE); - if (id == 0) - get_time(15, 1); - // free(buffer); + free(buffer); // printf("merger_%d all finished!\n", id); - // get_time(); + get_time(); return 0; } \ No newline at end of file diff --git a/user/wasmtime_merger/src/lib.rs b/user/wasmtime_merger/src/lib.rs index 9d866739..5ce0fb2d 100644 --- a/user/wasmtime_merger/src/lib.rs +++ b/user/wasmtime_merger/src/lib.rs @@ -44,17 +44,15 @@ fn func_body(my_id: &str, sorter_num: u64, merger_num: u64) -> Result<()> { let mut store = Store::new(&engine, LibosCtx{id: my_id.to_string()}); let instance = linker.instantiate(&mut store, &module)?; - let mut memory = instance.get_memory(&mut store, "memory").unwrap(); - let pages = memory.grow(&mut store, 20000).unwrap(); + let memory = instance.get_memory(&mut store, "memory").unwrap(); + let _pages = memory.grow(&mut store, 20000).unwrap(); let main = instance .get_typed_func::<(), ()>(&mut store, "_start") .map_err(|e| e.to_string())?; - // main.call(store, ()).map_err(|e| e.to_string())?; main.call(&mut store, ()).map_err(|e| e.to_string())?; forget(store); - Ok(().into()) } diff --git a/user/wasmtime_reducer/build.sh b/user/wasmtime_reducer/build.sh index d2d2dd4f..aed52545 100755 --- a/user/wasmtime_reducer/build.sh +++ b/user/wasmtime_reducer/build.sh @@ -11,7 +11,7 @@ cargo build --target x86_64-unknown-none --release && cc \ -shared \ -o target/x86_64-unknown-none/release/libwasmtime_reducer.so -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_reducer/target/x86_64-unknown-none/release/libwasmtime_reducer.so /home/wyj/alloy_stack/mslibos/target/release/libwasmtime_reducer.so +ln -s /home/wyj/dyx_workplace/mslibos/user/wasmtime_reducer/target/x86_64-unknown-none/release/libwasmtime_reducer.so /home/wyj/dyx_workplace/mslibos/target/release/libwasmtime_reducer.so # cargo build --target x86_64-unknown-none && cc \ @@ -22,4 +22,4 @@ ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_reducer/target/x86_64-unknown- # -shared \ # -o target/x86_64-unknown-none/debug/libwasmtime_reducer.so -# ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_reducer/target/x86_64-unknown-none/debug/libwasmtime_reducer.so /home/wyj/alloy_stack/mslibos/target/debug/libwasmtime_reducer.so +# ln -s /home/wyj/dyx_workplace/mslibos/user/wasmtime_reducer/target/x86_64-unknown-none/debug/libwasmtime_reducer.so /home/wyj/dyx_workplace/mslibos/target/debug/libwasmtime_reducer.so diff --git a/user/wasmtime_reducer/reducer.c b/user/wasmtime_reducer/reducer.c index f2eb59c4..3e77e1f0 100644 --- a/user/wasmtime_reducer/reducer.c +++ b/user/wasmtime_reducer/reducer.c @@ -5,13 +5,10 @@ __attribute__((import_module("env"), import_name("access_buffer"))) void access_buffer(void *slot_name, int name_size, void *buffer, int buffer_size); -#define MAX_WORD_LENGTH 50 -#define MAX_WORDS 18000000 -#define MAX_SLOT_NUM 5 -#define MAX_BUFFER_SIZE 500000 - -int count[MAX_WORDS]; -char *words[MAX_WORDS]; +#define MAX_WORD_LENGTH 20 +#define MAX_WORDS 5000 +#define MAX_SLOT_NUM 100 +#define MAX_BUFFER_SIZE 6000 void to_lowercase(char *str) { for (int i = 0; str[i]; i++) { @@ -23,16 +20,8 @@ int main(int argc, char* argv[]) { int mapper_num = atoi(argv[2]); printf("reducer.c recieve: id: %d, mapper_num: %d\n", id, mapper_num); - char **slot_name = (char **)malloc(MAX_SLOT_NUM * sizeof(char*)); - for (int i = 0; i < MAX_SLOT_NUM; i++) { - slot_name[i] = (char *)malloc(20 * sizeof(char)); - } - // char *slot_name[MAX_SLOT_NUM]; - char **buffer = (char **)malloc(MAX_SLOT_NUM * sizeof(char*)); - for (int i = 0; i < MAX_SLOT_NUM; i++) { - buffer[i] = (char *)malloc(MAX_BUFFER_SIZE * sizeof(char)); - } - // char *buffer[MAX_SLOT_NUM]; + char *slot_name[MAX_SLOT_NUM]; + char *buffer[MAX_SLOT_NUM]; char slot[20]; int bufferSize = MAX_BUFFER_SIZE; int slot_num = mapper_num; @@ -51,22 +40,22 @@ int main(int argc, char* argv[]) { } printf("access success!\n"); + int count[MAX_WORDS] = {0}; + char *words[MAX_WORDS]; char word[MAX_WORD_LENGTH]; int word_index = 0; - - char *ptr[MAX_SLOT_NUM]; - for (int i = 0; i < slot_num; i++) { - ptr[i] = buffer[i]; - } - int num; + for (int i = 0; i < slot_num; i++) { - while (sscanf(ptr[i], "%s: %d\n", word, &num) == 1) { + char *line = strtok(buffer[i], "\n"); + while (line != NULL) { + int num = 0; + sscanf(line, "%[^:]: %d", word, &num); // 解析每一行 to_lowercase(word); int found = 0; - for (int j = 0; j < word_index; j++) { - if (strcmp(words[j], word) == 0) { + for (int i = 0; i < word_index; i++) { + if (strcmp(words[i], word) == 0) { found = 1; - count[j] += num; + count[i] += num; break; } } @@ -75,14 +64,7 @@ int main(int argc, char* argv[]) { count[word_index] += num; word_index++; } - - // 移动指针到下一个char - while (*ptr[i] && *ptr[i] != ' ') { - ptr[i]++; - } - if (*ptr[i] == ' ') { - ptr[i]++; - } + line = strtok(NULL, "\n"); } } @@ -96,7 +78,6 @@ int main(int argc, char* argv[]) { fprintf(output, "%s %d\n", words[i], count[i]); free(words[i]); } - fclose(output); printf("reducer_%d finished!\n", id); diff --git a/user/wasmtime_reducer/reducer.cpp b/user/wasmtime_reducer/reducer.cpp deleted file mode 100644 index 1ca86554..00000000 --- a/user/wasmtime_reducer/reducer.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -using namespace std; - -#define MAX_SLOT_NUM 10 -#define MAX_WORDS 20000000 -#define MAX_BUFFER_SIZE 500000 - -__attribute__((import_module("env"), import_name("access_buffer"))) void access_buffer(void *slot_name, int name_size, void *buffer, int buffer_size); - -void get_time() { - timeval tv{}; - gettimeofday(&tv, nullptr); - - printf("%lld.%06ld\n", (long long)tv.tv_sec, tv.tv_usec); -} - -string words[MAX_WORDS]; -int counts[MAX_WORDS]; - -int main(int argc, char* argv[]) { - int id = atoi(argv[1]); - int mapper_num = atoi(argv[2]); - cout << "reducer_" << id << " start!" << endl; - int slot_num = mapper_num; - string slot_name[MAX_SLOT_NUM]; - string buffer[MAX_SLOT_NUM]; - - for (int i = 0; i < slot_num; ++i) { - slot_name[i] = "buffer_" + to_string(i) + "_" + to_string(id); - // size_t bufferSize = faasmReadStateSize(slot_name[i].c_str()); - buffer[i] = string(MAX_BUFFER_SIZE, 0); - // faasmReadState(slot_name[i].c_str(), (uint8_t*)buffer[i].c_str(), bufferSize); - access_buffer((void*)slot_name[i].c_str(), slot_name[i].length(), (void*)buffer[i].c_str(), buffer[i].size()); - } - - // vector words; - // vector count; - int word_index = 0; - - for (int i = 0; i < slot_num; i++) { - istringstream iss(buffer[i]); - string word; - int num; - while (iss >> word >> num) { - int found = 0; - for (int i = 0; i < word_index; i++) { - if (words[i] == word) { - counts[i] += num; - found = 1; - break; - } - } - if (!found) { - // words.push_back(word); - // count.push_back(num); - words[word_index] = word; - counts[word_index] = num; - word_index++; - } - } - } - - cout << "reducer_" << id << " solved " << word_index << " words!" << endl; - - // string output_file = "faasm://reducer_" + to_string(id) + "_" + to_string(get_time()) + ".txt"; - // ofstream output(output_file); - // for (int i = 0; i < word_index; i++) { - // output << words[i] << " " << count[i] << endl; - // } - // output.close(); - - cout << "reducer_" << id << " finished!" << endl; - get_time(); - return 0; -} \ No newline at end of file diff --git a/user/wasmtime_reducer/reducer.cwasm b/user/wasmtime_reducer/reducer.cwasm index 4910d330..da2d9a9d 100644 Binary files a/user/wasmtime_reducer/reducer.cwasm and b/user/wasmtime_reducer/reducer.cwasm differ diff --git a/user/wasmtime_reducer/reducer.wasm b/user/wasmtime_reducer/reducer.wasm index 49427296..c36bcb3b 100755 Binary files a/user/wasmtime_reducer/reducer.wasm and b/user/wasmtime_reducer/reducer.wasm differ diff --git a/user/wasmtime_reducer/reducer_new.cpp b/user/wasmtime_reducer/reducer_new.cpp index 6c629730..11e0e851 100644 --- a/user/wasmtime_reducer/reducer_new.cpp +++ b/user/wasmtime_reducer/reducer_new.cpp @@ -17,7 +17,8 @@ __attribute__((import_module("env"), import_name("access_buffer"))) void access_ void get_time() { timeval tv{}; gettimeofday(&tv, nullptr); - printf("%lld.%06lld\n", tv.tv_sec, tv.tv_usec); + + printf("%lld.%06ld\n", (long long)tv.tv_sec, tv.tv_usec); } string words[MAX_WORDS]; @@ -31,15 +32,12 @@ int main(int argc, char* argv[]) { string slot_name[MAX_SLOT_NUM]; string buffer[MAX_SLOT_NUM]; - printf("start data_trans\n"); - get_time(); for (int i = 0; i < slot_num; ++i) { slot_name[i] = "buffer_" + to_string(i) + "_" + to_string(id); buffer[i] = string(MAX_BUFFER_SIZE, 0); access_buffer((void*)slot_name[i].c_str(), slot_name[i].length(), (void*)buffer[i].c_str(), buffer[i].size()); } - printf("finish data_trans\n"); - get_time(); + unordered_map word_map; for (int i = 0; i < slot_num; i++) { diff --git a/user/wasmtime_reducer/reducer_ori.cpp b/user/wasmtime_reducer/reducer_ori.cpp deleted file mode 100644 index f2eb59c4..00000000 --- a/user/wasmtime_reducer/reducer_ori.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include -#include -#include -#include - -__attribute__((import_module("env"), import_name("access_buffer"))) void access_buffer(void *slot_name, int name_size, void *buffer, int buffer_size); - -#define MAX_WORD_LENGTH 50 -#define MAX_WORDS 18000000 -#define MAX_SLOT_NUM 5 -#define MAX_BUFFER_SIZE 500000 - -int count[MAX_WORDS]; -char *words[MAX_WORDS]; - -void to_lowercase(char *str) { - for (int i = 0; str[i]; i++) { - str[i] = tolower(str[i]); - } -} -int main(int argc, char* argv[]) { - int id = atoi(argv[1]); - int mapper_num = atoi(argv[2]); - printf("reducer.c recieve: id: %d, mapper_num: %d\n", id, mapper_num); - - char **slot_name = (char **)malloc(MAX_SLOT_NUM * sizeof(char*)); - for (int i = 0; i < MAX_SLOT_NUM; i++) { - slot_name[i] = (char *)malloc(20 * sizeof(char)); - } - // char *slot_name[MAX_SLOT_NUM]; - char **buffer = (char **)malloc(MAX_SLOT_NUM * sizeof(char*)); - for (int i = 0; i < MAX_SLOT_NUM; i++) { - buffer[i] = (char *)malloc(MAX_BUFFER_SIZE * sizeof(char)); - } - // char *buffer[MAX_SLOT_NUM]; - char slot[20]; - int bufferSize = MAX_BUFFER_SIZE; - int slot_num = mapper_num; - - printf("access start!\n"); - - for (int i = 0; i < slot_num; ++i) { - sprintf(slot, "buffer_%d_%d", id, i); - slot_name[i] = strdup(slot); - buffer[i] = (char *)malloc(bufferSize * sizeof(char)); - if (buffer[i] == NULL) { - printf("alloc mem failed\n"); - return 1; - } - access_buffer(slot_name[i], strlen(slot_name[i]), buffer[i], bufferSize); - } - printf("access success!\n"); - - char word[MAX_WORD_LENGTH]; - int word_index = 0; - - char *ptr[MAX_SLOT_NUM]; - for (int i = 0; i < slot_num; i++) { - ptr[i] = buffer[i]; - } - int num; - for (int i = 0; i < slot_num; i++) { - while (sscanf(ptr[i], "%s: %d\n", word, &num) == 1) { - to_lowercase(word); - int found = 0; - for (int j = 0; j < word_index; j++) { - if (strcmp(words[j], word) == 0) { - found = 1; - count[j] += num; - break; - } - } - if (!found) { - words[word_index] = strdup(word); - count[word_index] += num; - word_index++; - } - - // 移动指针到下一个char - while (*ptr[i] && *ptr[i] != ' ') { - ptr[i]++; - } - if (*ptr[i] == ' ') { - ptr[i]++; - } - } - } - - printf("reducer_%d_index: %d\n", id, word_index); - printf("reducer_%d read success!\n", id); - - char output_file[30]; - sprintf(output_file, "reducer_%d.txt", id); - FILE *output = fopen(output_file, "w"); - for (int i = 0; i < word_index; i++) { - fprintf(output, "%s %d\n", words[i], count[i]); - free(words[i]); - } - - fclose(output); - - printf("reducer_%d finished!\n", id); - return 0; -} \ No newline at end of file diff --git a/user/wasmtime_reducer/src/lib.rs b/user/wasmtime_reducer/src/lib.rs index b5929859..dc4418de 100644 --- a/user/wasmtime_reducer/src/lib.rs +++ b/user/wasmtime_reducer/src/lib.rs @@ -1,12 +1,11 @@ #![no_std] extern crate alloc; -use core::mem::forget; use alloc::{string::{String, ToString}, vec::Vec}; use spin::Mutex; use ms_hostcall::types::{OpenFlags, OpenMode}; -use ms_std::{agent::FaaSFuncResult as Result, args, libos::libos, println, time::{SystemTime, UNIX_EPOCH}}; +use ms_std::{agent::FaaSFuncResult as Result, args, libos::libos}; use wasmtime_wasi_api::{wasmtime, LibosCtx}; use wasmtime::Store; @@ -42,22 +41,18 @@ fn func_body(my_id: &str, mapper_num: u64) -> Result<()> { let mut store = Store::new(&engine, LibosCtx{id: my_id.to_string()}); let instance = linker.instantiate(&mut store, &module)?; - let mut memory = instance.get_memory(&mut store, "memory").unwrap(); - let pages = memory.grow(&mut store, 20000).unwrap(); - // println!("rust: pages: {}", pages); + let memory = instance.get_memory(&mut store, "memory").unwrap(); + let _pages = memory.grow(&mut store, 20000).unwrap(); let main = instance .get_typed_func::<(), ()>(&mut store, "_start") .map_err(|e| e.to_string())?; - // main.call(store, ()).map_err(|e| e.to_string())?; main.call(&mut store, ()).map_err(|e| e.to_string())?; - forget(store); #[cfg(feature = "log")] println!("rust: wasmtime_mapper_{:?} finished!", my_id); - let end_time = SystemTime::now().duration_since(UNIX_EPOCH).as_millis(); - // println!("end_time: {:?}", end_time); + Ok(().into()) } diff --git a/user/wasmtime_sorter/build.sh b/user/wasmtime_sorter/build.sh index 3ac709cd..5dc84ed5 100755 --- a/user/wasmtime_sorter/build.sh +++ b/user/wasmtime_sorter/build.sh @@ -2,7 +2,6 @@ $CPP sorter_ori.cpp -o sorter.wasm -fno-exceptions -fno-rtti -ffast-math -fomit-frame-pointer -Ofast #-funroll-loops # $CC sorter.c -o sorter.wasm wasmtime compile --target x86_64-unknown-none -W threads=n,tail-call=n sorter.wasm -# wasmtime compile --target x86_64-unknown-none -W simd=y,threads=n,tail-call=n sorter.wasm cargo build --target x86_64-unknown-none --release && cc \ -Wl,--gc-sections -nostdlib \ @@ -13,7 +12,7 @@ cargo build --target x86_64-unknown-none --release && cc \ -o target/x86_64-unknown-none/release/libwasmtime_sorter.so -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_sorter/target/x86_64-unknown-none/release/libwasmtime_sorter.so /home/wyj/alloy_stack/mslibos/target/release/libwasmtime_sorter.so +ln -s /home/wyj/dyx_workplace/mslibos/user/wasmtime_sorter/target/x86_64-unknown-none/release/libwasmtime_sorter.so /home/wyj/dyx_workplace/mslibos/target/release/libwasmtime_sorter.so @@ -25,4 +24,4 @@ ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_sorter/target/x86_64-unknown-n # -shared \ # -o target/x86_64-unknown-none/debug/libwasmtime_sorter.so -# ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_sorter/target/x86_64-unknown-none/debug/libwasmtime_sorter.so /home/wyj/alloy_stack/mslibos/target/debug/libwasmtime_sorter.so +# ln -s /home/wyj/dyx_workplace/mslibos/user/wasmtime_sorter/target/x86_64-unknown-none/debug/libwasmtime_sorter.so /home/wyj/dyx_workplace/mslibos/target/debug/libwasmtime_sorter.so diff --git a/user/wasmtime_sorter/sorter.cwasm b/user/wasmtime_sorter/sorter.cwasm index abc31a40..2c4b1374 100644 Binary files a/user/wasmtime_sorter/sorter.cwasm and b/user/wasmtime_sorter/sorter.cwasm differ diff --git a/user/wasmtime_sorter/sorter.wasm b/user/wasmtime_sorter/sorter.wasm index 8137e14d..23deaa7e 100755 Binary files a/user/wasmtime_sorter/sorter.wasm and b/user/wasmtime_sorter/sorter.wasm differ diff --git a/user/wasmtime_sorter/sorter.wat b/user/wasmtime_sorter/sorter.wat new file mode 100644 index 00000000..7dc27dda --- /dev/null +++ b/user/wasmtime_sorter/sorter.wat @@ -0,0 +1,15307 @@ +(module $sorter.wasm + (type (;0;) (func (param i32) (result i32))) + (type (;1;) (func (param i32 i32 i32) (result i32))) + (type (;2;) (func (param i32 i64 i32) (result i64))) + (type (;3;) (func (param i32 i32 i32 i32))) + (type (;4;) (func (param i32 i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i64 i32 i32) (result i32))) + (type (;7;) (func (param i32 i32 i32 i32 i32 i64 i64 i32 i32) (result i32))) + (type (;8;) (func (param i32))) + (type (;9;) (func)) + (type (;10;) (func (param i32 i32 i32 i32 i32) (result i32))) + (type (;11;) (func (result i32))) + (type (;12;) (func (param i32 i32 i32 i32 i64 i64 i32 i32) (result i32))) + (type (;13;) (func (param f64 i32) (result f64))) + (type (;14;) (func (param i32 i32 i32))) + (type (;15;) (func (param i32 i32 i32 i32 i32))) + (import "env" "buffer_register" (func $buffer_register (type 3))) + (import "wasi_snapshot_preview1" "args_get" (func $__imported_wasi_snapshot_preview1_args_get (type 4))) + (import "wasi_snapshot_preview1" "args_sizes_get" (func $__imported_wasi_snapshot_preview1_args_sizes_get (type 4))) + (import "wasi_snapshot_preview1" "fd_close" (func $__imported_wasi_snapshot_preview1_fd_close (type 0))) + (import "wasi_snapshot_preview1" "fd_fdstat_get" (func $__imported_wasi_snapshot_preview1_fd_fdstat_get (type 4))) + (import "wasi_snapshot_preview1" "fd_fdstat_set_flags" (func $__imported_wasi_snapshot_preview1_fd_fdstat_set_flags (type 4))) + (import "wasi_snapshot_preview1" "fd_prestat_get" (func $__imported_wasi_snapshot_preview1_fd_prestat_get (type 4))) + (import "wasi_snapshot_preview1" "fd_prestat_dir_name" (func $__imported_wasi_snapshot_preview1_fd_prestat_dir_name (type 1))) + (import "wasi_snapshot_preview1" "fd_read" (func $__imported_wasi_snapshot_preview1_fd_read (type 5))) + (import "wasi_snapshot_preview1" "fd_seek" (func $__imported_wasi_snapshot_preview1_fd_seek (type 6))) + (import "wasi_snapshot_preview1" "fd_write" (func $__imported_wasi_snapshot_preview1_fd_write (type 5))) + (import "wasi_snapshot_preview1" "path_open" (func $__imported_wasi_snapshot_preview1_path_open (type 7))) + (import "wasi_snapshot_preview1" "proc_exit" (func $__imported_wasi_snapshot_preview1_proc_exit (type 8))) + (func $__wasm_call_ctors (type 9)) + (func $signature_mismatch:read (type 1) (param i32 i32 i32) (result i32) + unreachable) + (func $undefined_weak:__wasilibc_find_relpath_alloc (type 10) (param i32 i32 i32 i32 i32) (result i32) + unreachable) + (func $_start (type 9) + (local i32) + block ;; label = @1 + block ;; label = @2 + global.get $GOT.data.internal.__memory_base + i32.const 3904 + i32.add + i32.load + br_if 0 (;@2;) + global.get $GOT.data.internal.__memory_base + i32.const 3904 + i32.add + i32.const 1 + i32.store + call $__wasm_call_ctors + call $__main_void + local.set 0 + call $__wasm_call_dtors + local.get 0 + br_if 1 (;@1;) + return + end + unreachable + unreachable + end + local.get 0 + call $__wasi_proc_exit + unreachable) + (func $nc (type 0) (param i32) (result i32) + (local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) + global.get $__stack_pointer + local.set 1 + i32.const 16 + local.set 2 + local.get 1 + local.get 2 + i32.sub + local.set 3 + local.get 3 + global.set $__stack_pointer + local.get 3 + local.get 0 + i32.store offset=12 + i32.const 0 + local.set 4 + local.get 4 + i32.load offset=3648 + local.set 5 + i32.const 0 + local.set 6 + local.get 6 + i32.load offset=3652 + local.set 7 + local.get 5 + local.set 8 + local.get 7 + local.set 9 + local.get 8 + local.get 9 + i32.eq + local.set 10 + i32.const 1 + local.set 11 + local.get 10 + local.get 11 + i32.and + local.set 12 + block ;; label = @1 + block ;; label = @2 + local.get 12 + i32.eqz + br_if 0 (;@2;) + i32.const 3920 + local.set 13 + i32.const 0 + local.set 14 + local.get 14 + local.get 13 + i32.store offset=3648 + local.get 3 + i32.load offset=12 + local.set 15 + i32.const 3920 + local.set 16 + i32.const 1 + local.set 17 + i32.const 1048576 + local.set 18 + local.get 16 + local.get 17 + local.get 18 + local.get 15 + call $fread + local.set 19 + i32.const 3920 + local.set 20 + local.get 20 + local.get 19 + i32.add + local.set 21 + i32.const 0 + local.set 22 + local.get 22 + local.get 21 + i32.store offset=3652 + i32.const 0 + local.set 23 + local.get 23 + i32.load offset=3648 + local.set 24 + i32.const 0 + local.set 25 + local.get 25 + i32.load offset=3652 + local.set 26 + local.get 24 + local.set 27 + local.get 26 + local.set 28 + local.get 27 + local.get 28 + i32.eq + local.set 29 + i32.const 1 + local.set 30 + local.get 29 + local.get 30 + i32.and + local.set 31 + local.get 31 + i32.eqz + br_if 0 (;@2;) + i32.const -1 + local.set 32 + local.get 32 + local.set 33 + br 1 (;@1;) + end + i32.const 0 + local.set 34 + local.get 34 + i32.load offset=3648 + local.set 35 + i32.const 1 + local.set 36 + local.get 35 + local.get 36 + i32.add + local.set 37 + i32.const 0 + local.set 38 + local.get 38 + local.get 37 + i32.store offset=3648 + local.get 35 + i32.load8_u + local.set 39 + i32.const 24 + local.set 40 + local.get 39 + local.get 40 + i32.shl + local.set 41 + local.get 41 + local.get 40 + i32.shr_s + local.set 42 + local.get 42 + local.set 33 + end + local.get 33 + local.set 43 + i32.const 24 + local.set 44 + local.get 43 + local.get 44 + i32.shl + local.set 45 + local.get 45 + local.get 44 + i32.shr_s + local.set 46 + i32.const 16 + local.set 47 + local.get 3 + local.get 47 + i32.add + local.set 48 + local.get 48 + global.set $__stack_pointer + local.get 46 + return) + (func $read (type 0) (param i32) (result i32) + (local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) + global.get $__stack_pointer + local.set 1 + i32.const 16 + local.set 2 + local.get 1 + local.get 2 + i32.sub + local.set 3 + local.get 3 + global.set $__stack_pointer + local.get 3 + local.get 0 + i32.store offset=12 + i32.const 0 + local.set 4 + local.get 3 + local.get 4 + i32.store offset=8 + local.get 3 + i32.load offset=12 + local.set 5 + local.get 5 + call $nc + local.set 6 + i32.const 24 + local.set 7 + local.get 6 + local.get 7 + i32.shl + local.set 8 + local.get 8 + local.get 7 + i32.shr_s + local.set 9 + local.get 3 + local.get 9 + i32.store offset=4 + loop ;; label = @1 + local.get 3 + i32.load offset=4 + local.set 10 + i32.const 48 + local.set 11 + local.get 10 + local.set 12 + local.get 11 + local.set 13 + local.get 12 + local.get 13 + i32.lt_s + local.set 14 + i32.const 1 + local.set 15 + i32.const 1 + local.set 16 + local.get 14 + local.get 16 + i32.and + local.set 17 + local.get 15 + local.set 18 + block ;; label = @2 + local.get 17 + br_if 0 (;@2;) + local.get 3 + i32.load offset=4 + local.set 19 + i32.const 57 + local.set 20 + local.get 19 + local.set 21 + local.get 20 + local.set 22 + local.get 21 + local.get 22 + i32.gt_s + local.set 23 + local.get 23 + local.set 18 + end + local.get 18 + local.set 24 + i32.const 1 + local.set 25 + local.get 24 + local.get 25 + i32.and + local.set 26 + block ;; label = @2 + local.get 26 + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=12 + local.set 27 + local.get 27 + call $nc + local.set 28 + i32.const 24 + local.set 29 + local.get 28 + local.get 29 + i32.shl + local.set 30 + local.get 30 + local.get 29 + i32.shr_s + local.set 31 + local.get 3 + local.get 31 + i32.store offset=4 + br 1 (;@1;) + end + end + loop ;; label = @1 + local.get 3 + i32.load offset=4 + local.set 32 + i32.const 48 + local.set 33 + local.get 32 + local.set 34 + local.get 33 + local.set 35 + local.get 34 + local.get 35 + i32.ge_s + local.set 36 + i32.const 0 + local.set 37 + i32.const 1 + local.set 38 + local.get 36 + local.get 38 + i32.and + local.set 39 + local.get 37 + local.set 40 + block ;; label = @2 + local.get 39 + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=4 + local.set 41 + i32.const 57 + local.set 42 + local.get 41 + local.set 43 + local.get 42 + local.set 44 + local.get 43 + local.get 44 + i32.le_s + local.set 45 + local.get 45 + local.set 40 + end + local.get 40 + local.set 46 + i32.const 1 + local.set 47 + local.get 46 + local.get 47 + i32.and + local.set 48 + block ;; label = @2 + local.get 48 + i32.eqz + br_if 0 (;@2;) + local.get 3 + i32.load offset=8 + local.set 49 + i32.const 1 + local.set 50 + local.get 49 + local.get 50 + i32.shl + local.set 51 + local.get 3 + i32.load offset=8 + local.set 52 + i32.const 3 + local.set 53 + local.get 52 + local.get 53 + i32.shl + local.set 54 + local.get 51 + local.get 54 + i32.add + local.set 55 + local.get 3 + i32.load offset=4 + local.set 56 + i32.const 48 + local.set 57 + local.get 56 + local.get 57 + i32.xor + local.set 58 + local.get 55 + local.get 58 + i32.add + local.set 59 + local.get 3 + local.get 59 + i32.store offset=8 + local.get 3 + i32.load offset=12 + local.set 60 + local.get 60 + call $nc + local.set 61 + i32.const 24 + local.set 62 + local.get 61 + local.get 62 + i32.shl + local.set 63 + local.get 63 + local.get 62 + i32.shr_s + local.set 64 + local.get 3 + local.get 64 + i32.store offset=4 + br 1 (;@1;) + end + end + local.get 3 + i32.load offset=8 + local.set 65 + i32.const 16 + local.set 66 + local.get 3 + local.get 66 + i32.add + local.set 67 + local.get 67 + global.set $__stack_pointer + local.get 65 + return) + (func $main (type 4) (param i32 i32) (result i32) + (local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) + global.get $__stack_pointer + local.set 2 + i32.const 368 + local.set 3 + local.get 2 + local.get 3 + i32.sub + local.set 4 + local.get 4 + local.set 5 + local.get 4 + global.set $__stack_pointer + i32.const 0 + local.set 6 + local.get 5 + local.get 6 + i32.store offset=364 + local.get 5 + local.get 0 + i32.store offset=360 + local.get 5 + local.get 1 + i32.store offset=356 + local.get 5 + i32.load offset=356 + local.set 7 + local.get 7 + i32.load offset=4 + local.set 8 + local.get 8 + call $atoi + local.set 9 + local.get 5 + local.get 9 + i32.store offset=352 + local.get 5 + i32.load offset=356 + local.set 10 + local.get 10 + i32.load offset=8 + local.set 11 + local.get 11 + call $atoi + local.set 12 + local.get 5 + local.get 12 + i32.store offset=348 + local.get 5 + i32.load offset=356 + local.set 13 + local.get 13 + i32.load offset=12 + local.set 14 + local.get 14 + call $atoi + local.set 15 + local.get 5 + local.get 15 + i32.store offset=344 + local.get 5 + i32.load offset=352 + local.set 16 + local.get 5 + local.get 16 + i32.store offset=128 + i32.const 1348 + local.set 17 + i32.const 128 + local.set 18 + local.get 5 + local.get 18 + i32.add + local.set 19 + local.get 17 + local.get 19 + call $printf + drop + i32.const 1600000 + local.set 20 + local.get 5 + local.get 20 + i32.store offset=340 + i32.const 304 + local.set 21 + local.get 5 + local.get 21 + i32.add + local.set 22 + local.get 22 + local.set 23 + local.get 5 + i32.load offset=352 + local.set 24 + local.get 5 + local.get 24 + i32.store offset=144 + i32.const 1053 + local.set 25 + i32.const 144 + local.set 26 + local.get 5 + local.get 26 + i32.add + local.set 27 + local.get 23 + local.get 25 + local.get 27 + call $sprintf + drop + i32.const 304 + local.set 28 + local.get 5 + local.get 28 + i32.add + local.set 29 + local.get 29 + local.set 30 + i32.const 1081 + local.set 31 + local.get 30 + local.get 31 + call $fopen + local.set 32 + local.get 5 + local.get 32 + i32.store offset=300 + local.get 5 + i32.load offset=300 + local.set 33 + i32.const 0 + local.set 34 + local.get 33 + local.set 35 + local.get 34 + local.set 36 + local.get 35 + local.get 36 + i32.ne + local.set 37 + i32.const 1 + local.set 38 + local.get 37 + local.get 38 + i32.and + local.set 39 + block ;; label = @1 + local.get 39 + br_if 0 (;@1;) + i32.const 1179 + local.set 40 + local.get 40 + call $perror + i32.const 1 + local.set 41 + local.get 41 + call $exit + unreachable + end + i32.const 0 + local.set 42 + local.get 5 + local.get 42 + i32.store offset=296 + block ;; label = @1 + loop ;; label = @2 + local.get 5 + i32.load offset=300 + local.set 43 + local.get 43 + call $read + local.set 44 + local.get 5 + i32.load offset=296 + local.set 45 + i32.const 1 + local.set 46 + local.get 45 + local.get 46 + i32.add + local.set 47 + local.get 5 + local.get 47 + i32.store offset=296 + i32.const 1052496 + local.set 48 + i32.const 2 + local.set 49 + local.get 45 + local.get 49 + i32.shl + local.set 50 + local.get 48 + local.get 50 + i32.add + local.set 51 + local.get 51 + local.get 44 + i32.store + local.get 44 + i32.eqz + br_if 1 (;@1;) + br 0 (;@2;) + end + end + local.get 5 + i32.load offset=352 + local.set 52 + local.get 5 + local.get 52 + i32.store offset=80 + i32.const 1417 + local.set 53 + i32.const 80 + local.set 54 + local.get 5 + local.get 54 + i32.add + local.set 55 + local.get 53 + local.get 55 + call $printf + drop + local.get 5 + i32.load offset=296 + local.set 56 + local.get 5 + local.get 56 + i32.store offset=96 + i32.const 1206 + local.set 57 + i32.const 96 + local.set 58 + local.get 5 + local.get 58 + i32.add + local.set 59 + local.get 57 + local.get 59 + call $printf + drop + local.get 5 + i32.load offset=300 + local.set 60 + local.get 60 + call $fclose + drop + local.get 5 + i32.load offset=352 + local.set 61 + local.get 5 + local.get 61 + i32.store offset=112 + i32.const 1366 + local.set 62 + i32.const 112 + local.set 63 + local.get 5 + local.get 63 + i32.add + local.set 64 + local.get 62 + local.get 64 + call $printf + drop + local.get 5 + i32.load offset=344 + local.set 65 + i32.const 1 + local.set 66 + local.get 65 + local.set 67 + local.get 66 + local.set 68 + local.get 67 + local.get 68 + i32.gt_s + local.set 69 + i32.const 1 + local.set 70 + local.get 69 + local.get 70 + i32.and + local.set 71 + block ;; label = @1 + block ;; label = @2 + local.get 71 + i32.eqz + br_if 0 (;@2;) + local.get 5 + i32.load offset=352 + local.set 72 + local.get 72 + br_if 0 (;@2;) + local.get 5 + i32.load offset=344 + local.set 73 + i32.const -1 + local.set 74 + local.get 73 + local.get 74 + i32.add + local.set 75 + local.get 4 + local.set 76 + local.get 5 + local.get 76 + i32.store offset=280 + i32.const 2 + local.set 77 + local.get 75 + local.get 77 + i32.shl + local.set 78 + i32.const 15 + local.set 79 + local.get 78 + local.get 79 + i32.add + local.set 80 + i32.const -16 + local.set 81 + local.get 80 + local.get 81 + i32.and + local.set 82 + local.get 4 + local.set 83 + local.get 83 + local.get 82 + i32.sub + local.set 84 + local.get 84 + local.set 4 + local.get 4 + global.set $__stack_pointer + local.get 5 + local.get 75 + i32.store offset=276 + i32.const 0 + local.set 85 + local.get 5 + local.get 85 + i32.store offset=272 + block ;; label = @3 + loop ;; label = @4 + local.get 5 + i32.load offset=272 + local.set 86 + local.get 5 + i32.load offset=344 + local.set 87 + i32.const 1 + local.set 88 + local.get 87 + local.get 88 + i32.sub + local.set 89 + local.get 86 + local.set 90 + local.get 89 + local.set 91 + local.get 90 + local.get 91 + i32.lt_s + local.set 92 + i32.const 1 + local.set 93 + local.get 92 + local.get 93 + i32.and + local.set 94 + local.get 94 + i32.eqz + br_if 1 (;@3;) + local.get 5 + i32.load offset=272 + local.set 95 + i32.const 1 + local.set 96 + local.get 95 + local.get 96 + i32.add + local.set 97 + local.get 5 + i32.load offset=296 + local.set 98 + local.get 97 + local.get 98 + i32.mul + local.set 99 + local.get 5 + i32.load offset=344 + local.set 100 + local.get 99 + local.get 100 + i32.div_s + local.set 101 + local.get 5 + local.get 101 + i32.store offset=268 + local.get 5 + i32.load offset=268 + local.set 102 + i32.const 1052496 + local.set 103 + i32.const 2 + local.set 104 + local.get 102 + local.get 104 + i32.shl + local.set 105 + local.get 103 + local.get 105 + i32.add + local.set 106 + local.get 106 + i32.load + local.set 107 + local.get 5 + i32.load offset=272 + local.set 108 + i32.const 2 + local.set 109 + local.get 108 + local.get 109 + i32.shl + local.set 110 + local.get 84 + local.get 110 + i32.add + local.set 111 + local.get 111 + local.get 107 + i32.store + local.get 5 + i32.load offset=272 + local.set 112 + i32.const 1 + local.set 113 + local.get 112 + local.get 113 + i32.add + local.set 114 + local.get 5 + local.get 114 + i32.store offset=272 + br 0 (;@4;) + end + end + local.get 5 + i32.load offset=340 + local.set 115 + i32.const 0 + local.set 116 + local.get 115 + local.get 116 + i32.shl + local.set 117 + local.get 117 + call $malloc + local.set 118 + local.get 5 + local.get 118 + i32.store offset=264 + local.get 5 + i32.load offset=264 + local.set 119 + i32.const 0 + local.set 120 + local.get 119 + local.set 121 + local.get 120 + local.set 122 + local.get 121 + local.get 122 + i32.eq + local.set 123 + i32.const 1 + local.set 124 + local.get 123 + local.get 124 + i32.and + local.set 125 + block ;; label = @3 + block ;; label = @4 + local.get 125 + i32.eqz + br_if 0 (;@4;) + i32.const 1070 + local.set 126 + local.get 126 + call $perror + i32.const 1 + local.set 127 + local.get 5 + local.get 127 + i32.store offset=364 + i32.const 1 + local.set 128 + local.get 5 + local.get 128 + i32.store offset=260 + br 1 (;@3;) + end + local.get 5 + i32.load offset=264 + local.set 129 + local.get 5 + i32.load offset=340 + local.set 130 + i32.const 0 + local.set 131 + local.get 130 + local.get 131 + i32.shl + local.set 132 + i32.const 0 + local.set 133 + local.get 129 + local.get 133 + local.get 132 + call $memset + drop + local.get 5 + i32.load offset=264 + local.set 134 + i32.const 0 + local.set 135 + local.get 134 + local.get 135 + i32.store8 + i32.const 0 + local.set 136 + local.get 5 + local.get 136 + i32.store offset=256 + block ;; label = @4 + loop ;; label = @5 + local.get 5 + i32.load offset=256 + local.set 137 + local.get 5 + i32.load offset=344 + local.set 138 + i32.const 1 + local.set 139 + local.get 138 + local.get 139 + i32.sub + local.set 140 + local.get 137 + local.set 141 + local.get 140 + local.set 142 + local.get 141 + local.get 142 + i32.lt_s + local.set 143 + i32.const 1 + local.set 144 + local.get 143 + local.get 144 + i32.and + local.set 145 + local.get 145 + i32.eqz + br_if 1 (;@4;) + i32.const 244 + local.set 146 + local.get 5 + local.get 146 + i32.add + local.set 147 + local.get 147 + local.set 148 + local.get 5 + i32.load offset=256 + local.set 149 + i32.const 2 + local.set 150 + local.get 149 + local.get 150 + i32.shl + local.set 151 + local.get 84 + local.get 151 + i32.add + local.set 152 + local.get 152 + i32.load + local.set 153 + local.get 5 + local.get 153 + i32.store offset=48 + i32.const 1175 + local.set 154 + i32.const 12 + local.set 155 + i32.const 48 + local.set 156 + local.get 5 + local.get 156 + i32.add + local.set 157 + local.get 148 + local.get 155 + local.get 154 + local.get 157 + call $snprintf + drop + local.get 5 + i32.load offset=264 + local.set 158 + i32.const 244 + local.set 159 + local.get 5 + local.get 159 + i32.add + local.set 160 + local.get 160 + local.set 161 + local.get 158 + local.get 161 + call $strcat + drop + local.get 5 + i32.load offset=256 + local.set 162 + i32.const 1 + local.set 163 + local.get 162 + local.get 163 + i32.add + local.set 164 + local.get 5 + local.get 164 + i32.store offset=256 + br 0 (;@5;) + end + end + local.get 5 + i32.load offset=264 + local.set 165 + local.get 5 + i32.load offset=264 + local.set 166 + local.get 166 + call $strlen + local.set 167 + i32.const 1 + local.set 168 + local.get 167 + local.get 168 + i32.sub + local.set 169 + local.get 165 + local.get 169 + i32.add + local.set 170 + i32.const 0 + local.set 171 + local.get 170 + local.get 171 + i32.store8 + i32.const 0 + local.set 172 + local.get 5 + local.get 172 + i32.store offset=240 + block ;; label = @4 + loop ;; label = @5 + local.get 5 + i32.load offset=240 + local.set 173 + local.get 5 + i32.load offset=348 + local.set 174 + local.get 173 + local.set 175 + local.get 174 + local.set 176 + local.get 175 + local.get 176 + i32.lt_s + local.set 177 + i32.const 1 + local.set 178 + local.get 177 + local.get 178 + i32.and + local.set 179 + local.get 179 + i32.eqz + br_if 1 (;@4;) + i32.const 208 + local.set 180 + local.get 5 + local.get 180 + i32.add + local.set 181 + local.get 181 + local.set 182 + local.get 5 + i32.load offset=240 + local.set 183 + local.get 5 + local.get 183 + i32.store offset=64 + i32.const 1122 + local.set 184 + i32.const 64 + local.set 185 + local.get 5 + local.get 185 + i32.add + local.set 186 + local.get 182 + local.get 184 + local.get 186 + call $sprintf + drop + i32.const 208 + local.set 187 + local.get 5 + local.get 187 + i32.add + local.set 188 + local.get 188 + local.set 189 + i32.const 208 + local.set 190 + local.get 5 + local.get 190 + i32.add + local.set 191 + local.get 191 + local.set 192 + local.get 192 + call $strlen + local.set 193 + local.get 5 + i32.load offset=264 + local.set 194 + local.get 5 + i32.load offset=340 + local.set 195 + local.get 189 + local.get 193 + local.get 194 + local.get 195 + call $buffer_register + local.get 5 + i32.load offset=240 + local.set 196 + i32.const 1 + local.set 197 + local.get 196 + local.get 197 + i32.add + local.set 198 + local.get 5 + local.get 198 + i32.store offset=240 + br 0 (;@5;) + end + end + local.get 5 + i32.load offset=264 + local.set 199 + local.get 199 + call $free + i32.const 0 + local.set 200 + local.get 5 + local.get 200 + i32.store offset=260 + end + local.get 5 + i32.load offset=280 + local.set 201 + local.get 201 + local.set 4 + local.get 5 + i32.load offset=260 + local.set 202 + block ;; label = @3 + local.get 202 + br_table 0 (;@3;) 2 (;@1;) 0 (;@3;) + end + end + i32.const 1141 + local.set 203 + local.get 203 + call $puts + drop + i32.const 176 + local.set 204 + local.get 5 + local.get 204 + i32.add + local.set 205 + local.get 205 + local.set 206 + local.get 5 + i32.load offset=352 + local.set 207 + local.get 5 + local.get 207 + i32.store offset=32 + i32.const 1131 + local.set 208 + i32.const 32 + local.set 209 + local.get 5 + local.get 209 + i32.add + local.set 210 + local.get 206 + local.get 208 + local.get 210 + call $sprintf + drop + local.get 5 + i32.load offset=340 + local.set 211 + i32.const 0 + local.set 212 + local.get 211 + local.get 212 + i32.shl + local.set 213 + local.get 213 + call $malloc + local.set 214 + local.get 5 + local.get 214 + i32.store offset=172 + local.get 5 + i32.load offset=172 + local.set 215 + i32.const 0 + local.set 216 + local.get 215 + local.set 217 + local.get 216 + local.set 218 + local.get 217 + local.get 218 + i32.eq + local.set 219 + i32.const 1 + local.set 220 + local.get 219 + local.get 220 + i32.and + local.set 221 + block ;; label = @2 + local.get 221 + i32.eqz + br_if 0 (;@2;) + i32.const 1070 + local.set 222 + local.get 222 + call $perror + i32.const 1 + local.set 223 + local.get 5 + local.get 223 + i32.store offset=364 + br 1 (;@1;) + end + i32.const 1107 + local.set 224 + local.get 224 + call $puts + drop + local.get 5 + i32.load offset=172 + local.set 225 + local.get 5 + i32.load offset=340 + local.set 226 + i32.const 0 + local.set 227 + local.get 226 + local.get 227 + i32.shl + local.set 228 + i32.const 0 + local.set 229 + local.get 225 + local.get 229 + local.get 228 + call $memset + drop + i32.const 1091 + local.set 230 + local.get 230 + call $puts + drop + local.get 5 + i32.load offset=172 + local.set 231 + i32.const 0 + local.set 232 + local.get 231 + local.get 232 + i32.store8 + i32.const 0 + local.set 233 + local.get 5 + local.get 233 + i32.store offset=168 + block ;; label = @2 + loop ;; label = @3 + local.get 5 + i32.load offset=168 + local.set 234 + local.get 5 + i32.load offset=296 + local.set 235 + local.get 234 + local.set 236 + local.get 235 + local.set 237 + local.get 236 + local.get 237 + i32.lt_s + local.set 238 + i32.const 1 + local.set 239 + local.get 238 + local.get 239 + i32.and + local.set 240 + local.get 240 + i32.eqz + br_if 1 (;@2;) + i32.const 156 + local.set 241 + local.get 5 + local.get 241 + i32.add + local.set 242 + local.get 242 + local.set 243 + local.get 5 + i32.load offset=168 + local.set 244 + i32.const 1052496 + local.set 245 + i32.const 2 + local.set 246 + local.get 244 + local.get 246 + i32.shl + local.set 247 + local.get 245 + local.get 247 + i32.add + local.set 248 + local.get 248 + i32.load + local.set 249 + local.get 5 + local.get 249 + i32.store + i32.const 1175 + local.set 250 + i32.const 12 + local.set 251 + local.get 243 + local.get 251 + local.get 250 + local.get 5 + call $snprintf + drop + local.get 5 + i32.load offset=172 + local.set 252 + i32.const 156 + local.set 253 + local.get 5 + local.get 253 + i32.add + local.set 254 + local.get 254 + local.set 255 + local.get 252 + local.get 255 + call $strcat + drop + local.get 5 + i32.load offset=168 + local.set 256 + i32.const 1 + local.set 257 + local.get 256 + local.get 257 + i32.add + local.set 258 + local.get 5 + local.get 258 + i32.store offset=168 + br 0 (;@3;) + end + end + local.get 5 + i32.load offset=172 + local.set 259 + local.get 5 + i32.load offset=172 + local.set 260 + local.get 260 + call $strlen + local.set 261 + i32.const 1 + local.set 262 + local.get 261 + local.get 262 + i32.sub + local.set 263 + local.get 259 + local.get 263 + i32.add + local.set 264 + i32.const 0 + local.set 265 + local.get 264 + local.get 265 + i32.store8 + i32.const 176 + local.set 266 + local.get 5 + local.get 266 + i32.add + local.set 267 + local.get 267 + local.set 268 + i32.const 176 + local.set 269 + local.get 5 + local.get 269 + i32.add + local.set 270 + local.get 270 + local.set 271 + local.get 271 + call $strlen + local.set 272 + local.get 5 + i32.load offset=172 + local.set 273 + local.get 5 + i32.load offset=340 + local.set 274 + local.get 268 + local.get 272 + local.get 273 + local.get 274 + call $buffer_register + local.get 5 + i32.load offset=172 + local.set 275 + local.get 275 + call $free + local.get 5 + i32.load offset=352 + local.set 276 + local.get 5 + local.get 276 + i32.store offset=16 + i32.const 1392 + local.set 277 + i32.const 16 + local.set 278 + local.get 5 + local.get 278 + i32.add + local.set 279 + local.get 277 + local.get 279 + call $printf + drop + i32.const 0 + local.set 280 + local.get 5 + local.get 280 + i32.store offset=364 + end + local.get 5 + i32.load offset=364 + local.set 281 + i32.const 368 + local.set 282 + local.get 5 + local.get 282 + i32.add + local.set 283 + local.get 283 + global.set $__stack_pointer + local.get 281 + return + unreachable) + (func $malloc (type 0) (param i32) (result i32) + local.get 0 + call $dlmalloc) + (func $dlmalloc (type 0) (param i32) (result i32) + (local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 1 + global.set $__stack_pointer + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + block ;; label = @7 + block ;; label = @8 + block ;; label = @9 + block ;; label = @10 + block ;; label = @11 + block ;; label = @12 + i32.const 0 + i32.load offset=1692520 + local.tee 2 + br_if 0 (;@12;) + block ;; label = @13 + i32.const 0 + i32.load offset=1692968 + local.tee 3 + br_if 0 (;@13;) + i32.const 0 + i64.const -1 + i64.store offset=1692980 align=4 + i32.const 0 + i64.const 281474976776192 + i64.store offset=1692972 align=4 + i32.const 0 + local.get 1 + i32.const 8 + i32.add + i32.const -16 + i32.and + i32.const 1431655768 + i32.xor + local.tee 3 + i32.store offset=1692968 + i32.const 0 + i32.const 0 + i32.store offset=1692988 + i32.const 0 + i32.const 0 + i32.store offset=1692940 + end + i32.const 1769472 + i32.const 1759648 + i32.lt_u + br_if 1 (;@11;) + i32.const 0 + local.set 2 + i32.const 1769472 + i32.const 1759648 + i32.sub + i32.const 89 + i32.lt_u + br_if 0 (;@12;) + i32.const 0 + local.set 4 + i32.const 0 + i32.const 1759648 + i32.store offset=1692944 + i32.const 0 + i32.const 1759648 + i32.store offset=1692512 + i32.const 0 + local.get 3 + i32.store offset=1692532 + i32.const 0 + i32.const -1 + i32.store offset=1692528 + i32.const 0 + i32.const 1769472 + i32.const 1759648 + i32.sub + local.tee 3 + i32.store offset=1692948 + i32.const 0 + local.get 3 + i32.store offset=1692932 + i32.const 0 + local.get 3 + i32.store offset=1692928 + loop ;; label = @13 + local.get 4 + i32.const 1692556 + i32.add + local.get 4 + i32.const 1692544 + i32.add + local.tee 3 + i32.store + local.get 3 + local.get 4 + i32.const 1692536 + i32.add + local.tee 5 + i32.store + local.get 4 + i32.const 1692548 + i32.add + local.get 5 + i32.store + local.get 4 + i32.const 1692564 + i32.add + local.get 4 + i32.const 1692552 + i32.add + local.tee 5 + i32.store + local.get 5 + local.get 3 + i32.store + local.get 4 + i32.const 1692572 + i32.add + local.get 4 + i32.const 1692560 + i32.add + local.tee 3 + i32.store + local.get 3 + local.get 5 + i32.store + local.get 4 + i32.const 1692568 + i32.add + local.get 3 + i32.store + local.get 4 + i32.const 32 + i32.add + local.tee 4 + i32.const 256 + i32.ne + br_if 0 (;@13;) + end + i32.const 1759648 + i32.const -8 + i32.const 1759648 + i32.sub + i32.const 15 + i32.and + local.tee 4 + i32.add + local.tee 2 + i32.const 1769472 + i32.const 1759648 + i32.sub + i32.const -56 + i32.add + local.tee 3 + local.get 4 + i32.sub + local.tee 4 + i32.const 1 + i32.or + i32.store offset=4 + i32.const 0 + i32.const 0 + i32.load offset=1692984 + i32.store offset=1692524 + i32.const 0 + local.get 4 + i32.store offset=1692508 + i32.const 0 + local.get 2 + i32.store offset=1692520 + local.get 3 + i32.const 1759648 + i32.add + i32.const 4 + i32.add + i32.const 56 + i32.store + end + block ;; label = @12 + block ;; label = @13 + local.get 0 + i32.const 236 + i32.gt_u + br_if 0 (;@13;) + block ;; label = @14 + i32.const 0 + i32.load offset=1692496 + local.tee 6 + i32.const 16 + local.get 0 + i32.const 19 + i32.add + i32.const 496 + i32.and + local.get 0 + i32.const 11 + i32.lt_u + select + local.tee 7 + i32.const 3 + i32.shr_u + local.tee 3 + i32.shr_u + local.tee 4 + i32.const 3 + i32.and + i32.eqz + br_if 0 (;@14;) + block ;; label = @15 + block ;; label = @16 + local.get 4 + i32.const 1 + i32.and + local.get 3 + i32.or + i32.const 1 + i32.xor + local.tee 5 + i32.const 3 + i32.shl + local.tee 3 + i32.const 1692536 + i32.add + local.tee 4 + local.get 3 + i32.const 1692544 + i32.add + i32.load + local.tee 3 + i32.load offset=8 + local.tee 7 + i32.ne + br_if 0 (;@16;) + i32.const 0 + local.get 6 + i32.const -2 + local.get 5 + i32.rotl + i32.and + i32.store offset=1692496 + br 1 (;@15;) + end + local.get 4 + local.get 7 + i32.store offset=8 + local.get 7 + local.get 4 + i32.store offset=12 + end + local.get 3 + i32.const 8 + i32.add + local.set 4 + local.get 3 + local.get 5 + i32.const 3 + i32.shl + local.tee 5 + i32.const 3 + i32.or + i32.store offset=4 + local.get 3 + local.get 5 + i32.add + local.tee 3 + local.get 3 + i32.load offset=4 + i32.const 1 + i32.or + i32.store offset=4 + br 13 (;@1;) + end + local.get 7 + i32.const 0 + i32.load offset=1692504 + local.tee 8 + i32.le_u + br_if 1 (;@12;) + block ;; label = @14 + local.get 4 + i32.eqz + br_if 0 (;@14;) + block ;; label = @15 + block ;; label = @16 + local.get 4 + local.get 3 + i32.shl + i32.const 2 + local.get 3 + i32.shl + local.tee 4 + i32.const 0 + local.get 4 + i32.sub + i32.or + i32.and + i32.ctz + local.tee 3 + i32.const 3 + i32.shl + local.tee 4 + i32.const 1692536 + i32.add + local.tee 5 + local.get 4 + i32.const 1692544 + i32.add + i32.load + local.tee 4 + i32.load offset=8 + local.tee 0 + i32.ne + br_if 0 (;@16;) + i32.const 0 + local.get 6 + i32.const -2 + local.get 3 + i32.rotl + i32.and + local.tee 6 + i32.store offset=1692496 + br 1 (;@15;) + end + local.get 5 + local.get 0 + i32.store offset=8 + local.get 0 + local.get 5 + i32.store offset=12 + end + local.get 4 + local.get 7 + i32.const 3 + i32.or + i32.store offset=4 + local.get 4 + local.get 3 + i32.const 3 + i32.shl + local.tee 3 + i32.add + local.get 3 + local.get 7 + i32.sub + local.tee 5 + i32.store + local.get 4 + local.get 7 + i32.add + local.tee 0 + local.get 5 + i32.const 1 + i32.or + i32.store offset=4 + block ;; label = @15 + local.get 8 + i32.eqz + br_if 0 (;@15;) + local.get 8 + i32.const -8 + i32.and + i32.const 1692536 + i32.add + local.set 7 + i32.const 0 + i32.load offset=1692516 + local.set 3 + block ;; label = @16 + block ;; label = @17 + local.get 6 + i32.const 1 + local.get 8 + i32.const 3 + i32.shr_u + i32.shl + local.tee 9 + i32.and + br_if 0 (;@17;) + i32.const 0 + local.get 6 + local.get 9 + i32.or + i32.store offset=1692496 + local.get 7 + local.set 9 + br 1 (;@16;) + end + local.get 7 + i32.load offset=8 + local.set 9 + end + local.get 9 + local.get 3 + i32.store offset=12 + local.get 7 + local.get 3 + i32.store offset=8 + local.get 3 + local.get 7 + i32.store offset=12 + local.get 3 + local.get 9 + i32.store offset=8 + end + local.get 4 + i32.const 8 + i32.add + local.set 4 + i32.const 0 + local.get 0 + i32.store offset=1692516 + i32.const 0 + local.get 5 + i32.store offset=1692504 + br 13 (;@1;) + end + i32.const 0 + i32.load offset=1692500 + local.tee 10 + i32.eqz + br_if 1 (;@12;) + local.get 10 + i32.ctz + i32.const 2 + i32.shl + i32.const 1692800 + i32.add + i32.load + local.tee 0 + i32.load offset=4 + i32.const -8 + i32.and + local.get 7 + i32.sub + local.set 3 + local.get 0 + local.set 5 + block ;; label = @14 + loop ;; label = @15 + block ;; label = @16 + local.get 5 + i32.load offset=16 + local.tee 4 + br_if 0 (;@16;) + local.get 5 + i32.const 20 + i32.add + i32.load + local.tee 4 + i32.eqz + br_if 2 (;@14;) + end + local.get 4 + i32.load offset=4 + i32.const -8 + i32.and + local.get 7 + i32.sub + local.tee 5 + local.get 3 + local.get 5 + local.get 3 + i32.lt_u + local.tee 5 + select + local.set 3 + local.get 4 + local.get 0 + local.get 5 + select + local.set 0 + local.get 4 + local.set 5 + br 0 (;@15;) + end + end + local.get 0 + i32.load offset=24 + local.set 11 + block ;; label = @14 + local.get 0 + i32.load offset=12 + local.tee 9 + local.get 0 + i32.eq + br_if 0 (;@14;) + local.get 0 + i32.load offset=8 + local.tee 4 + i32.const 0 + i32.load offset=1692512 + i32.lt_u + drop + local.get 9 + local.get 4 + i32.store offset=8 + local.get 4 + local.get 9 + i32.store offset=12 + br 12 (;@2;) + end + block ;; label = @14 + local.get 0 + i32.const 20 + i32.add + local.tee 5 + i32.load + local.tee 4 + br_if 0 (;@14;) + local.get 0 + i32.load offset=16 + local.tee 4 + i32.eqz + br_if 4 (;@10;) + local.get 0 + i32.const 16 + i32.add + local.set 5 + end + loop ;; label = @14 + local.get 5 + local.set 2 + local.get 4 + local.tee 9 + i32.const 20 + i32.add + local.tee 5 + i32.load + local.tee 4 + br_if 0 (;@14;) + local.get 9 + i32.const 16 + i32.add + local.set 5 + local.get 9 + i32.load offset=16 + local.tee 4 + br_if 0 (;@14;) + end + local.get 2 + i32.const 0 + i32.store + br 11 (;@2;) + end + i32.const -1 + local.set 7 + local.get 0 + i32.const -65 + i32.gt_u + br_if 0 (;@12;) + local.get 0 + i32.const 19 + i32.add + local.tee 4 + i32.const -16 + i32.and + local.set 7 + i32.const 0 + i32.load offset=1692500 + local.tee 11 + i32.eqz + br_if 0 (;@12;) + i32.const 0 + local.set 8 + block ;; label = @13 + local.get 7 + i32.const 256 + i32.lt_u + br_if 0 (;@13;) + i32.const 31 + local.set 8 + local.get 7 + i32.const 16777215 + i32.gt_u + br_if 0 (;@13;) + local.get 7 + i32.const 38 + local.get 4 + i32.const 8 + i32.shr_u + i32.clz + local.tee 4 + i32.sub + i32.shr_u + i32.const 1 + i32.and + local.get 4 + i32.const 1 + i32.shl + i32.sub + i32.const 62 + i32.add + local.set 8 + end + i32.const 0 + local.get 7 + i32.sub + local.set 3 + block ;; label = @13 + block ;; label = @14 + block ;; label = @15 + block ;; label = @16 + local.get 8 + i32.const 2 + i32.shl + i32.const 1692800 + i32.add + i32.load + local.tee 5 + br_if 0 (;@16;) + i32.const 0 + local.set 4 + i32.const 0 + local.set 9 + br 1 (;@15;) + end + i32.const 0 + local.set 4 + local.get 7 + i32.const 0 + i32.const 25 + local.get 8 + i32.const 1 + i32.shr_u + i32.sub + local.get 8 + i32.const 31 + i32.eq + select + i32.shl + local.set 0 + i32.const 0 + local.set 9 + loop ;; label = @16 + block ;; label = @17 + local.get 5 + i32.load offset=4 + i32.const -8 + i32.and + local.get 7 + i32.sub + local.tee 6 + local.get 3 + i32.ge_u + br_if 0 (;@17;) + local.get 6 + local.set 3 + local.get 5 + local.set 9 + local.get 6 + br_if 0 (;@17;) + i32.const 0 + local.set 3 + local.get 5 + local.set 9 + local.get 5 + local.set 4 + br 3 (;@14;) + end + local.get 4 + local.get 5 + i32.const 20 + i32.add + i32.load + local.tee 6 + local.get 6 + local.get 5 + local.get 0 + i32.const 29 + i32.shr_u + i32.const 4 + i32.and + i32.add + i32.const 16 + i32.add + i32.load + local.tee 5 + i32.eq + select + local.get 4 + local.get 6 + select + local.set 4 + local.get 0 + i32.const 1 + i32.shl + local.set 0 + local.get 5 + br_if 0 (;@16;) + end + end + block ;; label = @15 + local.get 4 + local.get 9 + i32.or + br_if 0 (;@15;) + i32.const 0 + local.set 9 + i32.const 2 + local.get 8 + i32.shl + local.tee 4 + i32.const 0 + local.get 4 + i32.sub + i32.or + local.get 11 + i32.and + local.tee 4 + i32.eqz + br_if 3 (;@12;) + local.get 4 + i32.ctz + i32.const 2 + i32.shl + i32.const 1692800 + i32.add + i32.load + local.set 4 + end + local.get 4 + i32.eqz + br_if 1 (;@13;) + end + loop ;; label = @14 + local.get 4 + i32.load offset=4 + i32.const -8 + i32.and + local.get 7 + i32.sub + local.tee 6 + local.get 3 + i32.lt_u + local.set 0 + block ;; label = @15 + local.get 4 + i32.load offset=16 + local.tee 5 + br_if 0 (;@15;) + local.get 4 + i32.const 20 + i32.add + i32.load + local.set 5 + end + local.get 6 + local.get 3 + local.get 0 + select + local.set 3 + local.get 4 + local.get 9 + local.get 0 + select + local.set 9 + local.get 5 + local.set 4 + local.get 5 + br_if 0 (;@14;) + end + end + local.get 9 + i32.eqz + br_if 0 (;@12;) + local.get 3 + i32.const 0 + i32.load offset=1692504 + local.get 7 + i32.sub + i32.ge_u + br_if 0 (;@12;) + local.get 9 + i32.load offset=24 + local.set 2 + block ;; label = @13 + local.get 9 + i32.load offset=12 + local.tee 0 + local.get 9 + i32.eq + br_if 0 (;@13;) + local.get 9 + i32.load offset=8 + local.tee 4 + i32.const 0 + i32.load offset=1692512 + i32.lt_u + drop + local.get 0 + local.get 4 + i32.store offset=8 + local.get 4 + local.get 0 + i32.store offset=12 + br 10 (;@3;) + end + block ;; label = @13 + local.get 9 + i32.const 20 + i32.add + local.tee 5 + i32.load + local.tee 4 + br_if 0 (;@13;) + local.get 9 + i32.load offset=16 + local.tee 4 + i32.eqz + br_if 4 (;@9;) + local.get 9 + i32.const 16 + i32.add + local.set 5 + end + loop ;; label = @13 + local.get 5 + local.set 6 + local.get 4 + local.tee 0 + i32.const 20 + i32.add + local.tee 5 + i32.load + local.tee 4 + br_if 0 (;@13;) + local.get 0 + i32.const 16 + i32.add + local.set 5 + local.get 0 + i32.load offset=16 + local.tee 4 + br_if 0 (;@13;) + end + local.get 6 + i32.const 0 + i32.store + br 9 (;@3;) + end + block ;; label = @12 + i32.const 0 + i32.load offset=1692504 + local.tee 4 + local.get 7 + i32.lt_u + br_if 0 (;@12;) + i32.const 0 + i32.load offset=1692516 + local.set 3 + block ;; label = @13 + block ;; label = @14 + local.get 4 + local.get 7 + i32.sub + local.tee 5 + i32.const 16 + i32.lt_u + br_if 0 (;@14;) + local.get 3 + local.get 7 + i32.add + local.tee 0 + local.get 5 + i32.const 1 + i32.or + i32.store offset=4 + local.get 3 + local.get 4 + i32.add + local.get 5 + i32.store + local.get 3 + local.get 7 + i32.const 3 + i32.or + i32.store offset=4 + br 1 (;@13;) + end + local.get 3 + local.get 4 + i32.const 3 + i32.or + i32.store offset=4 + local.get 3 + local.get 4 + i32.add + local.tee 4 + local.get 4 + i32.load offset=4 + i32.const 1 + i32.or + i32.store offset=4 + i32.const 0 + local.set 0 + i32.const 0 + local.set 5 + end + i32.const 0 + local.get 5 + i32.store offset=1692504 + i32.const 0 + local.get 0 + i32.store offset=1692516 + local.get 3 + i32.const 8 + i32.add + local.set 4 + br 11 (;@1;) + end + block ;; label = @12 + i32.const 0 + i32.load offset=1692508 + local.tee 5 + local.get 7 + i32.le_u + br_if 0 (;@12;) + local.get 2 + local.get 7 + i32.add + local.tee 4 + local.get 5 + local.get 7 + i32.sub + local.tee 3 + i32.const 1 + i32.or + i32.store offset=4 + i32.const 0 + local.get 4 + i32.store offset=1692520 + i32.const 0 + local.get 3 + i32.store offset=1692508 + local.get 2 + local.get 7 + i32.const 3 + i32.or + i32.store offset=4 + local.get 2 + i32.const 8 + i32.add + local.set 4 + br 11 (;@1;) + end + block ;; label = @12 + block ;; label = @13 + i32.const 0 + i32.load offset=1692968 + i32.eqz + br_if 0 (;@13;) + i32.const 0 + i32.load offset=1692976 + local.set 3 + br 1 (;@12;) + end + i32.const 0 + i64.const -1 + i64.store offset=1692980 align=4 + i32.const 0 + i64.const 281474976776192 + i64.store offset=1692972 align=4 + i32.const 0 + local.get 1 + i32.const 12 + i32.add + i32.const -16 + i32.and + i32.const 1431655768 + i32.xor + i32.store offset=1692968 + i32.const 0 + i32.const 0 + i32.store offset=1692988 + i32.const 0 + i32.const 0 + i32.store offset=1692940 + i32.const 65536 + local.set 3 + end + i32.const 0 + local.set 4 + block ;; label = @12 + local.get 3 + local.get 7 + i32.const 71 + i32.add + local.tee 8 + i32.add + local.tee 0 + i32.const 0 + local.get 3 + i32.sub + local.tee 6 + i32.and + local.tee 9 + local.get 7 + i32.gt_u + br_if 0 (;@12;) + i32.const 0 + i32.const 48 + i32.store offset=1692992 + br 11 (;@1;) + end + block ;; label = @12 + i32.const 0 + i32.load offset=1692936 + local.tee 4 + i32.eqz + br_if 0 (;@12;) + block ;; label = @13 + i32.const 0 + i32.load offset=1692928 + local.tee 3 + local.get 9 + i32.add + local.tee 11 + local.get 3 + i32.le_u + br_if 0 (;@13;) + local.get 11 + local.get 4 + i32.le_u + br_if 1 (;@12;) + end + i32.const 0 + local.set 4 + i32.const 0 + i32.const 48 + i32.store offset=1692992 + br 11 (;@1;) + end + i32.const 0 + i32.load8_u offset=1692940 + i32.const 4 + i32.and + br_if 5 (;@6;) + block ;; label = @12 + block ;; label = @13 + block ;; label = @14 + local.get 2 + i32.eqz + br_if 0 (;@14;) + i32.const 1692944 + local.set 4 + loop ;; label = @15 + block ;; label = @16 + local.get 4 + i32.load + local.tee 3 + local.get 2 + i32.gt_u + br_if 0 (;@16;) + local.get 3 + local.get 4 + i32.load offset=4 + i32.add + local.get 2 + i32.gt_u + br_if 3 (;@13;) + end + local.get 4 + i32.load offset=8 + local.tee 4 + br_if 0 (;@15;) + end + end + i32.const 0 + call $sbrk + local.tee 0 + i32.const -1 + i32.eq + br_if 6 (;@7;) + local.get 9 + local.set 6 + block ;; label = @14 + i32.const 0 + i32.load offset=1692972 + local.tee 4 + i32.const -1 + i32.add + local.tee 3 + local.get 0 + i32.and + i32.eqz + br_if 0 (;@14;) + local.get 9 + local.get 0 + i32.sub + local.get 3 + local.get 0 + i32.add + i32.const 0 + local.get 4 + i32.sub + i32.and + i32.add + local.set 6 + end + local.get 6 + local.get 7 + i32.le_u + br_if 6 (;@7;) + local.get 6 + i32.const 2147483646 + i32.gt_u + br_if 6 (;@7;) + block ;; label = @14 + i32.const 0 + i32.load offset=1692936 + local.tee 4 + i32.eqz + br_if 0 (;@14;) + i32.const 0 + i32.load offset=1692928 + local.tee 3 + local.get 6 + i32.add + local.tee 5 + local.get 3 + i32.le_u + br_if 7 (;@7;) + local.get 5 + local.get 4 + i32.gt_u + br_if 7 (;@7;) + end + local.get 6 + call $sbrk + local.tee 4 + local.get 0 + i32.ne + br_if 1 (;@12;) + br 8 (;@5;) + end + local.get 0 + local.get 5 + i32.sub + local.get 6 + i32.and + local.tee 6 + i32.const 2147483646 + i32.gt_u + br_if 5 (;@7;) + local.get 6 + call $sbrk + local.tee 0 + local.get 4 + i32.load + local.get 4 + i32.load offset=4 + i32.add + i32.eq + br_if 4 (;@8;) + local.get 0 + local.set 4 + end + block ;; label = @12 + local.get 6 + local.get 7 + i32.const 72 + i32.add + i32.ge_u + br_if 0 (;@12;) + local.get 4 + i32.const -1 + i32.eq + br_if 0 (;@12;) + block ;; label = @13 + local.get 8 + local.get 6 + i32.sub + i32.const 0 + i32.load offset=1692976 + local.tee 3 + i32.add + i32.const 0 + local.get 3 + i32.sub + i32.and + local.tee 3 + i32.const 2147483646 + i32.le_u + br_if 0 (;@13;) + local.get 4 + local.set 0 + br 8 (;@5;) + end + block ;; label = @13 + local.get 3 + call $sbrk + i32.const -1 + i32.eq + br_if 0 (;@13;) + local.get 3 + local.get 6 + i32.add + local.set 6 + local.get 4 + local.set 0 + br 8 (;@5;) + end + i32.const 0 + local.get 6 + i32.sub + call $sbrk + drop + br 5 (;@7;) + end + local.get 4 + local.set 0 + local.get 4 + i32.const -1 + i32.ne + br_if 6 (;@5;) + br 4 (;@7;) + end + unreachable + unreachable + end + i32.const 0 + local.set 9 + br 7 (;@2;) + end + i32.const 0 + local.set 0 + br 5 (;@3;) + end + local.get 0 + i32.const -1 + i32.ne + br_if 2 (;@5;) + end + i32.const 0 + i32.const 0 + i32.load offset=1692940 + i32.const 4 + i32.or + i32.store offset=1692940 + end + local.get 9 + i32.const 2147483646 + i32.gt_u + br_if 1 (;@4;) + local.get 9 + call $sbrk + local.set 0 + i32.const 0 + call $sbrk + local.set 4 + local.get 0 + i32.const -1 + i32.eq + br_if 1 (;@4;) + local.get 4 + i32.const -1 + i32.eq + br_if 1 (;@4;) + local.get 0 + local.get 4 + i32.ge_u + br_if 1 (;@4;) + local.get 4 + local.get 0 + i32.sub + local.tee 6 + local.get 7 + i32.const 56 + i32.add + i32.le_u + br_if 1 (;@4;) + end + i32.const 0 + i32.const 0 + i32.load offset=1692928 + local.get 6 + i32.add + local.tee 4 + i32.store offset=1692928 + block ;; label = @5 + local.get 4 + i32.const 0 + i32.load offset=1692932 + i32.le_u + br_if 0 (;@5;) + i32.const 0 + local.get 4 + i32.store offset=1692932 + end + block ;; label = @5 + block ;; label = @6 + block ;; label = @7 + block ;; label = @8 + i32.const 0 + i32.load offset=1692520 + local.tee 3 + i32.eqz + br_if 0 (;@8;) + i32.const 1692944 + local.set 4 + loop ;; label = @9 + local.get 0 + local.get 4 + i32.load + local.tee 5 + local.get 4 + i32.load offset=4 + local.tee 9 + i32.add + i32.eq + br_if 2 (;@7;) + local.get 4 + i32.load offset=8 + local.tee 4 + br_if 0 (;@9;) + br 3 (;@6;) + end + end + block ;; label = @8 + block ;; label = @9 + i32.const 0 + i32.load offset=1692512 + local.tee 4 + i32.eqz + br_if 0 (;@9;) + local.get 0 + local.get 4 + i32.ge_u + br_if 1 (;@8;) + end + i32.const 0 + local.get 0 + i32.store offset=1692512 + end + i32.const 0 + local.set 4 + i32.const 0 + local.get 6 + i32.store offset=1692948 + i32.const 0 + local.get 0 + i32.store offset=1692944 + i32.const 0 + i32.const -1 + i32.store offset=1692528 + i32.const 0 + i32.const 0 + i32.load offset=1692968 + i32.store offset=1692532 + i32.const 0 + i32.const 0 + i32.store offset=1692956 + loop ;; label = @8 + local.get 4 + i32.const 1692556 + i32.add + local.get 4 + i32.const 1692544 + i32.add + local.tee 3 + i32.store + local.get 3 + local.get 4 + i32.const 1692536 + i32.add + local.tee 5 + i32.store + local.get 4 + i32.const 1692548 + i32.add + local.get 5 + i32.store + local.get 4 + i32.const 1692564 + i32.add + local.get 4 + i32.const 1692552 + i32.add + local.tee 5 + i32.store + local.get 5 + local.get 3 + i32.store + local.get 4 + i32.const 1692572 + i32.add + local.get 4 + i32.const 1692560 + i32.add + local.tee 3 + i32.store + local.get 3 + local.get 5 + i32.store + local.get 4 + i32.const 1692568 + i32.add + local.get 3 + i32.store + local.get 4 + i32.const 32 + i32.add + local.tee 4 + i32.const 256 + i32.ne + br_if 0 (;@8;) + end + local.get 0 + i32.const -8 + local.get 0 + i32.sub + i32.const 15 + i32.and + local.tee 4 + i32.add + local.tee 3 + local.get 6 + i32.const -56 + i32.add + local.tee 5 + local.get 4 + i32.sub + local.tee 4 + i32.const 1 + i32.or + i32.store offset=4 + i32.const 0 + i32.const 0 + i32.load offset=1692984 + i32.store offset=1692524 + i32.const 0 + local.get 4 + i32.store offset=1692508 + i32.const 0 + local.get 3 + i32.store offset=1692520 + local.get 0 + local.get 5 + i32.add + i32.const 56 + i32.store offset=4 + br 2 (;@5;) + end + local.get 3 + local.get 0 + i32.ge_u + br_if 0 (;@6;) + local.get 3 + local.get 5 + i32.lt_u + br_if 0 (;@6;) + local.get 4 + i32.load offset=12 + i32.const 8 + i32.and + br_if 0 (;@6;) + local.get 3 + i32.const -8 + local.get 3 + i32.sub + i32.const 15 + i32.and + local.tee 5 + i32.add + local.tee 0 + i32.const 0 + i32.load offset=1692508 + local.get 6 + i32.add + local.tee 2 + local.get 5 + i32.sub + local.tee 5 + i32.const 1 + i32.or + i32.store offset=4 + local.get 4 + local.get 9 + local.get 6 + i32.add + i32.store offset=4 + i32.const 0 + i32.const 0 + i32.load offset=1692984 + i32.store offset=1692524 + i32.const 0 + local.get 5 + i32.store offset=1692508 + i32.const 0 + local.get 0 + i32.store offset=1692520 + local.get 3 + local.get 2 + i32.add + i32.const 56 + i32.store offset=4 + br 1 (;@5;) + end + block ;; label = @6 + local.get 0 + i32.const 0 + i32.load offset=1692512 + i32.ge_u + br_if 0 (;@6;) + i32.const 0 + local.get 0 + i32.store offset=1692512 + end + local.get 0 + local.get 6 + i32.add + local.set 5 + i32.const 1692944 + local.set 4 + block ;; label = @6 + block ;; label = @7 + block ;; label = @8 + block ;; label = @9 + loop ;; label = @10 + local.get 4 + i32.load + local.get 5 + i32.eq + br_if 1 (;@9;) + local.get 4 + i32.load offset=8 + local.tee 4 + br_if 0 (;@10;) + br 2 (;@8;) + end + end + local.get 4 + i32.load8_u offset=12 + i32.const 8 + i32.and + i32.eqz + br_if 1 (;@7;) + end + i32.const 1692944 + local.set 4 + block ;; label = @8 + loop ;; label = @9 + block ;; label = @10 + local.get 4 + i32.load + local.tee 5 + local.get 3 + i32.gt_u + br_if 0 (;@10;) + local.get 5 + local.get 4 + i32.load offset=4 + i32.add + local.tee 5 + local.get 3 + i32.gt_u + br_if 2 (;@8;) + end + local.get 4 + i32.load offset=8 + local.set 4 + br 0 (;@9;) + end + end + local.get 0 + i32.const -8 + local.get 0 + i32.sub + i32.const 15 + i32.and + local.tee 4 + i32.add + local.tee 2 + local.get 6 + i32.const -56 + i32.add + local.tee 9 + local.get 4 + i32.sub + local.tee 4 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 9 + i32.add + i32.const 56 + i32.store offset=4 + local.get 3 + local.get 5 + i32.const 55 + local.get 5 + i32.sub + i32.const 15 + i32.and + i32.add + i32.const -63 + i32.add + local.tee 9 + local.get 9 + local.get 3 + i32.const 16 + i32.add + i32.lt_u + select + local.tee 9 + i32.const 35 + i32.store offset=4 + i32.const 0 + i32.const 0 + i32.load offset=1692984 + i32.store offset=1692524 + i32.const 0 + local.get 4 + i32.store offset=1692508 + i32.const 0 + local.get 2 + i32.store offset=1692520 + local.get 9 + i32.const 16 + i32.add + i32.const 0 + i64.load offset=1692952 align=4 + i64.store align=4 + local.get 9 + i32.const 0 + i64.load offset=1692944 align=4 + i64.store offset=8 align=4 + i32.const 0 + local.get 9 + i32.const 8 + i32.add + i32.store offset=1692952 + i32.const 0 + local.get 6 + i32.store offset=1692948 + i32.const 0 + local.get 0 + i32.store offset=1692944 + i32.const 0 + i32.const 0 + i32.store offset=1692956 + local.get 9 + i32.const 36 + i32.add + local.set 4 + loop ;; label = @8 + local.get 4 + i32.const 7 + i32.store + local.get 4 + i32.const 4 + i32.add + local.tee 4 + local.get 5 + i32.lt_u + br_if 0 (;@8;) + end + local.get 9 + local.get 3 + i32.eq + br_if 2 (;@5;) + local.get 9 + local.get 9 + i32.load offset=4 + i32.const -2 + i32.and + i32.store offset=4 + local.get 9 + local.get 9 + local.get 3 + i32.sub + local.tee 0 + i32.store + local.get 3 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + block ;; label = @8 + local.get 0 + i32.const 255 + i32.gt_u + br_if 0 (;@8;) + local.get 0 + i32.const -8 + i32.and + i32.const 1692536 + i32.add + local.set 4 + block ;; label = @9 + block ;; label = @10 + i32.const 0 + i32.load offset=1692496 + local.tee 5 + i32.const 1 + local.get 0 + i32.const 3 + i32.shr_u + i32.shl + local.tee 0 + i32.and + br_if 0 (;@10;) + i32.const 0 + local.get 5 + local.get 0 + i32.or + i32.store offset=1692496 + local.get 4 + local.set 5 + br 1 (;@9;) + end + local.get 4 + i32.load offset=8 + local.set 5 + end + local.get 5 + local.get 3 + i32.store offset=12 + local.get 4 + local.get 3 + i32.store offset=8 + local.get 3 + local.get 4 + i32.store offset=12 + local.get 3 + local.get 5 + i32.store offset=8 + br 3 (;@5;) + end + i32.const 31 + local.set 4 + block ;; label = @8 + local.get 0 + i32.const 16777215 + i32.gt_u + br_if 0 (;@8;) + local.get 0 + i32.const 38 + local.get 0 + i32.const 8 + i32.shr_u + i32.clz + local.tee 4 + i32.sub + i32.shr_u + i32.const 1 + i32.and + local.get 4 + i32.const 1 + i32.shl + i32.sub + i32.const 62 + i32.add + local.set 4 + end + local.get 3 + local.get 4 + i32.store offset=28 + local.get 3 + i64.const 0 + i64.store offset=16 align=4 + local.get 4 + i32.const 2 + i32.shl + i32.const 1692800 + i32.add + local.set 5 + block ;; label = @8 + i32.const 0 + i32.load offset=1692500 + local.tee 9 + i32.const 1 + local.get 4 + i32.shl + local.tee 6 + i32.and + br_if 0 (;@8;) + local.get 5 + local.get 3 + i32.store + i32.const 0 + local.get 9 + local.get 6 + i32.or + i32.store offset=1692500 + local.get 3 + local.get 5 + i32.store offset=24 + local.get 3 + local.get 3 + i32.store offset=8 + local.get 3 + local.get 3 + i32.store offset=12 + br 3 (;@5;) + end + local.get 0 + i32.const 0 + i32.const 25 + local.get 4 + i32.const 1 + i32.shr_u + i32.sub + local.get 4 + i32.const 31 + i32.eq + select + i32.shl + local.set 4 + local.get 5 + i32.load + local.set 9 + loop ;; label = @8 + local.get 9 + local.tee 5 + i32.load offset=4 + i32.const -8 + i32.and + local.get 0 + i32.eq + br_if 2 (;@6;) + local.get 4 + i32.const 29 + i32.shr_u + local.set 9 + local.get 4 + i32.const 1 + i32.shl + local.set 4 + local.get 5 + local.get 9 + i32.const 4 + i32.and + i32.add + i32.const 16 + i32.add + local.tee 6 + i32.load + local.tee 9 + br_if 0 (;@8;) + end + local.get 6 + local.get 3 + i32.store + local.get 3 + local.get 5 + i32.store offset=24 + local.get 3 + local.get 3 + i32.store offset=12 + local.get 3 + local.get 3 + i32.store offset=8 + br 2 (;@5;) + end + local.get 4 + local.get 0 + i32.store + local.get 4 + local.get 4 + i32.load offset=4 + local.get 6 + i32.add + i32.store offset=4 + local.get 0 + local.get 5 + local.get 7 + call $prepend_alloc + local.set 4 + br 5 (;@1;) + end + local.get 5 + i32.load offset=8 + local.tee 4 + local.get 3 + i32.store offset=12 + local.get 5 + local.get 3 + i32.store offset=8 + local.get 3 + i32.const 0 + i32.store offset=24 + local.get 3 + local.get 5 + i32.store offset=12 + local.get 3 + local.get 4 + i32.store offset=8 + end + i32.const 0 + i32.load offset=1692508 + local.tee 4 + local.get 7 + i32.le_u + br_if 0 (;@4;) + i32.const 0 + i32.load offset=1692520 + local.tee 3 + local.get 7 + i32.add + local.tee 5 + local.get 4 + local.get 7 + i32.sub + local.tee 4 + i32.const 1 + i32.or + i32.store offset=4 + i32.const 0 + local.get 4 + i32.store offset=1692508 + i32.const 0 + local.get 5 + i32.store offset=1692520 + local.get 3 + local.get 7 + i32.const 3 + i32.or + i32.store offset=4 + local.get 3 + i32.const 8 + i32.add + local.set 4 + br 3 (;@1;) + end + i32.const 0 + local.set 4 + i32.const 0 + i32.const 48 + i32.store offset=1692992 + br 2 (;@1;) + end + block ;; label = @3 + local.get 2 + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + local.get 9 + local.get 9 + i32.load offset=28 + local.tee 5 + i32.const 2 + i32.shl + i32.const 1692800 + i32.add + local.tee 4 + i32.load + i32.ne + br_if 0 (;@5;) + local.get 4 + local.get 0 + i32.store + local.get 0 + br_if 1 (;@4;) + i32.const 0 + local.get 11 + i32.const -2 + local.get 5 + i32.rotl + i32.and + local.tee 11 + i32.store offset=1692500 + br 2 (;@3;) + end + local.get 2 + i32.const 16 + i32.const 20 + local.get 2 + i32.load offset=16 + local.get 9 + i32.eq + select + i32.add + local.get 0 + i32.store + local.get 0 + i32.eqz + br_if 1 (;@3;) + end + local.get 0 + local.get 2 + i32.store offset=24 + block ;; label = @4 + local.get 9 + i32.load offset=16 + local.tee 4 + i32.eqz + br_if 0 (;@4;) + local.get 0 + local.get 4 + i32.store offset=16 + local.get 4 + local.get 0 + i32.store offset=24 + end + local.get 9 + i32.const 20 + i32.add + i32.load + local.tee 4 + i32.eqz + br_if 0 (;@3;) + local.get 0 + i32.const 20 + i32.add + local.get 4 + i32.store + local.get 4 + local.get 0 + i32.store offset=24 + end + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.const 15 + i32.gt_u + br_if 0 (;@4;) + local.get 9 + local.get 3 + local.get 7 + i32.or + local.tee 4 + i32.const 3 + i32.or + i32.store offset=4 + local.get 9 + local.get 4 + i32.add + local.tee 4 + local.get 4 + i32.load offset=4 + i32.const 1 + i32.or + i32.store offset=4 + br 1 (;@3;) + end + local.get 9 + local.get 7 + i32.add + local.tee 0 + local.get 3 + i32.const 1 + i32.or + i32.store offset=4 + local.get 9 + local.get 7 + i32.const 3 + i32.or + i32.store offset=4 + local.get 0 + local.get 3 + i32.add + local.get 3 + i32.store + block ;; label = @4 + local.get 3 + i32.const 255 + i32.gt_u + br_if 0 (;@4;) + local.get 3 + i32.const -8 + i32.and + i32.const 1692536 + i32.add + local.set 4 + block ;; label = @5 + block ;; label = @6 + i32.const 0 + i32.load offset=1692496 + local.tee 5 + i32.const 1 + local.get 3 + i32.const 3 + i32.shr_u + i32.shl + local.tee 3 + i32.and + br_if 0 (;@6;) + i32.const 0 + local.get 5 + local.get 3 + i32.or + i32.store offset=1692496 + local.get 4 + local.set 3 + br 1 (;@5;) + end + local.get 4 + i32.load offset=8 + local.set 3 + end + local.get 3 + local.get 0 + i32.store offset=12 + local.get 4 + local.get 0 + i32.store offset=8 + local.get 0 + local.get 4 + i32.store offset=12 + local.get 0 + local.get 3 + i32.store offset=8 + br 1 (;@3;) + end + i32.const 31 + local.set 4 + block ;; label = @4 + local.get 3 + i32.const 16777215 + i32.gt_u + br_if 0 (;@4;) + local.get 3 + i32.const 38 + local.get 3 + i32.const 8 + i32.shr_u + i32.clz + local.tee 4 + i32.sub + i32.shr_u + i32.const 1 + i32.and + local.get 4 + i32.const 1 + i32.shl + i32.sub + i32.const 62 + i32.add + local.set 4 + end + local.get 0 + local.get 4 + i32.store offset=28 + local.get 0 + i64.const 0 + i64.store offset=16 align=4 + local.get 4 + i32.const 2 + i32.shl + i32.const 1692800 + i32.add + local.set 5 + block ;; label = @4 + local.get 11 + i32.const 1 + local.get 4 + i32.shl + local.tee 7 + i32.and + br_if 0 (;@4;) + local.get 5 + local.get 0 + i32.store + i32.const 0 + local.get 11 + local.get 7 + i32.or + i32.store offset=1692500 + local.get 0 + local.get 5 + i32.store offset=24 + local.get 0 + local.get 0 + i32.store offset=8 + local.get 0 + local.get 0 + i32.store offset=12 + br 1 (;@3;) + end + local.get 3 + i32.const 0 + i32.const 25 + local.get 4 + i32.const 1 + i32.shr_u + i32.sub + local.get 4 + i32.const 31 + i32.eq + select + i32.shl + local.set 4 + local.get 5 + i32.load + local.set 7 + block ;; label = @4 + loop ;; label = @5 + local.get 7 + local.tee 5 + i32.load offset=4 + i32.const -8 + i32.and + local.get 3 + i32.eq + br_if 1 (;@4;) + local.get 4 + i32.const 29 + i32.shr_u + local.set 7 + local.get 4 + i32.const 1 + i32.shl + local.set 4 + local.get 5 + local.get 7 + i32.const 4 + i32.and + i32.add + i32.const 16 + i32.add + local.tee 6 + i32.load + local.tee 7 + br_if 0 (;@5;) + end + local.get 6 + local.get 0 + i32.store + local.get 0 + local.get 5 + i32.store offset=24 + local.get 0 + local.get 0 + i32.store offset=12 + local.get 0 + local.get 0 + i32.store offset=8 + br 1 (;@3;) + end + local.get 5 + i32.load offset=8 + local.tee 4 + local.get 0 + i32.store offset=12 + local.get 5 + local.get 0 + i32.store offset=8 + local.get 0 + i32.const 0 + i32.store offset=24 + local.get 0 + local.get 5 + i32.store offset=12 + local.get 0 + local.get 4 + i32.store offset=8 + end + local.get 9 + i32.const 8 + i32.add + local.set 4 + br 1 (;@1;) + end + block ;; label = @2 + local.get 11 + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 0 + local.get 0 + i32.load offset=28 + local.tee 5 + i32.const 2 + i32.shl + i32.const 1692800 + i32.add + local.tee 4 + i32.load + i32.ne + br_if 0 (;@4;) + local.get 4 + local.get 9 + i32.store + local.get 9 + br_if 1 (;@3;) + i32.const 0 + local.get 10 + i32.const -2 + local.get 5 + i32.rotl + i32.and + i32.store offset=1692500 + br 2 (;@2;) + end + local.get 11 + i32.const 16 + i32.const 20 + local.get 11 + i32.load offset=16 + local.get 0 + i32.eq + select + i32.add + local.get 9 + i32.store + local.get 9 + i32.eqz + br_if 1 (;@2;) + end + local.get 9 + local.get 11 + i32.store offset=24 + block ;; label = @3 + local.get 0 + i32.load offset=16 + local.tee 4 + i32.eqz + br_if 0 (;@3;) + local.get 9 + local.get 4 + i32.store offset=16 + local.get 4 + local.get 9 + i32.store offset=24 + end + local.get 0 + i32.const 20 + i32.add + i32.load + local.tee 4 + i32.eqz + br_if 0 (;@2;) + local.get 9 + i32.const 20 + i32.add + local.get 4 + i32.store + local.get 4 + local.get 9 + i32.store offset=24 + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.const 15 + i32.gt_u + br_if 0 (;@3;) + local.get 0 + local.get 3 + local.get 7 + i32.or + local.tee 4 + i32.const 3 + i32.or + i32.store offset=4 + local.get 0 + local.get 4 + i32.add + local.tee 4 + local.get 4 + i32.load offset=4 + i32.const 1 + i32.or + i32.store offset=4 + br 1 (;@2;) + end + local.get 0 + local.get 7 + i32.add + local.tee 5 + local.get 3 + i32.const 1 + i32.or + i32.store offset=4 + local.get 0 + local.get 7 + i32.const 3 + i32.or + i32.store offset=4 + local.get 5 + local.get 3 + i32.add + local.get 3 + i32.store + block ;; label = @3 + local.get 8 + i32.eqz + br_if 0 (;@3;) + local.get 8 + i32.const -8 + i32.and + i32.const 1692536 + i32.add + local.set 7 + i32.const 0 + i32.load offset=1692516 + local.set 4 + block ;; label = @4 + block ;; label = @5 + i32.const 1 + local.get 8 + i32.const 3 + i32.shr_u + i32.shl + local.tee 9 + local.get 6 + i32.and + br_if 0 (;@5;) + i32.const 0 + local.get 9 + local.get 6 + i32.or + i32.store offset=1692496 + local.get 7 + local.set 9 + br 1 (;@4;) + end + local.get 7 + i32.load offset=8 + local.set 9 + end + local.get 9 + local.get 4 + i32.store offset=12 + local.get 7 + local.get 4 + i32.store offset=8 + local.get 4 + local.get 7 + i32.store offset=12 + local.get 4 + local.get 9 + i32.store offset=8 + end + i32.const 0 + local.get 5 + i32.store offset=1692516 + i32.const 0 + local.get 3 + i32.store offset=1692504 + end + local.get 0 + i32.const 8 + i32.add + local.set 4 + end + local.get 1 + i32.const 16 + i32.add + global.set $__stack_pointer + local.get 4) + (func $prepend_alloc (type 1) (param i32 i32 i32) (result i32) + (local i32 i32 i32 i32 i32 i32 i32) + local.get 0 + i32.const -8 + local.get 0 + i32.sub + i32.const 15 + i32.and + i32.add + local.tee 3 + local.get 2 + i32.const 3 + i32.or + i32.store offset=4 + local.get 1 + i32.const -8 + local.get 1 + i32.sub + i32.const 15 + i32.and + i32.add + local.tee 4 + local.get 3 + local.get 2 + i32.add + local.tee 5 + i32.sub + local.set 2 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.const 0 + i32.load offset=1692520 + i32.ne + br_if 0 (;@2;) + i32.const 0 + local.get 5 + i32.store offset=1692520 + i32.const 0 + i32.const 0 + i32.load offset=1692508 + local.get 2 + i32.add + local.tee 2 + i32.store offset=1692508 + local.get 5 + local.get 2 + i32.const 1 + i32.or + i32.store offset=4 + br 1 (;@1;) + end + block ;; label = @2 + local.get 4 + i32.const 0 + i32.load offset=1692516 + i32.ne + br_if 0 (;@2;) + i32.const 0 + local.get 5 + i32.store offset=1692516 + i32.const 0 + i32.const 0 + i32.load offset=1692504 + local.get 2 + i32.add + local.tee 2 + i32.store offset=1692504 + local.get 5 + local.get 2 + i32.const 1 + i32.or + i32.store offset=4 + local.get 5 + local.get 2 + i32.add + local.get 2 + i32.store + br 1 (;@1;) + end + block ;; label = @2 + local.get 4 + i32.load offset=4 + local.tee 0 + i32.const 3 + i32.and + i32.const 1 + i32.ne + br_if 0 (;@2;) + local.get 0 + i32.const -8 + i32.and + local.set 6 + block ;; label = @3 + block ;; label = @4 + local.get 0 + i32.const 255 + i32.gt_u + br_if 0 (;@4;) + local.get 4 + i32.load offset=8 + local.tee 1 + local.get 0 + i32.const 3 + i32.shr_u + local.tee 7 + i32.const 3 + i32.shl + i32.const 1692536 + i32.add + local.tee 8 + i32.eq + drop + block ;; label = @5 + local.get 4 + i32.load offset=12 + local.tee 0 + local.get 1 + i32.ne + br_if 0 (;@5;) + i32.const 0 + i32.const 0 + i32.load offset=1692496 + i32.const -2 + local.get 7 + i32.rotl + i32.and + i32.store offset=1692496 + br 2 (;@3;) + end + local.get 0 + local.get 8 + i32.eq + drop + local.get 0 + local.get 1 + i32.store offset=8 + local.get 1 + local.get 0 + i32.store offset=12 + br 1 (;@3;) + end + local.get 4 + i32.load offset=24 + local.set 9 + block ;; label = @4 + block ;; label = @5 + local.get 4 + i32.load offset=12 + local.tee 8 + local.get 4 + i32.eq + br_if 0 (;@5;) + local.get 4 + i32.load offset=8 + local.tee 0 + i32.const 0 + i32.load offset=1692512 + i32.lt_u + drop + local.get 8 + local.get 0 + i32.store offset=8 + local.get 0 + local.get 8 + i32.store offset=12 + br 1 (;@4;) + end + block ;; label = @5 + block ;; label = @6 + local.get 4 + i32.const 20 + i32.add + local.tee 1 + i32.load + local.tee 0 + br_if 0 (;@6;) + local.get 4 + i32.load offset=16 + local.tee 0 + i32.eqz + br_if 1 (;@5;) + local.get 4 + i32.const 16 + i32.add + local.set 1 + end + loop ;; label = @6 + local.get 1 + local.set 7 + local.get 0 + local.tee 8 + i32.const 20 + i32.add + local.tee 1 + i32.load + local.tee 0 + br_if 0 (;@6;) + local.get 8 + i32.const 16 + i32.add + local.set 1 + local.get 8 + i32.load offset=16 + local.tee 0 + br_if 0 (;@6;) + end + local.get 7 + i32.const 0 + i32.store + br 1 (;@4;) + end + i32.const 0 + local.set 8 + end + local.get 9 + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + local.get 4 + local.get 4 + i32.load offset=28 + local.tee 1 + i32.const 2 + i32.shl + i32.const 1692800 + i32.add + local.tee 0 + i32.load + i32.ne + br_if 0 (;@5;) + local.get 0 + local.get 8 + i32.store + local.get 8 + br_if 1 (;@4;) + i32.const 0 + i32.const 0 + i32.load offset=1692500 + i32.const -2 + local.get 1 + i32.rotl + i32.and + i32.store offset=1692500 + br 2 (;@3;) + end + local.get 9 + i32.const 16 + i32.const 20 + local.get 9 + i32.load offset=16 + local.get 4 + i32.eq + select + i32.add + local.get 8 + i32.store + local.get 8 + i32.eqz + br_if 1 (;@3;) + end + local.get 8 + local.get 9 + i32.store offset=24 + block ;; label = @4 + local.get 4 + i32.load offset=16 + local.tee 0 + i32.eqz + br_if 0 (;@4;) + local.get 8 + local.get 0 + i32.store offset=16 + local.get 0 + local.get 8 + i32.store offset=24 + end + local.get 4 + i32.const 20 + i32.add + i32.load + local.tee 0 + i32.eqz + br_if 0 (;@3;) + local.get 8 + i32.const 20 + i32.add + local.get 0 + i32.store + local.get 0 + local.get 8 + i32.store offset=24 + end + local.get 6 + local.get 2 + i32.add + local.set 2 + local.get 4 + local.get 6 + i32.add + local.tee 4 + i32.load offset=4 + local.set 0 + end + local.get 4 + local.get 0 + i32.const -2 + i32.and + i32.store offset=4 + local.get 5 + local.get 2 + i32.add + local.get 2 + i32.store + local.get 5 + local.get 2 + i32.const 1 + i32.or + i32.store offset=4 + block ;; label = @2 + local.get 2 + i32.const 255 + i32.gt_u + br_if 0 (;@2;) + local.get 2 + i32.const -8 + i32.and + i32.const 1692536 + i32.add + local.set 0 + block ;; label = @3 + block ;; label = @4 + i32.const 0 + i32.load offset=1692496 + local.tee 1 + i32.const 1 + local.get 2 + i32.const 3 + i32.shr_u + i32.shl + local.tee 2 + i32.and + br_if 0 (;@4;) + i32.const 0 + local.get 1 + local.get 2 + i32.or + i32.store offset=1692496 + local.get 0 + local.set 2 + br 1 (;@3;) + end + local.get 0 + i32.load offset=8 + local.set 2 + end + local.get 2 + local.get 5 + i32.store offset=12 + local.get 0 + local.get 5 + i32.store offset=8 + local.get 5 + local.get 0 + i32.store offset=12 + local.get 5 + local.get 2 + i32.store offset=8 + br 1 (;@1;) + end + i32.const 31 + local.set 0 + block ;; label = @2 + local.get 2 + i32.const 16777215 + i32.gt_u + br_if 0 (;@2;) + local.get 2 + i32.const 38 + local.get 2 + i32.const 8 + i32.shr_u + i32.clz + local.tee 0 + i32.sub + i32.shr_u + i32.const 1 + i32.and + local.get 0 + i32.const 1 + i32.shl + i32.sub + i32.const 62 + i32.add + local.set 0 + end + local.get 5 + local.get 0 + i32.store offset=28 + local.get 5 + i64.const 0 + i64.store offset=16 align=4 + local.get 0 + i32.const 2 + i32.shl + i32.const 1692800 + i32.add + local.set 1 + block ;; label = @2 + i32.const 0 + i32.load offset=1692500 + local.tee 8 + i32.const 1 + local.get 0 + i32.shl + local.tee 4 + i32.and + br_if 0 (;@2;) + local.get 1 + local.get 5 + i32.store + i32.const 0 + local.get 8 + local.get 4 + i32.or + i32.store offset=1692500 + local.get 5 + local.get 1 + i32.store offset=24 + local.get 5 + local.get 5 + i32.store offset=8 + local.get 5 + local.get 5 + i32.store offset=12 + br 1 (;@1;) + end + local.get 2 + i32.const 0 + i32.const 25 + local.get 0 + i32.const 1 + i32.shr_u + i32.sub + local.get 0 + i32.const 31 + i32.eq + select + i32.shl + local.set 0 + local.get 1 + i32.load + local.set 8 + block ;; label = @2 + loop ;; label = @3 + local.get 8 + local.tee 1 + i32.load offset=4 + i32.const -8 + i32.and + local.get 2 + i32.eq + br_if 1 (;@2;) + local.get 0 + i32.const 29 + i32.shr_u + local.set 8 + local.get 0 + i32.const 1 + i32.shl + local.set 0 + local.get 1 + local.get 8 + i32.const 4 + i32.and + i32.add + i32.const 16 + i32.add + local.tee 4 + i32.load + local.tee 8 + br_if 0 (;@3;) + end + local.get 4 + local.get 5 + i32.store + local.get 5 + local.get 1 + i32.store offset=24 + local.get 5 + local.get 5 + i32.store offset=12 + local.get 5 + local.get 5 + i32.store offset=8 + br 1 (;@1;) + end + local.get 1 + i32.load offset=8 + local.tee 2 + local.get 5 + i32.store offset=12 + local.get 1 + local.get 5 + i32.store offset=8 + local.get 5 + i32.const 0 + i32.store offset=24 + local.get 5 + local.get 1 + i32.store offset=12 + local.get 5 + local.get 2 + i32.store offset=8 + end + local.get 3 + i32.const 8 + i32.add) + (func $free (type 8) (param i32) + local.get 0 + call $dlfree) + (func $dlfree (type 8) (param i32) + (local i32 i32 i32 i32 i32 i32 i32) + block ;; label = @1 + local.get 0 + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.const -8 + i32.add + local.tee 1 + local.get 0 + i32.const -4 + i32.add + i32.load + local.tee 2 + i32.const -8 + i32.and + local.tee 0 + i32.add + local.set 3 + block ;; label = @2 + local.get 2 + i32.const 1 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 2 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 1 + local.get 1 + i32.load + local.tee 2 + i32.sub + local.tee 1 + i32.const 0 + i32.load offset=1692512 + local.tee 4 + i32.lt_u + br_if 1 (;@1;) + local.get 2 + local.get 0 + i32.add + local.set 0 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 1 + i32.const 0 + i32.load offset=1692516 + i32.eq + br_if 0 (;@5;) + block ;; label = @6 + local.get 2 + i32.const 255 + i32.gt_u + br_if 0 (;@6;) + local.get 1 + i32.load offset=8 + local.tee 4 + local.get 2 + i32.const 3 + i32.shr_u + local.tee 5 + i32.const 3 + i32.shl + i32.const 1692536 + i32.add + local.tee 6 + i32.eq + drop + block ;; label = @7 + local.get 1 + i32.load offset=12 + local.tee 2 + local.get 4 + i32.ne + br_if 0 (;@7;) + i32.const 0 + i32.const 0 + i32.load offset=1692496 + i32.const -2 + local.get 5 + i32.rotl + i32.and + i32.store offset=1692496 + br 5 (;@2;) + end + local.get 2 + local.get 6 + i32.eq + drop + local.get 2 + local.get 4 + i32.store offset=8 + local.get 4 + local.get 2 + i32.store offset=12 + br 4 (;@2;) + end + local.get 1 + i32.load offset=24 + local.set 7 + block ;; label = @6 + local.get 1 + i32.load offset=12 + local.tee 6 + local.get 1 + i32.eq + br_if 0 (;@6;) + local.get 1 + i32.load offset=8 + local.tee 2 + local.get 4 + i32.lt_u + drop + local.get 6 + local.get 2 + i32.store offset=8 + local.get 2 + local.get 6 + i32.store offset=12 + br 3 (;@3;) + end + block ;; label = @6 + local.get 1 + i32.const 20 + i32.add + local.tee 4 + i32.load + local.tee 2 + br_if 0 (;@6;) + local.get 1 + i32.load offset=16 + local.tee 2 + i32.eqz + br_if 2 (;@4;) + local.get 1 + i32.const 16 + i32.add + local.set 4 + end + loop ;; label = @6 + local.get 4 + local.set 5 + local.get 2 + local.tee 6 + i32.const 20 + i32.add + local.tee 4 + i32.load + local.tee 2 + br_if 0 (;@6;) + local.get 6 + i32.const 16 + i32.add + local.set 4 + local.get 6 + i32.load offset=16 + local.tee 2 + br_if 0 (;@6;) + end + local.get 5 + i32.const 0 + i32.store + br 2 (;@3;) + end + local.get 3 + i32.load offset=4 + local.tee 2 + i32.const 3 + i32.and + i32.const 3 + i32.ne + br_if 2 (;@2;) + local.get 3 + local.get 2 + i32.const -2 + i32.and + i32.store offset=4 + i32.const 0 + local.get 0 + i32.store offset=1692504 + local.get 3 + local.get 0 + i32.store + local.get 1 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + return + end + i32.const 0 + local.set 6 + end + local.get 7 + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 1 + local.get 1 + i32.load offset=28 + local.tee 4 + i32.const 2 + i32.shl + i32.const 1692800 + i32.add + local.tee 2 + i32.load + i32.ne + br_if 0 (;@4;) + local.get 2 + local.get 6 + i32.store + local.get 6 + br_if 1 (;@3;) + i32.const 0 + i32.const 0 + i32.load offset=1692500 + i32.const -2 + local.get 4 + i32.rotl + i32.and + i32.store offset=1692500 + br 2 (;@2;) + end + local.get 7 + i32.const 16 + i32.const 20 + local.get 7 + i32.load offset=16 + local.get 1 + i32.eq + select + i32.add + local.get 6 + i32.store + local.get 6 + i32.eqz + br_if 1 (;@2;) + end + local.get 6 + local.get 7 + i32.store offset=24 + block ;; label = @3 + local.get 1 + i32.load offset=16 + local.tee 2 + i32.eqz + br_if 0 (;@3;) + local.get 6 + local.get 2 + i32.store offset=16 + local.get 2 + local.get 6 + i32.store offset=24 + end + local.get 1 + i32.const 20 + i32.add + i32.load + local.tee 2 + i32.eqz + br_if 0 (;@2;) + local.get 6 + i32.const 20 + i32.add + local.get 2 + i32.store + local.get 2 + local.get 6 + i32.store offset=24 + end + local.get 1 + local.get 3 + i32.ge_u + br_if 0 (;@1;) + local.get 3 + i32.load offset=4 + local.tee 2 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + local.get 2 + i32.const 2 + i32.and + br_if 0 (;@6;) + block ;; label = @7 + local.get 3 + i32.const 0 + i32.load offset=1692520 + i32.ne + br_if 0 (;@7;) + i32.const 0 + local.get 1 + i32.store offset=1692520 + i32.const 0 + i32.const 0 + i32.load offset=1692508 + local.get 0 + i32.add + local.tee 0 + i32.store offset=1692508 + local.get 1 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 1 + i32.const 0 + i32.load offset=1692516 + i32.ne + br_if 6 (;@1;) + i32.const 0 + i32.const 0 + i32.store offset=1692504 + i32.const 0 + i32.const 0 + i32.store offset=1692516 + return + end + block ;; label = @7 + local.get 3 + i32.const 0 + i32.load offset=1692516 + i32.ne + br_if 0 (;@7;) + i32.const 0 + local.get 1 + i32.store offset=1692516 + i32.const 0 + i32.const 0 + i32.load offset=1692504 + local.get 0 + i32.add + local.tee 0 + i32.store offset=1692504 + local.get 1 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 1 + local.get 0 + i32.add + local.get 0 + i32.store + return + end + local.get 2 + i32.const -8 + i32.and + local.get 0 + i32.add + local.set 0 + block ;; label = @7 + local.get 2 + i32.const 255 + i32.gt_u + br_if 0 (;@7;) + local.get 3 + i32.load offset=8 + local.tee 4 + local.get 2 + i32.const 3 + i32.shr_u + local.tee 5 + i32.const 3 + i32.shl + i32.const 1692536 + i32.add + local.tee 6 + i32.eq + drop + block ;; label = @8 + local.get 3 + i32.load offset=12 + local.tee 2 + local.get 4 + i32.ne + br_if 0 (;@8;) + i32.const 0 + i32.const 0 + i32.load offset=1692496 + i32.const -2 + local.get 5 + i32.rotl + i32.and + i32.store offset=1692496 + br 5 (;@3;) + end + local.get 2 + local.get 6 + i32.eq + drop + local.get 2 + local.get 4 + i32.store offset=8 + local.get 4 + local.get 2 + i32.store offset=12 + br 4 (;@3;) + end + local.get 3 + i32.load offset=24 + local.set 7 + block ;; label = @7 + local.get 3 + i32.load offset=12 + local.tee 6 + local.get 3 + i32.eq + br_if 0 (;@7;) + local.get 3 + i32.load offset=8 + local.tee 2 + i32.const 0 + i32.load offset=1692512 + i32.lt_u + drop + local.get 6 + local.get 2 + i32.store offset=8 + local.get 2 + local.get 6 + i32.store offset=12 + br 3 (;@4;) + end + block ;; label = @7 + local.get 3 + i32.const 20 + i32.add + local.tee 4 + i32.load + local.tee 2 + br_if 0 (;@7;) + local.get 3 + i32.load offset=16 + local.tee 2 + i32.eqz + br_if 2 (;@5;) + local.get 3 + i32.const 16 + i32.add + local.set 4 + end + loop ;; label = @7 + local.get 4 + local.set 5 + local.get 2 + local.tee 6 + i32.const 20 + i32.add + local.tee 4 + i32.load + local.tee 2 + br_if 0 (;@7;) + local.get 6 + i32.const 16 + i32.add + local.set 4 + local.get 6 + i32.load offset=16 + local.tee 2 + br_if 0 (;@7;) + end + local.get 5 + i32.const 0 + i32.store + br 2 (;@4;) + end + local.get 3 + local.get 2 + i32.const -2 + i32.and + i32.store offset=4 + local.get 1 + local.get 0 + i32.add + local.get 0 + i32.store + local.get 1 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + br 3 (;@2;) + end + i32.const 0 + local.set 6 + end + local.get 7 + i32.eqz + br_if 0 (;@3;) + block ;; label = @4 + block ;; label = @5 + local.get 3 + local.get 3 + i32.load offset=28 + local.tee 4 + i32.const 2 + i32.shl + i32.const 1692800 + i32.add + local.tee 2 + i32.load + i32.ne + br_if 0 (;@5;) + local.get 2 + local.get 6 + i32.store + local.get 6 + br_if 1 (;@4;) + i32.const 0 + i32.const 0 + i32.load offset=1692500 + i32.const -2 + local.get 4 + i32.rotl + i32.and + i32.store offset=1692500 + br 2 (;@3;) + end + local.get 7 + i32.const 16 + i32.const 20 + local.get 7 + i32.load offset=16 + local.get 3 + i32.eq + select + i32.add + local.get 6 + i32.store + local.get 6 + i32.eqz + br_if 1 (;@3;) + end + local.get 6 + local.get 7 + i32.store offset=24 + block ;; label = @4 + local.get 3 + i32.load offset=16 + local.tee 2 + i32.eqz + br_if 0 (;@4;) + local.get 6 + local.get 2 + i32.store offset=16 + local.get 2 + local.get 6 + i32.store offset=24 + end + local.get 3 + i32.const 20 + i32.add + i32.load + local.tee 2 + i32.eqz + br_if 0 (;@3;) + local.get 6 + i32.const 20 + i32.add + local.get 2 + i32.store + local.get 2 + local.get 6 + i32.store offset=24 + end + local.get 1 + local.get 0 + i32.add + local.get 0 + i32.store + local.get 1 + local.get 0 + i32.const 1 + i32.or + i32.store offset=4 + local.get 1 + i32.const 0 + i32.load offset=1692516 + i32.ne + br_if 0 (;@2;) + i32.const 0 + local.get 0 + i32.store offset=1692504 + return + end + block ;; label = @2 + local.get 0 + i32.const 255 + i32.gt_u + br_if 0 (;@2;) + local.get 0 + i32.const -8 + i32.and + i32.const 1692536 + i32.add + local.set 2 + block ;; label = @3 + block ;; label = @4 + i32.const 0 + i32.load offset=1692496 + local.tee 4 + i32.const 1 + local.get 0 + i32.const 3 + i32.shr_u + i32.shl + local.tee 0 + i32.and + br_if 0 (;@4;) + i32.const 0 + local.get 4 + local.get 0 + i32.or + i32.store offset=1692496 + local.get 2 + local.set 0 + br 1 (;@3;) + end + local.get 2 + i32.load offset=8 + local.set 0 + end + local.get 0 + local.get 1 + i32.store offset=12 + local.get 2 + local.get 1 + i32.store offset=8 + local.get 1 + local.get 2 + i32.store offset=12 + local.get 1 + local.get 0 + i32.store offset=8 + return + end + i32.const 31 + local.set 2 + block ;; label = @2 + local.get 0 + i32.const 16777215 + i32.gt_u + br_if 0 (;@2;) + local.get 0 + i32.const 38 + local.get 0 + i32.const 8 + i32.shr_u + i32.clz + local.tee 2 + i32.sub + i32.shr_u + i32.const 1 + i32.and + local.get 2 + i32.const 1 + i32.shl + i32.sub + i32.const 62 + i32.add + local.set 2 + end + local.get 1 + local.get 2 + i32.store offset=28 + local.get 1 + i64.const 0 + i64.store offset=16 align=4 + local.get 2 + i32.const 2 + i32.shl + i32.const 1692800 + i32.add + local.set 4 + block ;; label = @2 + block ;; label = @3 + i32.const 0 + i32.load offset=1692500 + local.tee 6 + i32.const 1 + local.get 2 + i32.shl + local.tee 3 + i32.and + br_if 0 (;@3;) + local.get 4 + local.get 1 + i32.store + i32.const 0 + local.get 6 + local.get 3 + i32.or + i32.store offset=1692500 + local.get 1 + local.get 4 + i32.store offset=24 + local.get 1 + local.get 1 + i32.store offset=8 + local.get 1 + local.get 1 + i32.store offset=12 + br 1 (;@2;) + end + local.get 0 + i32.const 0 + i32.const 25 + local.get 2 + i32.const 1 + i32.shr_u + i32.sub + local.get 2 + i32.const 31 + i32.eq + select + i32.shl + local.set 2 + local.get 4 + i32.load + local.set 6 + block ;; label = @3 + loop ;; label = @4 + local.get 6 + local.tee 4 + i32.load offset=4 + i32.const -8 + i32.and + local.get 0 + i32.eq + br_if 1 (;@3;) + local.get 2 + i32.const 29 + i32.shr_u + local.set 6 + local.get 2 + i32.const 1 + i32.shl + local.set 2 + local.get 4 + local.get 6 + i32.const 4 + i32.and + i32.add + i32.const 16 + i32.add + local.tee 3 + i32.load + local.tee 6 + br_if 0 (;@4;) + end + local.get 3 + local.get 1 + i32.store + local.get 1 + local.get 4 + i32.store offset=24 + local.get 1 + local.get 1 + i32.store offset=12 + local.get 1 + local.get 1 + i32.store offset=8 + br 1 (;@2;) + end + local.get 4 + i32.load offset=8 + local.tee 0 + local.get 1 + i32.store offset=12 + local.get 4 + local.get 1 + i32.store offset=8 + local.get 1 + i32.const 0 + i32.store offset=24 + local.get 1 + local.get 4 + i32.store offset=12 + local.get 1 + local.get 0 + i32.store offset=8 + end + i32.const 0 + i32.const 0 + i32.load offset=1692528 + i32.const -1 + i32.add + local.tee 1 + i32.const -1 + local.get 1 + select + i32.store offset=1692528 + end) + (func $calloc (type 4) (param i32 i32) (result i32) + (local i32 i64) + block ;; label = @1 + block ;; label = @2 + local.get 0 + br_if 0 (;@2;) + i32.const 0 + local.set 2 + br 1 (;@1;) + end + local.get 0 + i64.extend_i32_u + local.get 1 + i64.extend_i32_u + i64.mul + local.tee 3 + i32.wrap_i64 + local.set 2 + local.get 1 + local.get 0 + i32.or + i32.const 65536 + i32.lt_u + br_if 0 (;@1;) + i32.const -1 + local.get 2 + local.get 3 + i64.const 32 + i64.shr_u + i32.wrap_i64 + i32.const 0 + i32.ne + select + local.set 2 + end + block ;; label = @1 + local.get 2 + call $dlmalloc + local.tee 0 + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.const -4 + i32.add + i32.load8_u + i32.const 3 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.const 0 + local.get 2 + call $memset + drop + end + local.get 0) + (func $_Exit (type 8) (param i32) + local.get 0 + call $__wasi_proc_exit + unreachable) + (func $__main_void (type 11) (result i32) + (local i32 i32 i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 0 + global.set $__stack_pointer + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 0 + i32.const 8 + i32.add + local.get 0 + i32.const 12 + i32.add + call $__wasi_args_sizes_get + br_if 0 (;@5;) + local.get 0 + i32.load offset=8 + i32.const 1 + i32.add + local.tee 1 + i32.eqz + br_if 1 (;@4;) + local.get 0 + i32.load offset=12 + call $malloc + local.tee 2 + i32.eqz + br_if 2 (;@3;) + local.get 1 + i32.const 4 + call $calloc + local.tee 1 + i32.eqz + br_if 3 (;@2;) + local.get 1 + local.get 2 + call $__wasi_args_get + br_if 4 (;@1;) + local.get 0 + i32.load offset=8 + local.get 1 + call $main + local.set 1 + local.get 0 + i32.const 16 + i32.add + global.set $__stack_pointer + local.get 1 + return + end + i32.const 71 + call $_Exit + unreachable + end + i32.const 70 + call $_Exit + unreachable + end + i32.const 70 + call $_Exit + unreachable + end + local.get 2 + call $free + i32.const 70 + call $_Exit + unreachable + end + local.get 2 + call $free + local.get 1 + call $free + i32.const 71 + call $_Exit + unreachable) + (func $__wasi_args_get (type 4) (param i32 i32) (result i32) + local.get 0 + local.get 1 + call $__imported_wasi_snapshot_preview1_args_get + i32.const 65535 + i32.and) + (func $__wasi_args_sizes_get (type 4) (param i32 i32) (result i32) + local.get 0 + local.get 1 + call $__imported_wasi_snapshot_preview1_args_sizes_get + i32.const 65535 + i32.and) + (func $__wasi_fd_close (type 0) (param i32) (result i32) + local.get 0 + call $__imported_wasi_snapshot_preview1_fd_close + i32.const 65535 + i32.and) + (func $__wasi_fd_fdstat_get (type 4) (param i32 i32) (result i32) + local.get 0 + local.get 1 + call $__imported_wasi_snapshot_preview1_fd_fdstat_get + i32.const 65535 + i32.and) + (func $__wasi_fd_fdstat_set_flags (type 4) (param i32 i32) (result i32) + local.get 0 + local.get 1 + call $__imported_wasi_snapshot_preview1_fd_fdstat_set_flags + i32.const 65535 + i32.and) + (func $__wasi_fd_prestat_get (type 4) (param i32 i32) (result i32) + local.get 0 + local.get 1 + call $__imported_wasi_snapshot_preview1_fd_prestat_get + i32.const 65535 + i32.and) + (func $__wasi_fd_prestat_dir_name (type 1) (param i32 i32 i32) (result i32) + local.get 0 + local.get 1 + local.get 2 + call $__imported_wasi_snapshot_preview1_fd_prestat_dir_name + i32.const 65535 + i32.and) + (func $__wasi_fd_read (type 5) (param i32 i32 i32 i32) (result i32) + local.get 0 + local.get 1 + local.get 2 + local.get 3 + call $__imported_wasi_snapshot_preview1_fd_read + i32.const 65535 + i32.and) + (func $__wasi_fd_seek (type 6) (param i32 i64 i32 i32) (result i32) + local.get 0 + local.get 1 + local.get 2 + local.get 3 + call $__imported_wasi_snapshot_preview1_fd_seek + i32.const 65535 + i32.and) + (func $__wasi_fd_write (type 5) (param i32 i32 i32 i32) (result i32) + local.get 0 + local.get 1 + local.get 2 + local.get 3 + call $__imported_wasi_snapshot_preview1_fd_write + i32.const 65535 + i32.and) + (func $__wasi_path_open (type 12) (param i32 i32 i32 i32 i64 i64 i32 i32) (result i32) + local.get 0 + local.get 1 + local.get 2 + local.get 2 + call $strlen + local.get 3 + local.get 4 + local.get 5 + local.get 6 + local.get 7 + call $__imported_wasi_snapshot_preview1_path_open + i32.const 65535 + i32.and) + (func $__wasi_proc_exit (type 8) (param i32) + local.get 0 + call $__imported_wasi_snapshot_preview1_proc_exit + unreachable) + (func $abort (type 9) + unreachable + unreachable) + (func $sbrk (type 0) (param i32) (result i32) + block ;; label = @1 + local.get 0 + br_if 0 (;@1;) + memory.size + i32.const 16 + i32.shl + return + end + block ;; label = @1 + local.get 0 + i32.const 65535 + i32.and + br_if 0 (;@1;) + local.get 0 + i32.const -1 + i32.le_s + br_if 0 (;@1;) + block ;; label = @2 + local.get 0 + i32.const 16 + i32.shr_u + memory.grow + local.tee 0 + i32.const -1 + i32.ne + br_if 0 (;@2;) + i32.const 0 + i32.const 48 + i32.store offset=1692992 + i32.const -1 + return + end + local.get 0 + i32.const 16 + i32.shl + return + end + call $abort + unreachable) + (func $dummy (type 9)) + (func $__wasm_call_dtors (type 9) + call $dummy + call $__stdio_exit) + (func $exit (type 8) (param i32) + call $dummy + call $__stdio_exit + local.get 0 + call $_Exit + unreachable) + (func $dummy.1 (type 8) (param i32)) + (func $fclose (type 0) (param i32) (result i32) + (local i32 i32 i32 i32 i32) + local.get 0 + call $fflush + local.set 1 + local.get 0 + local.get 0 + i32.load offset=12 + call_indirect (type 0) + local.set 2 + block ;; label = @1 + local.get 0 + i32.load8_u + i32.const 1 + i32.and + br_if 0 (;@1;) + local.get 0 + call $dummy.1 + call $__ofl_lock + local.set 3 + local.get 0 + i32.load offset=52 + local.set 4 + block ;; label = @2 + local.get 0 + i32.load offset=48 + local.tee 5 + i32.eqz + br_if 0 (;@2;) + local.get 5 + local.get 4 + i32.store offset=52 + end + block ;; label = @2 + local.get 4 + i32.eqz + br_if 0 (;@2;) + local.get 4 + local.get 5 + i32.store offset=48 + end + block ;; label = @2 + local.get 3 + i32.load + local.get 0 + i32.ne + br_if 0 (;@2;) + local.get 3 + local.get 4 + i32.store + end + call $__ofl_unlock + local.get 0 + i32.load offset=80 + call $free + local.get 0 + call $free + end + local.get 2 + local.get 1 + i32.or) + (func $fflush (type 0) (param i32) (result i32) + (local i32 i32 i32) + block ;; label = @1 + local.get 0 + br_if 0 (;@1;) + i32.const 0 + local.set 1 + block ;; label = @2 + i32.const 0 + i32.load offset=3888 + i32.eqz + br_if 0 (;@2;) + i32.const 0 + i32.load offset=3888 + call $fflush + local.set 1 + end + block ;; label = @2 + i32.const 0 + i32.load offset=3768 + i32.eqz + br_if 0 (;@2;) + i32.const 0 + i32.load offset=3768 + call $fflush + local.get 1 + i32.or + local.set 1 + end + block ;; label = @2 + call $__ofl_lock + i32.load + local.tee 0 + i32.eqz + br_if 0 (;@2;) + loop ;; label = @3 + block ;; label = @4 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=24 + i32.eq + br_if 0 (;@4;) + local.get 0 + i32.const 0 + i32.const 0 + local.get 0 + i32.load offset=32 + call_indirect (type 1) + drop + block ;; label = @5 + block ;; label = @6 + local.get 0 + i32.load offset=20 + br_if 0 (;@6;) + i32.const -1 + local.set 2 + br 1 (;@5;) + end + block ;; label = @6 + local.get 0 + i32.load offset=4 + local.tee 2 + local.get 0 + i32.load offset=8 + local.tee 3 + i32.eq + br_if 0 (;@6;) + local.get 0 + local.get 2 + local.get 3 + i32.sub + i64.extend_i32_s + i32.const 1 + local.get 0 + i32.load offset=36 + call_indirect (type 2) + drop + end + i32.const 0 + local.set 2 + local.get 0 + i32.const 0 + i32.store offset=24 + local.get 0 + i64.const 0 + i64.store offset=16 + local.get 0 + i64.const 0 + i64.store offset=4 align=4 + end + local.get 2 + local.get 1 + i32.or + local.set 1 + end + local.get 0 + i32.load offset=52 + local.tee 0 + br_if 0 (;@3;) + end + end + call $__ofl_unlock + local.get 1 + return + end + block ;; label = @1 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=24 + i32.eq + br_if 0 (;@1;) + local.get 0 + i32.const 0 + i32.const 0 + local.get 0 + i32.load offset=32 + call_indirect (type 1) + drop + local.get 0 + i32.load offset=20 + br_if 0 (;@1;) + i32.const -1 + return + end + block ;; label = @1 + local.get 0 + i32.load offset=4 + local.tee 1 + local.get 0 + i32.load offset=8 + local.tee 2 + i32.eq + br_if 0 (;@1;) + local.get 0 + local.get 1 + local.get 2 + i32.sub + i64.extend_i32_s + i32.const 1 + local.get 0 + i32.load offset=36 + call_indirect (type 2) + drop + end + local.get 0 + i32.const 0 + i32.store offset=24 + local.get 0 + i64.const 0 + i64.store offset=16 + local.get 0 + i64.const 0 + i64.store offset=4 align=4 + i32.const 0) + (func $__fmodeflags (type 0) (param i32) (result i32) + (local i32 i32 i32) + i32.const 335544320 + i32.const 67108864 + i32.const 268435456 + local.get 0 + i32.load8_u + local.tee 1 + i32.const 114 + i32.eq + local.tee 2 + select + local.get 0 + i32.const 43 + call $strchr + select + local.tee 3 + i32.const 16384 + i32.or + local.get 3 + local.get 0 + i32.const 120 + call $strchr + select + local.tee 0 + local.get 0 + i32.const 4096 + i32.or + local.get 2 + select + local.tee 0 + i32.const 32768 + i32.or + local.get 0 + local.get 1 + i32.const 119 + i32.eq + select + local.get 1 + i32.const 97 + i32.eq + i32.or) + (func $__wasilibc_populate_preopens (type 9) + (local i32 i32 i32 i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 0 + global.set $__stack_pointer + block ;; label = @1 + i32.const 0 + i32.load8_u offset=1693004 + i32.const 1 + i32.and + br_if 0 (;@1;) + i32.const 0 + i32.load8_u offset=1693004 + i32.const 1 + i32.and + br_if 0 (;@1;) + i32.const 3 + local.set 1 + block ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + block ;; label = @5 + local.get 1 + local.get 0 + i32.const 8 + i32.add + call $__wasi_fd_prestat_get + local.tee 2 + i32.eqz + br_if 0 (;@5;) + local.get 2 + i32.const 8 + i32.ne + br_if 2 (;@3;) + i32.const 0 + i32.const 1 + i32.store8 offset=1693004 + br 4 (;@1;) + end + block ;; label = @5 + local.get 0 + i32.load8_u offset=8 + br_if 0 (;@5;) + local.get 0 + i32.load offset=12 + local.tee 3 + i32.const 1 + i32.add + call $malloc + local.tee 2 + i32.eqz + br_if 3 (;@2;) + local.get 1 + local.get 2 + local.get 3 + call $__wasi_fd_prestat_dir_name + br_if 2 (;@3;) + local.get 2 + local.get 0 + i32.load offset=12 + i32.add + i32.const 0 + i32.store8 + local.get 1 + local.get 2 + call $internal_register_preopened_fd_unlocked + br_if 3 (;@2;) + local.get 2 + call $free + end + local.get 1 + i32.const 1 + i32.add + local.set 1 + br 0 (;@4;) + end + end + i32.const 71 + call $_Exit + unreachable + end + i32.const 70 + call $_Exit + unreachable + end + local.get 0 + i32.const 16 + i32.add + global.set $__stack_pointer) + (func $internal_register_preopened_fd_unlocked (type 4) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + block ;; label = @1 + block ;; label = @2 + local.get 0 + i32.const 2 + i32.add + br_table 1 (;@1;) 1 (;@1;) 0 (;@2;) + end + local.get 1 + i32.eqz + br_if 0 (;@1;) + block ;; label = @2 + i32.const 0 + i32.load offset=1692996 + local.tee 2 + i32.const 0 + i32.load offset=1693008 + i32.ne + br_if 0 (;@2;) + i32.const 0 + i32.load offset=1693000 + local.set 3 + block ;; label = @3 + i32.const 8 + local.get 2 + i32.const 1 + i32.shl + i32.const 4 + local.get 2 + select + local.tee 4 + call $calloc + local.tee 5 + br_if 0 (;@3;) + i32.const -1 + return + end + local.get 5 + local.get 3 + local.get 2 + i32.const 3 + i32.shl + call $memcpy + local.set 5 + i32.const 0 + local.get 4 + i32.store offset=1693008 + i32.const 0 + local.get 5 + i32.store offset=1693000 + local.get 3 + call $free + end + block ;; label = @2 + loop ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 1 + local.tee 3 + i32.load8_u + i32.const -46 + i32.add + br_table 1 (;@4;) 0 (;@5;) 3 (;@2;) + end + local.get 3 + i32.const 1 + i32.add + local.set 1 + br 1 (;@3;) + end + local.get 3 + i32.const 1 + i32.add + local.set 1 + local.get 3 + i32.load8_u offset=1 + local.tee 4 + i32.eqz + br_if 0 (;@3;) + local.get 4 + i32.const 47 + i32.ne + br_if 1 (;@2;) + local.get 3 + i32.const 2 + i32.add + local.set 1 + br 0 (;@3;) + end + end + block ;; label = @2 + local.get 3 + call $strdup + local.tee 3 + br_if 0 (;@2;) + i32.const -1 + return + end + i32.const 0 + local.get 2 + i32.const 1 + i32.add + i32.store offset=1692996 + i32.const 0 + i32.load offset=1693000 + local.get 2 + i32.const 3 + i32.shl + i32.add + local.tee 1 + local.get 0 + i32.store offset=4 + local.get 1 + local.get 3 + i32.store + i32.const 0 + return + end + call $abort + unreachable) + (func $__wasilibc_find_relpath (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 4 + global.set $__stack_pointer + local.get 4 + local.get 3 + i32.store offset=12 + block ;; label = @1 + block ;; label = @2 + i32.const 0 + i32.eqz + br_if 0 (;@2;) + local.get 0 + local.get 1 + local.get 2 + local.get 4 + i32.const 12 + i32.add + i32.const 0 + call $undefined_weak:__wasilibc_find_relpath_alloc + local.set 3 + br 1 (;@1;) + end + local.get 0 + local.get 1 + local.get 2 + call $__wasilibc_find_abspath + local.set 3 + end + local.get 4 + i32.const 16 + i32.add + global.set $__stack_pointer + local.get 3) + (func $__wasilibc_find_abspath (type 1) (param i32 i32 i32) (result i32) + (local i32 i32 i32 i32 i32 i32 i32 i32 i32) + local.get 0 + i32.const -1 + i32.add + local.set 0 + call $__wasilibc_populate_preopens + loop ;; label = @1 + local.get 0 + i32.const 1 + i32.add + local.tee 0 + i32.load8_u + i32.const 47 + i32.eq + br_if 0 (;@1;) + end + i32.const 0 + local.set 3 + block ;; label = @1 + block ;; label = @2 + i32.const 0 + i32.load offset=1692996 + local.tee 4 + i32.eqz + br_if 0 (;@2;) + i32.const 0 + i32.load offset=1693000 + local.set 5 + i32.const -1 + local.set 6 + loop ;; label = @3 + local.get 5 + local.get 4 + i32.const 3 + i32.shl + i32.add + local.tee 7 + i32.const -8 + i32.add + i32.load + local.tee 8 + call $strlen + local.set 9 + block ;; label = @4 + block ;; label = @5 + local.get 6 + i32.const -1 + i32.eq + br_if 0 (;@5;) + local.get 9 + local.get 3 + i32.le_u + br_if 1 (;@4;) + end + local.get 0 + i32.load8_u + local.set 10 + block ;; label = @5 + block ;; label = @6 + local.get 9 + br_if 0 (;@6;) + local.get 10 + i32.const 255 + i32.and + i32.const 47 + i32.ne + br_if 1 (;@5;) + end + local.get 0 + local.get 8 + local.get 9 + call $memcmp + br_if 1 (;@4;) + block ;; label = @6 + local.get 9 + i32.eqz + br_if 0 (;@6;) + local.get 8 + i32.const -1 + i32.add + local.set 11 + local.get 9 + local.set 10 + block ;; label = @7 + loop ;; label = @8 + local.get 11 + local.get 10 + i32.add + i32.load8_u + i32.const 47 + i32.ne + br_if 1 (;@7;) + local.get 10 + i32.const -1 + i32.add + local.tee 10 + br_if 0 (;@8;) + end + i32.const 0 + local.set 10 + end + local.get 0 + local.get 10 + i32.add + i32.load8_u + local.set 10 + end + local.get 10 + i32.const 255 + i32.and + local.tee 10 + i32.const 47 + i32.eq + br_if 0 (;@5;) + local.get 10 + br_if 1 (;@4;) + end + local.get 1 + local.get 8 + i32.store + local.get 7 + i32.const -4 + i32.add + i32.load + local.set 6 + local.get 9 + local.set 3 + end + local.get 4 + i32.const -1 + i32.add + local.tee 4 + br_if 0 (;@3;) + end + local.get 6 + i32.const -1 + i32.ne + br_if 1 (;@1;) + end + i32.const 0 + i32.const 44 + i32.store offset=1692992 + i32.const -1 + return + end + local.get 0 + local.get 3 + i32.add + i32.const -1 + i32.add + local.set 0 + loop ;; label = @1 + local.get 0 + i32.const 1 + i32.add + local.tee 0 + i32.load8_u + local.tee 4 + i32.const 47 + i32.eq + br_if 0 (;@1;) + end + local.get 2 + local.get 0 + i32.const 1166 + local.get 4 + select + i32.store + local.get 6) + (func $__wasilibc_nocwd_openat_nomode (type 1) (param i32 i32 i32) (result i32) + (local i32 i32 i64 i64) + global.get $__stack_pointer + i32.const 32 + i32.sub + local.tee 3 + global.set $__stack_pointer + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + local.get 2 + i32.const 503316480 + i32.and + i32.const -33554432 + i32.add + i32.const 25 + i32.shr_u + local.tee 4 + i32.const 9 + i32.gt_u + br_if 0 (;@4;) + i32.const 1 + local.get 4 + i32.shl + local.tee 4 + i32.const 642 + i32.and + br_if 1 (;@3;) + i64.const -4211012 + local.set 5 + local.get 4 + i32.const 9 + i32.and + br_if 2 (;@2;) + end + i32.const 0 + i32.const 28 + i32.store offset=1692992 + i32.const -1 + local.set 4 + br 2 (;@1;) + end + i64.const -4194626 + i64.const -4211012 + local.get 2 + i32.const 67108864 + i32.and + select + local.tee 5 + i64.const 4194625 + i64.or + local.get 5 + local.get 2 + i32.const 268435456 + i32.and + select + local.set 5 + end + block ;; label = @2 + local.get 0 + local.get 3 + i32.const 8 + i32.add + call $__wasi_fd_fdstat_get + local.tee 4 + i32.eqz + br_if 0 (;@2;) + i32.const 0 + local.get 4 + i32.store offset=1692992 + i32.const -1 + local.set 4 + br 1 (;@1;) + end + i32.const -1 + local.set 4 + block ;; label = @2 + local.get 0 + local.get 2 + i32.const -1 + i32.xor + i32.const 24 + i32.shr_u + i32.const 1 + i32.and + local.get 1 + local.get 2 + i32.const 12 + i32.shr_u + i32.const 4095 + i32.and + local.get 3 + i64.load offset=24 + local.tee 6 + local.get 5 + i64.and + local.get 6 + local.get 2 + i32.const 4095 + i32.and + local.get 3 + i32.const 4 + i32.add + call $__wasi_path_open + local.tee 2 + i32.eqz + br_if 0 (;@2;) + i32.const 0 + local.get 2 + i32.store offset=1692992 + br 1 (;@1;) + end + local.get 3 + i32.load offset=4 + local.set 4 + end + local.get 3 + i32.const 32 + i32.add + global.set $__stack_pointer + local.get 4) + (func $close (type 0) (param i32) (result i32) + call $__wasilibc_populate_preopens + block ;; label = @1 + local.get 0 + call $__wasi_fd_close + local.tee 0 + br_if 0 (;@1;) + i32.const 0 + return + end + i32.const 0 + local.get 0 + i32.store offset=1692992 + i32.const -1) + (func $__wasilibc_open_nomode (type 4) (param i32 i32) (result i32) + (local i32 i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 2 + global.set $__stack_pointer + block ;; label = @1 + block ;; label = @2 + i32.const 0 + i32.eqz + br_if 0 (;@2;) + local.get 0 + local.get 2 + i32.const 12 + i32.add + i32.const 1693012 + i32.const 1693016 + i32.const 1 + call $undefined_weak:__wasilibc_find_relpath_alloc + local.set 0 + br 1 (;@1;) + end + local.get 0 + local.get 2 + i32.const 12 + i32.add + i32.const 1693012 + i32.const 1693016 + i32.load + call $__wasilibc_find_relpath + local.set 0 + end + i32.const -1 + local.set 3 + block ;; label = @1 + block ;; label = @2 + local.get 0 + i32.const -1 + i32.ne + br_if 0 (;@2;) + i32.const 0 + i32.const 44 + i32.store offset=1692992 + br 1 (;@1;) + end + local.get 0 + i32.const 1693012 + i32.load + local.get 1 + call $__wasilibc_nocwd_openat_nomode + local.set 3 + end + local.get 2 + i32.const 16 + i32.add + global.set $__stack_pointer + local.get 3) + (func $fcntl (type 1) (param i32 i32 i32) (result i32) + (local i32 i64 i64) + global.get $__stack_pointer + i32.const 32 + i32.sub + local.tee 3 + global.set $__stack_pointer + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + local.get 1 + i32.const -1 + i32.add + br_table 5 (;@1;) 0 (;@6;) 1 (;@5;) 2 (;@4;) 3 (;@3;) + end + i32.const 0 + local.set 1 + br 4 (;@1;) + end + block ;; label = @5 + local.get 0 + local.get 3 + i32.const 8 + i32.add + call $__wasi_fd_fdstat_get + local.tee 1 + i32.eqz + br_if 0 (;@5;) + i32.const 0 + local.get 1 + i32.store offset=1692992 + br 3 (;@2;) + end + local.get 3 + i64.load offset=16 + local.tee 4 + i64.const 64 + i64.and + local.set 5 + local.get 3 + i32.load16_u offset=10 + local.set 1 + block ;; label = @5 + local.get 4 + i64.const 16386 + i64.and + i64.eqz + br_if 0 (;@5;) + block ;; label = @6 + local.get 5 + i64.eqz + br_if 0 (;@6;) + local.get 1 + i32.const 335544320 + i32.or + local.set 1 + br 5 (;@1;) + end + local.get 1 + i32.const 67108864 + i32.or + local.set 1 + br 4 (;@1;) + end + block ;; label = @5 + local.get 5 + i64.eqz + br_if 0 (;@5;) + local.get 1 + i32.const 268435456 + i32.or + local.set 1 + br 4 (;@1;) + end + local.get 1 + i32.const 134217728 + i32.or + local.set 1 + br 3 (;@1;) + end + local.get 3 + local.get 2 + i32.const 4 + i32.add + i32.store offset=8 + block ;; label = @4 + local.get 0 + local.get 2 + i32.load + i32.const 4095 + i32.and + call $__wasi_fd_fdstat_set_flags + local.tee 1 + br_if 0 (;@4;) + i32.const 0 + local.set 1 + br 3 (;@1;) + end + i32.const 0 + local.get 1 + i32.store offset=1692992 + br 1 (;@2;) + end + i32.const 0 + i32.const 28 + i32.store offset=1692992 + end + i32.const -1 + local.set 1 + end + local.get 3 + i32.const 32 + i32.add + global.set $__stack_pointer + local.get 1) + (func $__isatty (type 0) (param i32) (result i32) + (local i32 i32) + global.get $__stack_pointer + i32.const 32 + i32.sub + local.tee 1 + global.set $__stack_pointer + block ;; label = @1 + block ;; label = @2 + local.get 0 + local.get 1 + i32.const 8 + i32.add + call $__wasi_fd_fdstat_get + local.tee 0 + br_if 0 (;@2;) + i32.const 59 + local.set 0 + local.get 1 + i32.load8_u offset=8 + i32.const 2 + i32.ne + br_if 0 (;@2;) + local.get 1 + i32.load8_u offset=16 + i32.const 36 + i32.and + br_if 0 (;@2;) + i32.const 1 + local.set 2 + br 1 (;@1;) + end + i32.const 0 + local.set 2 + i32.const 0 + local.get 0 + i32.store offset=1692992 + end + local.get 1 + i32.const 32 + i32.add + global.set $__stack_pointer + local.get 2) + (func $__lseek (type 2) (param i32 i64 i32) (result i64) + (local i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 3 + global.set $__stack_pointer + block ;; label = @1 + block ;; label = @2 + local.get 0 + local.get 1 + local.get 2 + i32.const 255 + i32.and + local.get 3 + i32.const 8 + i32.add + call $__wasi_fd_seek + local.tee 2 + i32.eqz + br_if 0 (;@2;) + i32.const 0 + i32.const 70 + local.get 2 + local.get 2 + i32.const 76 + i32.eq + select + i32.store offset=1692992 + i64.const -1 + local.set 1 + br 1 (;@1;) + end + local.get 3 + i64.load offset=8 + local.set 1 + end + local.get 3 + i32.const 16 + i32.add + global.set $__stack_pointer + local.get 1) + (func $__stdio_seek (type 2) (param i32 i64 i32) (result i64) + local.get 0 + i32.load offset=56 + local.get 1 + local.get 2 + call $__lseek) + (func $writev (type 1) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 3 + global.set $__stack_pointer + i32.const -1 + local.set 4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.const -1 + i32.gt_s + br_if 0 (;@2;) + i32.const 0 + i32.const 28 + i32.store offset=1692992 + br 1 (;@1;) + end + block ;; label = @2 + local.get 0 + local.get 1 + local.get 2 + local.get 3 + i32.const 12 + i32.add + call $__wasi_fd_write + local.tee 2 + i32.eqz + br_if 0 (;@2;) + i32.const 0 + local.get 2 + i32.store offset=1692992 + i32.const -1 + local.set 4 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.set 4 + end + local.get 3 + i32.const 16 + i32.add + global.set $__stack_pointer + local.get 4) + (func $__stdio_write (type 1) (param i32 i32 i32) (result i32) + (local i32 i32 i32 i32 i32 i32 i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 3 + global.set $__stack_pointer + local.get 3 + local.get 2 + i32.store offset=12 + local.get 3 + local.get 1 + i32.store offset=8 + local.get 3 + local.get 0 + i32.load offset=24 + local.tee 1 + i32.store + local.get 3 + local.get 0 + i32.load offset=20 + local.get 1 + i32.sub + local.tee 4 + i32.store offset=4 + i32.const 2 + local.set 5 + block ;; label = @1 + block ;; label = @2 + local.get 0 + i32.load offset=56 + local.get 3 + i32.const 2 + call $writev + local.tee 1 + local.get 4 + local.get 2 + i32.add + local.tee 6 + i32.eq + br_if 0 (;@2;) + local.get 3 + local.set 4 + loop ;; label = @3 + block ;; label = @4 + local.get 1 + i32.const -1 + i32.gt_s + br_if 0 (;@4;) + i32.const 0 + local.set 1 + local.get 0 + i32.const 0 + i32.store offset=24 + local.get 0 + i64.const 0 + i64.store offset=16 + local.get 0 + local.get 0 + i32.load + i32.const 32 + i32.or + i32.store + local.get 5 + i32.const 2 + i32.eq + br_if 3 (;@1;) + local.get 2 + local.get 4 + i32.load offset=4 + i32.sub + local.set 1 + br 3 (;@1;) + end + local.get 4 + local.get 1 + local.get 4 + i32.load offset=4 + local.tee 7 + i32.gt_u + local.tee 8 + i32.const 3 + i32.shl + i32.add + local.tee 9 + local.get 9 + i32.load + local.get 1 + local.get 7 + i32.const 0 + local.get 8 + select + i32.sub + local.tee 7 + i32.add + i32.store + local.get 4 + i32.const 12 + i32.const 4 + local.get 8 + select + i32.add + local.tee 4 + local.get 4 + i32.load + local.get 7 + i32.sub + i32.store + local.get 9 + local.set 4 + local.get 6 + local.get 1 + i32.sub + local.tee 6 + local.get 0 + i32.load offset=56 + local.get 9 + local.get 5 + local.get 8 + i32.sub + local.tee 5 + call $writev + local.tee 1 + i32.ne + br_if 0 (;@3;) + end + end + local.get 0 + local.get 0 + i32.load offset=40 + local.tee 1 + i32.store offset=24 + local.get 0 + local.get 1 + i32.store offset=20 + local.get 0 + local.get 1 + local.get 0 + i32.load offset=44 + i32.add + i32.store offset=16 + local.get 2 + local.set 1 + end + local.get 3 + i32.const 16 + i32.add + global.set $__stack_pointer + local.get 1) + (func $readv (type 1) (param i32 i32 i32) (result i32) + (local i32 i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 3 + global.set $__stack_pointer + i32.const -1 + local.set 4 + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.const -1 + i32.gt_s + br_if 0 (;@2;) + i32.const 0 + i32.const 28 + i32.store offset=1692992 + br 1 (;@1;) + end + block ;; label = @2 + local.get 0 + local.get 1 + local.get 2 + local.get 3 + i32.const 12 + i32.add + call $__wasi_fd_read + local.tee 2 + i32.eqz + br_if 0 (;@2;) + i32.const 0 + local.get 2 + i32.store offset=1692992 + i32.const -1 + local.set 4 + br 1 (;@1;) + end + local.get 3 + i32.load offset=12 + local.set 4 + end + local.get 3 + i32.const 16 + i32.add + global.set $__stack_pointer + local.get 4) + (func $__stdio_read (type 1) (param i32 i32 i32) (result i32) + (local i32 i32 i32 i32 i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 3 + global.set $__stack_pointer + local.get 3 + local.get 1 + i32.store + local.get 3 + local.get 0 + i32.load offset=44 + local.tee 4 + i32.store offset=12 + local.get 3 + local.get 0 + i32.load offset=40 + local.tee 5 + i32.store offset=8 + local.get 3 + local.get 2 + local.get 4 + i32.const 0 + i32.ne + i32.sub + local.tee 6 + i32.store offset=4 + local.get 0 + i32.load offset=56 + local.set 7 + block ;; label = @1 + block ;; label = @2 + local.get 6 + i32.eqz + br_if 0 (;@2;) + local.get 7 + local.get 3 + i32.const 2 + call $readv + local.set 4 + br 1 (;@1;) + end + local.get 7 + local.get 5 + local.get 4 + call $signature_mismatch:read + local.set 4 + end + i32.const 0 + local.set 6 + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.const 0 + i32.gt_s + br_if 0 (;@2;) + local.get 0 + local.get 0 + i32.load + i32.const 32 + i32.const 16 + local.get 4 + select + i32.or + i32.store + br 1 (;@1;) + end + block ;; label = @2 + local.get 4 + local.get 3 + i32.load offset=4 + local.tee 7 + i32.gt_u + br_if 0 (;@2;) + local.get 4 + local.set 6 + br 1 (;@1;) + end + local.get 0 + local.get 0 + i32.load offset=40 + local.tee 6 + i32.store offset=4 + local.get 0 + local.get 6 + local.get 4 + local.get 7 + i32.sub + i32.add + i32.store offset=8 + block ;; label = @2 + local.get 0 + i32.load offset=44 + i32.eqz + br_if 0 (;@2;) + local.get 0 + local.get 6 + i32.const 1 + i32.add + i32.store offset=4 + local.get 1 + local.get 2 + i32.add + i32.const -1 + i32.add + local.get 6 + i32.load8_u + i32.store8 + end + local.get 2 + local.set 6 + end + local.get 3 + i32.const 16 + i32.add + global.set $__stack_pointer + local.get 6) + (func $__stdio_close (type 0) (param i32) (result i32) + local.get 0 + i32.load offset=56 + call $close) + (func $__fdopen (type 4) (param i32 i32) (result i32) + (local i32 i32 i32 i32) + global.get $__stack_pointer + i32.const 32 + i32.sub + local.tee 2 + global.set $__stack_pointer + block ;; label = @1 + block ;; label = @2 + i32.const 1154 + local.get 1 + i32.load8_s + local.tee 3 + i32.const 4 + call $memchr + br_if 0 (;@2;) + i32.const 0 + local.set 4 + i32.const 0 + i32.const 28 + i32.store offset=1692992 + br 1 (;@1;) + end + block ;; label = @2 + i32.const 1144 + call $malloc + local.tee 4 + br_if 0 (;@2;) + i32.const 0 + local.set 4 + br 1 (;@1;) + end + i32.const 0 + local.set 5 + local.get 4 + i32.const 0 + i32.const 112 + call $memset + local.set 4 + block ;; label = @2 + local.get 1 + i32.const 43 + call $strchr + br_if 0 (;@2;) + local.get 4 + i32.const 8 + i32.const 4 + local.get 3 + i32.const 114 + i32.eq + select + local.tee 5 + i32.store + end + block ;; label = @2 + local.get 1 + i32.const 101 + call $strchr + i32.eqz + br_if 0 (;@2;) + local.get 2 + i32.const 1 + i32.store offset=16 + local.get 0 + i32.const 2 + local.get 2 + i32.const 16 + i32.add + call $fcntl + drop + local.get 1 + i32.load8_u + local.set 3 + end + block ;; label = @2 + local.get 3 + i32.const 255 + i32.and + i32.const 97 + i32.ne + br_if 0 (;@2;) + block ;; label = @3 + local.get 0 + i32.const 3 + i32.const 0 + call $fcntl + local.tee 1 + i32.const 1 + i32.and + br_if 0 (;@3;) + local.get 2 + local.get 1 + i32.const 1 + i32.or + i32.store + local.get 0 + i32.const 4 + local.get 2 + call $fcntl + drop + end + local.get 4 + local.get 5 + i32.const 128 + i32.or + local.tee 5 + i32.store + end + local.get 4 + i32.const -1 + i32.store offset=64 + local.get 4 + i32.const 1024 + i32.store offset=44 + local.get 4 + local.get 0 + i32.store offset=56 + local.get 4 + local.get 4 + i32.const 120 + i32.add + i32.store offset=40 + block ;; label = @2 + local.get 5 + i32.const 8 + i32.and + br_if 0 (;@2;) + local.get 0 + call $__isatty + i32.eqz + br_if 0 (;@2;) + local.get 4 + i32.const 10 + i32.store offset=64 + end + local.get 4 + i32.const 1 + i32.store offset=36 + local.get 4 + i32.const 2 + i32.store offset=32 + local.get 4 + i32.const 3 + i32.store offset=28 + local.get 4 + i32.const 4 + i32.store offset=12 + local.get 4 + call $__ofl_add + local.set 4 + end + local.get 2 + i32.const 32 + i32.add + global.set $__stack_pointer + local.get 4) + (func $fopen (type 4) (param i32 i32) (result i32) + (local i32) + block ;; label = @1 + i32.const 1154 + local.get 1 + i32.load8_s + i32.const 4 + call $memchr + br_if 0 (;@1;) + i32.const 0 + i32.const 28 + i32.store offset=1692992 + i32.const 0 + return + end + i32.const 0 + local.set 2 + block ;; label = @1 + local.get 0 + local.get 1 + call $__fmodeflags + call $__wasilibc_open_nomode + local.tee 0 + i32.const 0 + i32.lt_s + br_if 0 (;@1;) + local.get 0 + local.get 1 + call $__fdopen + local.tee 2 + br_if 0 (;@1;) + local.get 0 + call $close + drop + i32.const 0 + local.set 2 + end + local.get 2) + (func $__stdio_exit (type 9) + (local i32 i32 i32) + block ;; label = @1 + call $__ofl_lock + i32.load + local.tee 0 + i32.eqz + br_if 0 (;@1;) + loop ;; label = @2 + block ;; label = @3 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=24 + i32.eq + br_if 0 (;@3;) + local.get 0 + i32.const 0 + i32.const 0 + local.get 0 + i32.load offset=32 + call_indirect (type 1) + drop + end + block ;; label = @3 + local.get 0 + i32.load offset=4 + local.tee 1 + local.get 0 + i32.load offset=8 + local.tee 2 + i32.eq + br_if 0 (;@3;) + local.get 0 + local.get 1 + local.get 2 + i32.sub + i64.extend_i32_s + i32.const 1 + local.get 0 + i32.load offset=36 + call_indirect (type 2) + drop + end + local.get 0 + i32.load offset=52 + local.tee 0 + br_if 0 (;@2;) + end + end + block ;; label = @1 + i32.const 0 + i32.load offset=1693020 + local.tee 0 + i32.eqz + br_if 0 (;@1;) + block ;; label = @2 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=24 + i32.eq + br_if 0 (;@2;) + local.get 0 + i32.const 0 + i32.const 0 + local.get 0 + i32.load offset=32 + call_indirect (type 1) + drop + end + local.get 0 + i32.load offset=4 + local.tee 1 + local.get 0 + i32.load offset=8 + local.tee 2 + i32.eq + br_if 0 (;@1;) + local.get 0 + local.get 1 + local.get 2 + i32.sub + i64.extend_i32_s + i32.const 1 + local.get 0 + i32.load offset=36 + call_indirect (type 2) + drop + end + block ;; label = @1 + i32.const 0 + i32.load offset=3888 + local.tee 0 + i32.eqz + br_if 0 (;@1;) + block ;; label = @2 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=24 + i32.eq + br_if 0 (;@2;) + local.get 0 + i32.const 0 + i32.const 0 + local.get 0 + i32.load offset=32 + call_indirect (type 1) + drop + end + local.get 0 + i32.load offset=4 + local.tee 1 + local.get 0 + i32.load offset=8 + local.tee 2 + i32.eq + br_if 0 (;@1;) + local.get 0 + local.get 1 + local.get 2 + i32.sub + i64.extend_i32_s + i32.const 1 + local.get 0 + i32.load offset=36 + call_indirect (type 2) + drop + end + block ;; label = @1 + i32.const 0 + i32.load offset=3768 + local.tee 0 + i32.eqz + br_if 0 (;@1;) + block ;; label = @2 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=24 + i32.eq + br_if 0 (;@2;) + local.get 0 + i32.const 0 + i32.const 0 + local.get 0 + i32.load offset=32 + call_indirect (type 1) + drop + end + local.get 0 + i32.load offset=4 + local.tee 1 + local.get 0 + i32.load offset=8 + local.tee 2 + i32.eq + br_if 0 (;@1;) + local.get 0 + local.get 1 + local.get 2 + i32.sub + i64.extend_i32_s + i32.const 1 + local.get 0 + i32.load offset=36 + call_indirect (type 2) + drop + end) + (func $__toread (type 0) (param i32) (result i32) + (local i32 i32) + local.get 0 + local.get 0 + i32.load offset=60 + local.tee 1 + i32.const -1 + i32.add + local.get 1 + i32.or + i32.store offset=60 + block ;; label = @1 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=24 + i32.eq + br_if 0 (;@1;) + local.get 0 + i32.const 0 + i32.const 0 + local.get 0 + i32.load offset=32 + call_indirect (type 1) + drop + end + local.get 0 + i32.const 0 + i32.store offset=24 + local.get 0 + i64.const 0 + i64.store offset=16 + block ;; label = @1 + local.get 0 + i32.load + local.tee 1 + i32.const 4 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + local.get 1 + i32.const 32 + i32.or + i32.store + i32.const -1 + return + end + local.get 0 + local.get 0 + i32.load offset=40 + local.get 0 + i32.load offset=44 + i32.add + local.tee 2 + i32.store offset=8 + local.get 0 + local.get 2 + i32.store offset=4 + local.get 1 + i32.const 27 + i32.shl + i32.const 31 + i32.shr_s) + (func $fread (type 5) (param i32 i32 i32 i32) (result i32) + (local i32 i32 i32) + local.get 3 + local.get 3 + i32.load offset=60 + local.tee 4 + i32.const -1 + i32.add + local.get 4 + i32.or + i32.store offset=60 + local.get 2 + local.get 1 + i32.mul + local.set 5 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=4 + local.tee 4 + local.get 3 + i32.load offset=8 + local.tee 6 + i32.ne + br_if 0 (;@2;) + local.get 5 + local.set 4 + br 1 (;@1;) + end + local.get 0 + local.get 4 + local.get 6 + local.get 4 + i32.sub + local.tee 6 + local.get 5 + local.get 6 + local.get 5 + i32.lt_u + select + local.tee 6 + call $memcpy + local.set 0 + local.get 3 + local.get 4 + local.get 6 + i32.add + i32.store offset=4 + local.get 5 + local.get 6 + i32.sub + local.set 4 + local.get 0 + local.get 6 + i32.add + local.set 0 + end + local.get 2 + i32.const 0 + local.get 1 + select + local.set 6 + block ;; label = @1 + local.get 4 + i32.eqz + br_if 0 (;@1;) + loop ;; label = @2 + block ;; label = @3 + block ;; label = @4 + local.get 3 + call $__toread + br_if 0 (;@4;) + local.get 3 + local.get 0 + local.get 4 + local.get 3 + i32.load offset=28 + call_indirect (type 1) + local.tee 2 + br_if 1 (;@3;) + end + local.get 5 + local.get 4 + i32.sub + local.get 1 + i32.div_u + return + end + local.get 0 + local.get 2 + i32.add + local.set 0 + local.get 4 + local.get 2 + i32.sub + local.tee 4 + br_if 0 (;@2;) + end + end + local.get 6) + (func $__ofl_lock (type 11) (result i32) + i32.const 1693024) + (func $__ofl_unlock (type 9)) + (func $__ofl_add (type 0) (param i32) (result i32) + (local i32 i32) + local.get 0 + call $__ofl_lock + local.tee 1 + i32.load + local.tee 2 + i32.store offset=52 + block ;; label = @1 + local.get 2 + i32.eqz + br_if 0 (;@1;) + local.get 2 + local.get 0 + i32.store offset=48 + end + local.get 1 + local.get 0 + i32.store + call $__ofl_unlock + local.get 0) + (func $dummy.2 (type 4) (param i32 i32) (result i32) + local.get 0) + (func $__lctrans (type 4) (param i32 i32) (result i32) + local.get 0 + local.get 1 + call $dummy.2) + (func $strerror (type 0) (param i32) (result i32) + (local i32) + block ;; label = @1 + i32.const 0 + i32.load offset=1693052 + local.tee 1 + br_if 0 (;@1;) + i32.const 1693028 + local.set 1 + i32.const 0 + i32.const 1693028 + i32.store offset=1693052 + end + i32.const 0 + local.get 0 + local.get 0 + i32.const 76 + i32.gt_u + select + i32.const 1 + i32.shl + i32.const 3008 + i32.add + i32.load16_u + i32.const 1443 + i32.add + local.get 1 + i32.load offset=20 + call $__lctrans) + (func $__towrite (type 0) (param i32) (result i32) + (local i32) + local.get 0 + local.get 0 + i32.load offset=60 + local.tee 1 + i32.const -1 + i32.add + local.get 1 + i32.or + i32.store offset=60 + block ;; label = @1 + local.get 0 + i32.load + local.tee 1 + i32.const 8 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 0 + local.get 1 + i32.const 32 + i32.or + i32.store + i32.const -1 + return + end + local.get 0 + i64.const 0 + i64.store offset=4 align=4 + local.get 0 + local.get 0 + i32.load offset=40 + local.tee 1 + i32.store offset=24 + local.get 0 + local.get 1 + i32.store offset=20 + local.get 0 + local.get 1 + local.get 0 + i32.load offset=44 + i32.add + i32.store offset=16 + i32.const 0) + (func $__fwritex (type 1) (param i32 i32 i32) (result i32) + (local i32 i32 i32 i32) + block ;; label = @1 + block ;; label = @2 + local.get 2 + i32.load offset=16 + local.tee 3 + br_if 0 (;@2;) + i32.const 0 + local.set 4 + local.get 2 + call $__towrite + br_if 1 (;@1;) + local.get 2 + i32.load offset=16 + local.set 3 + end + block ;; label = @2 + local.get 3 + local.get 2 + i32.load offset=20 + local.tee 5 + i32.sub + local.get 1 + i32.ge_u + br_if 0 (;@2;) + local.get 2 + local.get 0 + local.get 1 + local.get 2 + i32.load offset=32 + call_indirect (type 1) + return + end + i32.const 0 + local.set 6 + block ;; label = @2 + local.get 2 + i32.load offset=64 + i32.const 0 + i32.lt_s + br_if 0 (;@2;) + local.get 1 + i32.eqz + br_if 0 (;@2;) + local.get 0 + local.get 1 + i32.add + local.set 4 + i32.const 0 + local.set 3 + block ;; label = @3 + loop ;; label = @4 + local.get 4 + local.get 3 + i32.add + i32.const -1 + i32.add + i32.load8_u + i32.const 10 + i32.eq + br_if 1 (;@3;) + local.get 1 + local.get 3 + i32.const -1 + i32.add + local.tee 3 + i32.add + br_if 0 (;@4;) + end + i32.const 0 + local.set 6 + br 1 (;@2;) + end + local.get 2 + local.get 0 + local.get 1 + local.get 3 + i32.add + local.tee 6 + local.get 2 + i32.load offset=32 + call_indirect (type 1) + local.tee 4 + local.get 6 + i32.lt_u + br_if 1 (;@1;) + local.get 6 + local.get 0 + i32.add + local.set 0 + i32.const 0 + local.get 3 + i32.sub + local.set 1 + local.get 2 + i32.load offset=20 + local.set 5 + end + local.get 5 + local.get 0 + local.get 1 + call $memcpy + drop + local.get 2 + local.get 2 + i32.load offset=20 + local.get 1 + i32.add + i32.store offset=20 + local.get 6 + local.get 1 + i32.add + local.set 4 + end + local.get 4) + (func $fwrite (type 5) (param i32 i32 i32 i32) (result i32) + (local i32 i32 i32 i32 i32) + local.get 2 + local.get 1 + i32.mul + local.set 4 + block ;; label = @1 + block ;; label = @2 + local.get 3 + i32.load offset=16 + local.tee 5 + br_if 0 (;@2;) + i32.const 0 + local.set 6 + local.get 3 + call $__towrite + br_if 1 (;@1;) + local.get 3 + i32.load offset=16 + local.set 5 + end + block ;; label = @2 + local.get 5 + local.get 3 + i32.load offset=20 + local.tee 7 + i32.sub + local.get 4 + i32.ge_u + br_if 0 (;@2;) + local.get 3 + local.get 0 + local.get 4 + local.get 3 + i32.load offset=32 + call_indirect (type 1) + local.set 6 + br 1 (;@1;) + end + i32.const 0 + local.set 8 + block ;; label = @2 + block ;; label = @3 + local.get 4 + br_if 0 (;@3;) + local.get 4 + local.set 5 + br 1 (;@2;) + end + i32.const 0 + local.set 5 + block ;; label = @3 + local.get 3 + i32.load offset=64 + i32.const 0 + i32.ge_s + br_if 0 (;@3;) + local.get 4 + local.set 5 + br 1 (;@2;) + end + local.get 0 + local.get 4 + i32.add + local.set 6 + block ;; label = @3 + loop ;; label = @4 + local.get 6 + local.get 5 + i32.add + i32.const -1 + i32.add + i32.load8_u + i32.const 10 + i32.eq + br_if 1 (;@3;) + local.get 4 + local.get 5 + i32.const -1 + i32.add + local.tee 5 + i32.add + br_if 0 (;@4;) + end + i32.const 0 + local.set 8 + local.get 4 + local.set 5 + br 1 (;@2;) + end + local.get 3 + local.get 0 + local.get 4 + local.get 5 + i32.add + local.tee 8 + local.get 3 + i32.load offset=32 + call_indirect (type 1) + local.tee 6 + local.get 8 + i32.lt_u + br_if 1 (;@1;) + local.get 8 + local.get 0 + i32.add + local.set 0 + i32.const 0 + local.get 5 + i32.sub + local.set 5 + local.get 3 + i32.load offset=20 + local.set 7 + end + local.get 7 + local.get 0 + local.get 5 + call $memcpy + drop + local.get 3 + local.get 3 + i32.load offset=20 + local.get 5 + i32.add + i32.store offset=20 + local.get 8 + local.get 5 + i32.add + local.set 6 + end + block ;; label = @1 + local.get 6 + local.get 4 + i32.ne + br_if 0 (;@1;) + local.get 2 + i32.const 0 + local.get 1 + select + return + end + local.get 6 + local.get 1 + i32.div_u) + (func $__overflow (type 4) (param i32 i32) (result i32) + (local i32 i32 i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 2 + global.set $__stack_pointer + local.get 2 + local.get 1 + i32.store8 offset=15 + block ;; label = @1 + block ;; label = @2 + local.get 0 + i32.load offset=16 + local.tee 3 + br_if 0 (;@2;) + i32.const -1 + local.set 3 + local.get 0 + call $__towrite + br_if 1 (;@1;) + local.get 0 + i32.load offset=16 + local.set 3 + end + block ;; label = @2 + local.get 0 + i32.load offset=20 + local.tee 4 + local.get 3 + i32.eq + br_if 0 (;@2;) + local.get 0 + i32.load offset=64 + local.get 1 + i32.const 255 + i32.and + local.tee 3 + i32.eq + br_if 0 (;@2;) + local.get 0 + local.get 4 + i32.const 1 + i32.add + i32.store offset=20 + local.get 4 + local.get 1 + i32.store8 + br 1 (;@1;) + end + i32.const -1 + local.set 3 + local.get 0 + local.get 2 + i32.const 15 + i32.add + i32.const 1 + local.get 0 + i32.load offset=32 + call_indirect (type 1) + i32.const 1 + i32.ne + br_if 0 (;@1;) + local.get 2 + i32.load8_u offset=15 + local.set 3 + end + local.get 2 + i32.const 16 + i32.add + global.set $__stack_pointer + local.get 3) + (func $fputc (type 4) (param i32 i32) (result i32) + (local i32 i32) + block ;; label = @1 + local.get 0 + i32.const 255 + i32.and + local.tee 2 + local.get 1 + i32.load offset=64 + i32.eq + br_if 0 (;@1;) + local.get 1 + i32.load offset=20 + local.tee 3 + local.get 1 + i32.load offset=16 + i32.eq + br_if 0 (;@1;) + local.get 1 + local.get 3 + i32.const 1 + i32.add + i32.store offset=20 + local.get 3 + local.get 0 + i32.store8 + local.get 2 + return + end + local.get 1 + local.get 2 + call $__overflow) + (func $perror (type 8) (param i32) + (local i32 i32 i32) + i32.const 0 + i32.load offset=1692992 + call $strerror + local.set 1 + i32.const 0 + i32.load offset=3716 + local.set 2 + i32.const 0 + i32.load offset=3760 + local.set 3 + block ;; label = @1 + local.get 0 + i32.eqz + br_if 0 (;@1;) + local.get 0 + i32.load8_u + i32.eqz + br_if 0 (;@1;) + local.get 0 + local.get 0 + call $strlen + i32.const 1 + i32.const 3656 + call $fwrite + drop + i32.const 58 + i32.const 3656 + call $fputc + drop + i32.const 32 + i32.const 3656 + call $fputc + drop + end + local.get 1 + local.get 1 + call $strlen + i32.const 1 + i32.const 3656 + call $fwrite + drop + i32.const 10 + i32.const 3656 + call $fputc + drop + i32.const 0 + local.get 3 + i32.store offset=3760 + i32.const 0 + local.get 2 + i32.store offset=3716) + (func $printf (type 4) (param i32 i32) (result i32) + (local i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 2 + global.set $__stack_pointer + local.get 2 + local.get 1 + i32.store offset=12 + i32.const 3776 + local.get 0 + local.get 1 + call $vfprintf + local.set 1 + local.get 2 + i32.const 16 + i32.add + global.set $__stack_pointer + local.get 1) + (func $fputs (type 4) (param i32 i32) (result i32) + (local i32) + local.get 0 + call $strlen + local.set 2 + i32.const -1 + i32.const 0 + local.get 2 + local.get 0 + i32.const 1 + local.get 2 + local.get 1 + call $fwrite + i32.ne + select) + (func $puts (type 0) (param i32) (result i32) + block ;; label = @1 + local.get 0 + i32.const 3776 + call $fputs + i32.const 0 + i32.ge_s + br_if 0 (;@1;) + i32.const -1 + return + end + block ;; label = @1 + i32.const 0 + i32.load offset=3840 + i32.const 10 + i32.eq + br_if 0 (;@1;) + i32.const 0 + i32.load offset=3796 + local.tee 0 + i32.const 0 + i32.load offset=3792 + i32.eq + br_if 0 (;@1;) + i32.const 0 + local.get 0 + i32.const 1 + i32.add + i32.store offset=3796 + local.get 0 + i32.const 10 + i32.store8 + i32.const 0 + return + end + i32.const 3776 + i32.const 10 + call $__overflow + i32.const 31 + i32.shr_s) + (func $snprintf (type 5) (param i32 i32 i32 i32) (result i32) + (local i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 4 + global.set $__stack_pointer + local.get 4 + local.get 3 + i32.store offset=12 + local.get 0 + local.get 1 + local.get 2 + local.get 3 + call $vsnprintf + local.set 3 + local.get 4 + i32.const 16 + i32.add + global.set $__stack_pointer + local.get 3) + (func $sprintf (type 1) (param i32 i32 i32) (result i32) + (local i32) + global.get $__stack_pointer + i32.const 16 + i32.sub + local.tee 3 + global.set $__stack_pointer + local.get 3 + local.get 2 + i32.store offset=12 + local.get 0 + local.get 1 + local.get 2 + call $vsprintf + local.set 2 + local.get 3 + i32.const 16 + i32.add + global.set $__stack_pointer + local.get 2) + (func $__stdout_write (type 1) (param i32 i32 i32) (result i32) + local.get 0 + i32.const 2 + i32.store offset=32 + block ;; label = @1 + local.get 0 + i32.load8_u + i32.const 64 + i32.and + br_if 0 (;@1;) + local.get 0 + i32.load offset=56 + call $__isatty + br_if 0 (;@1;) + local.get 0 + i32.const -1 + i32.store offset=64 + end + local.get 0 + local.get 1 + local.get 2 + call $__stdio_write) + (func $wcrtomb (type 1) (param i32 i32 i32) (result i32) + (local i32) + i32.const 1 + local.set 3 + block ;; label = @1 + local.get 0 + i32.eqz + br_if 0 (;@1;) + block ;; label = @2 + local.get 1 + i32.const 127 + i32.gt_u + br_if 0 (;@2;) + local.get 0 + local.get 1 + i32.store8 + i32.const 1 + return + end + block ;; label = @2 + i32.const 0 + i32.load offset=1693052 + local.tee 3 + br_if 0 (;@2;) + i32.const 1693028 + local.set 3 + i32.const 0 + i32.const 1693028 + i32.store offset=1693052 + end + block ;; label = @2 + block ;; label = @3 + local.get 3 + i32.load + br_if 0 (;@3;) + block ;; label = @4 + local.get 1 + i32.const -128 + i32.and + i32.const 57216 + i32.eq + br_if 0 (;@4;) + i32.const 0 + i32.const 25 + i32.store offset=1692992 + br 2 (;@2;) + end + local.get 0 + local.get 1 + i32.store8 + i32.const 1 + return + end + block ;; label = @3 + local.get 1 + i32.const 2047 + i32.gt_u + br_if 0 (;@3;) + local.get 0 + local.get 1 + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=1 + local.get 0 + local.get 1 + i32.const 6 + i32.shr_u + i32.const 192 + i32.or + i32.store8 + i32.const 2 + return + end + block ;; label = @3 + block ;; label = @4 + local.get 1 + i32.const 55296 + i32.lt_u + br_if 0 (;@4;) + local.get 1 + i32.const -8192 + i32.and + i32.const 57344 + i32.ne + br_if 1 (;@3;) + end + local.get 0 + local.get 1 + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=2 + local.get 0 + local.get 1 + i32.const 12 + i32.shr_u + i32.const 224 + i32.or + i32.store8 + local.get 0 + local.get 1 + i32.const 6 + i32.shr_u + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=1 + i32.const 3 + return + end + block ;; label = @3 + local.get 1 + i32.const -65536 + i32.add + i32.const 1048575 + i32.gt_u + br_if 0 (;@3;) + local.get 0 + local.get 1 + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=3 + local.get 0 + local.get 1 + i32.const 18 + i32.shr_u + i32.const 240 + i32.or + i32.store8 + local.get 0 + local.get 1 + i32.const 6 + i32.shr_u + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=2 + local.get 0 + local.get 1 + i32.const 12 + i32.shr_u + i32.const 63 + i32.and + i32.const 128 + i32.or + i32.store8 offset=1 + i32.const 4 + return + end + i32.const 0 + i32.const 25 + i32.store offset=1692992 + end + i32.const -1 + local.set 3 + end + local.get 3) + (func $wctomb (type 4) (param i32 i32) (result i32) + block ;; label = @1 + local.get 0 + br_if 0 (;@1;) + i32.const 0 + return + end + local.get 0 + local.get 1 + i32.const 0 + call $wcrtomb) + (func $frexp (type 13) (param f64 i32) (result f64) + (local i64 i32) + block ;; label = @1 + local.get 0 + i64.reinterpret_f64 + local.tee 2 + i64.const 52 + i64.shr_u + i32.wrap_i64 + i32.const 2047 + i32.and + local.tee 3 + i32.const 2047 + i32.eq + br_if 0 (;@1;) + block ;; label = @2 + local.get 3 + br_if 0 (;@2;) + block ;; label = @3 + local.get 0 + f64.const 0x0p+0 (;=0;) + f64.ne + br_if 0 (;@3;) + local.get 1 + i32.const 0 + i32.store + local.get 0 + return + end + local.get 0 + f64.const 0x1p+64 (;=1.84467e+19;) + f64.mul + local.get 1 + call $frexp + local.set 0 + local.get 1 + local.get 1 + i32.load + i32.const -64 + i32.add + i32.store + local.get 0 + return + end + local.get 1 + local.get 3 + i32.const -1022 + i32.add + i32.store + local.get 2 + i64.const -9218868437227405313 + i64.and + i64.const 4602678819172646912 + i64.or + f64.reinterpret_i64 + local.set 0 + end + local.get 0) + (func $vfprintf (type 1) (param i32 i32 i32) (result i32) + (local i32 i32 i32) + global.get $__stack_pointer + i32.const 208 + i32.sub + local.tee 3 + global.set $__stack_pointer + local.get 3 + local.get 2 + i32.store offset=204 + local.get 3 + i32.const 160 + i32.add + i32.const 32 + i32.add + i64.const 0 + i64.store + local.get 3 + i32.const 184 + i32.add + i64.const 0 + i64.store + local.get 3 + i32.const 176 + i32.add + i64.const 0 + i64.store + local.get 3 + i64.const 0 + i64.store offset=168 + local.get 3 + i64.const 0 + i64.store offset=160 + local.get 3 + local.get 2 + i32.store offset=200 + block ;; label = @1 + block ;; label = @2 + i32.const 0 + local.get 1 + local.get 3 + i32.const 200 + i32.add + local.get 3 + i32.const 80 + i32.add + local.get 3 + i32.const 160 + i32.add + call $printf_core + i32.const 0 + i32.ge_s + br_if 0 (;@2;) + i32.const -1 + local.set 0 + br 1 (;@1;) + end + local.get 0 + i32.load + local.set 4 + block ;; label = @2 + local.get 0 + i32.load offset=60 + i32.const 0 + i32.gt_s + br_if 0 (;@2;) + local.get 0 + local.get 4 + i32.const -33 + i32.and + i32.store + end + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + local.get 0 + i32.load offset=44 + br_if 0 (;@5;) + local.get 0 + i32.const 80 + i32.store offset=44 + local.get 0 + i32.const 0 + i32.store offset=24 + local.get 0 + i64.const 0 + i64.store offset=16 + local.get 0 + i32.load offset=40 + local.set 5 + local.get 0 + local.get 3 + i32.store offset=40 + br 1 (;@4;) + end + i32.const 0 + local.set 5 + local.get 0 + i32.load offset=16 + br_if 1 (;@3;) + end + i32.const -1 + local.set 2 + local.get 0 + call $__towrite + br_if 1 (;@2;) + end + local.get 0 + local.get 1 + local.get 3 + i32.const 200 + i32.add + local.get 3 + i32.const 80 + i32.add + local.get 3 + i32.const 160 + i32.add + call $printf_core + local.set 2 + end + local.get 4 + i32.const 32 + i32.and + local.set 1 + block ;; label = @2 + local.get 5 + i32.eqz + br_if 0 (;@2;) + local.get 0 + i32.const 0 + i32.const 0 + local.get 0 + i32.load offset=32 + call_indirect (type 1) + drop + local.get 0 + i32.const 0 + i32.store offset=44 + local.get 0 + local.get 5 + i32.store offset=40 + local.get 0 + i32.const 0 + i32.store offset=24 + local.get 0 + i32.load offset=20 + local.set 5 + local.get 0 + i64.const 0 + i64.store offset=16 + local.get 2 + i32.const -1 + local.get 5 + select + local.set 2 + end + local.get 0 + local.get 0 + i32.load + local.tee 5 + local.get 1 + i32.or + i32.store + i32.const -1 + local.get 2 + local.get 5 + i32.const 32 + i32.and + select + local.set 0 + end + local.get 3 + i32.const 208 + i32.add + global.set $__stack_pointer + local.get 0) + (func $printf_core (type 10) (param i32 i32 i32 i32 i32) (result i32) + (local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i64 i64 f64 i32 i32 i32 i32 i32 i32 i32 i32 i32 f64) + global.get $__stack_pointer + i32.const 880 + i32.sub + local.tee 5 + global.set $__stack_pointer + local.get 3 + i32.const -384 + i32.add + local.set 6 + local.get 5 + i32.const 68 + i32.add + i32.const 12 + i32.add + local.set 7 + i32.const 0 + local.get 5 + i32.const 112 + i32.add + i32.sub + local.set 8 + local.get 5 + i32.const 112 + i32.add + i32.const -4100 + i32.add + local.set 9 + local.get 5 + i32.const 55 + i32.add + local.set 10 + local.get 5 + i32.const 68 + i32.add + i32.const 11 + i32.add + local.set 11 + local.get 5 + i32.const 80 + i32.add + i32.const -1 + i32.add + local.set 12 + local.get 5 + i32.const 80 + i32.add + i32.const 8 + i32.or + local.set 13 + local.get 5 + i32.const 80 + i32.add + i32.const 9 + i32.or + local.set 14 + local.get 5 + i32.const 68 + i32.add + i32.const 10 + i32.add + local.set 15 + local.get 5 + i32.const 56 + i32.add + local.set 16 + i32.const 0 + local.set 17 + i32.const 0 + local.set 18 + i32.const 0 + local.set 19 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + loop ;; label = @4 + local.get 1 + local.set 20 + local.get 19 + local.get 18 + i32.const 2147483647 + i32.xor + i32.gt_s + br_if 1 (;@3;) + local.get 19 + local.get 18 + i32.add + local.set 18 + block ;; label = @5 + block ;; label = @6 + block ;; label = @7 + block ;; label = @8 + block ;; label = @9 + block ;; label = @10 + block ;; label = @11 + block ;; label = @12 + block ;; label = @13 + local.get 20 + i32.load8_u + local.tee 19 + i32.eqz + br_if 0 (;@13;) + local.get 20 + local.set 1 + loop ;; label = @14 + block ;; label = @15 + block ;; label = @16 + block ;; label = @17 + local.get 19 + i32.const 255 + i32.and + local.tee 19 + i32.eqz + br_if 0 (;@17;) + local.get 19 + i32.const 37 + i32.ne + br_if 2 (;@15;) + local.get 1 + local.set 21 + local.get 1 + local.set 19 + loop ;; label = @18 + block ;; label = @19 + local.get 19 + i32.load8_u offset=1 + i32.const 37 + i32.eq + br_if 0 (;@19;) + local.get 19 + local.set 1 + br 3 (;@16;) + end + local.get 21 + i32.const 1 + i32.add + local.set 21 + local.get 19 + i32.load8_u offset=2 + local.set 22 + local.get 19 + i32.const 2 + i32.add + local.tee 1 + local.set 19 + local.get 22 + i32.const 37 + i32.eq + br_if 0 (;@18;) + br 2 (;@16;) + end + end + local.get 1 + local.set 21 + end + local.get 21 + local.get 20 + i32.sub + local.tee 19 + local.get 18 + i32.const 2147483647 + i32.xor + local.tee 21 + i32.gt_s + br_if 12 (;@3;) + block ;; label = @16 + local.get 0 + i32.eqz + br_if 0 (;@16;) + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@16;) + local.get 20 + local.get 19 + local.get 0 + call $__fwritex + drop + end + local.get 19 + br_if 11 (;@4;) + local.get 1 + i32.const 1 + i32.add + local.set 19 + i32.const -1 + local.set 23 + block ;; label = @16 + local.get 1 + i32.load8_s offset=1 + local.tee 24 + i32.const -48 + i32.add + local.tee 22 + i32.const 9 + i32.gt_u + br_if 0 (;@16;) + local.get 1 + i32.load8_u offset=2 + i32.const 36 + i32.ne + br_if 0 (;@16;) + local.get 1 + i32.const 3 + i32.add + local.set 19 + local.get 1 + i32.load8_s offset=3 + local.set 24 + i32.const 1 + local.set 17 + local.get 22 + local.set 23 + end + i32.const 0 + local.set 25 + block ;; label = @16 + local.get 24 + i32.const -32 + i32.add + local.tee 1 + i32.const 31 + i32.gt_u + br_if 0 (;@16;) + i32.const 1 + local.get 1 + i32.shl + local.tee 1 + i32.const 75913 + i32.and + i32.eqz + br_if 0 (;@16;) + local.get 19 + i32.const 1 + i32.add + local.set 22 + i32.const 0 + local.set 25 + loop ;; label = @17 + local.get 1 + local.get 25 + i32.or + local.set 25 + local.get 22 + local.tee 19 + i32.load8_s + local.tee 24 + i32.const -32 + i32.add + local.tee 1 + i32.const 32 + i32.ge_u + br_if 1 (;@16;) + local.get 19 + i32.const 1 + i32.add + local.set 22 + i32.const 1 + local.get 1 + i32.shl + local.tee 1 + i32.const 75913 + i32.and + br_if 0 (;@17;) + end + end + block ;; label = @16 + local.get 24 + i32.const 42 + i32.ne + br_if 0 (;@16;) + block ;; label = @17 + block ;; label = @18 + local.get 19 + i32.load8_s offset=1 + i32.const -48 + i32.add + local.tee 1 + i32.const 9 + i32.gt_u + br_if 0 (;@18;) + local.get 19 + i32.load8_u offset=2 + i32.const 36 + i32.ne + br_if 0 (;@18;) + local.get 4 + local.get 1 + i32.const 2 + i32.shl + i32.add + i32.const 10 + i32.store + local.get 19 + i32.const 3 + i32.add + local.set 22 + local.get 6 + local.get 19 + i32.load8_s offset=1 + i32.const 3 + i32.shl + i32.add + i32.load + local.set 26 + i32.const 1 + local.set 17 + br 1 (;@17;) + end + local.get 17 + br_if 6 (;@11;) + local.get 19 + i32.const 1 + i32.add + local.set 22 + block ;; label = @18 + local.get 0 + br_if 0 (;@18;) + i32.const 0 + local.set 17 + i32.const 0 + local.set 26 + br 6 (;@12;) + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 1 + i32.load + local.set 26 + i32.const 0 + local.set 17 + end + local.get 26 + i32.const -1 + i32.gt_s + br_if 4 (;@12;) + i32.const 0 + local.get 26 + i32.sub + local.set 26 + local.get 25 + i32.const 8192 + i32.or + local.set 25 + br 4 (;@12;) + end + i32.const 0 + local.set 26 + block ;; label = @16 + local.get 24 + i32.const -48 + i32.add + local.tee 1 + i32.const 9 + i32.le_u + br_if 0 (;@16;) + local.get 19 + local.set 22 + br 4 (;@12;) + end + i32.const 0 + local.set 26 + loop ;; label = @16 + block ;; label = @17 + local.get 26 + i32.const 214748364 + i32.gt_u + br_if 0 (;@17;) + i32.const -1 + local.get 26 + i32.const 10 + i32.mul + local.tee 22 + local.get 1 + i32.add + local.get 1 + local.get 22 + i32.const 2147483647 + i32.xor + i32.gt_u + local.tee 24 + select + local.set 26 + local.get 19 + i32.load8_s offset=1 + local.set 1 + local.get 19 + i32.const 1 + i32.add + local.tee 22 + local.set 19 + local.get 1 + i32.const -48 + i32.add + local.tee 1 + i32.const 10 + i32.lt_u + br_if 1 (;@16;) + local.get 24 + br_if 14 (;@3;) + br 5 (;@12;) + end + local.get 19 + i32.load8_s offset=1 + local.set 1 + i32.const -1 + local.set 26 + local.get 19 + i32.const 1 + i32.add + local.set 19 + local.get 1 + i32.const -48 + i32.add + local.tee 1 + i32.const 10 + i32.lt_u + br_if 0 (;@16;) + br 13 (;@3;) + end + end + local.get 1 + i32.load8_u offset=1 + local.set 19 + local.get 1 + i32.const 1 + i32.add + local.set 1 + br 0 (;@14;) + end + end + local.get 0 + br_if 11 (;@1;) + block ;; label = @13 + local.get 17 + br_if 0 (;@13;) + i32.const 0 + local.set 18 + br 12 (;@1;) + end + block ;; label = @13 + block ;; label = @14 + block ;; label = @15 + local.get 4 + i32.load offset=4 + local.tee 1 + br_if 0 (;@15;) + i32.const 1 + local.set 1 + br 1 (;@14;) + end + local.get 3 + i32.const 8 + i32.add + local.get 1 + local.get 2 + call $pop_arg + block ;; label = @15 + local.get 4 + i32.load offset=8 + local.tee 1 + br_if 0 (;@15;) + i32.const 2 + local.set 1 + br 1 (;@14;) + end + local.get 3 + i32.const 16 + i32.add + local.get 1 + local.get 2 + call $pop_arg + block ;; label = @15 + local.get 4 + i32.load offset=12 + local.tee 1 + br_if 0 (;@15;) + i32.const 3 + local.set 1 + br 1 (;@14;) + end + local.get 3 + i32.const 24 + i32.add + local.get 1 + local.get 2 + call $pop_arg + block ;; label = @15 + local.get 4 + i32.load offset=16 + local.tee 1 + br_if 0 (;@15;) + i32.const 4 + local.set 1 + br 1 (;@14;) + end + local.get 3 + i32.const 32 + i32.add + local.get 1 + local.get 2 + call $pop_arg + block ;; label = @15 + local.get 4 + i32.load offset=20 + local.tee 1 + br_if 0 (;@15;) + i32.const 5 + local.set 1 + br 1 (;@14;) + end + local.get 3 + i32.const 40 + i32.add + local.get 1 + local.get 2 + call $pop_arg + block ;; label = @15 + local.get 4 + i32.load offset=24 + local.tee 1 + br_if 0 (;@15;) + i32.const 6 + local.set 1 + br 1 (;@14;) + end + local.get 3 + i32.const 48 + i32.add + local.get 1 + local.get 2 + call $pop_arg + block ;; label = @15 + local.get 4 + i32.load offset=28 + local.tee 1 + br_if 0 (;@15;) + i32.const 7 + local.set 1 + br 1 (;@14;) + end + local.get 3 + i32.const 56 + i32.add + local.get 1 + local.get 2 + call $pop_arg + block ;; label = @15 + local.get 4 + i32.load offset=32 + local.tee 1 + br_if 0 (;@15;) + i32.const 8 + local.set 1 + br 1 (;@14;) + end + local.get 3 + i32.const 64 + i32.add + local.get 1 + local.get 2 + call $pop_arg + local.get 4 + i32.load offset=36 + local.tee 1 + br_if 1 (;@13;) + i32.const 9 + local.set 1 + end + local.get 1 + i32.const 2 + i32.shl + local.set 1 + loop ;; label = @14 + local.get 4 + local.get 1 + i32.add + i32.load + br_if 3 (;@11;) + local.get 1 + i32.const 4 + i32.add + local.tee 1 + i32.const 40 + i32.ne + br_if 0 (;@14;) + end + i32.const 1 + local.set 18 + br 12 (;@1;) + end + local.get 3 + i32.const 72 + i32.add + local.get 1 + local.get 2 + call $pop_arg + i32.const 1 + local.set 18 + br 11 (;@1;) + end + i32.const 0 + local.set 19 + i32.const -1 + local.set 24 + block ;; label = @12 + block ;; label = @13 + local.get 22 + i32.load8_u + i32.const 46 + i32.eq + br_if 0 (;@13;) + local.get 22 + local.set 1 + i32.const 0 + local.set 27 + br 1 (;@12;) + end + block ;; label = @13 + local.get 22 + i32.load8_s offset=1 + local.tee 24 + i32.const 42 + i32.ne + br_if 0 (;@13;) + block ;; label = @14 + local.get 22 + i32.load8_s offset=2 + i32.const -48 + i32.add + local.tee 1 + i32.const 9 + i32.gt_u + br_if 0 (;@14;) + local.get 22 + i32.load8_u offset=3 + i32.const 36 + i32.ne + br_if 0 (;@14;) + local.get 4 + local.get 1 + i32.const 2 + i32.shl + i32.add + i32.const 10 + i32.store + local.get 22 + i32.const 4 + i32.add + local.set 1 + local.get 6 + local.get 22 + i32.load8_s offset=2 + i32.const 3 + i32.shl + i32.add + i32.load + local.tee 24 + i32.const -1 + i32.gt_s + local.set 27 + br 2 (;@12;) + end + local.get 17 + br_if 2 (;@11;) + local.get 22 + i32.const 2 + i32.add + local.set 1 + block ;; label = @14 + local.get 0 + br_if 0 (;@14;) + i32.const 0 + local.set 24 + i32.const 0 + i32.const -1 + i32.gt_s + local.set 27 + br 2 (;@12;) + end + local.get 2 + local.get 2 + i32.load + local.tee 22 + i32.const 4 + i32.add + i32.store + local.get 22 + i32.load + local.tee 24 + i32.const -1 + i32.gt_s + local.set 27 + br 1 (;@12;) + end + local.get 22 + i32.const 1 + i32.add + local.set 1 + block ;; label = @13 + local.get 24 + i32.const -48 + i32.add + local.tee 28 + i32.const 9 + i32.le_u + br_if 0 (;@13;) + i32.const 1 + local.set 27 + i32.const 0 + local.set 24 + br 1 (;@12;) + end + i32.const 0 + local.set 29 + local.get 1 + local.set 22 + loop ;; label = @13 + i32.const -1 + local.set 24 + block ;; label = @14 + local.get 29 + i32.const 214748364 + i32.gt_u + br_if 0 (;@14;) + i32.const -1 + local.get 29 + i32.const 10 + i32.mul + local.tee 1 + local.get 28 + i32.add + local.get 28 + local.get 1 + i32.const 2147483647 + i32.xor + i32.gt_u + select + local.set 24 + end + i32.const 1 + local.set 27 + local.get 22 + i32.load8_s offset=1 + local.set 28 + local.get 24 + local.set 29 + local.get 22 + i32.const 1 + i32.add + local.tee 1 + local.set 22 + local.get 28 + i32.const -48 + i32.add + local.tee 28 + i32.const 10 + i32.lt_u + br_if 0 (;@13;) + end + end + loop ;; label = @12 + local.get 19 + local.set 22 + local.get 1 + i32.load8_s + local.tee 19 + i32.const -123 + i32.add + i32.const -58 + i32.lt_u + br_if 1 (;@11;) + local.get 1 + i32.const 1 + i32.add + local.set 1 + local.get 19 + local.get 22 + i32.const 58 + i32.mul + i32.add + i32.const 3103 + i32.add + i32.load8_u + local.tee 19 + i32.const -1 + i32.add + i32.const 8 + i32.lt_u + br_if 0 (;@12;) + end + block ;; label = @12 + block ;; label = @13 + block ;; label = @14 + local.get 19 + i32.const 27 + i32.eq + br_if 0 (;@14;) + local.get 19 + i32.eqz + br_if 3 (;@11;) + block ;; label = @15 + local.get 23 + i32.const 0 + i32.lt_s + br_if 0 (;@15;) + local.get 4 + local.get 23 + i32.const 2 + i32.shl + i32.add + local.get 19 + i32.store + local.get 5 + local.get 3 + local.get 23 + i32.const 3 + i32.shl + i32.add + i64.load + i64.store offset=56 + br 2 (;@13;) + end + block ;; label = @15 + local.get 0 + br_if 0 (;@15;) + i32.const 0 + local.set 18 + br 14 (;@1;) + end + local.get 5 + i32.const 56 + i32.add + local.get 19 + local.get 2 + call $pop_arg + br 2 (;@12;) + end + local.get 23 + i32.const -1 + i32.gt_s + br_if 2 (;@11;) + end + i32.const 0 + local.set 19 + local.get 0 + i32.eqz + br_if 8 (;@4;) + end + local.get 25 + i32.const -65537 + i32.and + local.tee 29 + local.get 25 + local.get 25 + i32.const 8192 + i32.and + select + local.set 30 + block ;; label = @12 + block ;; label = @13 + block ;; label = @14 + block ;; label = @15 + block ;; label = @16 + block ;; label = @17 + block ;; label = @18 + block ;; label = @19 + block ;; label = @20 + block ;; label = @21 + block ;; label = @22 + block ;; label = @23 + block ;; label = @24 + block ;; label = @25 + block ;; label = @26 + block ;; label = @27 + block ;; label = @28 + local.get 1 + i32.const -1 + i32.add + i32.load8_s + local.tee 19 + i32.const -45 + i32.and + local.get 19 + local.get 19 + i32.const 15 + i32.and + i32.const 3 + i32.eq + select + local.get 19 + local.get 22 + select + local.tee 31 + i32.const -65 + i32.add + br_table 16 (;@12;) 18 (;@10;) 13 (;@15;) 18 (;@10;) 16 (;@12;) 16 (;@12;) 16 (;@12;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 12 (;@16;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 3 (;@25;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 16 (;@12;) 18 (;@10;) 8 (;@20;) 5 (;@23;) 16 (;@12;) 16 (;@12;) 16 (;@12;) 18 (;@10;) 5 (;@23;) 18 (;@10;) 18 (;@10;) 18 (;@10;) 9 (;@19;) 1 (;@27;) 4 (;@24;) 2 (;@26;) 18 (;@10;) 18 (;@10;) 10 (;@18;) 18 (;@10;) 0 (;@28;) 18 (;@10;) 18 (;@10;) 3 (;@25;) 18 (;@10;) + end + i32.const 0 + local.set 28 + i32.const 1024 + local.set 23 + local.get 5 + i64.load offset=56 + local.set 32 + br 5 (;@22;) + end + i32.const 0 + local.set 19 + block ;; label = @27 + block ;; label = @28 + block ;; label = @29 + block ;; label = @30 + block ;; label = @31 + block ;; label = @32 + block ;; label = @33 + local.get 22 + i32.const 255 + i32.and + br_table 0 (;@33;) 1 (;@32;) 2 (;@31;) 3 (;@30;) 4 (;@29;) 29 (;@4;) 5 (;@28;) 6 (;@27;) 29 (;@4;) + end + local.get 5 + i32.load offset=56 + local.get 18 + i32.store + br 28 (;@4;) + end + local.get 5 + i32.load offset=56 + local.get 18 + i32.store + br 27 (;@4;) + end + local.get 5 + i32.load offset=56 + local.get 18 + i64.extend_i32_s + i64.store + br 26 (;@4;) + end + local.get 5 + i32.load offset=56 + local.get 18 + i32.store16 + br 25 (;@4;) + end + local.get 5 + i32.load offset=56 + local.get 18 + i32.store8 + br 24 (;@4;) + end + local.get 5 + i32.load offset=56 + local.get 18 + i32.store + br 23 (;@4;) + end + local.get 5 + i32.load offset=56 + local.get 18 + i64.extend_i32_s + i64.store + br 22 (;@4;) + end + local.get 24 + i32.const 8 + local.get 24 + i32.const 8 + i32.gt_u + select + local.set 24 + local.get 30 + i32.const 8 + i32.or + local.set 30 + i32.const 120 + local.set 31 + end + i32.const 0 + local.set 28 + i32.const 1024 + local.set 23 + block ;; label = @25 + local.get 5 + i64.load offset=56 + local.tee 32 + i64.eqz + i32.eqz + br_if 0 (;@25;) + local.get 16 + local.set 20 + br 4 (;@21;) + end + local.get 31 + i32.const 32 + i32.and + local.set 22 + local.get 16 + local.set 20 + loop ;; label = @25 + local.get 20 + i32.const -1 + i32.add + local.tee 20 + local.get 32 + i32.wrap_i64 + i32.const 15 + i32.and + i32.const 3632 + i32.add + i32.load8_u + local.get 22 + i32.or + i32.store8 + local.get 32 + i64.const 15 + i64.gt_u + local.set 19 + local.get 32 + i64.const 4 + i64.shr_u + local.set 32 + local.get 19 + br_if 0 (;@25;) + end + local.get 30 + i32.const 8 + i32.and + i32.eqz + br_if 3 (;@21;) + local.get 31 + i32.const 4 + i32.shr_s + i32.const 1024 + i32.add + local.set 23 + i32.const 2 + local.set 28 + br 3 (;@21;) + end + local.get 16 + local.set 20 + block ;; label = @24 + local.get 5 + i64.load offset=56 + local.tee 32 + i64.eqz + br_if 0 (;@24;) + local.get 16 + local.set 20 + loop ;; label = @25 + local.get 20 + i32.const -1 + i32.add + local.tee 20 + local.get 32 + i32.wrap_i64 + i32.const 7 + i32.and + i32.const 48 + i32.or + i32.store8 + local.get 32 + i64.const 7 + i64.gt_u + local.set 19 + local.get 32 + i64.const 3 + i64.shr_u + local.set 32 + local.get 19 + br_if 0 (;@25;) + end + end + i32.const 0 + local.set 28 + i32.const 1024 + local.set 23 + local.get 30 + i32.const 8 + i32.and + i32.eqz + br_if 2 (;@21;) + local.get 24 + local.get 16 + local.get 20 + i32.sub + local.tee 19 + i32.const 1 + i32.add + local.get 24 + local.get 19 + i32.gt_s + select + local.set 24 + br 2 (;@21;) + end + block ;; label = @23 + local.get 5 + i64.load offset=56 + local.tee 32 + i64.const -1 + i64.gt_s + br_if 0 (;@23;) + local.get 5 + i64.const 0 + local.get 32 + i64.sub + local.tee 32 + i64.store offset=56 + i32.const 1 + local.set 28 + i32.const 1024 + local.set 23 + br 1 (;@22;) + end + block ;; label = @23 + local.get 30 + i32.const 2048 + i32.and + i32.eqz + br_if 0 (;@23;) + i32.const 1 + local.set 28 + i32.const 1025 + local.set 23 + br 1 (;@22;) + end + i32.const 1026 + i32.const 1024 + local.get 30 + i32.const 1 + i32.and + local.tee 28 + select + local.set 23 + end + block ;; label = @22 + block ;; label = @23 + local.get 32 + i64.const 4294967296 + i64.ge_u + br_if 0 (;@23;) + local.get 32 + local.set 33 + local.get 16 + local.set 20 + br 1 (;@22;) + end + local.get 16 + local.set 20 + loop ;; label = @23 + local.get 20 + i32.const -1 + i32.add + local.tee 20 + local.get 32 + local.get 32 + i64.const 10 + i64.div_u + local.tee 33 + i64.const 10 + i64.mul + i64.sub + i32.wrap_i64 + i32.const 48 + i32.or + i32.store8 + local.get 32 + i64.const 42949672959 + i64.gt_u + local.set 19 + local.get 33 + local.set 32 + local.get 19 + br_if 0 (;@23;) + end + end + local.get 33 + i32.wrap_i64 + local.tee 19 + i32.eqz + br_if 0 (;@21;) + loop ;; label = @22 + local.get 20 + i32.const -1 + i32.add + local.tee 20 + local.get 19 + local.get 19 + i32.const 10 + i32.div_u + local.tee 22 + i32.const 10 + i32.mul + i32.sub + i32.const 48 + i32.or + i32.store8 + local.get 19 + i32.const 9 + i32.gt_u + local.set 25 + local.get 22 + local.set 19 + local.get 25 + br_if 0 (;@22;) + end + end + local.get 27 + local.get 24 + i32.const 0 + i32.lt_s + i32.and + br_if 17 (;@3;) + local.get 30 + i32.const -65537 + i32.and + local.get 30 + local.get 27 + select + local.set 29 + block ;; label = @21 + local.get 5 + i64.load offset=56 + local.tee 32 + i64.const 0 + i64.ne + br_if 0 (;@21;) + i32.const 0 + local.set 25 + local.get 24 + br_if 0 (;@21;) + local.get 16 + local.set 20 + local.get 16 + local.set 19 + br 12 (;@9;) + end + local.get 24 + local.get 16 + local.get 20 + i32.sub + local.get 32 + i64.eqz + i32.add + local.tee 19 + local.get 24 + local.get 19 + i32.gt_s + select + local.set 25 + local.get 16 + local.set 19 + br 11 (;@9;) + end + local.get 5 + local.get 5 + i64.load offset=56 + i64.store8 offset=55 + i32.const 0 + local.set 28 + i32.const 1024 + local.set 23 + i32.const 1 + local.set 25 + local.get 10 + local.set 20 + local.get 16 + local.set 19 + br 10 (;@9;) + end + i32.const 1692992 + i32.load + call $strerror + local.set 20 + br 1 (;@17;) + end + local.get 5 + i32.load offset=56 + local.tee 19 + i32.const 1168 + local.get 19 + select + local.set 20 + end + local.get 20 + local.get 20 + local.get 24 + i32.const 2147483647 + local.get 24 + i32.const 2147483647 + i32.lt_u + select + call $strnlen + local.tee 25 + i32.add + local.set 19 + i32.const 0 + local.set 28 + i32.const 1024 + local.set 23 + local.get 24 + i32.const -1 + i32.gt_s + br_if 7 (;@9;) + local.get 19 + i32.load8_u + i32.eqz + br_if 7 (;@9;) + br 13 (;@3;) + end + local.get 5 + i32.load offset=56 + local.set 20 + local.get 24 + br_if 1 (;@14;) + i32.const 0 + local.set 19 + br 2 (;@13;) + end + local.get 5 + i32.const 0 + i32.store offset=12 + local.get 5 + local.get 5 + i64.load offset=56 + i64.store32 offset=8 + local.get 5 + local.get 5 + i32.const 8 + i32.add + i32.store offset=56 + local.get 5 + i32.const 8 + i32.add + local.set 20 + i32.const -1 + local.set 24 + end + i32.const 0 + local.set 19 + local.get 20 + local.set 21 + block ;; label = @14 + loop ;; label = @15 + local.get 21 + i32.load + local.tee 22 + i32.eqz + br_if 1 (;@14;) + local.get 5 + i32.const 4 + i32.add + local.get 22 + call $wctomb + local.tee 22 + i32.const 0 + i32.lt_s + br_if 13 (;@2;) + local.get 22 + local.get 24 + local.get 19 + i32.sub + i32.gt_u + br_if 1 (;@14;) + local.get 21 + i32.const 4 + i32.add + local.set 21 + local.get 22 + local.get 19 + i32.add + local.tee 19 + local.get 24 + i32.lt_u + br_if 0 (;@15;) + end + end + local.get 19 + i32.const 0 + i32.lt_s + br_if 10 (;@3;) + end + block ;; label = @13 + local.get 30 + i32.const 73728 + i32.and + local.tee 25 + br_if 0 (;@13;) + local.get 26 + local.get 19 + i32.le_s + br_if 0 (;@13;) + local.get 5 + i32.const 112 + i32.add + i32.const 32 + local.get 26 + local.get 19 + i32.sub + local.tee 21 + i32.const 256 + local.get 21 + i32.const 256 + i32.lt_u + local.tee 22 + select + call $memset + drop + block ;; label = @14 + local.get 22 + br_if 0 (;@14;) + loop ;; label = @15 + block ;; label = @16 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@16;) + local.get 5 + i32.const 112 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 21 + i32.const -256 + i32.add + local.tee 21 + i32.const 255 + i32.gt_u + br_if 0 (;@15;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@13;) + local.get 5 + i32.const 112 + i32.add + local.get 21 + local.get 0 + call $__fwritex + drop + end + block ;; label = @13 + local.get 19 + i32.eqz + br_if 0 (;@13;) + i32.const 0 + local.set 21 + loop ;; label = @14 + local.get 20 + i32.load + local.tee 22 + i32.eqz + br_if 1 (;@13;) + local.get 5 + i32.const 4 + i32.add + local.get 22 + call $wctomb + local.tee 22 + local.get 21 + i32.add + local.tee 21 + local.get 19 + i32.gt_u + br_if 1 (;@13;) + block ;; label = @15 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@15;) + local.get 5 + i32.const 4 + i32.add + local.get 22 + local.get 0 + call $__fwritex + drop + end + local.get 20 + i32.const 4 + i32.add + local.set 20 + local.get 21 + local.get 19 + i32.lt_u + br_if 0 (;@14;) + end + end + block ;; label = @13 + local.get 25 + i32.const 8192 + i32.ne + br_if 0 (;@13;) + local.get 26 + local.get 19 + i32.le_s + br_if 0 (;@13;) + local.get 5 + i32.const 112 + i32.add + i32.const 32 + local.get 26 + local.get 19 + i32.sub + local.tee 21 + i32.const 256 + local.get 21 + i32.const 256 + i32.lt_u + local.tee 22 + select + call $memset + drop + block ;; label = @14 + local.get 22 + br_if 0 (;@14;) + loop ;; label = @15 + block ;; label = @16 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@16;) + local.get 5 + i32.const 112 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 21 + i32.const -256 + i32.add + local.tee 21 + i32.const 255 + i32.gt_u + br_if 0 (;@15;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@13;) + local.get 5 + i32.const 112 + i32.add + local.get 21 + local.get 0 + call $__fwritex + drop + end + local.get 26 + local.get 19 + local.get 26 + local.get 19 + i32.gt_s + select + local.set 19 + br 8 (;@4;) + end + local.get 27 + local.get 24 + i32.const 0 + i32.lt_s + local.tee 19 + i32.and + br_if 8 (;@3;) + local.get 5 + f64.load offset=56 + local.set 34 + local.get 5 + i32.const 0 + i32.store offset=108 + block ;; label = @12 + block ;; label = @13 + local.get 34 + i64.reinterpret_f64 + i64.const -1 + i64.gt_s + br_if 0 (;@13;) + local.get 34 + f64.neg + local.set 34 + i32.const 1 + local.set 35 + i32.const 0 + local.set 36 + i32.const 1034 + local.set 37 + br 1 (;@12;) + end + block ;; label = @13 + local.get 30 + i32.const 2048 + i32.and + i32.eqz + br_if 0 (;@13;) + i32.const 1 + local.set 35 + i32.const 0 + local.set 36 + i32.const 1037 + local.set 37 + br 1 (;@12;) + end + i32.const 1040 + i32.const 1035 + local.get 30 + i32.const 1 + i32.and + local.tee 35 + select + local.set 37 + local.get 35 + i32.eqz + local.set 36 + end + block ;; label = @12 + local.get 34 + f64.abs + f64.const inf (;=inf;) + f64.lt + br_if 0 (;@12;) + local.get 35 + i32.const 3 + i32.add + local.set 21 + block ;; label = @13 + local.get 30 + i32.const 8192 + i32.and + br_if 0 (;@13;) + local.get 26 + local.get 21 + i32.le_s + br_if 0 (;@13;) + local.get 5 + i32.const 624 + i32.add + i32.const 32 + local.get 26 + local.get 21 + i32.sub + local.tee 19 + i32.const 256 + local.get 19 + i32.const 256 + i32.lt_u + local.tee 22 + select + call $memset + drop + block ;; label = @14 + local.get 22 + br_if 0 (;@14;) + loop ;; label = @15 + block ;; label = @16 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@16;) + local.get 5 + i32.const 624 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 19 + i32.const -256 + i32.add + local.tee 19 + i32.const 255 + i32.gt_u + br_if 0 (;@15;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@13;) + local.get 5 + i32.const 624 + i32.add + local.get 19 + local.get 0 + call $__fwritex + drop + end + block ;; label = @13 + local.get 0 + i32.load + local.tee 19 + i32.const 32 + i32.and + br_if 0 (;@13;) + local.get 37 + local.get 35 + local.get 0 + call $__fwritex + drop + local.get 0 + i32.load + local.set 19 + end + block ;; label = @13 + local.get 19 + i32.const 32 + i32.and + br_if 0 (;@13;) + i32.const 1083 + i32.const 1158 + local.get 31 + i32.const 32 + i32.and + local.tee 19 + select + i32.const 1087 + i32.const 1162 + local.get 19 + select + local.get 34 + local.get 34 + f64.ne + select + i32.const 3 + local.get 0 + call $__fwritex + drop + end + block ;; label = @13 + local.get 30 + i32.const 73728 + i32.and + i32.const 8192 + i32.ne + br_if 0 (;@13;) + local.get 26 + local.get 21 + i32.le_s + br_if 0 (;@13;) + local.get 5 + i32.const 624 + i32.add + i32.const 32 + local.get 26 + local.get 21 + i32.sub + local.tee 19 + i32.const 256 + local.get 19 + i32.const 256 + i32.lt_u + local.tee 22 + select + call $memset + drop + block ;; label = @14 + local.get 22 + br_if 0 (;@14;) + loop ;; label = @15 + block ;; label = @16 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@16;) + local.get 5 + i32.const 624 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 19 + i32.const -256 + i32.add + local.tee 19 + i32.const 255 + i32.gt_u + br_if 0 (;@15;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@13;) + local.get 5 + i32.const 624 + i32.add + local.get 19 + local.get 0 + call $__fwritex + drop + end + local.get 21 + local.get 26 + local.get 21 + local.get 26 + i32.gt_s + select + local.set 19 + br 8 (;@4;) + end + block ;; label = @12 + block ;; label = @13 + block ;; label = @14 + local.get 34 + local.get 5 + i32.const 108 + i32.add + call $frexp + local.tee 34 + local.get 34 + f64.add + local.tee 34 + f64.const 0x0p+0 (;=0;) + f64.eq + br_if 0 (;@14;) + local.get 5 + local.get 5 + i32.load offset=108 + local.tee 21 + i32.const -1 + i32.add + i32.store offset=108 + local.get 31 + i32.const 32 + i32.or + local.tee 38 + i32.const 97 + i32.ne + br_if 1 (;@13;) + br 8 (;@6;) + end + local.get 31 + i32.const 32 + i32.or + local.tee 38 + i32.const 97 + i32.eq + br_if 7 (;@6;) + i32.const 6 + local.get 24 + local.get 19 + select + local.set 27 + local.get 5 + i32.load offset=108 + local.set 20 + br 1 (;@12;) + end + local.get 5 + local.get 21 + i32.const -29 + i32.add + local.tee 20 + i32.store offset=108 + i32.const 6 + local.get 24 + local.get 19 + select + local.set 27 + local.get 34 + f64.const 0x1p+28 (;=2.68435e+08;) + f64.mul + local.set 34 + end + local.get 5 + i32.const 112 + i32.add + i32.const 0 + i32.const 72 + local.get 20 + i32.const 0 + i32.lt_s + local.tee 39 + select + i32.const 2 + i32.shl + local.tee 40 + i32.add + local.tee 23 + local.set 21 + loop ;; label = @12 + block ;; label = @13 + block ;; label = @14 + local.get 34 + f64.const 0x1p+32 (;=4.29497e+09;) + f64.lt + local.get 34 + f64.const 0x0p+0 (;=0;) + f64.ge + i32.and + i32.eqz + br_if 0 (;@14;) + local.get 34 + i32.trunc_f64_u + local.set 19 + br 1 (;@13;) + end + i32.const 0 + local.set 19 + end + local.get 21 + local.get 19 + i32.store + local.get 21 + i32.const 4 + i32.add + local.set 21 + local.get 34 + local.get 19 + f64.convert_i32_u + f64.sub + f64.const 0x1.dcd65p+29 (;=1e+09;) + f64.mul + local.tee 34 + f64.const 0x0p+0 (;=0;) + f64.ne + br_if 0 (;@12;) + end + block ;; label = @12 + block ;; label = @13 + local.get 20 + i32.const 1 + i32.ge_s + br_if 0 (;@13;) + local.get 21 + local.set 19 + local.get 23 + local.set 22 + br 1 (;@12;) + end + local.get 23 + local.set 22 + loop ;; label = @13 + local.get 20 + i32.const 29 + local.get 20 + i32.const 29 + i32.lt_s + select + local.set 20 + block ;; label = @14 + local.get 21 + i32.const -4 + i32.add + local.tee 19 + local.get 22 + i32.lt_u + br_if 0 (;@14;) + local.get 20 + i64.extend_i32_u + local.set 33 + i64.const 0 + local.set 32 + loop ;; label = @15 + local.get 19 + local.get 19 + i64.load32_u + local.get 33 + i64.shl + local.get 32 + i64.const 4294967295 + i64.and + i64.add + local.tee 32 + local.get 32 + i64.const 1000000000 + i64.div_u + local.tee 32 + i64.const 1000000000 + i64.mul + i64.sub + i64.store32 + local.get 19 + i32.const -4 + i32.add + local.tee 19 + local.get 22 + i32.ge_u + br_if 0 (;@15;) + end + local.get 32 + i32.wrap_i64 + local.tee 19 + i32.eqz + br_if 0 (;@14;) + local.get 22 + i32.const -4 + i32.add + local.tee 22 + local.get 19 + i32.store + end + block ;; label = @14 + loop ;; label = @15 + local.get 21 + local.tee 19 + local.get 22 + i32.le_u + br_if 1 (;@14;) + local.get 19 + i32.const -4 + i32.add + local.tee 21 + i32.load + i32.eqz + br_if 0 (;@15;) + end + end + local.get 5 + local.get 5 + i32.load offset=108 + local.get 20 + i32.sub + local.tee 20 + i32.store offset=108 + local.get 19 + local.set 21 + local.get 20 + i32.const 0 + i32.gt_s + br_if 0 (;@13;) + end + end + block ;; label = @12 + local.get 20 + i32.const -1 + i32.gt_s + br_if 0 (;@12;) + local.get 27 + i32.const 25 + i32.add + i32.const 9 + i32.div_u + i32.const 1 + i32.add + local.set 41 + local.get 38 + i32.const 102 + i32.eq + local.set 42 + loop ;; label = @13 + i32.const 0 + local.get 20 + i32.sub + local.tee 21 + i32.const 9 + local.get 21 + i32.const 9 + i32.lt_s + select + local.set 24 + block ;; label = @14 + block ;; label = @15 + local.get 22 + local.get 19 + i32.lt_u + br_if 0 (;@15;) + local.get 22 + i32.load + local.set 21 + br 1 (;@14;) + end + i32.const 1000000000 + local.get 24 + i32.shr_u + local.set 29 + i32.const -1 + local.get 24 + i32.shl + i32.const -1 + i32.xor + local.set 28 + i32.const 0 + local.set 20 + local.get 22 + local.set 21 + loop ;; label = @15 + local.get 21 + local.get 21 + i32.load + local.tee 25 + local.get 24 + i32.shr_u + local.get 20 + i32.add + i32.store + local.get 25 + local.get 28 + i32.and + local.get 29 + i32.mul + local.set 20 + local.get 21 + i32.const 4 + i32.add + local.tee 21 + local.get 19 + i32.lt_u + br_if 0 (;@15;) + end + local.get 22 + i32.load + local.set 21 + local.get 20 + i32.eqz + br_if 0 (;@14;) + local.get 19 + local.get 20 + i32.store + local.get 19 + i32.const 4 + i32.add + local.set 19 + end + local.get 5 + local.get 5 + i32.load offset=108 + local.get 24 + i32.add + local.tee 20 + i32.store offset=108 + local.get 23 + local.get 22 + local.get 21 + i32.eqz + i32.const 2 + i32.shl + i32.add + local.tee 22 + local.get 42 + select + local.tee 21 + local.get 41 + i32.const 2 + i32.shl + i32.add + local.get 19 + local.get 19 + local.get 21 + i32.sub + i32.const 2 + i32.shr_s + local.get 41 + i32.gt_s + select + local.set 19 + local.get 20 + i32.const 0 + i32.lt_s + br_if 0 (;@13;) + end + end + i32.const 0 + local.set 25 + block ;; label = @12 + local.get 22 + local.get 19 + i32.ge_u + br_if 0 (;@12;) + local.get 23 + local.get 22 + i32.sub + i32.const 2 + i32.shr_s + i32.const 9 + i32.mul + local.set 25 + local.get 22 + i32.load + local.tee 20 + i32.const 10 + i32.lt_u + br_if 0 (;@12;) + i32.const 10 + local.set 21 + loop ;; label = @13 + local.get 25 + i32.const 1 + i32.add + local.set 25 + local.get 20 + local.get 21 + i32.const 10 + i32.mul + local.tee 21 + i32.ge_u + br_if 0 (;@13;) + end + end + block ;; label = @12 + local.get 27 + i32.const 0 + local.get 25 + local.get 38 + i32.const 102 + i32.eq + select + i32.sub + local.get 27 + i32.const 0 + i32.ne + local.get 38 + i32.const 103 + i32.eq + local.tee 28 + i32.and + i32.sub + local.tee 21 + local.get 19 + local.get 23 + i32.sub + i32.const 2 + i32.shr_s + i32.const 9 + i32.mul + i32.const -9 + i32.add + i32.ge_s + br_if 0 (;@12;) + local.get 5 + i32.const 112 + i32.add + i32.const 1 + i32.const 73 + local.get 39 + select + i32.const 2 + i32.shl + local.tee 39 + i32.add + local.get 21 + i32.const 9216 + i32.add + local.tee 20 + i32.const 9 + i32.div_s + local.tee 24 + i32.const 2 + i32.shl + local.tee 43 + i32.add + local.tee 42 + i32.const -4096 + i32.add + local.set 29 + i32.const 10 + local.set 21 + block ;; label = @13 + local.get 20 + local.get 24 + i32.const 9 + i32.mul + i32.sub + local.tee 24 + i32.const 7 + i32.gt_s + br_if 0 (;@13;) + i32.const 8 + local.get 24 + i32.sub + local.tee 41 + i32.const 7 + i32.and + local.set 20 + i32.const 10 + local.set 21 + block ;; label = @14 + local.get 24 + i32.const -1 + i32.add + i32.const 7 + i32.lt_u + br_if 0 (;@14;) + local.get 41 + i32.const -8 + i32.and + local.set 24 + i32.const 10 + local.set 21 + loop ;; label = @15 + local.get 21 + i32.const 100000000 + i32.mul + local.set 21 + local.get 24 + i32.const -8 + i32.add + local.tee 24 + br_if 0 (;@15;) + end + end + local.get 20 + i32.eqz + br_if 0 (;@13;) + loop ;; label = @14 + local.get 21 + i32.const 10 + i32.mul + local.set 21 + local.get 20 + i32.const -1 + i32.add + local.tee 20 + br_if 0 (;@14;) + end + end + local.get 42 + i32.const -4092 + i32.add + local.set 41 + block ;; label = @13 + block ;; label = @14 + local.get 29 + i32.load + local.tee 20 + local.get 20 + local.get 21 + i32.div_u + local.tee 38 + local.get 21 + i32.mul + i32.sub + local.tee 24 + br_if 0 (;@14;) + local.get 41 + local.get 19 + i32.eq + br_if 1 (;@13;) + end + block ;; label = @14 + block ;; label = @15 + local.get 38 + i32.const 1 + i32.and + br_if 0 (;@15;) + f64.const 0x1p+53 (;=9.0072e+15;) + local.set 34 + local.get 21 + i32.const 1000000000 + i32.ne + br_if 1 (;@14;) + local.get 29 + local.get 22 + i32.le_u + br_if 1 (;@14;) + local.get 42 + i32.const -4100 + i32.add + i32.load8_u + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@14;) + end + f64.const 0x1.0000000000001p+53 (;=9.0072e+15;) + local.set 34 + end + f64.const 0x1p-1 (;=0.5;) + f64.const 0x1p+0 (;=1;) + f64.const 0x1.8p+0 (;=1.5;) + local.get 41 + local.get 19 + i32.eq + select + f64.const 0x1.8p+0 (;=1.5;) + local.get 24 + local.get 21 + i32.const 1 + i32.shr_u + local.tee 41 + i32.eq + select + local.get 24 + local.get 41 + i32.lt_u + select + local.set 44 + block ;; label = @14 + local.get 36 + br_if 0 (;@14;) + local.get 37 + i32.load8_u + i32.const 45 + i32.ne + br_if 0 (;@14;) + local.get 44 + f64.neg + local.set 44 + local.get 34 + f64.neg + local.set 34 + end + local.get 29 + local.get 20 + local.get 24 + i32.sub + local.tee 20 + i32.store + local.get 34 + local.get 44 + f64.add + local.get 34 + f64.eq + br_if 0 (;@13;) + local.get 29 + local.get 20 + local.get 21 + i32.add + local.tee 21 + i32.store + block ;; label = @14 + local.get 21 + i32.const 1000000000 + i32.lt_u + br_if 0 (;@14;) + local.get 9 + local.get 39 + local.get 43 + i32.add + i32.add + local.set 21 + loop ;; label = @15 + local.get 21 + i32.const 4 + i32.add + i32.const 0 + i32.store + block ;; label = @16 + local.get 21 + local.get 22 + i32.ge_u + br_if 0 (;@16;) + local.get 22 + i32.const -4 + i32.add + local.tee 22 + i32.const 0 + i32.store + end + local.get 21 + local.get 21 + i32.load + i32.const 1 + i32.add + local.tee 20 + i32.store + local.get 21 + i32.const -4 + i32.add + local.set 21 + local.get 20 + i32.const 999999999 + i32.gt_u + br_if 0 (;@15;) + end + local.get 21 + i32.const 4 + i32.add + local.set 29 + end + local.get 23 + local.get 22 + i32.sub + i32.const 2 + i32.shr_s + i32.const 9 + i32.mul + local.set 25 + local.get 22 + i32.load + local.tee 20 + i32.const 10 + i32.lt_u + br_if 0 (;@13;) + i32.const 10 + local.set 21 + loop ;; label = @14 + local.get 25 + i32.const 1 + i32.add + local.set 25 + local.get 20 + local.get 21 + i32.const 10 + i32.mul + local.tee 21 + i32.ge_u + br_if 0 (;@14;) + end + end + local.get 29 + i32.const 4 + i32.add + local.tee 21 + local.get 19 + local.get 19 + local.get 21 + i32.gt_u + select + local.set 19 + end + local.get 8 + local.get 19 + i32.add + local.get 40 + i32.sub + local.set 21 + block ;; label = @12 + loop ;; label = @13 + local.get 21 + local.set 20 + local.get 19 + local.tee 29 + local.get 22 + i32.le_u + local.tee 24 + br_if 1 (;@12;) + local.get 20 + i32.const -4 + i32.add + local.set 21 + local.get 29 + i32.const -4 + i32.add + local.tee 19 + i32.load + i32.eqz + br_if 0 (;@13;) + end + end + block ;; label = @12 + block ;; label = @13 + local.get 28 + br_if 0 (;@13;) + local.get 30 + i32.const 8 + i32.and + local.set 41 + br 1 (;@12;) + end + local.get 25 + i32.const -1 + i32.xor + i32.const -1 + local.get 27 + i32.const 1 + local.get 27 + select + local.tee 19 + local.get 25 + i32.gt_s + local.get 25 + i32.const -5 + i32.gt_s + i32.and + local.tee 21 + select + local.get 19 + i32.add + local.set 27 + i32.const -1 + i32.const -2 + local.get 21 + select + local.get 31 + i32.add + local.set 31 + local.get 30 + i32.const 8 + i32.and + local.tee 41 + br_if 0 (;@12;) + i32.const -9 + local.set 19 + block ;; label = @13 + local.get 24 + br_if 0 (;@13;) + local.get 29 + i32.const -4 + i32.add + i32.load + local.tee 24 + i32.eqz + br_if 0 (;@13;) + i32.const 0 + local.set 19 + local.get 24 + i32.const 10 + i32.rem_u + br_if 0 (;@13;) + i32.const 10 + local.set 21 + i32.const 0 + local.set 19 + loop ;; label = @14 + local.get 19 + i32.const -1 + i32.add + local.set 19 + local.get 24 + local.get 21 + i32.const 10 + i32.mul + local.tee 21 + i32.rem_u + i32.eqz + br_if 0 (;@14;) + end + end + local.get 20 + i32.const 2 + i32.shr_s + i32.const 9 + i32.mul + local.set 21 + block ;; label = @13 + local.get 31 + i32.const -33 + i32.and + i32.const 70 + i32.ne + br_if 0 (;@13;) + i32.const 0 + local.set 41 + local.get 27 + local.get 21 + local.get 19 + i32.add + i32.const -9 + i32.add + local.tee 19 + i32.const 0 + local.get 19 + i32.const 0 + i32.gt_s + select + local.tee 19 + local.get 27 + local.get 19 + i32.lt_s + select + local.set 27 + br 1 (;@12;) + end + i32.const 0 + local.set 41 + local.get 27 + local.get 25 + local.get 21 + i32.add + local.get 19 + i32.add + i32.const -9 + i32.add + local.tee 19 + i32.const 0 + local.get 19 + i32.const 0 + i32.gt_s + select + local.tee 19 + local.get 27 + local.get 19 + i32.lt_s + select + local.set 27 + end + local.get 27 + i32.const 2147483645 + i32.const 2147483646 + local.get 27 + local.get 41 + i32.or + local.tee 38 + select + i32.gt_s + br_if 8 (;@3;) + local.get 27 + local.get 38 + i32.const 0 + i32.ne + i32.add + i32.const 1 + i32.add + local.set 42 + block ;; label = @12 + block ;; label = @13 + local.get 31 + i32.const -33 + i32.and + i32.const 70 + i32.ne + local.tee 40 + br_if 0 (;@13;) + local.get 25 + local.get 42 + i32.const 2147483647 + i32.xor + i32.gt_s + br_if 10 (;@3;) + local.get 25 + i32.const 0 + local.get 25 + i32.const 0 + i32.gt_s + select + local.set 19 + br 1 (;@12;) + end + block ;; label = @13 + block ;; label = @14 + local.get 25 + br_if 0 (;@14;) + local.get 7 + local.set 20 + local.get 7 + local.set 21 + br 1 (;@13;) + end + local.get 25 + local.get 25 + i32.const 31 + i32.shr_s + local.tee 19 + i32.xor + local.get 19 + i32.sub + local.set 19 + local.get 7 + local.set 20 + local.get 7 + local.set 21 + loop ;; label = @14 + local.get 21 + i32.const -1 + i32.add + local.tee 21 + local.get 19 + local.get 19 + i32.const 10 + i32.div_u + local.tee 24 + i32.const 10 + i32.mul + i32.sub + i32.const 48 + i32.or + i32.store8 + local.get 20 + i32.const -1 + i32.add + local.set 20 + local.get 19 + i32.const 9 + i32.gt_u + local.set 28 + local.get 24 + local.set 19 + local.get 28 + br_if 0 (;@14;) + end + end + block ;; label = @13 + local.get 7 + local.get 20 + i32.sub + i32.const 1 + i32.gt_s + br_if 0 (;@13;) + local.get 21 + local.get 15 + local.get 20 + i32.sub + i32.add + local.tee 21 + i32.const 48 + local.get 20 + local.get 5 + i32.const 68 + i32.add + i32.sub + i32.const -10 + i32.add + call $memset + drop + end + local.get 21 + i32.const -2 + i32.add + local.tee 36 + local.get 31 + i32.store8 + local.get 21 + i32.const -1 + i32.add + i32.const 45 + i32.const 43 + local.get 25 + i32.const 0 + i32.lt_s + select + i32.store8 + local.get 7 + local.get 36 + i32.sub + local.tee 19 + local.get 42 + i32.const 2147483647 + i32.xor + i32.gt_s + br_if 9 (;@3;) + end + local.get 19 + local.get 42 + i32.add + local.tee 19 + local.get 35 + i32.const 2147483647 + i32.xor + i32.gt_s + br_if 8 (;@3;) + local.get 19 + local.get 35 + i32.add + local.set 28 + block ;; label = @12 + local.get 30 + i32.const 73728 + i32.and + local.tee 30 + br_if 0 (;@12;) + local.get 26 + local.get 28 + i32.le_s + br_if 0 (;@12;) + local.get 5 + i32.const 624 + i32.add + i32.const 32 + local.get 26 + local.get 28 + i32.sub + local.tee 19 + i32.const 256 + local.get 19 + i32.const 256 + i32.lt_u + local.tee 21 + select + call $memset + drop + block ;; label = @13 + local.get 21 + br_if 0 (;@13;) + loop ;; label = @14 + block ;; label = @15 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@15;) + local.get 5 + i32.const 624 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 19 + i32.const -256 + i32.add + local.tee 19 + i32.const 255 + i32.gt_u + br_if 0 (;@14;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@12;) + local.get 5 + i32.const 624 + i32.add + local.get 19 + local.get 0 + call $__fwritex + drop + end + block ;; label = @12 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@12;) + local.get 37 + local.get 35 + local.get 0 + call $__fwritex + drop + end + block ;; label = @12 + local.get 30 + i32.const 65536 + i32.ne + br_if 0 (;@12;) + local.get 26 + local.get 28 + i32.le_s + br_if 0 (;@12;) + local.get 5 + i32.const 624 + i32.add + i32.const 48 + local.get 26 + local.get 28 + i32.sub + local.tee 19 + i32.const 256 + local.get 19 + i32.const 256 + i32.lt_u + local.tee 21 + select + call $memset + drop + block ;; label = @13 + local.get 21 + br_if 0 (;@13;) + loop ;; label = @14 + block ;; label = @15 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@15;) + local.get 5 + i32.const 624 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 19 + i32.const -256 + i32.add + local.tee 19 + i32.const 255 + i32.gt_u + br_if 0 (;@14;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@12;) + local.get 5 + i32.const 624 + i32.add + local.get 19 + local.get 0 + call $__fwritex + drop + end + local.get 40 + br_if 3 (;@8;) + local.get 23 + local.get 22 + local.get 22 + local.get 23 + i32.gt_u + select + local.tee 25 + local.set 24 + loop ;; label = @12 + block ;; label = @13 + block ;; label = @14 + block ;; label = @15 + block ;; label = @16 + local.get 24 + i32.load + local.tee 19 + i32.eqz + br_if 0 (;@16;) + i32.const 8 + local.set 21 + loop ;; label = @17 + local.get 5 + i32.const 80 + i32.add + local.get 21 + i32.add + local.get 19 + local.get 19 + i32.const 10 + i32.div_u + local.tee 22 + i32.const 10 + i32.mul + i32.sub + i32.const 48 + i32.or + i32.store8 + local.get 21 + i32.const -1 + i32.add + local.set 21 + local.get 19 + i32.const 9 + i32.gt_u + local.set 20 + local.get 22 + local.set 19 + local.get 20 + br_if 0 (;@17;) + end + local.get 21 + i32.const 1 + i32.add + local.tee 22 + local.get 5 + i32.const 80 + i32.add + i32.add + local.set 19 + block ;; label = @17 + local.get 24 + local.get 25 + i32.eq + br_if 0 (;@17;) + local.get 21 + i32.const 2 + i32.add + i32.const 2 + i32.lt_s + br_if 4 (;@13;) + br 3 (;@14;) + end + local.get 21 + i32.const 8 + i32.ne + br_if 3 (;@13;) + br 1 (;@15;) + end + i32.const 9 + local.set 22 + local.get 24 + local.get 25 + i32.ne + br_if 1 (;@14;) + end + local.get 5 + i32.const 48 + i32.store8 offset=88 + local.get 13 + local.set 19 + br 1 (;@13;) + end + local.get 5 + i32.const 80 + i32.add + local.get 12 + local.get 22 + i32.add + local.tee 19 + local.get 5 + i32.const 80 + i32.add + local.get 19 + i32.lt_u + select + local.tee 19 + i32.const 48 + local.get 22 + local.get 5 + i32.const 80 + i32.add + i32.add + local.get 19 + i32.sub + call $memset + drop + end + block ;; label = @13 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@13;) + local.get 19 + local.get 14 + local.get 19 + i32.sub + local.get 0 + call $__fwritex + drop + end + local.get 24 + i32.const 4 + i32.add + local.tee 24 + local.get 23 + i32.le_u + br_if 0 (;@12;) + end + block ;; label = @12 + local.get 38 + i32.eqz + br_if 0 (;@12;) + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@12;) + i32.const 1166 + i32.const 1 + local.get 0 + call $__fwritex + drop + end + block ;; label = @12 + block ;; label = @13 + local.get 27 + i32.const 1 + i32.ge_s + br_if 0 (;@13;) + local.get 27 + local.set 19 + br 1 (;@12;) + end + block ;; label = @13 + local.get 24 + local.get 29 + i32.lt_u + br_if 0 (;@13;) + local.get 27 + local.set 19 + br 1 (;@12;) + end + loop ;; label = @13 + block ;; label = @14 + block ;; label = @15 + block ;; label = @16 + local.get 24 + i32.load + local.tee 19 + br_if 0 (;@16;) + local.get 14 + local.set 21 + local.get 14 + local.set 22 + br 1 (;@15;) + end + local.get 14 + local.set 22 + local.get 14 + local.set 21 + loop ;; label = @16 + local.get 21 + i32.const -1 + i32.add + local.tee 21 + local.get 19 + local.get 19 + i32.const 10 + i32.div_u + local.tee 20 + i32.const 10 + i32.mul + i32.sub + i32.const 48 + i32.or + i32.store8 + local.get 22 + i32.const -1 + i32.add + local.set 22 + local.get 19 + i32.const 9 + i32.gt_u + local.set 25 + local.get 20 + local.set 19 + local.get 25 + br_if 0 (;@16;) + end + local.get 21 + local.get 5 + i32.const 80 + i32.add + i32.le_u + br_if 1 (;@14;) + end + local.get 21 + local.get 5 + i32.const 80 + i32.add + i32.add + local.get 22 + i32.sub + local.tee 21 + i32.const 48 + local.get 22 + local.get 5 + i32.const 80 + i32.add + i32.sub + call $memset + drop + end + block ;; label = @14 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@14;) + local.get 21 + local.get 27 + i32.const 9 + local.get 27 + i32.const 9 + i32.lt_s + select + local.get 0 + call $__fwritex + drop + end + local.get 27 + i32.const -9 + i32.add + local.set 19 + local.get 24 + i32.const 4 + i32.add + local.tee 24 + local.get 29 + i32.ge_u + br_if 1 (;@12;) + local.get 27 + i32.const 9 + i32.gt_s + local.set 21 + local.get 19 + local.set 27 + local.get 21 + br_if 0 (;@13;) + end + end + local.get 0 + i32.const 48 + local.get 19 + i32.const 9 + i32.add + i32.const 9 + i32.const 0 + call $pad + br 4 (;@7;) + end + i32.const 1692992 + i32.const 28 + i32.store + br 8 (;@2;) + end + i32.const 0 + local.set 28 + i32.const 1024 + local.set 23 + local.get 16 + local.set 19 + local.get 30 + local.set 29 + local.get 24 + local.set 25 + end + local.get 25 + local.get 19 + local.get 20 + i32.sub + local.tee 24 + local.get 25 + local.get 24 + i32.gt_s + select + local.tee 27 + local.get 28 + i32.const 2147483647 + i32.xor + i32.gt_s + br_if 5 (;@3;) + local.get 26 + local.get 28 + local.get 27 + i32.add + local.tee 22 + local.get 26 + local.get 22 + i32.gt_s + select + local.tee 19 + local.get 21 + i32.gt_s + br_if 5 (;@3;) + block ;; label = @9 + local.get 29 + i32.const 73728 + i32.and + local.tee 29 + br_if 0 (;@9;) + local.get 26 + local.get 22 + i32.le_s + br_if 0 (;@9;) + local.get 5 + i32.const 112 + i32.add + i32.const 32 + local.get 19 + local.get 22 + i32.sub + local.tee 21 + i32.const 256 + local.get 21 + i32.const 256 + i32.lt_u + local.tee 30 + select + call $memset + drop + block ;; label = @10 + local.get 30 + br_if 0 (;@10;) + loop ;; label = @11 + block ;; label = @12 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@12;) + local.get 5 + i32.const 112 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 21 + i32.const -256 + i32.add + local.tee 21 + i32.const 255 + i32.gt_u + br_if 0 (;@11;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@9;) + local.get 5 + i32.const 112 + i32.add + local.get 21 + local.get 0 + call $__fwritex + drop + end + block ;; label = @9 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@9;) + local.get 23 + local.get 28 + local.get 0 + call $__fwritex + drop + end + block ;; label = @9 + local.get 29 + i32.const 65536 + i32.ne + br_if 0 (;@9;) + local.get 26 + local.get 22 + i32.le_s + br_if 0 (;@9;) + local.get 5 + i32.const 112 + i32.add + i32.const 48 + local.get 19 + local.get 22 + i32.sub + local.tee 21 + i32.const 256 + local.get 21 + i32.const 256 + i32.lt_u + local.tee 28 + select + call $memset + drop + block ;; label = @10 + local.get 28 + br_if 0 (;@10;) + loop ;; label = @11 + block ;; label = @12 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@12;) + local.get 5 + i32.const 112 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 21 + i32.const -256 + i32.add + local.tee 21 + i32.const 255 + i32.gt_u + br_if 0 (;@11;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@9;) + local.get 5 + i32.const 112 + i32.add + local.get 21 + local.get 0 + call $__fwritex + drop + end + block ;; label = @9 + local.get 25 + local.get 24 + i32.le_s + br_if 0 (;@9;) + local.get 5 + i32.const 112 + i32.add + i32.const 48 + local.get 27 + local.get 24 + i32.sub + local.tee 21 + i32.const 256 + local.get 21 + i32.const 256 + i32.lt_u + local.tee 25 + select + call $memset + drop + block ;; label = @10 + local.get 25 + br_if 0 (;@10;) + loop ;; label = @11 + block ;; label = @12 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@12;) + local.get 5 + i32.const 112 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 21 + i32.const -256 + i32.add + local.tee 21 + i32.const 255 + i32.gt_u + br_if 0 (;@11;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@9;) + local.get 5 + i32.const 112 + i32.add + local.get 21 + local.get 0 + call $__fwritex + drop + end + block ;; label = @9 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@9;) + local.get 20 + local.get 24 + local.get 0 + call $__fwritex + drop + end + local.get 29 + i32.const 8192 + i32.ne + br_if 4 (;@4;) + local.get 26 + local.get 22 + i32.le_s + br_if 4 (;@4;) + local.get 5 + i32.const 112 + i32.add + i32.const 32 + local.get 19 + local.get 22 + i32.sub + local.tee 21 + i32.const 256 + local.get 21 + i32.const 256 + i32.lt_u + local.tee 22 + select + call $memset + drop + block ;; label = @9 + local.get 22 + br_if 0 (;@9;) + loop ;; label = @10 + block ;; label = @11 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@11;) + local.get 5 + i32.const 112 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 21 + i32.const -256 + i32.add + local.tee 21 + i32.const 255 + i32.gt_u + br_if 0 (;@10;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 4 (;@4;) + local.get 5 + i32.const 112 + i32.add + local.get 21 + local.get 0 + call $__fwritex + drop + br 4 (;@4;) + end + block ;; label = @8 + local.get 27 + i32.const 0 + i32.lt_s + br_if 0 (;@8;) + local.get 29 + local.get 22 + i32.const 4 + i32.add + local.get 29 + local.get 22 + i32.gt_u + select + local.set 29 + local.get 22 + local.set 24 + loop ;; label = @9 + block ;; label = @10 + block ;; label = @11 + local.get 24 + i32.load + local.tee 19 + i32.eqz + br_if 0 (;@11;) + local.get 14 + local.set 21 + loop ;; label = @12 + local.get 21 + i32.const -1 + i32.add + local.tee 21 + local.get 19 + local.get 19 + i32.const 10 + i32.div_u + local.tee 20 + i32.const 10 + i32.mul + i32.sub + i32.const 48 + i32.or + i32.store8 + local.get 19 + i32.const 10 + i32.lt_u + local.set 25 + local.get 20 + local.set 19 + local.get 25 + i32.eqz + br_if 0 (;@12;) + br 2 (;@10;) + end + end + local.get 5 + i32.const 48 + i32.store8 offset=88 + local.get 13 + local.set 21 + end + block ;; label = @10 + block ;; label = @11 + local.get 24 + local.get 22 + i32.eq + br_if 0 (;@11;) + local.get 21 + local.get 5 + i32.const 80 + i32.add + i32.le_u + br_if 1 (;@10;) + local.get 5 + i32.const 80 + i32.add + i32.const 48 + local.get 21 + local.get 5 + i32.const 80 + i32.add + i32.sub + call $memset + drop + local.get 5 + i32.const 80 + i32.add + local.set 21 + br 1 (;@10;) + end + block ;; label = @11 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@11;) + local.get 21 + i32.const 1 + local.get 0 + call $__fwritex + drop + end + local.get 21 + i32.const 1 + i32.add + local.set 21 + block ;; label = @11 + local.get 41 + br_if 0 (;@11;) + local.get 27 + i32.const 1 + i32.lt_s + br_if 1 (;@10;) + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@10;) + i32.const 1166 + i32.const 1 + local.get 0 + call $__fwritex + drop + end + local.get 14 + local.get 21 + i32.sub + local.set 19 + block ;; label = @10 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@10;) + local.get 21 + local.get 19 + local.get 27 + local.get 19 + local.get 27 + i32.lt_s + select + local.get 0 + call $__fwritex + drop + end + local.get 27 + local.get 19 + i32.sub + local.set 27 + local.get 24 + i32.const 4 + i32.add + local.tee 24 + local.get 29 + i32.ge_u + br_if 1 (;@8;) + local.get 27 + i32.const -1 + i32.gt_s + br_if 0 (;@9;) + end + end + local.get 0 + i32.const 48 + local.get 27 + i32.const 18 + i32.add + i32.const 18 + i32.const 0 + call $pad + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@7;) + local.get 36 + local.get 7 + local.get 36 + i32.sub + local.get 0 + call $__fwritex + drop + end + local.get 30 + i32.const 8192 + i32.ne + br_if 1 (;@5;) + local.get 26 + local.get 28 + i32.le_s + br_if 1 (;@5;) + local.get 5 + i32.const 624 + i32.add + i32.const 32 + local.get 26 + local.get 28 + i32.sub + local.tee 19 + i32.const 256 + local.get 19 + i32.const 256 + i32.lt_u + local.tee 21 + select + call $memset + drop + block ;; label = @7 + local.get 21 + br_if 0 (;@7;) + loop ;; label = @8 + block ;; label = @9 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@9;) + local.get 5 + i32.const 624 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 19 + i32.const -256 + i32.add + local.tee 19 + i32.const 255 + i32.gt_u + br_if 0 (;@8;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 1 (;@5;) + local.get 5 + i32.const 624 + i32.add + local.get 19 + local.get 0 + call $__fwritex + drop + br 1 (;@5;) + end + local.get 37 + local.get 31 + i32.const 26 + i32.shl + i32.const 31 + i32.shr_s + i32.const 9 + i32.and + i32.add + local.set 23 + block ;; label = @6 + local.get 24 + i32.const 11 + i32.gt_u + br_if 0 (;@6;) + block ;; label = @7 + block ;; label = @8 + i32.const 12 + local.get 24 + i32.sub + local.tee 19 + i32.const 7 + i32.and + local.tee 21 + br_if 0 (;@8;) + f64.const 0x1p+4 (;=16;) + local.set 44 + br 1 (;@7;) + end + local.get 24 + i32.const -12 + i32.add + local.set 19 + f64.const 0x1p+4 (;=16;) + local.set 44 + loop ;; label = @8 + local.get 19 + i32.const 1 + i32.add + local.set 19 + local.get 44 + f64.const 0x1p+4 (;=16;) + f64.mul + local.set 44 + local.get 21 + i32.const -1 + i32.add + local.tee 21 + br_if 0 (;@8;) + end + i32.const 0 + local.get 19 + i32.sub + local.set 19 + end + block ;; label = @7 + local.get 24 + i32.const -5 + i32.add + i32.const 7 + i32.lt_u + br_if 0 (;@7;) + loop ;; label = @8 + local.get 44 + f64.const 0x1p+4 (;=16;) + f64.mul + f64.const 0x1p+4 (;=16;) + f64.mul + f64.const 0x1p+4 (;=16;) + f64.mul + f64.const 0x1p+4 (;=16;) + f64.mul + f64.const 0x1p+4 (;=16;) + f64.mul + f64.const 0x1p+4 (;=16;) + f64.mul + f64.const 0x1p+4 (;=16;) + f64.mul + f64.const 0x1p+4 (;=16;) + f64.mul + local.set 44 + local.get 19 + i32.const -8 + i32.add + local.tee 19 + br_if 0 (;@8;) + end + end + block ;; label = @7 + local.get 23 + i32.load8_u + i32.const 45 + i32.ne + br_if 0 (;@7;) + local.get 44 + local.get 34 + f64.neg + local.get 44 + f64.sub + f64.add + f64.neg + local.set 34 + br 1 (;@6;) + end + local.get 34 + local.get 44 + f64.add + local.get 44 + f64.sub + local.set 34 + end + block ;; label = @6 + block ;; label = @7 + local.get 5 + i32.load offset=108 + local.tee 25 + i32.eqz + br_if 0 (;@7;) + local.get 25 + local.get 25 + i32.const 31 + i32.shr_s + local.tee 19 + i32.xor + local.get 19 + i32.sub + local.set 19 + local.get 7 + local.set 21 + loop ;; label = @8 + local.get 21 + i32.const -1 + i32.add + local.tee 21 + local.get 19 + local.get 19 + i32.const 10 + i32.div_u + local.tee 22 + i32.const 10 + i32.mul + i32.sub + i32.const 48 + i32.or + i32.store8 + local.get 19 + i32.const 10 + i32.lt_u + local.set 20 + local.get 22 + local.set 19 + local.get 20 + i32.eqz + br_if 0 (;@8;) + br 2 (;@6;) + end + end + local.get 5 + i32.const 48 + i32.store8 offset=79 + local.get 11 + local.set 21 + end + local.get 35 + i32.const 2 + i32.or + local.set 29 + local.get 31 + i32.const 32 + i32.and + local.set 22 + local.get 21 + i32.const -2 + i32.add + local.tee 27 + local.get 31 + i32.const 15 + i32.add + i32.store8 + local.get 21 + i32.const -1 + i32.add + i32.const 45 + i32.const 43 + local.get 25 + i32.const 0 + i32.lt_s + select + i32.store8 + local.get 30 + i32.const 8 + i32.and + local.set 20 + local.get 5 + i32.const 80 + i32.add + local.set 21 + loop ;; label = @6 + local.get 21 + local.set 19 + block ;; label = @7 + block ;; label = @8 + local.get 34 + f64.abs + f64.const 0x1p+31 (;=2.14748e+09;) + f64.lt + i32.eqz + br_if 0 (;@8;) + local.get 34 + i32.trunc_f64_s + local.set 21 + br 1 (;@7;) + end + i32.const -2147483648 + local.set 21 + end + local.get 19 + local.get 21 + i32.const 3632 + i32.add + i32.load8_u + local.get 22 + i32.or + i32.store8 + local.get 34 + local.get 21 + f64.convert_i32_s + f64.sub + f64.const 0x1p+4 (;=16;) + f64.mul + local.set 34 + block ;; label = @7 + local.get 19 + i32.const 1 + i32.add + local.tee 21 + local.get 5 + i32.const 80 + i32.add + i32.sub + i32.const 1 + i32.ne + br_if 0 (;@7;) + block ;; label = @8 + local.get 20 + br_if 0 (;@8;) + local.get 24 + i32.const 0 + i32.gt_s + br_if 0 (;@8;) + local.get 34 + f64.const 0x0p+0 (;=0;) + f64.eq + br_if 1 (;@7;) + end + local.get 19 + i32.const 46 + i32.store8 offset=1 + local.get 19 + i32.const 2 + i32.add + local.set 21 + end + local.get 34 + f64.const 0x0p+0 (;=0;) + f64.ne + br_if 0 (;@6;) + end + i32.const 2147483645 + local.get 7 + local.get 27 + i32.sub + local.tee 25 + local.get 29 + i32.add + local.tee 19 + i32.sub + local.get 24 + i32.lt_s + br_if 2 (;@3;) + local.get 24 + i32.const 2 + i32.add + local.get 21 + local.get 5 + i32.const 80 + i32.add + i32.sub + local.tee 21 + local.get 21 + i32.const -2 + i32.add + local.get 24 + i32.lt_s + select + local.get 21 + local.get 24 + select + local.tee 20 + local.get 19 + i32.add + local.set 28 + block ;; label = @6 + local.get 30 + i32.const 73728 + i32.and + local.tee 22 + br_if 0 (;@6;) + local.get 26 + local.get 28 + i32.le_s + br_if 0 (;@6;) + local.get 5 + i32.const 624 + i32.add + i32.const 32 + local.get 26 + local.get 28 + i32.sub + local.tee 19 + i32.const 256 + local.get 19 + i32.const 256 + i32.lt_u + local.tee 24 + select + call $memset + drop + block ;; label = @7 + local.get 24 + br_if 0 (;@7;) + loop ;; label = @8 + block ;; label = @9 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@9;) + local.get 5 + i32.const 624 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 19 + i32.const -256 + i32.add + local.tee 19 + i32.const 255 + i32.gt_u + br_if 0 (;@8;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@6;) + local.get 5 + i32.const 624 + i32.add + local.get 19 + local.get 0 + call $__fwritex + drop + end + block ;; label = @6 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@6;) + local.get 23 + local.get 29 + local.get 0 + call $__fwritex + drop + end + block ;; label = @6 + local.get 22 + i32.const 65536 + i32.ne + br_if 0 (;@6;) + local.get 26 + local.get 28 + i32.le_s + br_if 0 (;@6;) + local.get 5 + i32.const 624 + i32.add + i32.const 48 + local.get 26 + local.get 28 + i32.sub + local.tee 19 + i32.const 256 + local.get 19 + i32.const 256 + i32.lt_u + local.tee 24 + select + call $memset + drop + block ;; label = @7 + local.get 24 + br_if 0 (;@7;) + loop ;; label = @8 + block ;; label = @9 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@9;) + local.get 5 + i32.const 624 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 19 + i32.const -256 + i32.add + local.tee 19 + i32.const 255 + i32.gt_u + br_if 0 (;@8;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@6;) + local.get 5 + i32.const 624 + i32.add + local.get 19 + local.get 0 + call $__fwritex + drop + end + block ;; label = @6 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@6;) + local.get 5 + i32.const 80 + i32.add + local.get 21 + local.get 0 + call $__fwritex + drop + end + block ;; label = @6 + local.get 20 + local.get 21 + i32.sub + local.tee 19 + i32.const 1 + i32.lt_s + br_if 0 (;@6;) + local.get 5 + i32.const 624 + i32.add + i32.const 48 + local.get 19 + i32.const 256 + local.get 19 + i32.const 256 + i32.lt_u + local.tee 21 + select + call $memset + drop + block ;; label = @7 + local.get 21 + br_if 0 (;@7;) + loop ;; label = @8 + block ;; label = @9 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@9;) + local.get 5 + i32.const 624 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 19 + i32.const -256 + i32.add + local.tee 19 + i32.const 255 + i32.gt_u + br_if 0 (;@8;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@6;) + local.get 5 + i32.const 624 + i32.add + local.get 19 + local.get 0 + call $__fwritex + drop + end + block ;; label = @6 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@6;) + local.get 27 + local.get 25 + local.get 0 + call $__fwritex + drop + end + local.get 22 + i32.const 8192 + i32.ne + br_if 0 (;@5;) + local.get 26 + local.get 28 + i32.le_s + br_if 0 (;@5;) + local.get 5 + i32.const 624 + i32.add + i32.const 32 + local.get 26 + local.get 28 + i32.sub + local.tee 19 + i32.const 256 + local.get 19 + i32.const 256 + i32.lt_u + local.tee 21 + select + call $memset + drop + block ;; label = @6 + local.get 21 + br_if 0 (;@6;) + loop ;; label = @7 + block ;; label = @8 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@8;) + local.get 5 + i32.const 624 + i32.add + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 19 + i32.const -256 + i32.add + local.tee 19 + i32.const 255 + i32.gt_u + br_if 0 (;@7;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@5;) + local.get 5 + i32.const 624 + i32.add + local.get 19 + local.get 0 + call $__fwritex + drop + end + local.get 28 + local.get 26 + local.get 28 + local.get 26 + i32.gt_s + select + local.tee 19 + i32.const 0 + i32.ge_s + br_if 0 (;@4;) + end + end + i32.const 1692992 + i32.const 61 + i32.store + end + i32.const -1 + local.set 18 + end + local.get 5 + i32.const 880 + i32.add + global.set $__stack_pointer + local.get 18) + (func $pop_arg (type 14) (param i32 i32 i32) + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + block ;; label = @7 + block ;; label = @8 + block ;; label = @9 + block ;; label = @10 + block ;; label = @11 + block ;; label = @12 + block ;; label = @13 + block ;; label = @14 + block ;; label = @15 + block ;; label = @16 + block ;; label = @17 + block ;; label = @18 + block ;; label = @19 + local.get 1 + i32.const -9 + i32.add + br_table 17 (;@2;) 0 (;@19;) 1 (;@18;) 4 (;@15;) 2 (;@17;) 3 (;@16;) 5 (;@14;) 6 (;@13;) 7 (;@12;) 8 (;@11;) 9 (;@10;) 10 (;@9;) 11 (;@8;) 12 (;@7;) 13 (;@6;) 14 (;@5;) 15 (;@4;) 16 (;@3;) 18 (;@1;) + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load32_s + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load32_u + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load32_s + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load32_u + i64.store + return + end + local.get 2 + local.get 2 + i32.load + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee 1 + i32.const 8 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load16_s + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load16_u + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load8_s + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load8_u + i64.store + return + end + local.get 2 + local.get 2 + i32.load + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee 1 + i32.const 8 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load32_u + i64.store + return + end + local.get 2 + local.get 2 + i32.load + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee 1 + i32.const 8 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load + i64.store + return + end + local.get 2 + local.get 2 + i32.load + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee 1 + i32.const 8 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load32_s + i64.store + return + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i64.load32_u + i64.store + return + end + local.get 2 + local.get 2 + i32.load + i32.const 7 + i32.add + i32.const -8 + i32.and + local.tee 1 + i32.const 8 + i32.add + i32.store + local.get 0 + local.get 1 + f64.load + f64.store + return + end + call $long_double_not_supported + unreachable + end + local.get 2 + local.get 2 + i32.load + local.tee 1 + i32.const 4 + i32.add + i32.store + local.get 0 + local.get 1 + i32.load + i32.store + end) + (func $pad (type 15) (param i32 i32 i32 i32 i32) + (local i32) + global.get $__stack_pointer + i32.const 256 + i32.sub + local.tee 5 + global.set $__stack_pointer + block ;; label = @1 + local.get 2 + local.get 3 + i32.le_s + br_if 0 (;@1;) + local.get 4 + i32.const 73728 + i32.and + br_if 0 (;@1;) + local.get 5 + local.get 1 + local.get 2 + local.get 3 + i32.sub + local.tee 3 + i32.const 256 + local.get 3 + i32.const 256 + i32.lt_u + local.tee 4 + select + call $memset + local.set 2 + block ;; label = @2 + local.get 4 + br_if 0 (;@2;) + loop ;; label = @3 + block ;; label = @4 + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@4;) + local.get 2 + i32.const 256 + local.get 0 + call $__fwritex + drop + end + local.get 3 + i32.const -256 + i32.add + local.tee 3 + i32.const 255 + i32.gt_u + br_if 0 (;@3;) + end + end + local.get 0 + i32.load8_u + i32.const 32 + i32.and + br_if 0 (;@1;) + local.get 2 + local.get 3 + local.get 0 + call $__fwritex + drop + end + local.get 5 + i32.const 256 + i32.add + global.set $__stack_pointer) + (func $long_double_not_supported (type 9) + i32.const 1217 + i32.const 3656 + call $fputs + drop + call $abort + unreachable) + (func $vsnprintf (type 5) (param i32 i32 i32 i32) (result i32) + (local i32 i32 i32) + global.get $__stack_pointer + i32.const 128 + i32.sub + local.tee 4 + global.set $__stack_pointer + local.get 4 + local.get 0 + local.get 4 + i32.const 126 + i32.add + local.get 1 + select + local.tee 5 + i32.store offset=116 + i32.const -1 + local.set 0 + local.get 4 + i32.const 0 + local.get 1 + i32.const -1 + i32.add + local.tee 6 + local.get 6 + local.get 1 + i32.gt_u + select + i32.store offset=120 + local.get 4 + i32.const 0 + i32.const 112 + call $memset + local.tee 4 + i32.const -1 + i32.store offset=64 + local.get 4 + i32.const 6 + i32.store offset=32 + local.get 4 + local.get 4 + i32.const 116 + i32.add + i32.store offset=68 + local.get 4 + local.get 4 + i32.const 127 + i32.add + i32.store offset=40 + block ;; label = @1 + block ;; label = @2 + local.get 1 + i32.const -1 + i32.gt_s + br_if 0 (;@2;) + i32.const 0 + i32.const 61 + i32.store offset=1692992 + br 1 (;@1;) + end + local.get 5 + i32.const 0 + i32.store8 + local.get 4 + local.get 2 + local.get 3 + call $vfprintf + local.set 0 + end + local.get 4 + i32.const 128 + i32.add + global.set $__stack_pointer + local.get 0) + (func $sn_write (type 1) (param i32 i32 i32) (result i32) + (local i32 i32 i32 i32 i32) + local.get 0 + i32.load offset=68 + local.tee 3 + i32.load + local.set 4 + block ;; label = @1 + local.get 3 + i32.load offset=4 + local.tee 5 + local.get 0 + i32.load offset=20 + local.get 0 + i32.load offset=24 + local.tee 6 + i32.sub + local.tee 7 + local.get 5 + local.get 7 + i32.lt_u + select + local.tee 7 + i32.eqz + br_if 0 (;@1;) + local.get 4 + local.get 6 + local.get 7 + call $memcpy + drop + local.get 3 + local.get 3 + i32.load + local.get 7 + i32.add + local.tee 4 + i32.store + local.get 3 + local.get 3 + i32.load offset=4 + local.get 7 + i32.sub + local.tee 5 + i32.store offset=4 + end + block ;; label = @1 + local.get 5 + local.get 2 + local.get 5 + local.get 2 + i32.lt_u + select + local.tee 5 + i32.eqz + br_if 0 (;@1;) + local.get 4 + local.get 1 + local.get 5 + call $memcpy + drop + local.get 3 + local.get 3 + i32.load + local.get 5 + i32.add + local.tee 4 + i32.store + local.get 3 + local.get 3 + i32.load offset=4 + local.get 5 + i32.sub + i32.store offset=4 + end + local.get 4 + i32.const 0 + i32.store8 + local.get 0 + local.get 0 + i32.load offset=40 + local.tee 3 + i32.store offset=24 + local.get 0 + local.get 3 + i32.store offset=20 + local.get 2) + (func $vsprintf (type 1) (param i32 i32 i32) (result i32) + local.get 0 + i32.const 2147483647 + local.get 1 + local.get 2 + call $vsnprintf) + (func $atoi (type 0) (param i32) (result i32) + (local i32 i32 i32 i32 i32) + loop ;; label = @1 + local.get 0 + i32.load8_s + local.tee 1 + i32.const -14 + i32.add + local.set 2 + local.get 0 + i32.const 1 + i32.add + local.tee 3 + local.set 0 + local.get 1 + i32.const 255 + i32.and + local.tee 4 + i32.const 32 + i32.eq + br_if 0 (;@1;) + local.get 3 + local.set 0 + local.get 2 + i32.const -6 + i32.gt_u + br_if 0 (;@1;) + end + i32.const 1 + local.set 5 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + local.get 4 + i32.const -43 + i32.add + br_table 2 (;@2;) 0 (;@4;) 1 (;@3;) 0 (;@4;) + end + local.get 3 + i32.const -1 + i32.add + local.set 3 + i32.const 1 + local.set 5 + br 2 (;@1;) + end + i32.const 0 + local.set 5 + end + local.get 3 + i32.load8_s + local.set 1 + end + i32.const 0 + local.set 2 + block ;; label = @1 + local.get 1 + i32.const -48 + i32.add + local.tee 1 + i32.const 9 + i32.gt_u + br_if 0 (;@1;) + local.get 3 + i32.const 1 + i32.add + local.set 0 + i32.const 0 + local.set 2 + loop ;; label = @2 + local.get 2 + i32.const 10 + i32.mul + local.get 1 + i32.sub + local.set 2 + local.get 0 + i32.load8_s + local.set 1 + local.get 0 + i32.const 1 + i32.add + local.set 0 + local.get 1 + i32.const -48 + i32.add + local.tee 1 + i32.const 10 + i32.lt_u + br_if 0 (;@2;) + end + end + i32.const 0 + local.get 2 + i32.sub + local.get 2 + local.get 5 + select) + (func $memchr (type 1) (param i32 i32 i32) (result i32) + (local i32 i32 i32) + local.get 2 + i32.const 0 + i32.ne + local.set 3 + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + local.get 0 + i32.const 3 + i32.and + i32.eqz + br_if 0 (;@4;) + local.get 2 + i32.eqz + br_if 0 (;@4;) + block ;; label = @5 + local.get 0 + i32.load8_u + local.get 1 + i32.const 255 + i32.and + i32.ne + br_if 0 (;@5;) + local.get 0 + local.set 4 + local.get 2 + local.set 5 + br 3 (;@2;) + end + local.get 2 + i32.const -1 + i32.add + local.tee 5 + i32.const 0 + i32.ne + local.set 3 + local.get 0 + i32.const 1 + i32.add + local.tee 4 + i32.const 3 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 5 + i32.eqz + br_if 1 (;@3;) + local.get 4 + i32.load8_u + local.get 1 + i32.const 255 + i32.and + i32.eq + br_if 2 (;@2;) + local.get 2 + i32.const -2 + i32.add + local.tee 5 + i32.const 0 + i32.ne + local.set 3 + local.get 0 + i32.const 2 + i32.add + local.tee 4 + i32.const 3 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 5 + i32.eqz + br_if 1 (;@3;) + local.get 4 + i32.load8_u + local.get 1 + i32.const 255 + i32.and + i32.eq + br_if 2 (;@2;) + local.get 2 + i32.const -3 + i32.add + local.tee 5 + i32.const 0 + i32.ne + local.set 3 + local.get 0 + i32.const 3 + i32.add + local.tee 4 + i32.const 3 + i32.and + i32.eqz + br_if 1 (;@3;) + local.get 5 + i32.eqz + br_if 1 (;@3;) + local.get 4 + i32.load8_u + local.get 1 + i32.const 255 + i32.and + i32.eq + br_if 2 (;@2;) + local.get 0 + i32.const 4 + i32.add + local.set 4 + local.get 2 + i32.const -4 + i32.add + local.tee 5 + i32.const 0 + i32.ne + local.set 3 + br 1 (;@3;) + end + local.get 2 + local.set 5 + local.get 0 + local.set 4 + end + local.get 3 + i32.eqz + br_if 1 (;@1;) + block ;; label = @3 + local.get 4 + i32.load8_u + local.get 1 + i32.const 255 + i32.and + i32.eq + br_if 0 (;@3;) + local.get 5 + i32.const 4 + i32.lt_u + br_if 0 (;@3;) + local.get 1 + i32.const 255 + i32.and + i32.const 16843009 + i32.mul + local.set 0 + loop ;; label = @4 + local.get 4 + i32.load + local.get 0 + i32.xor + local.tee 2 + i32.const -1 + i32.xor + local.get 2 + i32.const -16843009 + i32.add + i32.and + i32.const -2139062144 + i32.and + br_if 2 (;@2;) + local.get 4 + i32.const 4 + i32.add + local.set 4 + local.get 5 + i32.const -4 + i32.add + local.tee 5 + i32.const 3 + i32.gt_u + br_if 0 (;@4;) + end + end + local.get 5 + i32.eqz + br_if 1 (;@1;) + end + local.get 1 + i32.const 255 + i32.and + local.set 2 + loop ;; label = @2 + block ;; label = @3 + local.get 4 + i32.load8_u + local.get 2 + i32.ne + br_if 0 (;@3;) + local.get 4 + return + end + local.get 4 + i32.const 1 + i32.add + local.set 4 + local.get 5 + i32.const -1 + i32.add + local.tee 5 + br_if 0 (;@2;) + end + end + i32.const 0) + (func $memcmp (type 1) (param i32 i32 i32) (result i32) + (local i32 i32 i32) + i32.const 0 + local.set 3 + block ;; label = @1 + local.get 2 + i32.eqz + br_if 0 (;@1;) + block ;; label = @2 + loop ;; label = @3 + local.get 0 + i32.load8_u + local.tee 4 + local.get 1 + i32.load8_u + local.tee 5 + i32.ne + br_if 1 (;@2;) + local.get 1 + i32.const 1 + i32.add + local.set 1 + local.get 0 + i32.const 1 + i32.add + local.set 0 + local.get 2 + i32.const -1 + i32.add + local.tee 2 + br_if 0 (;@3;) + br 2 (;@1;) + end + end + local.get 4 + local.get 5 + i32.sub + local.set 3 + end + local.get 3) + (func $memcpy (type 1) (param i32 i32 i32) (result i32) + (local i32 i32 i32 i32) + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 2 + i32.const 32 + i32.gt_u + br_if 0 (;@3;) + local.get 1 + i32.const 3 + i32.and + i32.eqz + br_if 1 (;@2;) + local.get 2 + i32.eqz + br_if 1 (;@2;) + local.get 0 + local.get 1 + i32.load8_u + i32.store8 + local.get 2 + i32.const -1 + i32.add + local.set 3 + local.get 0 + i32.const 1 + i32.add + local.set 4 + local.get 1 + i32.const 1 + i32.add + local.tee 5 + i32.const 3 + i32.and + i32.eqz + br_if 2 (;@1;) + local.get 3 + i32.eqz + br_if 2 (;@1;) + local.get 0 + local.get 1 + i32.load8_u offset=1 + i32.store8 offset=1 + local.get 2 + i32.const -2 + i32.add + local.set 3 + local.get 0 + i32.const 2 + i32.add + local.set 4 + local.get 1 + i32.const 2 + i32.add + local.tee 5 + i32.const 3 + i32.and + i32.eqz + br_if 2 (;@1;) + local.get 3 + i32.eqz + br_if 2 (;@1;) + local.get 0 + local.get 1 + i32.load8_u offset=2 + i32.store8 offset=2 + local.get 2 + i32.const -3 + i32.add + local.set 3 + local.get 0 + i32.const 3 + i32.add + local.set 4 + local.get 1 + i32.const 3 + i32.add + local.tee 5 + i32.const 3 + i32.and + i32.eqz + br_if 2 (;@1;) + local.get 3 + i32.eqz + br_if 2 (;@1;) + local.get 0 + local.get 1 + i32.load8_u offset=3 + i32.store8 offset=3 + local.get 2 + i32.const -4 + i32.add + local.set 3 + local.get 0 + i32.const 4 + i32.add + local.set 4 + local.get 1 + i32.const 4 + i32.add + local.set 5 + br 2 (;@1;) + end + local.get 0 + local.get 1 + local.get 2 + memory.copy + local.get 0 + return + end + local.get 2 + local.set 3 + local.get 0 + local.set 4 + local.get 1 + local.set 5 + end + block ;; label = @1 + block ;; label = @2 + local.get 4 + i32.const 3 + i32.and + local.tee 2 + br_if 0 (;@2;) + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.const 16 + i32.ge_u + br_if 0 (;@4;) + local.get 3 + local.set 2 + br 1 (;@3;) + end + block ;; label = @4 + local.get 3 + i32.const -16 + i32.add + local.tee 2 + i32.const 16 + i32.and + br_if 0 (;@4;) + local.get 4 + local.get 5 + i64.load align=4 + i64.store align=4 + local.get 4 + local.get 5 + i64.load offset=8 align=4 + i64.store offset=8 align=4 + local.get 4 + i32.const 16 + i32.add + local.set 4 + local.get 5 + i32.const 16 + i32.add + local.set 5 + local.get 2 + local.set 3 + end + local.get 2 + i32.const 16 + i32.lt_u + br_if 0 (;@3;) + local.get 3 + local.set 2 + loop ;; label = @4 + local.get 4 + local.get 5 + i64.load align=4 + i64.store align=4 + local.get 4 + local.get 5 + i64.load offset=8 align=4 + i64.store offset=8 align=4 + local.get 4 + local.get 5 + i64.load offset=16 align=4 + i64.store offset=16 align=4 + local.get 4 + local.get 5 + i64.load offset=24 align=4 + i64.store offset=24 align=4 + local.get 4 + i32.const 32 + i32.add + local.set 4 + local.get 5 + i32.const 32 + i32.add + local.set 5 + local.get 2 + i32.const -32 + i32.add + local.tee 2 + i32.const 15 + i32.gt_u + br_if 0 (;@4;) + end + end + block ;; label = @3 + local.get 2 + i32.const 8 + i32.lt_u + br_if 0 (;@3;) + local.get 4 + local.get 5 + i64.load align=4 + i64.store align=4 + local.get 5 + i32.const 8 + i32.add + local.set 5 + local.get 4 + i32.const 8 + i32.add + local.set 4 + end + block ;; label = @3 + local.get 2 + i32.const 4 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 4 + local.get 5 + i32.load + i32.store + local.get 5 + i32.const 4 + i32.add + local.set 5 + local.get 4 + i32.const 4 + i32.add + local.set 4 + end + block ;; label = @3 + local.get 2 + i32.const 2 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 4 + local.get 5 + i32.load16_u align=1 + i32.store16 align=1 + local.get 4 + i32.const 2 + i32.add + local.set 4 + local.get 5 + i32.const 2 + i32.add + local.set 5 + end + local.get 2 + i32.const 1 + i32.and + i32.eqz + br_if 1 (;@1;) + local.get 4 + local.get 5 + i32.load8_u + i32.store8 + local.get 0 + return + end + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + block ;; label = @5 + block ;; label = @6 + local.get 3 + i32.const 32 + i32.lt_u + br_if 0 (;@6;) + local.get 4 + local.get 5 + i32.load + local.tee 3 + i32.store8 + block ;; label = @7 + block ;; label = @8 + local.get 2 + i32.const -1 + i32.add + br_table 3 (;@5;) 0 (;@8;) 1 (;@7;) 3 (;@5;) + end + local.get 4 + local.get 3 + i32.const 8 + i32.shr_u + i32.store8 offset=1 + local.get 4 + local.get 5 + i32.const 6 + i32.add + i64.load align=2 + i64.store offset=6 align=4 + local.get 4 + local.get 5 + i32.load offset=4 + i32.const 16 + i32.shl + local.get 3 + i32.const 16 + i32.shr_u + i32.or + i32.store offset=2 + local.get 4 + i32.const 18 + i32.add + local.set 2 + local.get 5 + i32.const 18 + i32.add + local.set 1 + i32.const 14 + local.set 6 + local.get 5 + i32.const 14 + i32.add + i32.load align=2 + local.set 5 + i32.const 14 + local.set 3 + br 3 (;@4;) + end + local.get 4 + local.get 5 + i32.const 5 + i32.add + i64.load align=1 + i64.store offset=5 align=4 + local.get 4 + local.get 5 + i32.load offset=4 + i32.const 24 + i32.shl + local.get 3 + i32.const 8 + i32.shr_u + i32.or + i32.store offset=1 + local.get 4 + i32.const 17 + i32.add + local.set 2 + local.get 5 + i32.const 17 + i32.add + local.set 1 + i32.const 13 + local.set 6 + local.get 5 + i32.const 13 + i32.add + i32.load align=1 + local.set 5 + i32.const 15 + local.set 3 + br 2 (;@4;) + end + block ;; label = @6 + block ;; label = @7 + local.get 3 + i32.const 16 + i32.ge_u + br_if 0 (;@7;) + local.get 4 + local.set 2 + local.get 5 + local.set 1 + br 1 (;@6;) + end + local.get 4 + local.get 5 + i32.load8_u + i32.store8 + local.get 4 + local.get 5 + i32.load offset=1 align=1 + i32.store offset=1 align=1 + local.get 4 + local.get 5 + i64.load offset=5 align=1 + i64.store offset=5 align=1 + local.get 4 + local.get 5 + i32.load16_u offset=13 align=1 + i32.store16 offset=13 align=1 + local.get 4 + local.get 5 + i32.load8_u offset=15 + i32.store8 offset=15 + local.get 4 + i32.const 16 + i32.add + local.set 2 + local.get 5 + i32.const 16 + i32.add + local.set 1 + end + local.get 3 + i32.const 8 + i32.and + br_if 2 (;@3;) + br 3 (;@2;) + end + local.get 4 + local.get 3 + i32.const 16 + i32.shr_u + i32.store8 offset=2 + local.get 4 + local.get 3 + i32.const 8 + i32.shr_u + i32.store8 offset=1 + local.get 4 + local.get 5 + i32.const 7 + i32.add + i64.load align=1 + i64.store offset=7 align=4 + local.get 4 + local.get 5 + i32.load offset=4 + i32.const 8 + i32.shl + local.get 3 + i32.const 24 + i32.shr_u + i32.or + i32.store offset=3 + local.get 4 + i32.const 19 + i32.add + local.set 2 + local.get 5 + i32.const 19 + i32.add + local.set 1 + i32.const 15 + local.set 6 + local.get 5 + i32.const 15 + i32.add + i32.load align=1 + local.set 5 + i32.const 13 + local.set 3 + end + local.get 4 + local.get 6 + i32.add + local.get 5 + i32.store + end + local.get 2 + local.get 1 + i64.load align=1 + i64.store align=1 + local.get 2 + i32.const 8 + i32.add + local.set 2 + local.get 1 + i32.const 8 + i32.add + local.set 1 + end + block ;; label = @2 + local.get 3 + i32.const 4 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 1 + i32.load align=1 + i32.store align=1 + local.get 2 + i32.const 4 + i32.add + local.set 2 + local.get 1 + i32.const 4 + i32.add + local.set 1 + end + block ;; label = @2 + local.get 3 + i32.const 2 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 2 + local.get 1 + i32.load16_u align=1 + i32.store16 align=1 + local.get 2 + i32.const 2 + i32.add + local.set 2 + local.get 1 + i32.const 2 + i32.add + local.set 1 + end + local.get 3 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + local.get 1 + i32.load8_u + i32.store8 + end + local.get 0) + (func $memset (type 1) (param i32 i32 i32) (result i32) + (local i32 i32 i32 i64) + block ;; label = @1 + local.get 2 + i32.const 33 + i32.lt_u + br_if 0 (;@1;) + local.get 0 + local.get 1 + local.get 2 + memory.fill + local.get 0 + return + end + block ;; label = @1 + local.get 2 + i32.eqz + br_if 0 (;@1;) + local.get 0 + local.get 1 + i32.store8 + local.get 0 + local.get 2 + i32.add + local.tee 3 + i32.const -1 + i32.add + local.get 1 + i32.store8 + local.get 2 + i32.const 3 + i32.lt_u + br_if 0 (;@1;) + local.get 0 + local.get 1 + i32.store8 offset=2 + local.get 0 + local.get 1 + i32.store8 offset=1 + local.get 3 + i32.const -3 + i32.add + local.get 1 + i32.store8 + local.get 3 + i32.const -2 + i32.add + local.get 1 + i32.store8 + local.get 2 + i32.const 7 + i32.lt_u + br_if 0 (;@1;) + local.get 0 + local.get 1 + i32.store8 offset=3 + local.get 3 + i32.const -4 + i32.add + local.get 1 + i32.store8 + local.get 2 + i32.const 9 + i32.lt_u + br_if 0 (;@1;) + local.get 0 + i32.const 0 + local.get 0 + i32.sub + i32.const 3 + i32.and + local.tee 4 + i32.add + local.tee 5 + local.get 1 + i32.const 255 + i32.and + i32.const 16843009 + i32.mul + local.tee 3 + i32.store + local.get 5 + local.get 2 + local.get 4 + i32.sub + i32.const -4 + i32.and + local.tee 1 + i32.add + local.tee 2 + i32.const -4 + i32.add + local.get 3 + i32.store + local.get 1 + i32.const 9 + i32.lt_u + br_if 0 (;@1;) + local.get 5 + local.get 3 + i32.store offset=8 + local.get 5 + local.get 3 + i32.store offset=4 + local.get 2 + i32.const -8 + i32.add + local.get 3 + i32.store + local.get 2 + i32.const -12 + i32.add + local.get 3 + i32.store + local.get 1 + i32.const 25 + i32.lt_u + br_if 0 (;@1;) + local.get 5 + local.get 3 + i32.store offset=24 + local.get 5 + local.get 3 + i32.store offset=20 + local.get 5 + local.get 3 + i32.store offset=16 + local.get 5 + local.get 3 + i32.store offset=12 + local.get 2 + i32.const -16 + i32.add + local.get 3 + i32.store + local.get 2 + i32.const -20 + i32.add + local.get 3 + i32.store + local.get 2 + i32.const -24 + i32.add + local.get 3 + i32.store + local.get 2 + i32.const -28 + i32.add + local.get 3 + i32.store + local.get 1 + local.get 5 + i32.const 4 + i32.and + i32.const 24 + i32.or + local.tee 2 + i32.sub + local.tee 1 + i32.const 32 + i32.lt_u + br_if 0 (;@1;) + local.get 3 + i64.extend_i32_u + i64.const 4294967297 + i64.mul + local.set 6 + local.get 5 + local.get 2 + i32.add + local.set 2 + loop ;; label = @2 + local.get 2 + local.get 6 + i64.store offset=24 + local.get 2 + local.get 6 + i64.store offset=16 + local.get 2 + local.get 6 + i64.store offset=8 + local.get 2 + local.get 6 + i64.store + local.get 2 + i32.const 32 + i32.add + local.set 2 + local.get 1 + i32.const -32 + i32.add + local.tee 1 + i32.const 31 + i32.gt_u + br_if 0 (;@2;) + end + end + local.get 0) + (func $strcat (type 4) (param i32 i32) (result i32) + local.get 0 + local.get 0 + call $strlen + i32.add + local.get 1 + call $strcpy + drop + local.get 0) + (func $strchr (type 4) (param i32 i32) (result i32) + local.get 0 + local.get 1 + call $__strchrnul + local.tee 0 + i32.const 0 + local.get 0 + i32.load8_u + local.get 1 + i32.const 255 + i32.and + i32.eq + select) + (func $__strchrnul (type 4) (param i32 i32) (result i32) + (local i32 i32 i32) + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + local.get 1 + i32.const 255 + i32.and + local.tee 2 + i32.eqz + br_if 0 (;@4;) + local.get 0 + i32.const 3 + i32.and + i32.eqz + br_if 2 (;@2;) + block ;; label = @5 + local.get 0 + i32.load8_u + local.tee 3 + br_if 0 (;@5;) + local.get 0 + return + end + local.get 3 + local.get 1 + i32.const 255 + i32.and + i32.ne + br_if 1 (;@3;) + local.get 0 + return + end + local.get 0 + local.get 0 + call $strlen + i32.add + return + end + block ;; label = @3 + local.get 0 + i32.const 1 + i32.add + local.tee 3 + i32.const 3 + i32.and + br_if 0 (;@3;) + local.get 3 + local.set 0 + br 1 (;@2;) + end + local.get 3 + i32.load8_u + local.tee 4 + i32.eqz + br_if 1 (;@1;) + local.get 4 + local.get 1 + i32.const 255 + i32.and + i32.eq + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.const 2 + i32.add + local.tee 3 + i32.const 3 + i32.and + br_if 0 (;@3;) + local.get 3 + local.set 0 + br 1 (;@2;) + end + local.get 3 + i32.load8_u + local.tee 4 + i32.eqz + br_if 1 (;@1;) + local.get 4 + local.get 1 + i32.const 255 + i32.and + i32.eq + br_if 1 (;@1;) + block ;; label = @3 + local.get 0 + i32.const 3 + i32.add + local.tee 3 + i32.const 3 + i32.and + br_if 0 (;@3;) + local.get 3 + local.set 0 + br 1 (;@2;) + end + local.get 3 + i32.load8_u + local.tee 4 + i32.eqz + br_if 1 (;@1;) + local.get 4 + local.get 1 + i32.const 255 + i32.and + i32.eq + br_if 1 (;@1;) + local.get 0 + i32.const 4 + i32.add + local.set 0 + end + block ;; label = @2 + local.get 0 + i32.load + local.tee 3 + i32.const -1 + i32.xor + local.get 3 + i32.const -16843009 + i32.add + i32.and + i32.const -2139062144 + i32.and + br_if 0 (;@2;) + local.get 2 + i32.const 16843009 + i32.mul + local.set 2 + loop ;; label = @3 + local.get 3 + local.get 2 + i32.xor + local.tee 3 + i32.const -1 + i32.xor + local.get 3 + i32.const -16843009 + i32.add + i32.and + i32.const -2139062144 + i32.and + br_if 1 (;@2;) + local.get 0 + i32.const 4 + i32.add + local.tee 0 + i32.load + local.tee 3 + i32.const -1 + i32.xor + local.get 3 + i32.const -16843009 + i32.add + i32.and + i32.const -2139062144 + i32.and + i32.eqz + br_if 0 (;@3;) + end + end + local.get 0 + i32.const -1 + i32.add + local.set 3 + local.get 1 + i32.const 255 + i32.and + local.set 1 + loop ;; label = @2 + local.get 3 + i32.const 1 + i32.add + local.tee 3 + i32.load8_u + local.tee 0 + i32.eqz + br_if 1 (;@1;) + local.get 0 + local.get 1 + i32.ne + br_if 0 (;@2;) + end + end + local.get 3) + (func $__stpcpy (type 4) (param i32 i32) (result i32) + (local i32 i32) + block ;; label = @1 + block ;; label = @2 + block ;; label = @3 + local.get 1 + local.get 0 + i32.xor + i32.const 3 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 1 + i32.load8_u + local.set 2 + br 1 (;@2;) + end + block ;; label = @3 + local.get 1 + i32.const 3 + i32.and + i32.eqz + br_if 0 (;@3;) + local.get 0 + local.get 1 + i32.load8_u + local.tee 2 + i32.store8 + block ;; label = @4 + local.get 2 + br_if 0 (;@4;) + local.get 0 + return + end + local.get 0 + i32.const 1 + i32.add + local.set 2 + block ;; label = @4 + local.get 1 + i32.const 1 + i32.add + local.tee 3 + i32.const 3 + i32.and + br_if 0 (;@4;) + local.get 2 + local.set 0 + local.get 3 + local.set 1 + br 1 (;@3;) + end + local.get 2 + local.get 3 + i32.load8_u + local.tee 3 + i32.store8 + local.get 3 + i32.eqz + br_if 2 (;@1;) + local.get 0 + i32.const 2 + i32.add + local.set 2 + block ;; label = @4 + local.get 1 + i32.const 2 + i32.add + local.tee 3 + i32.const 3 + i32.and + br_if 0 (;@4;) + local.get 2 + local.set 0 + local.get 3 + local.set 1 + br 1 (;@3;) + end + local.get 2 + local.get 3 + i32.load8_u + local.tee 3 + i32.store8 + local.get 3 + i32.eqz + br_if 2 (;@1;) + local.get 0 + i32.const 3 + i32.add + local.set 2 + block ;; label = @4 + local.get 1 + i32.const 3 + i32.add + local.tee 3 + i32.const 3 + i32.and + br_if 0 (;@4;) + local.get 2 + local.set 0 + local.get 3 + local.set 1 + br 1 (;@3;) + end + local.get 2 + local.get 3 + i32.load8_u + local.tee 3 + i32.store8 + local.get 3 + i32.eqz + br_if 2 (;@1;) + local.get 0 + i32.const 4 + i32.add + local.set 0 + local.get 1 + i32.const 4 + i32.add + local.set 1 + end + local.get 1 + i32.load + local.tee 2 + i32.const -1 + i32.xor + local.get 2 + i32.const -16843009 + i32.add + i32.and + i32.const -2139062144 + i32.and + br_if 0 (;@2;) + loop ;; label = @3 + local.get 0 + local.get 2 + i32.store + local.get 0 + i32.const 4 + i32.add + local.set 0 + local.get 1 + i32.const 4 + i32.add + local.tee 1 + i32.load + local.tee 2 + i32.const -1 + i32.xor + local.get 2 + i32.const -16843009 + i32.add + i32.and + i32.const -2139062144 + i32.and + i32.eqz + br_if 0 (;@3;) + end + end + local.get 0 + local.get 2 + i32.store8 + block ;; label = @2 + local.get 2 + i32.const 255 + i32.and + br_if 0 (;@2;) + local.get 0 + return + end + local.get 1 + i32.const 1 + i32.add + local.set 1 + local.get 0 + local.set 2 + loop ;; label = @2 + local.get 2 + local.get 1 + i32.load8_u + local.tee 0 + i32.store8 offset=1 + local.get 1 + i32.const 1 + i32.add + local.set 1 + local.get 2 + i32.const 1 + i32.add + local.set 2 + local.get 0 + br_if 0 (;@2;) + end + end + local.get 2) + (func $strcpy (type 4) (param i32 i32) (result i32) + local.get 0 + local.get 1 + call $__stpcpy + drop + local.get 0) + (func $strdup (type 0) (param i32) (result i32) + (local i32 i32) + block ;; label = @1 + local.get 0 + call $strlen + i32.const 1 + i32.add + local.tee 1 + call $malloc + local.tee 2 + i32.eqz + br_if 0 (;@1;) + local.get 2 + local.get 0 + local.get 1 + call $memcpy + drop + end + local.get 2) + (func $strlen (type 0) (param i32) (result i32) + (local i32 i32 i32) + local.get 0 + local.set 1 + block ;; label = @1 + block ;; label = @2 + local.get 0 + i32.const 3 + i32.and + i32.eqz + br_if 0 (;@2;) + block ;; label = @3 + local.get 0 + i32.load8_u + br_if 0 (;@3;) + local.get 0 + local.get 0 + i32.sub + return + end + local.get 0 + i32.const 1 + i32.add + local.tee 1 + i32.const 3 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load8_u + i32.eqz + br_if 1 (;@1;) + local.get 0 + i32.const 2 + i32.add + local.tee 1 + i32.const 3 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load8_u + i32.eqz + br_if 1 (;@1;) + local.get 0 + i32.const 3 + i32.add + local.tee 1 + i32.const 3 + i32.and + i32.eqz + br_if 0 (;@2;) + local.get 1 + i32.load8_u + i32.eqz + br_if 1 (;@1;) + local.get 0 + i32.const 4 + i32.add + local.tee 1 + i32.const 3 + i32.and + br_if 1 (;@1;) + end + local.get 1 + i32.const -4 + i32.add + local.set 2 + local.get 1 + i32.const -5 + i32.add + local.set 1 + loop ;; label = @2 + local.get 1 + i32.const 4 + i32.add + local.set 1 + local.get 2 + i32.const 4 + i32.add + local.tee 2 + i32.load + local.tee 3 + i32.const -1 + i32.xor + local.get 3 + i32.const -16843009 + i32.add + i32.and + i32.const -2139062144 + i32.and + i32.eqz + br_if 0 (;@2;) + end + loop ;; label = @2 + local.get 1 + i32.const 1 + i32.add + local.set 1 + local.get 2 + i32.load8_u + local.set 3 + local.get 2 + i32.const 1 + i32.add + local.set 2 + local.get 3 + br_if 0 (;@2;) + end + end + local.get 1 + local.get 0 + i32.sub) + (func $strnlen (type 4) (param i32 i32) (result i32) + (local i32) + local.get 0 + i32.const 0 + local.get 1 + call $memchr + local.tee 2 + local.get 0 + i32.sub + local.get 1 + local.get 2 + select) + (table (;0;) 7 7 funcref) + (memory (;0;) 27) + (global $__stack_pointer (mut i32) (i32.const 1759648)) + (global $GOT.data.internal.__memory_base i32 (i32.const 0)) + (export "memory" (memory 0)) + (export "_start" (func $_start)) + (elem (;0;) (i32.const 1) func $__stdio_seek $__stdio_write $__stdio_read $__stdio_close $__stdout_write $sn_write) + (data $.rodata (i32.const 1024) "-+ 0X0x\00-0X+0X 0X-0x+0x 0x\00sort_data_%d.txt\00malloc error\00nan\00inf\00memset finished\00alloc finished\00pivot_%d\00sorter_%d\00before alloc\00rwa\00NAN\00INF\00.\00(null)\00%d \00Failed to open input file\0a\00index: %d\0a\00Support for formatting long double values is currently disabled.\0aTo enable it, add -lc-printscan-long-double to the link command.\0a\00sorter_%d start!\0a\00sorter_%d sort finished!\0a\00sorter_%d all finished!\0a\00sorter_%d read finished!\0a\00Success\00Illegal byte sequence\00Domain error\00Result not representable\00Not a tty\00Permission denied\00Operation not permitted\00No such file or directory\00No such process\00File exists\00Value too large for data type\00No space left on device\00Out of memory\00Resource busy\00Interrupted system call\00Resource temporarily unavailable\00Invalid seek\00Cross-device link\00Read-only file system\00Directory not empty\00Connection reset by peer\00Operation timed out\00Connection refused\00Host is unreachable\00Address in use\00Broken pipe\00I/O error\00No such device or address\00No such device\00Not a directory\00Is a directory\00Text file busy\00Exec format error\00Invalid argument\00Argument list too long\00Symbolic link loop\00Filename too long\00Too many open files in system\00No file descriptors available\00Bad file descriptor\00No child process\00Bad address\00File too large\00Too many links\00No locks available\00Resource deadlock would occur\00State not recoverable\00Previous owner died\00Operation canceled\00Function not implemented\00No message of desired type\00Identifier removed\00Link has been severed\00Protocol error\00Bad message\00Not a socket\00Destination address required\00Message too large\00Protocol wrong type for socket\00Protocol not available\00Protocol not supported\00Not supported\00Address family not supported by protocol\00Address not available\00Network is down\00Network unreachable\00Connection reset by network\00Connection aborted\00No buffer space available\00Socket is connected\00Socket not connected\00Operation already in progress\00Operation in progress\00Stale file handle\00Quota exceeded\00Multihop attempted\00Capabilities insufficient\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00u\02N\00\d6\01\e2\04\b9\04\18\01\8e\05\ed\02\16\04\f2\00\97\03\01\038\05\af\01\82\01O\03/\04\1e\00\d4\05\a2\00\12\03\1e\03\c2\01\de\03\08\00\ac\05\00\01d\02\f1\01e\054\02\8c\02\cf\02-\03L\04\e3\05\9f\02\f8\04\1c\05\08\05\b1\02K\05\15\02x\00R\02<\03\f1\03\e4\00\c3\03}\04\cc\00\aa\03y\05$\02n\01m\03\22\04\ab\04D\00\fb\01\ae\00\83\03`\00\e5\01\07\04\94\04^\04+\00X\019\01\92\00\c2\05\9b\01C\02F\01\f6\05\00\00\00\00\00\00\19\00\0a\00\19\19\19\00\00\00\00\05\00\00\00\00\00\00\09\00\00\00\00\0b\00\00\00\00\00\00\00\00\19\00\11\0a\19\19\19\03\0a\07\00\01\1b\09\0b\18\00\00\09\06\0b\00\00\0b\00\06\19\00\00\00\19\19\19\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\0e\00\00\00\00\00\00\00\00\19\00\0a\0d\19\19\19\00\0d\00\00\02\00\09\0e\00\00\00\09\00\0e\00\00\0e\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\0c\00\00\00\00\00\00\00\00\00\00\00\13\00\00\00\00\13\00\00\00\00\09\0c\00\00\00\00\00\0c\00\00\0c\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\10\00\00\00\00\00\00\00\00\00\00\00\0f\00\00\00\04\0f\00\00\00\00\09\10\00\00\00\00\00\10\00\00\10\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\12\00\00\00\00\00\00\00\00\00\00\00\11\00\00\00\00\11\00\00\00\00\09\12\00\00\00\00\00\12\00\00\12\00\00\1a\00\00\00\1a\1a\1a\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1a\00\00\00\1a\1a\1a\00\00\00\00\00\00\09\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\14\00\00\00\00\00\00\00\00\00\00\00\17\00\00\00\00\17\00\00\00\00\09\14\00\00\00\00\00\14\00\00\14\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\16\00\00\00\00\00\00\00\00\00\00\00\15\00\00\00\00\15\00\00\00\00\09\16\00\00\00\00\00\16\00\00\16\00\000123456789ABCDEF") + (data $.data (i32.const 3648) "P\0f\00\00P\0f\00\00\05\00\00\00\00\00\00\00\00\00\00\00\04\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\00\00\01\00\00\00\88\d5\19\00\00\00\00\00\00\00\00\00\00\00\00\00\02\00\00\00\00\00\00\00\ff\ff\ff\ff\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00H\0e\00\00\00\00\00\00\05\00\00\00\00\00\00\00\00\00\00\00\04\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\05\00\00\00\01\00\00\00\98\d5\19\00\00\04\00\00\00\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\0a\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\c0\0e\00\00")) diff --git a/user/wasmtime_sorter/sorter_ori.cpp b/user/wasmtime_sorter/sorter_ori.cpp index df8e3561..330e7698 100644 --- a/user/wasmtime_sorter/sorter_ori.cpp +++ b/user/wasmtime_sorter/sorter_ori.cpp @@ -11,15 +11,15 @@ using namespace std; __attribute__((import_module("env"), import_name("buffer_register"))) void buffer_register(void *slot_name, int name_size, void *buffer, int buffer_size); -// #define MAX_ARRAY_LENGTH 152221 +// #define MAX_ARRAY_LENGTH 7611020 // #define MAX_BUFFER_SIZE 1024*1024+152221 -#define MAX_ARRAY_LENGTH 3805441 -#define MAX_BUFFER_SIZE 25*1024*1024+3805441 - // #define MAX_ARRAY_LENGTH 7611001 // #define MAX_BUFFER_SIZE 50*1024*1024+7611001 +#define MAX_ARRAY_LENGTH 3805441 +#define MAX_BUFFER_SIZE 25*1024*1024+3805441 + // 比较函数,用于 qsort int compare(const void *a, const void *b) { return (*(int *)a - *(int *)b); // 升序排序 @@ -38,18 +38,18 @@ int readfile(FILE *stream) { return x; } -void get_time(int num, int phase) { +void get_time() { timeval tv{}; gettimeofday(&tv, nullptr); - printf("%lld.%06lld--%d--%d\n", tv.tv_sec, tv.tv_usec, num, phase); + printf("%lld.%06lld\n", tv.tv_sec, tv.tv_usec); } int main(int argc, char* argv[]) { - // get_time(); + get_time(); int id = atoi(argv[1]); int sorter_num = atoi(argv[2]); int merger_num = atoi(argv[3]); - // get_time(); + get_time(); // printf("sorter_%d start!\n", id); char input_file[30]; sprintf(input_file, "sort_data_%d.txt", id); @@ -73,8 +73,7 @@ int main(int argc, char* argv[]) { // printf("%ld read start\n", now); // write(1, "read start\n", sizeof("read start\n")); char number[10]; - if (id == 0) - get_time(0, 0); + get_time(); // while (array[index++] = readfile(file)); int ch = nc(file), x = 0; for (; ch != EOF; ch = nc(file)) { @@ -83,9 +82,8 @@ int main(int argc, char* argv[]) { } arrays.push_back(x); index = arrays.size(); - // printf("sorter_index: %d\n", index); - if (id == 0) - get_time(0, 1); + printf("sorter_index: %d\n", index); + get_time(); // time(&now); // printf("%ld read finished\n", now); // write(1, "read finished\n", sizeof("read finished\n")); @@ -97,10 +95,10 @@ int main(int argc, char* argv[]) { // printf("sorter_%d read finished!\n", id); printf("index: %d\n", index); fclose(file); - // get_time(); + get_time(); // qsort(arrays.data(), index, sizeof(int), compare); sort(arrays.data(), arrays.data()+index); - // get_time(); + get_time(); // printf("sorter_%d sort finished!\n", id); if (merger_num > 1 && id == 0) { @@ -123,11 +121,7 @@ int main(int argc, char* argv[]) { char slot_name[20]; sprintf(slot_name, "pivot_%d", k); // printf("pivotname: %s\n", slot_name); - if (id == 0) - get_time(k+1, 0); buffer_register(slot_name, strlen(slot_name), buffer, MAX_BUFFER_SIZE); - if (id == 0) - get_time(k+1, 1); } // free(buffer); } @@ -147,7 +141,7 @@ int main(int argc, char* argv[]) { // printf("%ld memset finished\n", now); // write(1, "memset finished\n", sizeof("memset finished\n")); // buffer[0] = '\0'; // 初始化为空字符串 - // get_time(); + get_time(); char *ptr = buffer; for (int i = 0; i < index; i++) { char temp[12]; // 临时缓冲区,注意要足够大以容纳最大整数和一个空格 @@ -157,16 +151,12 @@ int main(int argc, char* argv[]) { // strcat(buffer, temp); // 追加到 buffer } *ptr++ = '\0'; - // get_time(); + get_time(); // buffer[strlen(buffer) - 1] = '\0'; // write(1, "buffer make finished\n", sizeof("buffer make finished\n")); - // get_time(); - if (id == 0) - get_time(4, 0); + get_time(); buffer_register(slot_name, strlen(slot_name), buffer, MAX_BUFFER_SIZE); - if (id == 0) - get_time(4, 1); - // get_time(); + get_time(); // write(1, "buffer register finished\n", sizeof("buffer register finished\n")); // free(buffer); // printf("sorter_%d all finished!\n", id); diff --git a/user/wasmtime_sorter/src/lib.rs b/user/wasmtime_sorter/src/lib.rs index 831270ad..55a6a2b5 100644 --- a/user/wasmtime_sorter/src/lib.rs +++ b/user/wasmtime_sorter/src/lib.rs @@ -44,7 +44,7 @@ fn func_body(my_id: &str, sorter_num: u64, merger_num: u64) -> Result<()> { let mut store = Store::new(&engine, LibosCtx{id: my_id.to_string()}); let instance = linker.instantiate(&mut store, &module)?; - let mut memory = instance.get_memory(&mut store, "memory").unwrap(); + let memory = instance.get_memory(&mut store, "memory").unwrap(); let pages = memory.grow(&mut store, 20000).unwrap(); println!("rust: pages: {}", pages); // drop(memory); diff --git a/user/wasmtime_spliter/build.sh b/user/wasmtime_spliter/build.sh index de3288a2..2dca26a3 100755 --- a/user/wasmtime_spliter/build.sh +++ b/user/wasmtime_spliter/build.sh @@ -2,7 +2,6 @@ $CPP spliter_ori.cpp -o spliter.wasm # -fno-exceptions -fno-rtti -ffast-math -funroll-loops -fomit-frame-pointer -Ofast # $CC spliter.c -o spliter.wasm wasmtime compile --target x86_64-unknown-none -W threads=n,tail-call=n spliter.wasm -# wasmtime compile --target x86_64-unknown-none -W simd=y,threads=n,tail-call=n spliter.wasm cargo build --target x86_64-unknown-none --release && cc \ -Wl,--gc-sections -nostdlib \ @@ -13,5 +12,5 @@ cargo build --target x86_64-unknown-none --release && cc \ -o target/x86_64-unknown-none/release/libwasmtime_spliter.so -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_spliter/target/x86_64-unknown-none/release/libwasmtime_spliter.so /home/wyj/alloy_stack/mslibos/target/release/libwasmtime_spliter.so +ln -s /home/wyj/dyx_workplace/mslibos/user/wasmtime_spliter/target/x86_64-unknown-none/release/libwasmtime_spliter.so /home/wyj/dyx_workplace/mslibos/target/release/libwasmtime_spliter.so diff --git a/user/wasmtime_spliter/spliter.cwasm b/user/wasmtime_spliter/spliter.cwasm index 7cf54b10..882b840f 100644 Binary files a/user/wasmtime_spliter/spliter.cwasm and b/user/wasmtime_spliter/spliter.cwasm differ diff --git a/user/wasmtime_spliter/spliter.wasm b/user/wasmtime_spliter/spliter.wasm index e9e5492f..35fa9e4c 100755 Binary files a/user/wasmtime_spliter/spliter.wasm and b/user/wasmtime_spliter/spliter.wasm differ diff --git a/user/wasmtime_spliter/spliter_ori.cpp b/user/wasmtime_spliter/spliter_ori.cpp index c7aa3d00..c8e5ecd9 100644 --- a/user/wasmtime_spliter/spliter_ori.cpp +++ b/user/wasmtime_spliter/spliter_ori.cpp @@ -9,26 +9,26 @@ __attribute__((import_module("env"), import_name("access_buffer"))) void access_ // #define MAX_ARRAY_LENGTH 152221 // #define MAX_BUFFER_SIZE 1024*1024+152221 -#define MAX_ARRAY_LENGTH 3805441 -#define MAX_BUFFER_SIZE 25*1024*1024+3805441 - // #define MAX_ARRAY_LENGTH 7611001 // #define MAX_BUFFER_SIZE 50*1024*1024+7611001 +#define MAX_ARRAY_LENGTH 3805441 +#define MAX_BUFFER_SIZE 25*1024*1024+3805441 + int sorter_array[MAX_ARRAY_LENGTH]; -void get_time(int num, int phase) { +void get_time() { timeval tv{}; gettimeofday(&tv, nullptr); - printf("%lld.%06lld--%d--%d\n", tv.tv_sec, tv.tv_usec, num, phase); + printf("%lld.%06lld\n", tv.tv_sec, tv.tv_usec); } int main(int argc, char* argv[]) { - // get_time(); + get_time(); int id = atoi(argv[1]); int sorter_num = atoi(argv[2]); int merger_num = atoi(argv[3]); - // get_time(); + get_time(); // printf("spliter_%d start!\n", id); char slot_name[20]; int bufferSize = MAX_BUFFER_SIZE; @@ -38,19 +38,13 @@ int main(int argc, char* argv[]) { // access pivot buffer int pivot_array[10]; int pivot_index = 0; - int time_num = 5; if (merger_num > 1) { sprintf(slot_name, "pivot_%d", id); char *pivot_buffer; pivot_buffer = (char *)malloc(bufferSize * sizeof(char)); memset(pivot_buffer, 0, bufferSize * sizeof(char)); pivot_buffer[0] = '\0'; // 初始化为空字符串 - if (id == 0) - get_time(time_num, 0); access_buffer(slot_name, strlen(slot_name), pivot_buffer, bufferSize); - if (id == 0) - get_time(time_num, 1); - time_num++; ptr = pivot_buffer; // printf("pivot_buffer: %s", pivot_buffer); while (sscanf(ptr, "%d", &num) == 1) { @@ -74,16 +68,12 @@ int main(int argc, char* argv[]) { sorter_buffer = (char *)malloc(bufferSize * sizeof(char)); memset(sorter_buffer, 0, bufferSize * sizeof(char)); sorter_buffer[0] = '\0'; // 初始化为空字符串 - // get_time(); - if (id == 0) - get_time(8, 0); + get_time(); access_buffer(slot_name, strlen(slot_name), sorter_buffer, bufferSize); - if (id == 0) - get_time(8, 1); - // get_time(); + get_time(); int sorter_index = 0; ptr = sorter_buffer; - // get_time(); + get_time(); while (sscanf(ptr, "%d", &num) == 1) { sorter_array[sorter_index] = num; sorter_index++; @@ -97,13 +87,13 @@ int main(int argc, char* argv[]) { } // free(ptr); printf("sorter_index: %d\n", sorter_index); - // get_time(); + get_time(); // free(sorter_buffer); // printf("spliter_%d sorter access finished!\n", id); // trans to merger // int array[merger_num][MAX_ARRAY_LENGTH]; - // get_time(); + get_time(); int **array = (int **)malloc(merger_num * sizeof(int*)); for (int i = 0; i < merger_num; i++) { array[i] = (int *)malloc(MAX_ARRAY_LENGTH * sizeof(int)); @@ -123,10 +113,9 @@ int main(int argc, char* argv[]) { array_index[row]++; } printf("merger_index_before_register: %d\n", array_index[0]); - // get_time(); - // get_time(); + get_time(); + get_time(); printf("array0: %d :%d\n", (void*)(array_index), *array_index); - time_num = 9; for (int i = 0; i < merger_num; i++) { printf("i(%d) = %d array0: %d :%d\n", (void*)&i, i, (void*)(array_index), *array_index); char slot_name[20]; @@ -150,17 +139,12 @@ int main(int argc, char* argv[]) { // 去掉最后一个多余的空格 // buffer[strlen(buffer) - 1] = '\0'; *merger_ptr++ = '\0'; - if (id == 0) - get_time(time_num, 0); buffer_register(slot_name, strlen(slot_name), merger_buffer, MAX_BUFFER_SIZE); - if (id == 0) - get_time(time_num, 1); - time_num++; // buffer_register(slot_name, strlen(slot_name), buffer, bufferSize); // free(buffer); // free(array[i]); } - // get_time(); + get_time(); // free(array_index); // printf("spliter_%d all finished!\n", id); // get_time(); diff --git a/user/wasmtime_spliter/src/lib.rs b/user/wasmtime_spliter/src/lib.rs index 5e153eaa..9e351faf 100644 --- a/user/wasmtime_spliter/src/lib.rs +++ b/user/wasmtime_spliter/src/lib.rs @@ -44,8 +44,8 @@ fn func_body(my_id: &str, sorter_num: u64, merger_num: u64) -> Result<()> { let mut store = Store::new(&engine, LibosCtx{id: my_id.to_string()}); let instance = linker.instantiate(&mut store, &module)?; - let mut memory = instance.get_memory(&mut store, "memory").unwrap(); - let pages = memory.grow(&mut store, 20000).unwrap(); + let memory = instance.get_memory(&mut store, "memory").unwrap(); + let _pages = memory.grow(&mut store, 20000).unwrap(); let main = instance .get_typed_func::<(), ()>(&mut store, "_start") diff --git a/user/wasmtime_trans_data/build.sh b/user/wasmtime_trans_data/build.sh index 53981be9..f64b608a 100755 --- a/user/wasmtime_trans_data/build.sh +++ b/user/wasmtime_trans_data/build.sh @@ -1,5 +1,4 @@ $CPP trans_data.cpp -o trans_data.wasm -fno-exceptions -fno-rtti -ffast-math -funroll-loops -fomit-frame-pointer -Ofast -# $CPP trans_data.cpp -o trans_data.wasm wasmtime compile --target x86_64-unknown-none -W threads=n,tail-call=n trans_data.wasm @@ -11,4 +10,4 @@ cargo build --target x86_64-unknown-none --release && cc \ -shared \ -o target/x86_64-unknown-none/release/libwasmtime_trans_data.so -ln -s /home/wyj/alloy_stack/mslibos/user/wasmtime_trans_data/target/x86_64-unknown-none/release/libwasmtime_trans_data.so /home/wyj/alloy_stack/mslibos/target/release/libwasmtime_trans_data.so +ln -s /home/wyj/dyx_workplace/mslibos/user/wasmtime_trans_data/target/x86_64-unknown-none/release/libwasmtime_trans_data.so /home/wyj/dyx_workplace/mslibos/target/release/libwasmtime_trans_data.so diff --git a/user/wasmtime_trans_data/src/lib.rs b/user/wasmtime_trans_data/src/lib.rs index 45e7db9c..828dd8cc 100644 --- a/user/wasmtime_trans_data/src/lib.rs +++ b/user/wasmtime_trans_data/src/lib.rs @@ -34,7 +34,7 @@ fn func_body() -> Result<()> { let mut store = Store::new(&engine, LibosCtx{id: "0".to_string()}); let instance = linker.instantiate(&mut store, &module)?; - let mut memory = instance.get_memory(&mut store, "memory").unwrap(); + let memory = instance.get_memory(&mut store, "memory").unwrap(); let pages = memory.grow(&mut store, 20000).unwrap(); println!("rust: pages: {}", pages); @@ -49,6 +49,5 @@ fn func_body() -> Result<()> { #[no_mangle] pub fn main() -> Result<()> { - println!("start_time: {}", SystemTime::now().duration_since(UNIX_EPOCH).as_micros() as f64 / 1000000f64); func_body() } diff --git a/user/wasmtime_trans_data/trans_data.cpp b/user/wasmtime_trans_data/trans_data.cpp index 95b9fd3d..3f1f8549 100644 --- a/user/wasmtime_trans_data/trans_data.cpp +++ b/user/wasmtime_trans_data/trans_data.cpp @@ -11,7 +11,7 @@ using namespace std; -#define MAX_BUFFER_SIZE 1024 * 64 +#define MAX_BUFFER_SIZE 4 * 1024 __attribute__((import_module("env"), import_name("buffer_register"))) void buffer_register(void *slot_name, int name_size, void *buffer, int buffer_size); @@ -24,53 +24,18 @@ void get_time() { printf("%lld.%06lld\n", tv.tv_sec, tv.tv_usec); } -int arrays[100000000]; - int main() { - // get_time(); - // string slot_name = "tmp"; - // // string buffer(MAX_BUFFER_SIZE, '0'); - // vector buffer(MAX_BUFFER_SIZE, 0); - // buffer_register((void*)slot_name.c_str(), slot_name.length(), (void*)buffer.data(), MAX_BUFFER_SIZE); - - // get_time(); - // access_buffer((void*)slot_name.c_str(), slot_name.length(), (void*)buffer.data(), MAX_BUFFER_SIZE); - // get_time(); - - - //breakdown test - // get_time(); - // const int N = 1e9; - // unsigned int a = 0, b = 1; - // for (int i = 1; i <= N; i++) { - // a += b; - // b *= 2; - // } - // get_time(); - // printf("a: %u\n", a); - - // for (int i = 0; i < 100000000; i++) { - // arrays[i] = 100000000 - i; - // } - // get_time(); - // sort(arrays, arrays+100000000); - // get_time(); - - srand(42); - get_time(); - for (int i = 0; i < 100000000; i++) { - arrays[i] = rand(); - } + string slot_name = "tmp"; + // string buffer(MAX_BUFFER_SIZE, '0'); + vector buffer(MAX_BUFFER_SIZE, 0); + for(int i=0;i arrays; - // get_time(); - // for (int i = 0; i < 100000000; i++) { - // arrays.push_back(1); - // } - // get_time(); + return 0; } \ No newline at end of file diff --git a/user/wasmtime_trans_data/trans_data.cwasm b/user/wasmtime_trans_data/trans_data.cwasm index d26828c0..80636f08 100644 Binary files a/user/wasmtime_trans_data/trans_data.cwasm and b/user/wasmtime_trans_data/trans_data.cwasm differ diff --git a/user/wasmtime_trans_data/trans_data.wasm b/user/wasmtime_trans_data/trans_data.wasm index 7b9d015b..6b79b136 100755 Binary files a/user/wasmtime_trans_data/trans_data.wasm and b/user/wasmtime_trans_data/trans_data.wasm differ diff --git a/user/wasmtime_longchain/Cargo.lock b/user/wasmtime_write/Cargo.lock similarity index 99% rename from user/wasmtime_longchain/Cargo.lock rename to user/wasmtime_write/Cargo.lock index 78d79910..1b5a16b5 100644 --- a/user/wasmtime_longchain/Cargo.lock +++ b/user/wasmtime_write/Cargo.lock @@ -52,9 +52,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "cc" -version = "1.1.28" +version = "1.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e80e3b6a3ab07840e1cae9b0666a63970dc28e8ed5ffbcdacbfc760c281bfc1" +checksum = "58e804ac3194a48bb129643eb1d62fcc20d18c6b8c181704489353d13120bcd1" dependencies = [ "shlex", ] @@ -1042,29 +1042,28 @@ dependencies = [ ] [[package]] -name = "wasmtime_func" +name = "wasmtime_wasi_api" version = "0.1.0" dependencies = [ + "hashbrown 0.14.5", "lazy_static", "ms_hostcall", "ms_std", "ms_std_proc_macro", + "sjlj", "spin", - "wasmtime_wasi_api", + "wasmtime", ] [[package]] -name = "wasmtime_wasi_api" +name = "wasmtime_write" version = "0.1.0" dependencies = [ - "hashbrown 0.14.5", "lazy_static", "ms_hostcall", "ms_std", - "ms_std_proc_macro", - "sjlj", "spin", - "wasmtime", + "wasmtime_wasi_api", ] [[package]] diff --git a/user/wasmtime_func_a/Cargo.toml b/user/wasmtime_write/Cargo.toml similarity index 75% rename from user/wasmtime_func_a/Cargo.toml rename to user/wasmtime_write/Cargo.toml index 73966ea7..601c5e10 100644 --- a/user/wasmtime_func_a/Cargo.toml +++ b/user/wasmtime_write/Cargo.toml @@ -1,22 +1,22 @@ -[package] -name = "wasmtime_mapper" -version = "0.1.0" -edition = "2021" -build = "build.rs" -# build = "../../build_wasm.rs" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[lib] -crate-type = ["staticlib"] - -[dependencies] -ms_std = { path = "../../ms_std", features = ["panic_def", "alloc_def"] } -ms_hostcall = { path = "../../ms_hostcall", features = ["signal"] } - -wasmtime_wasi_api = { path = "../../wasmtime_wasi_api" } - -lazy_static = { version = "1.5.0", features = ["spin_no_std"] } -spin = "0.9.8" - -[features] -mpk = ["ms_std/mpk"] +[package] +name = "wasmtime_write" +version = "0.1.0" +edition = "2021" +build = "build.rs" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lib] +crate-type = ["staticlib"] + +[dependencies] +ms_std = { path = "../../ms_std", features = ["panic_def", "alloc_def"] } +ms_hostcall = { path = "../../ms_hostcall" } +wasmtime_wasi_api = { path = "../../wasmtime_wasi_api" } + +lazy_static = { version = "1.5.0", features = ["spin_no_std"] } +spin = "0.9.8" + +[features] +mpk = ["ms_std/mpk"] + +default = [] diff --git a/user/wasmtime_write/build.rs b/user/wasmtime_write/build.rs new file mode 100644 index 00000000..9fc09ddf --- /dev/null +++ b/user/wasmtime_write/build.rs @@ -0,0 +1,4 @@ +fn main() { + println!("cargo:rustc-link-lib=static={}", "wasmtime-platform"); + println!("cargo:rustc-link-search=native={}", "./"); +} diff --git a/user/wasmtime_write/libwasmtime-platform.a b/user/wasmtime_write/libwasmtime-platform.a new file mode 100644 index 00000000..beebf570 Binary files /dev/null and b/user/wasmtime_write/libwasmtime-platform.a differ diff --git a/user/wasmtime_write/libwasmtime-platform.o b/user/wasmtime_write/libwasmtime-platform.o new file mode 100644 index 00000000..90bbf6dd Binary files /dev/null and b/user/wasmtime_write/libwasmtime-platform.o differ diff --git a/user/wasmtime_write/src/lib.rs b/user/wasmtime_write/src/lib.rs new file mode 100644 index 00000000..ddcb18c0 --- /dev/null +++ b/user/wasmtime_write/src/lib.rs @@ -0,0 +1,36 @@ +#![no_std] + +extern crate alloc; +use alloc::string::ToString; +use spin::Mutex; + +use ms_std::{agent::FaaSFuncResult as Result, args, println, libos::libos}; + +use wasmtime_wasi_api::{wasmtime, LibosCtx}; +use wasmtime::Store; + +static CWASM: &[u8] = include_bytes!("../write.cwasm"); + +static INIT_LOCK: Mutex<()> = Mutex::new(()); + +#[no_mangle] +pub fn main() -> Result<()> { + let id = args::get("id").unwrap(); + println!("rust: write_{} begin", id); + + let lock = INIT_LOCK.lock(); + let (engine, module, linker) = wasmtime_wasi_api::build_wasm(CWASM); + drop(lock); + + let mut store = Store::new(&engine, LibosCtx{id: id.to_string()}); + let instance = linker.instantiate(&mut store, &module)?; + + let main = instance + .get_typed_func::<(), ()>(&mut store, "_start") + .map_err(|e| e.to_string())?; + + main.call(store, ()).map_err(|e| e.to_string())?; + + println!("rust: write_{} end", id); + Ok(().into()) +} diff --git a/user/wasmtime_write/write.c b/user/wasmtime_write/write.c new file mode 100644 index 00000000..09391446 --- /dev/null +++ b/user/wasmtime_write/write.c @@ -0,0 +1,7 @@ +#include + +int main() +{ + write(1, "write.c: Hello World!\n", sizeof("write.c: Hello World!\n")); + return 0; +} \ No newline at end of file diff --git a/user/wasmtime_write/write.cwasm b/user/wasmtime_write/write.cwasm new file mode 100644 index 00000000..13aeb220 Binary files /dev/null and b/user/wasmtime_write/write.cwasm differ diff --git a/user/wasmtime_write/write.wasm b/user/wasmtime_write/write.wasm new file mode 100755 index 00000000..cda229da Binary files /dev/null and b/user/wasmtime_write/write.wasm differ diff --git a/wasi_api/Cargo.toml b/wasi_api/Cargo.toml deleted file mode 100644 index fc89c2ab..00000000 --- a/wasi_api/Cargo.toml +++ /dev/null @@ -1,29 +0,0 @@ -[package] -name = "wasi_api" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -ms_std = { path = "../ms_std", default-features = false } -ms_hostcall = { path = "../ms_hostcall", default-features = false } -ms_std_proc_macro = { path = "../ms_std_proc_macro" } -# unwinding = { version = "=0.2.0", features = ["panic-handler", "personality"] } -spin = "0.9.8" -hashbrown = { version = "0.14", default-features = false, features = ["ahash"] } -lazy_static = { version = "1.4.0", features = ["spin_no_std"] } - -tinywasm = { git = "https://github.com/anti-entropy123/tinywasm", branch = "master", default-features = false, features = [ - "parser", -] } -# tinywasm = { path = "/home/yjn/rust_project/tinywasm-lym", default-features = false, features = [ -# tinywasm = { path = "/home/dyx/workplace/mslibos/tinywasm", default-features = false, features = [ -#tinywasm = { path = "../tinywasm", default-features = false, features = [ -# "parser", -#] } - -[features] -log = [] - -# default = ["log"] diff --git a/wasi_api/src/data_buffer.rs b/wasi_api/src/data_buffer.rs deleted file mode 100644 index 2011121b..00000000 --- a/wasi_api/src/data_buffer.rs +++ /dev/null @@ -1,78 +0,0 @@ -use core::mem::forget; - -use ms_std::agent::DataBuffer; -// #[cfg(feature = "log")] -use ms_std::println; -use ms_std_proc_macro::FaasData; -use tinywasm::{FuncContext, MemoryStringExt}; - -#[derive(FaasData)] -struct WasmDataBuffer(*mut u8, usize); - -impl Default for WasmDataBuffer { - fn default() -> Self { - Self(core::ptr::null_mut(), Default::default()) - } -} - -pub fn buffer_register( - mut ctx: FuncContext, - (slot_name_base, slot_name_size, buffer_base, buffer_size): (i32, i32, i32, i32), -) -> tinywasm::Result<()> { - #[cfg(feature = "log")] - println!("buffer_register"); - - let memory = ctx.exported_memory("memory").unwrap(); - let slot_name = memory - .load_string(slot_name_base as usize, slot_name_size as usize) - .unwrap(); - #[cfg(feature = "log")] - println!("slot_name={}", slot_name); - - let mut content = memory - .load_string(buffer_base as usize, buffer_size as usize) - .unwrap(); - let buffer_base = content.as_mut_ptr(); - #[cfg(feature = "log")] - println!("content={}", content); - forget(content); - - let mut wasm_buffer: DataBuffer = DataBuffer::with_slot(slot_name); - wasm_buffer.0 = buffer_base; - wasm_buffer.1 = buffer_size as usize; - - Ok(()) -} - -pub fn access_buffer( - mut ctx: FuncContext, - (slot_name_base, slot_name_size, buffer_base, buffer_size): (i32, i32, i32, i32), -) -> tinywasm::Result<()> { - #[cfg(feature = "log")] - println!("access_buffer"); - - let mut memory = ctx.exported_memory_mut("memory").unwrap(); - let slot_name = memory - .load_string(slot_name_base as usize, slot_name_size as usize) - .unwrap(); - #[cfg(feature = "log")] - println!("slot_name={}", slot_name); - let wasm_buffer: DataBuffer = DataBuffer::from_buffer_slot(slot_name).unwrap(); - #[cfg(feature = "log")] - println!( - "wasm_buffer -> addr={:?}, size={}", - wasm_buffer.0, wasm_buffer.1 - ); - - if buffer_size as usize != wasm_buffer.1 { - panic!() - } - let buffer = unsafe { core::slice::from_raw_parts(wasm_buffer.0, wasm_buffer.1) }; - #[cfg(feature = "log")] - println!("buffer: {:?}", buffer); - memory - .store(buffer_base as usize, buffer_size as usize, buffer) - .unwrap(); - - Ok(()) -} diff --git a/wasi_api/src/lib.rs b/wasi_api/src/lib.rs deleted file mode 100644 index 6c45b5ad..00000000 --- a/wasi_api/src/lib.rs +++ /dev/null @@ -1,241 +0,0 @@ -#![no_std] - -extern crate alloc; -use alloc::{string::String, vec::Vec}; -pub use tinywasm; -use tinywasm::{Extern, Imports}; - -mod data_buffer; -mod wasi; - -pub fn set_wasi_args(id: usize, _args: Vec) { - wasi::set_wasi_state(id, _args); -} - -pub fn import_all() -> tinywasm::Result { - let mut imports = Imports::new(); - - imports - .define( - "env", - "buffer_register", - Extern::typed_func(data_buffer::buffer_register), - )? - .define( - "env", - "access_buffer", - Extern::typed_func(data_buffer::access_buffer), - )? - .define( - "wasi_snapshot_preview1", - "args_get", - Extern::typed_func(wasi::args_get), - )? - .define( - "wasi_snapshot_preview1", - "args_sizes_get", - Extern::typed_func(wasi::args_sizes_get), - )? - .define( - "wasi_snapshot_preview1", - "clock_res_get", - Extern::typed_func(wasi::clock_res_get), - )? - .define( - "wasi_snapshot_preview1", - "clock_time_get", - Extern::typed_func(wasi::clock_time_get), - )? - .define( - "wasi_snapshot_preview1", - "environ_get", - Extern::typed_func(wasi::environ_get), - )? - .define( - "wasi_snapshot_preview1", - "environ_sizes_get", - Extern::typed_func(wasi::environ_sizes_get), - )? - .define( - "wasi_snapshot_preview1", - "fd_advise", - Extern::typed_func(wasi::fd_advise), - )? - .define( - "wasi_snapshot_preview1", - "fd_close", - Extern::typed_func(wasi::fd_close), - )? - .define( - "wasi_snapshot_preview1", - "fd_datasync", - Extern::typed_func(wasi::fd_datasync), - )? - .define( - "wasi_snapshot_preview1", - "fd_fdstat_get", - Extern::typed_func(wasi::fd_fdstat_get), - )? - .define( - "wasi_snapshot_preview1", - "fd_fdstat_set_flags", - Extern::typed_func(wasi::fd_fdstat_set_flags), - )? - .define( - "wasi_snapshot_preview1", - "fd_filestat_get", - Extern::typed_func(wasi::fd_filestat_get), - )? - .define( - "wasi_snapshot_preview1", - "fd_filestat_set_size", - Extern::typed_func(wasi::fd_filestat_set_size), - )? - .define( - "wasi_snapshot_preview1", - "fd_filestat_set_times", - Extern::typed_func(wasi::fd_filestat_set_times), - )? - .define( - "wasi_snapshot_preview1", - "fd_pread", - Extern::typed_func(wasi::fd_pread), - )? - .define( - "wasi_snapshot_preview1", - "fd_pwrite", - Extern::typed_func(wasi::fd_pwrite), - )? - .define( - "wasi_snapshot_preview1", - "fd_prestat_get", - Extern::typed_func(wasi::fd_prestat_get), - )? - .define( - "wasi_snapshot_preview1", - "fd_prestat_dir_name", - Extern::typed_func(wasi::fd_prestat_dir_name), - )? - .define( - "wasi_snapshot_preview1", - "fd_read", - Extern::typed_func(wasi::fd_read), - )? - .define( - "wasi_snapshot_preview1", - "fd_readdir", - Extern::typed_func(wasi::fd_readdir), - )? - .define( - "wasi_snapshot_preview1", - "fd_seek", - Extern::typed_func(wasi::fd_seek), - )? - .define( - "wasi_snapshot_preview1", - "fd_sync", - Extern::typed_func(wasi::fd_sync), - )? - .define( - "wasi_snapshot_preview1", - "fd_tell", - Extern::typed_func(wasi::fd_tell), - )? - .define( - "wasi_snapshot_preview1", - "fd_write", - Extern::typed_func(wasi::fd_write), - )? - .define( - "wasi_snapshot_preview1", - "path_create_directory", - Extern::typed_func(wasi::path_create_directory), - )? - .define( - "wasi_snapshot_preview1", - "path_link", - Extern::typed_func(wasi::path_link), - )? - .define( - "wasi_snapshot_preview1", - "path_open", - Extern::typed_func(wasi::path_open), - )? - .define( - "wasi_snapshot_preview1", - "path_readlink", - Extern::typed_func(wasi::path_readlink), - )? - .define( - "wasi_snapshot_preview1", - "path_filestat_get", - Extern::typed_func(wasi::path_filestat_get), - )? - .define( - "wasi_snapshot_preview1", - "path_filestat_set_times", - Extern::typed_func(wasi::path_filestat_set_times), - )? - .define( - "wasi_snapshot_preview1", - "path_remove_directory", - Extern::typed_func(wasi::path_remove_directory), - )? - .define( - "wasi_snapshot_preview1", - "path_rename", - Extern::typed_func(wasi::path_rename), - )? - .define( - "wasi_snapshot_preview1", - "path_symlink", - Extern::typed_func(wasi::path_symlink), - )? - .define( - "wasi_snapshot_preview1", - "path_unlink_file", - Extern::typed_func(wasi::path_unlink_file), - )? - .define( - "wasi_snapshot_preview1", - "poll_oneoff", - Extern::typed_func(wasi::poll_oneoff), - )? - .define( - "wasi_snapshot_preview1", - "proc_exit", - Extern::typed_func(wasi::proc_exit), - )? - .define( - "wasi_snapshot_preview1", - "random_get", - Extern::typed_func(wasi::random_get), - )? - .define( - "wasi_snapshot_preview1", - "sched_yield", - Extern::typed_func(wasi::sched_yield), - )? - .define( - "wasi_snapshot_preview1", - "sock_accept", - Extern::typed_func(wasi::sock_accept), - )? - .define( - "wasi_snapshot_preview1", - "sock_recv", - Extern::typed_func(wasi::sock_recv), - )? - .define( - "wasi_snapshot_preview1", - "sock_send", - Extern::typed_func(wasi::sock_send), - )? - .define( - "wasi_snapshot_preview1", - "sock_shutdown", - Extern::typed_func(wasi::sock_shutdown), - )?; - - Ok(imports) -} diff --git a/wasi_api/src/wasi.rs b/wasi_api/src/wasi.rs deleted file mode 100644 index 4920dfd7..00000000 --- a/wasi_api/src/wasi.rs +++ /dev/null @@ -1,1111 +0,0 @@ -extern crate alloc; - -#[cfg(feature = "log")] -use ms_std::println; -#[cfg(feature = "log")] -use alloc::format; -use alloc::{borrow::ToOwned, string::String, vec::Vec}; -use core::{mem::forget, slice}; -use hashbrown::HashMap; -use spin::{Mutex, MutexGuard}; - -use ms_hostcall::{fdtab::FdtabResult, types::{OpenFlags, OpenMode, Stat, Fd, DirEntry}}; -use ms_std::{ - libos::libos, - time::{SystemTime, UNIX_EPOCH}, -}; -use tinywasm::{FuncContext, MemoryStringExt}; - -#[repr(C)] -struct WasiCiovec { - buf: u32, - buf_len: u32, -} - -#[repr(C)] -struct WasiFdstat { - fs_filetype: u8, - fs_flags: u16, - fs_rights_base: u64, - fs_rights_inheriting: u64, -} - -#[repr(C)] -#[derive(Debug)] -struct WasiFilestat { - dev: u64, - ino: u64, - filetype: u8, - nlink: u64, - size: u64, - atim: u64, - mtim: u64, - ctim: u64, -} - -#[repr(C)] -#[derive(Debug)] -struct Dirent { - d_next: u64, - d_ino: u64, - d_namelen: u32, - d_type: u8 -} - -#[repr(C)] -struct WasiPrestatDir { - dirname_len: u32, -} - -#[repr(C)] -struct WasiPrestatUt { - dir: WasiPrestatDir, -} - -#[repr(C)] -struct WasiPrestatT { - tag: u8, - u: WasiPrestatUt, -} - -#[derive(Clone)] -pub struct WasiState { - pub args: Vec, -} - -lazy_static::lazy_static! { - static ref WASI_STATE: Mutex> = Mutex::new( HashMap::new() ); -} - -// This is a non-pub function because it should not be init in other file. -fn get_hashmap_wasi_state_mut() -> MutexGuard<'static, HashMap> { - WASI_STATE.lock() -} - -fn get_wasi_state<'a>( - id: usize, - map: &'a MutexGuard<'static, HashMap>, -) -> &'a WasiState { - let wasi_state = map.get(&id).unwrap(); - if wasi_state.args.len() == 0 { - panic!("WASI_STATE uninit") - } - wasi_state -} - -pub fn set_wasi_state(id: usize, _args: Vec) { - let mut map = get_hashmap_wasi_state_mut(); - let wasi_state: WasiState = WasiState { args: _args }; - map.insert(id, (&wasi_state).clone()); -} - -lazy_static::lazy_static! { - static ref FD2PATH: Mutex> = Mutex::new( HashMap::new() ); -} - -fn get_hashmap_fd2path_mut() -> MutexGuard<'static, HashMap> { - FD2PATH.lock() -} - -fn get_fd2path<'a>(fd: u32, map: &'a MutexGuard<'static, HashMap>) -> &'a String { - let path = map.get(&fd).unwrap(); - if path.len() == 0 { - panic!("FD2PATH uninit") - } - path -} - -pub fn set_fd2path(fd: u32, path: String) { - let mut map = get_hashmap_fd2path_mut(); - map.insert(fd, path); -} - -struct LCG { - state: u64, -} - -impl LCG { - fn new(seed: u64) -> Self { - LCG { state: seed } - } - - fn next_u8(&mut self) -> u8 { - // LCG的参数 - const A: u64 = 1664525; - const C: u64 = 1013904223; - const MOD: u64 = 1 << 32; - - // 更新状态 - self.state = (A.wrapping_mul(self.state).wrapping_add(C)) % MOD; - - // 返回一个0到255之间的随机u8 - (self.state % 256) as u8 - } - - fn generate_random_u8_slice(&mut self, length: usize) -> Vec { - (0..length).map(|_| self.next_u8()).collect() - } -} - -pub fn args_get(mut ctx: FuncContext, args: (i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into args_get"); - println!("args: argv: {:?}, argv_buf: {:?}", args.0, args.1); - } - - // argv是每个arg在argv_buf中的起始地址的数组的起始地址 - // argv_buf是存arg的buf的起始地址 - // 在buf中存入arg,并以\0结尾 (len需要+1) - let argv = args.0 as usize; - let argv_buf = args.1 as usize; - - let ctx_id = ctx.store().id(); - let map = WASI_STATE.lock(); - let wasi_state = get_wasi_state(ctx_id, &map); - let args: Vec<&[u8]> = wasi_state - .args - .iter() - .map(|a| a.as_bytes()) - .collect::>(); - let mut offset: usize = 0; - - let mut mem = ctx.exported_memory_mut("memory")?; - - #[cfg(feature = "log")] - println!("arg_vec len: {}", args.len()); - for (i, arg) in args.iter().enumerate() { - #[cfg(feature = "log")] - println!( - "i: {:?}, offset: {:?}, arg: {:?}, arg_len: {:?}", - i, - offset, - arg, - arg.len() - ); - let arg_addr = argv_buf + offset; - - mem.store( - argv + i * core::mem::size_of::(), - core::mem::size_of::(), - &(arg_addr as u32).to_ne_bytes(), - )?; - mem.store(arg_addr, arg.len(), arg)?; - mem.store( - arg_addr + arg.len(), - core::mem::size_of::(), - "\0".as_bytes(), - )?; - - offset += arg.len() + 1; - } - - Ok(0) -} - -pub fn args_sizes_get(mut ctx: FuncContext, args: (i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into args_sizes_get"); - println!("args: argc: {:?}, argv_buf_size: {:?}", args.0, args.1); - } - - let argc_ptr = args.0 as usize; - let argv_buf_size_ptr = args.1 as usize; - - let ctx_id = ctx.store().id(); - let map = WASI_STATE.lock(); - let wasi_state = get_wasi_state(ctx_id, &map); - let argc_val = wasi_state.args.len(); - let argv_buf_size_val: usize = wasi_state.args.iter().map(|v| v.len() + 1).sum(); - - #[cfg(feature = "log")] - println!( - "argc_val={:?}, argv_buf_size_val: {:?}", - argc_val, argv_buf_size_val - ); - - let mut mem = ctx.exported_memory_mut("memory")?; - - mem.store( - argc_ptr, - core::mem::size_of::(), - &(argc_val as u32).to_ne_bytes(), - )?; - mem.store( - argv_buf_size_ptr, - core::mem::size_of::(), - &(argv_buf_size_val as u32).to_ne_bytes(), - )?; - - Ok(0) -} - -pub fn clock_res_get(_: FuncContext, _args: (i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into clock_res_get"); - println!("args: clock_id: {:?}, resolution: {:?}", _args.0, _args.1); - } - - Ok(0) -} - -pub fn clock_time_get(mut ctx: FuncContext, args: (i32, i64, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into clock_time_get"); - println!( - "args: clock_id: {:?}, precision: {:?}, time: {:?}", - args.0, args.1, args.2 - ); - } - - let time_ptr = args.2 as usize; - let mut mem = ctx.exported_memory_mut("memory")?; - let time_var = SystemTime::now().duration_since(UNIX_EPOCH).as_nanos(); - mem.store( - time_ptr, - core::mem::size_of::(), - &time_var.to_ne_bytes(), - )?; - - Ok(0) -} - -pub fn environ_get(_: FuncContext<'_>, _args: (i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into environ_get"); - println!("args: environ: {:?}, environ_buf: {:?}", _args.0, _args.1); - } - Ok(0) -} - -pub fn environ_sizes_get(mut ctx: FuncContext, args: (i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into environ_sizes_get"); - println!( - "args: environ_count: {:?}, environ_buf_size: {:?}", - args.0, args.1 - ); - } - - let count_ptr = args.0 as usize; - let buf_size_ptr = args.1 as usize; - let count = 0i32; - let buf_size = 0i32; - let mut mem = ctx.exported_memory_mut("memory")?; - mem.store(count_ptr, core::mem::size_of::(), &count.to_ne_bytes())?; - mem.store( - buf_size_ptr, - core::mem::size_of::(), - &buf_size.to_ne_bytes(), - )?; - - Ok(0) -} - -pub fn fd_advise(_: FuncContext<'_>, _args: (i32, i64, i64, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_advise"); - println!("args: fd: {:?}, offset: {:?}, len: {:?}, advice: {:?}", _args.0, _args.1, _args.2, _args.3); - } - Ok(0) -} - -pub fn fd_close(mut _ctx: FuncContext, _args: i32) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_close"); - println!("args: fd: {:?}", _args); - } - - let fd = _args as u32; - libos!(close(fd)).unwrap(); - - Ok(0) -} - -pub fn fd_datasync(_: FuncContext<'_>, _args: i32) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_datasync"); - println!("args: fd: {:?}", _args); - } - Ok(0) -} - -pub fn fd_fdstat_get(mut ctx: FuncContext<'_>, args: (i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_fdstat_get"); - println!("args: fd: {:?}, retptr: {:?}", args.0, args.1); - } - let fd = args.0 as u32; - let retptr = args.1 as usize; - let mut mem = ctx.exported_memory_mut("memory")?; - - let mut fdstat: WasiFdstat = WasiFdstat { - fs_filetype: 0, - fs_flags: 0, - fs_rights_base: 0, - fs_rights_inheriting: 0, - }; - match fd { - 0 => { - // stdin - fdstat.fs_filetype = 2; // CharacterDevice - fdstat.fs_flags = 0; - fdstat.fs_rights_base = 0xFFFFFFFFFFFFFFFF; - fdstat.fs_rights_inheriting = 0; - } - 1 => { - // stdout - fdstat.fs_filetype = 2; - fdstat.fs_flags = 1; - fdstat.fs_rights_base = 0xFFFFFFFFFFFFFFFF; - fdstat.fs_rights_inheriting = 0; - } - 2 => { - // stderr - fdstat.fs_filetype = 2; - fdstat.fs_flags = 1; - fdstat.fs_rights_base = 0xFFFFFFFFFFFFFFFF; - fdstat.fs_rights_inheriting = 0; - } - 3 => { - // root inode - fdstat.fs_filetype = 3; // Directory - fdstat.fs_flags = 0; - fdstat.fs_rights_base = 0xFFFFFFFFFFFFFFFF; - fdstat.fs_rights_inheriting = 0xFFFFFFFFFFFFFFFF; - } - _ => (), - } - // Todo: 从表中寻找fd - // let FdStruct = table.find(fd); - // fdstat.fs_filetype = match FdStruct.kind { - // 0 => 4, // 0 代表File,4代表RegularFile - // 1 => 3 // 1 代表Dir,3代表Directory - // }; - // fdstat.fs_flags = FdStruct.flags; - // fdstat.fs_rights_base = FdStruct.fs_rights_base; - // fdstat.fs_rights_inheriting = FdStruct.fs_rights_inheriting; - if fd == 4 || fd == 5 || fd == 6 || fd == 7 || fd == 8 { - // 假设前面几个都打开的文件 - fdstat.fs_filetype = 4; - fdstat.fs_flags = 0; - fdstat.fs_rights_base = 0xFFFFFFFFFFFFFFFF; - fdstat.fs_rights_inheriting = 0xFFFFFFFFFFFFFFFF; - } - - let ret = (&fdstat) as *const _ as usize; - let ret = unsafe { - core::slice::from_raw_parts(ret as *const u8, core::mem::size_of::()) - }; - mem.store(retptr, core::mem::size_of::(), ret)?; - - Ok(0) -} - -pub fn fd_fdstat_set_flags(mut _ctx: FuncContext<'_>, args: (i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_fdstat_set_flags"); - println!("args: fd: {:?}, flag: {:?}", args.0 as u32, args.1 as u16); - } - - let _fd = args.0 as u32; - let _flag = args.1 as u16; - - Ok(0) -} - -pub fn fd_filestat_get(_: FuncContext<'_>, _args: (i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_filestat_get"); - println!("args: fd: {:?}, buf: {:?}", _args.0, _args.1); - } - - Ok(0) -} - -pub fn fd_filestat_set_size(_: FuncContext<'_>, _args: (i32, i64)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_filestat_set_size"); - println!("args: fd: {:?}, st_size: {:?}", _args.0, _args.1); - } - - Ok(0) -} - -pub fn fd_filestat_set_times(_: FuncContext<'_>, _args: (i32, i64, i64, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_filestat_set_times"); - println!("args: fd: {:?}, st_atim: {:?}, st_mtim: {:?}, fst_flags: {:?}", _args.0, _args.1, _args.2, _args.3); - } - Ok(0) -} - -pub fn fd_pread(mut _ctx: FuncContext<'_>, _args: (i32, i32, i32, i64, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_pread"); - println!( - "args: fd: {:?}, iovs: {:?}, iovs_len: {:?}, offset: {:?}, nread: {:?}", - _args.0, _args.1, _args.2, _args.3, _args.4 - ); - } - - Ok(0) -} - -pub fn fd_prestat_get(mut ctx: FuncContext<'_>, args: (i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_prestat_get"); - println!("args: fd: {:?}, retptr: {:?}", args.0, args.1); - } - let fd = args.0 as u32; - let retptr = args.1 as usize; - let mut mem = ctx.exported_memory_mut("memory")?; - - match fd { - 3 => { - // root inode - let prestat = WasiPrestatT { - tag: 0, // tag 应为 0,表示这是一个目录,非0表示unknown - u: WasiPrestatUt { - dir: WasiPrestatDir { - // dirname_len: "/".len() as u32 + 1, // +1以防止递归错误 - dirname_len: "/".len() as u32, - }, - }, - }; - - let ret = (&prestat) as *const _ as usize; - let ret = unsafe { - core::slice::from_raw_parts(ret as *const u8, core::mem::size_of::()) - }; - mem.store(retptr, core::mem::size_of::(), ret)?; - - Ok(0) // Success - } - // Todo: libos需要维护一个表,从表中找fd,找不到就返回Badf - _ => Ok(8), // Badf - } -} - -pub fn fd_prestat_dir_name( - mut ctx: FuncContext<'_>, - args: (i32, i32, i32), -) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_prestat_dir_name"); - println!( - "args: fd: {:?}, path_addr: {:?}, path_len: {:?}", - args.0, args.1, args.2 - ); - } - - let fd = args.0 as u32; - let path = args.1 as u32; - let path_len = args.2 as u32; - let mut mem = ctx.exported_memory_mut("memory")?; - - // Todo: 从表中寻找fd - if fd == 3 { - let name = "/"; - mem.store(path as usize, path_len as usize, name.as_bytes())?; - - Ok(0) - } else { - Ok(61) // Overflow - } -} - -pub fn fd_read(mut ctx: FuncContext<'_>, args: (i32, i32, i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_read"); - println!( - "args: fd: {:?}, iovs_ptr: {:?}, iovs_len: {:?}, retptr: {:?}", - args.0, args.1, args.2, args.3 - ); - } - let fd = args.0 as u32; - let iovs_ptr = args.1 as usize; - let iovs_len = args.2 as usize; - let retptr = args.3 as usize; - - let mut mem = ctx.exported_memory_mut("memory")?; - let mut read_size: usize = 0; - - for i in 0..iovs_len { - let offset = iovs_ptr + i * core::mem::size_of::(); - let iovs: &[u8] = mem.load(offset, core::mem::size_of::())?; - let iovs: &WasiCiovec = unsafe { &*(iovs.as_ptr() as *const WasiCiovec) }; - let buf: &[u8] = mem.load(iovs.buf as usize, iovs.buf_len as usize)?; - let buf: &mut [u8] = unsafe { - slice::from_raw_parts_mut(buf.as_ptr() as usize as *mut u8, iovs.buf_len as usize) - }; - read_size += libos!(read(fd, buf)).unwrap(); - } - - #[cfg(feature = "log")] - println!("read_size: {:?}", read_size); - mem.store( - retptr, - core::mem::size_of::(), - &read_size.to_ne_bytes(), - )?; - - Ok(0) -} - -pub fn fd_pwrite(mut _ctx: FuncContext<'_>, _args: (i32, i32, i32, i64, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_pwrite"); - println!( - "args: fd: {:?}, iovs: {:?}, iovs_len: {:?}, offset: {:?}, nwritten: {:?}", - _args.0, _args.1, _args.2, _args.3, _args.4 - ); - } - - Ok(0) -} - -pub fn fd_readdir(mut ctx: FuncContext<'_>, args: (i32, i32, i32, i64, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_readdir"); - println!( - "args: fd: {:?}, buf: {:?}, buf_len: {:?}, cookie: {:?}, bufused: {:?}", - args.0, args.1, args.2, args.3, args.4 - ); - } - - let fd = args.0 as u32; - let buf = args.1 as u32; - let buf_len = args.2 as u32; - let cookie = args.3 as u64; - let bufused = args.4 as u32; - let mut mem = ctx.exported_memory_mut("memory")?; - - let map = FD2PATH.lock(); - let path = get_fd2path(fd, &map); - - #[cfg(feature = "log")] { - println!("[DEBUG] fd_readdir: fd = {:?}, path = {:?}", fd, path); - } - - let mut entries: Vec = libos!(readdir(path)).unwrap(); - - entries.push(DirEntry{ - dir_path: ".".to_owned(), - entry_name: ".".to_owned(), - entry_type: 4 - }); - entries.push(DirEntry{ - dir_path: "..".to_owned(), - entry_name: "..".to_owned(), - entry_type: 4 - }); - - entries.sort_by(|a, b| a.entry_name.cmp(&b.entry_name)); - - let mut cur_cookie = cookie; - let mut cur_buf = buf; - let mut bufused_len: u32 = 0; - for item in entries.iter().skip(cookie as usize) { - cur_cookie += 1; - let dirent = Dirent { - d_next: cur_cookie, - d_ino: match item.entry_name.as_str() { - "." | ".." => 0, - _ => { - let item_fd = libos!(open(&item.dir_path, OpenFlags::empty(), OpenMode::RD)).unwrap(); - let item_stat = libos!(stat(item_fd)).unwrap(); - let _close_result = libos!(close(item_fd)); - item_stat.st_ino - } - }, - d_namelen: item.entry_name.len() as u32, - d_type: match item.entry_type { - 2 => 2, // CharDevice - 4 => 3, // Directory - 8 => 4, // Regular file - _ => 0 // Unknown - } - }; - // println!("[DEBUG] dirent: {:?}", dirent); - let ret = (&dirent) as *const _ as usize; - let ret = unsafe { - core::slice::from_raw_parts(ret as *const u8, core::mem::size_of::()) - }; - - if bufused_len + core::mem::size_of::() as u32 + item.entry_name.len() as u32 > buf_len { - #[cfg(feature = "log")] - println!("[ERR] fd_readdir: bufused overflow!"); - // let cap = buf_len.wrapping_sub(bufused_len); - let cap: u32 = buf_len - bufused_len; - #[cfg(feature = "log")] - println!("[ERR] fd_readdir: wrapping_sub over! ({:?} = {:?} - {:?})", cap, buf_len, bufused_len); - let result: Vec = [ret, item.entry_name.as_bytes()].concat(); - // let result: &[u8] = &result; - let result_void = &result as *const _ as _; - let result_write = unsafe { core::slice::from_raw_parts(&result_void, cap as _) }; - #[cfg(feature = "log")] - println!("[ERR] fd_readdir: cap: {:?}, result_write.len(): {:?}", cap, result_write.len()); - mem.store(cur_buf as usize, cap as usize, result_write)?; - mem.store(bufused as usize, core::mem::size_of::(), &buf_len.to_ne_bytes())?; - #[cfg(feature = "log")] - println!("[ERR] fd_readdir: store over!"); - forget(entries); - return Ok(0); // Overflow - } - - mem.store(cur_buf as usize, core::mem::size_of::(), ret)?; - cur_buf += core::mem::size_of::() as u32; - bufused_len += core::mem::size_of::() as u32; - - mem.store(cur_buf as usize, item.entry_name.len(), item.entry_name.as_bytes())?; - cur_buf += item.entry_name.len() as u32; - bufused_len += item.entry_name.len() as u32; - - } - mem.store(bufused as usize, core::mem::size_of::(), &bufused_len.to_ne_bytes())?; - forget(entries); - Ok(0) -} - -pub fn fd_seek(mut _ctx: FuncContext<'_>, _args: (i32, i64, i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_seek"); - println!( - "args: fd: {:?}, offset: {:?}, whence: {:?}, pos: {:?}", - _args.0, _args.1, _args.2, _args.3 - ); - } - - // TO BE FIX FOR PY HELLO - // let fd = args.0 as u32; - // let offset = args.1; - // let whence = args.2; - // let pos = offset as u32; - // // if whence == 0 { - - // // } else if whence == 1 { - - // // } else if whence == 2{ - - // // } - - // libos!(lseek(fd, pos)).unwrap(); - - Ok(0) -} - -pub fn fd_sync(_: FuncContext<'_>, _args: i32) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_sync"); - println!("args: fd: {:?}", _args); - } - Ok(0) -} - -pub fn fd_tell(_: FuncContext, _args: (i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_tell"); - println!("args: fd: {:?}, offset: {:?}", _args.0, _args.1); - } - - Ok(0) -} - -pub fn fd_write(mut ctx: FuncContext<'_>, args: (i32, i32, i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into fd_write"); - println!( - "args: fd: {:?}, iovs_ptr: {:?}, iovs_len: {:?}, retptr: {:?}", - args.0, args.1, args.2, args.3 - ); - } - let fd = args.0 as u32; - let iovs_ptr = args.1 as usize; - let iovs_len = args.2 as usize; - let retptr = args.3 as usize; - - let mut mem = ctx.exported_memory_mut("memory")?; - let mut write_size: usize = 0; - - for i in 0..iovs_len { - let offset = iovs_ptr + i * core::mem::size_of::(); - let iovs: &[u8] = mem.load(offset, core::mem::size_of::())?; - let iovs: &WasiCiovec = unsafe { &*(iovs.as_ptr() as *const WasiCiovec) }; - let buf = mem.load(iovs.buf as usize, iovs.buf_len as usize)? as &[u8]; - write_size += libos!(write(fd, buf)).unwrap(); - } - - #[cfg(feature = "log")] - println!("write_size: {:?}", write_size); - mem.store( - retptr, - core::mem::size_of::(), - &write_size.to_ne_bytes(), - )?; - Ok(0) -} - -pub fn path_create_directory( - _ctx: FuncContext<'_>, - _args: (i32, i32, i32), -) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into path_create_directory"); - println!( - "args: fd: {:?}, path: {:?}, path_len: {:?}", - _args.0, _args.1, _args.2 - ); - } - - Ok(0) -} - -pub fn path_filestat_get( - mut ctx: FuncContext<'_>, - args: (i32, i32, i32, i32, i32), -) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into path_filestat_get"); - println!( - "args: fd: {:?}, flags: {:?}, path: {:?}, path_len: {:?}, buf: {:?}", - args.0, args.1, args.2, args.3, args.4 - ); - } - - let _fd = args.0 as usize; - let _flags = args.1 as usize; - let _path = args.2 as usize; - let _path_len = args.3 as usize; - let buf = args.4 as usize; - - let mut mem = ctx.exported_memory_mut("memory")?; - let path = mem.load_string(args.2 as usize, args.3 as usize)?; - #[cfg(feature = "log")] - println!("path: {:?}", path); - - let path_fd: FdtabResult = libos!(open(&path, OpenFlags::empty(), OpenMode::RD)); - let path_fd = if let Err(_e) = path_fd { - #[cfg(feature = "log")] { - println!("[DEBUG] get path err: {:?}", _e); - println!("[DEBUG] return to wasi with errno 44: (noent - No such file or directory)"); - } - forget(_e); - return Ok(44); - } else { - path_fd.unwrap() - }; - - - let ruxstat: Stat = libos!(stat(path_fd)).unwrap(); - - // println!("[DEBUG] ruxstat.st_mode: {:?}", (ruxstat.st_mode >> 12)); - - let stat = WasiFilestat{ - dev: ruxstat.st_dev, - ino: ruxstat.st_ino, - filetype: match ruxstat.st_mode >> 12 { - 2 => 2, // CharDevice - 4 => 3, // Directory - 8 => 4, // Regular file - _ => 0 // Unknown - }, - nlink: ruxstat.st_nlink, - size: ruxstat.st_size as u64, - atim: ruxstat.st_atime.tv_nsec as u64, - mtim: ruxstat.st_mtime.tv_nsec as u64 , - ctim: ruxstat.st_ctime.tv_nsec as u64, - }; - - // println!("[DEBUG] return WasiFilestat: {:?}", stat); - - let ret = (&stat) as *const _ as usize; - let ret = unsafe { - core::slice::from_raw_parts(ret as *const u8, core::mem::size_of::()) - }; - mem.store(buf, core::mem::size_of::(), ret)?; - - Ok(0) -} - -pub fn path_filestat_set_times( - _: FuncContext<'_>, - _args: (i32, i32, i32, i32, i64, i64, i32), -) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into path_filestat_set_times"); - println!("args: fd: {:?}, flags: {:?}, path: {:?}, path_len: {:?}, st_atim: {:?}, st_mtim: {:?}, fst_flags: {:?}", _args.0, _args.1, _args.2, _args.3, _args.4, _args.5, _args.6); - } - Ok(0) -} - -pub fn path_link( - _ctx: FuncContext<'_>, - _args: (i32, i32, i32, i32, i32, i32, i32), -) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into path_link"); - println!("args: old_fd: {:?}, old_flags: {:?}, old_path: {:?}, old_path_len: {:?}, new_fd: {:?}, new_path: {:?}, new_path_len: {:?}", _args.0, _args.1, _args.2, _args.3, _args.4, _args.5, _args.6); - } - Ok(0) -} - -pub fn path_open( - mut ctx: FuncContext<'_>, - args: (i32, i32, i32, i32, i32, i64, i64, i32, i32), -) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into path_open"); - // println!("args: fd: {:?}, dirflags: {:?}, path_addr: {:?}, path_len: {:?}, oflags: {:?}, fs_rights_base: {:?}, fs_rights_inheriting: {:?}, fdflags: {:?}, retptr: {:?}", args.0 as u32, args.1 as u32, args.2 as u32, args.3 as u32, args.4 as u16, format!("{:064b}", args.5 as u64), format!("{:064b}", args.6 as u64), args.7 as u16, args.8 as u32); - } - let mut mem = ctx.exported_memory_mut("memory")?; - let _fd = args.0 as u32; - let _dirflags = args.1 as u32; - let path_addr = args.2 as u32; - let path_len = args.3 as u32; - let oflags = args.4 as u16; - - let fs_rights_base = args.5 as u64; - let _fs_rights_inheriting = args.6 as u64; - let fdflags = args.7 as u16; - let retptr = args.8 as usize; - - let path = mem.load_string(path_addr as usize, path_len as usize)?; - #[cfg(feature = "log")] - println!("path: {:?}", path); - - // special processing for cpython - if path == "pyvenv.cfg" { - // println!("[DEBUG] Return 44 (noent - No such file or directory)"); - return Ok(44); - } - - if path == "pybuilddir.txt" { - // println!("[DEBUG] Return 44 (noent - No such file or directory)"); - return Ok(44); - } - - let mut flags: OpenFlags = OpenFlags::empty(); - if (fdflags & 1) == 1 { - flags |= OpenFlags::O_APPEND; - } - if (oflags & 1) == 1 { - flags |= OpenFlags::O_CREAT; - } - - let mut mode: OpenMode = OpenMode::empty(); - if ((fs_rights_base >> 1) & 1) == 1 { - mode |= OpenMode::RD; - } - if ((fs_rights_base >> 6) & 1) == 1 { - mode |= OpenMode::WR; - } - - let ret_fd = libos!(open(&path, flags, mode)).unwrap() as i32; - #[cfg(feature = "log")] - println!("ret_fd: {:?}", ret_fd); - mem.store(retptr, core::mem::size_of::(), &ret_fd.to_ne_bytes())?; - // set fd2path - set_fd2path(ret_fd as u32, path); - Ok(0) -} - -pub fn path_readlink( - _ctx: FuncContext<'_>, - _args: (i32, i32, i32, i32, i32, i32), -) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into path_readlink"); - println!("args: dir_fd: {:?}, path: {:?}, path_len: {:?}, buf: {:?}, buf_len: {:?}, buf_used: {:?}", _args.0, _args.1, _args.2, _args.3, _args.4, _args.5); - } - Ok(0) -} - -pub fn path_remove_directory( - _ctx: FuncContext<'_>, - _args: (i32, i32, i32), -) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into path_remove_directory"); - println!( - "args: fd: {:?}, path: {:?}, path_len: {:?}", - _args.0, _args.1, _args.2 - ); - } - - Ok(0) -} - -pub fn path_rename( - _ctx: FuncContext<'_>, - _args: (i32, i32, i32, i32, i32, i32), -) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into path_rename"); - println!("args: old_fd: {:?}, old_path: {:?}, old_path_len: {:?}, new_fd: {:?}, new_path: {:?}, new_path_len: {:?}", _args.0, _args.1, _args.2, _args.3, _args.4, _args.5); - } - - Ok(0) -} - -pub fn path_symlink( - _ctx: FuncContext<'_>, - _args: (i32, i32, i32, i32, i32), -) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into path_symlink"); - println!( - "args: old_path: {:?}, old_path_len: {:?}, fd: {:?}, new_path: {:?}, new_path_len: {:?}", - _args.0, _args.1, _args.2, _args.3, _args.4 - ); - } - - Ok(0) -} - -pub fn path_unlink_file(_ctx: FuncContext<'_>, _args: (i32, i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into path_unlink_file"); - println!( - "args: fd: {:?}, path: {:?}, path_len: {:?}", - _args.0, _args.1, _args.2 - ); - } - - Ok(0) -} - -pub fn poll_oneoff(_ctx: FuncContext<'_>, _args: (i32, i32, i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into poll_oneoff"); - println!( - "args: in_: {:?}, out_: {:?}, nsubscriptions: {:?}, nevents: {:?}", - _args.0, _args.1, _args.2, _args.3 - ); - } - - Ok(0) -} - -pub fn proc_exit(_ctx: FuncContext<'_>, _args: i32) -> tinywasm::Result<()> { - #[cfg(feature = "log")] - println!("[Debug] Invoke into proc_exit"); - - panic!("normally exit") -} - -pub fn random_get(mut ctx: FuncContext<'_>, args: (i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into random_get"); - println!("args: buf: {:?}, buf_len: {:?}", args.0, args.1); - } - - let mut mem = ctx.exported_memory_mut("memory")?; - let buf = args.0 as usize; - let buf_len = args.1 as usize; - // let seed: u64 = 42; - let mut lcg = LCG::new(buf as u64); - let array = lcg.generate_random_u8_slice(buf_len); - - let data: &[u8] = &array; - mem.store(buf, buf_len, data)?; - - Ok(0) -} - -pub fn sched_yield(_ctx: FuncContext<'_>, _args: ()) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into sched_yield"); - } - - Ok(0) -} - -pub fn sock_accept(_ctx: FuncContext<'_>, _args: (i32, i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into sock_accept"); - // TO FIX: different parameters with https://wasix.org/docs/api-reference/wasi/sock_accept - println!( - "args: sock: {:?}, fd_flags: {:?}, ro_fd: {:?}", - _args.0, _args.1, _args.2 - ); - } - - Ok(0) -} - -pub fn sock_recv( - _ctx: FuncContext<'_>, - _args: (i32, i32, i32, i32, i32, i32), -) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into sock_recv"); - println!("args: sock: {:?}, ri_data: {:?}, ri_data_len: {:?}, ri_flags: {:?}, ro_data_len: {:?}, ro_flags: {:?}", _args.0, _args.1, _args.2, _args.3, _args.4, _args.5); - } - - Ok(0) -} - -pub fn sock_send( - _ctx: FuncContext<'_>, - _args: (i32, i32, i32, i32, i32), -) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into sock_send"); - println!( - "args: sock: {:?}, si_data: {:?}, si_data_len: {:?}, si_flags: {:?}, ret_data_len: {:?}", - _args.0, _args.1, _args.2, _args.3, _args.4 - ); - } - - Ok(0) -} - -pub fn sock_shutdown(_: FuncContext, _args: (i32, i32)) -> tinywasm::Result { - #[cfg(feature = "log")] - { - println!("[Debug] Invoke into sock_shutdown"); - println!("args: sock: {:?}, how: {:?}", _args.0, _args.1); - } - - Ok(0) -} diff --git a/wasmtime_wasi_api/src/data_buffer.rs b/wasmtime_wasi_api/src/data_buffer.rs index 09ccc7ca..f557f64c 100644 --- a/wasmtime_wasi_api/src/data_buffer.rs +++ b/wasmtime_wasi_api/src/data_buffer.rs @@ -1,11 +1,13 @@ extern crate alloc; -use core::mem::forget; use alloc::{string::String, vec::Vec}; use ms_std::agent::DataBuffer; #[cfg(feature = "log")] -use ms_std::{println, time::{SystemTime, UNIX_EPOCH}}; +use ms_std::{ + println, + time::{SystemTime, UNIX_EPOCH}, +}; use ms_std_proc_macro::FaasData; use wasmtime::Caller; @@ -22,34 +24,48 @@ impl Default for WasmDataBuffer { pub fn buffer_register( mut caller: Caller<'_, LibosCtx>, - slot_name_base: i32, slot_name_size: i32, buffer_offset: i32, buffer_size: i32, + slot_name_base: i32, + slot_name_size: i32, + buffer_offset: i32, + buffer_size: i32, ) { #[cfg(feature = "log")] { println!("[Debug] buffer_register"); - println!("[Time] buffer_register: {}", SystemTime::now().duration_since(UNIX_EPOCH).as_micros() as f64 / 1000000f64); + println!( + "[Time] buffer_register: {}", + SystemTime::now().duration_since(UNIX_EPOCH).as_micros() as f64 / 1000000f64 + ); } let memory = caller.get_export("memory").unwrap().into_memory().unwrap(); let mut slot_name: Vec = Vec::with_capacity(slot_name_size as usize); slot_name.resize(slot_name_size as usize, 0); - memory.read(&caller, slot_name_base as usize, &mut slot_name).unwrap(); + memory + .read(&caller, slot_name_base as usize, &mut slot_name) + .unwrap(); let slot_name = String::from_utf8(slot_name).expect("[Err] Not a valid UTF-8 sequence"); #[cfg(feature = "log")] println!("slot_name={}", slot_name); - let content = memory.data_mut(&mut caller) - .get_mut(buffer_offset as usize..) - .and_then(|s| s.get_mut(..buffer_size as usize)) - .unwrap(); - + let data = memory.data_mut(&mut caller); + let content = data + .get_mut(buffer_offset as usize..) + .and_then(|s| s.get_mut(..buffer_size as usize)) + .unwrap(); let buffer_base = content.as_mut_ptr(); #[cfg(feature = "log")] - println!("base={:?}, addr={:?}, offset={:?}, size={}", base, buffer_base, buffer_offset, buffer_size); - #[cfg(feature = "log")] - println!("content={:?}", content); + { + let base = data.as_mut_ptr(); + println!( + "base={:?}, addr={:?}, offset={:?}, size={}", + base, buffer_base, buffer_offset, buffer_size + ); + } + // #[cfg(feature = "log")] + // println!("content={:?}", content); let mut wasm_buffer: DataBuffer = DataBuffer::with_slot(slot_name); wasm_buffer.0 = buffer_base; @@ -58,23 +74,42 @@ pub fn buffer_register( pub fn access_buffer( mut caller: Caller<'_, LibosCtx>, - slot_name_base: i32, slot_name_size: i32, buffer_base: i32, buffer_size: i32, + slot_name_base: i32, + slot_name_size: i32, + buffer_offset: i32, + buffer_size: i32, ) { #[cfg(feature = "log")] { println!("[Debug] access_buffer"); - println!("[Time] access_buffer: {}", SystemTime::now().duration_since(UNIX_EPOCH).as_micros() as f64 / 1000000f64); + println!( + "[Time] access_buffer: {}", + SystemTime::now().duration_since(UNIX_EPOCH).as_micros() as f64 / 1000000f64 + ); } let memory = caller.get_export("memory").unwrap().into_memory().unwrap(); let mut slot_name: Vec = Vec::with_capacity(slot_name_size as usize); slot_name.resize(slot_name_size as usize, 0); - memory.read(&caller, slot_name_base as usize, &mut slot_name).unwrap(); + memory + .read(&caller, slot_name_base as usize, &mut slot_name) + .unwrap(); let slot_name = String::from_utf8(slot_name).expect("[Err] Not a valid UTF-8 sequence"); #[cfg(feature = "log")] println!("slot_name={}", slot_name); - let wasm_buffer: DataBuffer = DataBuffer::from_buffer_slot(slot_name).unwrap(); + let wasm_buffer: DataBuffer = DataBuffer::from_buffer_slot(slot_name) + .unwrap_or_else(|| { + #[cfg(feature = "log")] + println!("[Err] access_buffer didn't find the slot_name, return a empty buffer!"); + let mut content: Vec = Vec::with_capacity(buffer_size as usize); + content.resize(buffer_size as usize, 0); + let mut buffer: DataBuffer = DataBuffer::new(); + buffer.0 = content.as_mut_ptr(); + buffer.1 = buffer_size as usize; + buffer + }); + #[cfg(feature = "log")] println!( "wasm_buffer -> addr={:?}, size={}", @@ -85,7 +120,9 @@ pub fn access_buffer( panic!("buffer_size={}, wasm_buffer.1={}, access_buffer's size is different from buffer_register's size", buffer_size, wasm_buffer.1) } let buffer = unsafe { core::slice::from_raw_parts(wasm_buffer.0, wasm_buffer.1) }; - #[cfg(feature = "log")] - println!("buffer: {:?}", buffer); - memory.write(&mut caller, buffer_base as usize, buffer).unwrap(); + // #[cfg(feature = "log")] + // println!("buffer: {:?}", buffer); + memory + .write(&mut caller, buffer_offset as usize, buffer) + .unwrap(); }