Skip to content

Commit f2c2968

Browse files
committed
Commence wasm parsing support
1 parent b86a248 commit f2c2968

36 files changed

+672
-100
lines changed

Cargo.lock

+174-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
[workspace]
22
members = [
3-
'compiler'
3+
'cli',
4+
'runtime',
5+
'tests'
46
]

IDEAS.md

+56-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### GOALS
2+
3+
- The module must to be portable. Can be moved across threads but not necessarily shareable across threads.
4+
15
### LAZY MODE
26

37
- Single-pass compilation only (https://v8.dev/blog/liftoff)
@@ -32,10 +36,61 @@
3236

3337
```rs
3438
let imports = Imports::default(/* memories, tables, globals, functions */)?;
35-
let module = Module::new(&bytes, CompileMode::Eager)?; // Compiles with unresolved symbols. Creates trampolines.
39+
let module = Module::new(&bytes, opts)?; // Compiles with unresolved symbols. Creates trampolines.
3640
let instance = Instance::new(&module, &imports)?; // Links memory pieces. Makes imported functions where accessible.
3741
```
3842

3943
```rs
4044
module.dump(); // Dumps serialized module to Vec<u8> or &[u8].
4145
```
46+
47+
```rs
48+
module.clone(); // Cloning module
49+
```
50+
51+
Module has to be Send and Sync
52+
53+
https://webassembly.github.io/spec/core/appendix/embedding.html
54+
55+
Using ORCJIT.
56+
- Potential for Profile Guided Optimization.
57+
- Dump ObjectFile to disk
58+
- Load Object File.
59+
60+
```
61+
Store {
62+
init() -> { funcs, mems, globals, tables }
63+
}
64+
65+
Module {
66+
decode(Vec<u8>) -> Module? // wasm binary
67+
parse(String) -> Module? // wat text
68+
validate(&self) -> ()?
69+
instantiate() => (Store, Instance?)
70+
imports() -> Vec<(String, String, ExternType)>
71+
exports() -> Vec<(String, ExternType)>
72+
}
73+
74+
Instance {
75+
export(Module, String) -> (String, ExternType)
76+
}
77+
78+
Function {
79+
alloc(Store, FuncType, HostFunc) -> (Store, FuncAddr)
80+
type(Store, FuncAddr) -> FuncType
81+
invoke(Store, FuncAddr, Vec<Value>) -> (Store, Vec<Value>)
82+
}
83+
84+
Table {
85+
alloc(Store, FuncType, Ref) -> (Store, TableAddr)
86+
...
87+
}
88+
89+
Memory {
90+
...
91+
}
92+
93+
Global {
94+
...
95+
}
96+
```

cli/Cargo.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "wasmo_cli"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
clap = { version = "3.1.0", features = ["derive"] }
10+
11+
[[bin]]
12+
name = "wasmo"
13+
path = "bin/wasmo.rs"

0 commit comments

Comments
 (0)