Skip to content

Commit 5879d78

Browse files
committed
target/wasm_unknown: remove bulk memory and use imported memory for extreme tinyness
Signed-off-by: deadprogram <ron@hybridgroup.com>
1 parent 186018a commit 5879d78

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

src/runtime/arch_tinygowasm_malloc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//go:build tinygo.wasm && !custommalloc
1+
//go:build tinygo.wasm && !(custommalloc || wasm_unknown)
22

33
package runtime
44

src/runtime/runtime_tinygowasm_unknown.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ func abort() {
3131

3232
//go:linkname syscall_Exit syscall.Exit
3333
func syscall_Exit(code int) {
34-
//proc_exit(uint32(code))
3534
}
3635

37-
// TinyGo does not yet support any form of parallelism on WebAssembly, so these
36+
// There is not yet any support for any form of parallelism on WebAssembly, so these
3837
// can be left empty.
3938

4039
//go:linkname procPin sync/atomic.runtime_procPin

src/runtime/runtime_wasm_unknown.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
package runtime
44

5-
import (
6-
"unsafe"
7-
)
5+
import "unsafe"
86

97
type timeUnit int64
108

@@ -21,10 +19,6 @@ func _start() {
2119
run()
2220
}
2321

24-
// Read the command line arguments from WASI.
25-
// For example, they can be passed to a program with wasmtime like this:
26-
//
27-
// wasmtime run ./program.wasm arg1 arg2
2822
func init() {
2923
__wasm_call_ctors()
3024
}
@@ -39,7 +33,8 @@ func nanosecondsToTicks(ns int64) timeUnit {
3933
return timeUnit(ns)
4034
}
4135

42-
const timePrecisionNanoseconds = 1000 // TODO: how can we determine the appropriate `precision`?
36+
// with the wasm32-unknown-unknown target there is no way to determine any `precision`
37+
const timePrecisionNanoseconds = 1000
4338

4439
func sleepTicks(d timeUnit) {
4540
}

targets/wasm-unknown.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"llvm-target": "wasm32-unknown-unknown",
33
"cpu": "generic",
4-
"features": "+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext",
4+
"features": "+mutable-globals,+nontrapping-fptoint,+sign-ext",
55
"build-tags": ["tinygo.wasm", "wasm_unknown"],
66
"goos": "linux",
77
"goarch": "arm",
@@ -10,13 +10,14 @@
1010
"scheduler": "none",
1111
"default-stack-size": 4096,
1212
"cflags": [
13-
"-mbulk-memory",
13+
"-mno-bulk-memory",
1414
"-mnontrapping-fptoint",
1515
"-msign-ext"
1616
],
1717
"ldflags": [
1818
"--no-demangle",
19-
"--no-entry"
19+
"--no-entry",
20+
"--import-memory"
2021
],
2122
"extra-files": [
2223
"src/runtime/asm_tinygowasm.S"

0 commit comments

Comments
 (0)