Граф коммитов

29 коммитов

Автор SHA1 Сообщение Дата
=
cc3e785692 Remove unused value 2024-01-29 16:23:35 +01:00
Ayke van Laethem
a93f0ed12a all: Go 1.21 support 2023-08-04 11:59:11 +02:00
Ayke van Laethem
4d2a6d2bbe wasm: remove i64 workaround, use BigInt instead
Browsers previously didn't support the WebAssembly i64 type, so we had
to work around that limitation by converting the LLVM i64 type to
something else. Some people used a pair of i32 values, but we used a
pointer to a stack allocated i64.

Now however, all major browsers and Node.js do support WebAssembly
BigInt integration so that i64 values can be passed back and forth
between WebAssembly and JavaScript easily. Therefore, I think the time
has come to drop support for this workaround.

For more information: https://v8.dev/features/wasm-bigint (note that
TinyGo has used a slightly different way of passing i64 values between
JS and Wasm).

For information on browser support: https://webassembly.org/roadmap/
2023-06-17 18:08:09 +02:00
Samuel Stauffer
0fd3d785a3 syscall/js: allow copyBytesTo(Go|JS) to use Uint8ClampedArray
From f0e8b81aa3

Fixes https://github.com/tinygo-org/tinygo/issues/1941
2022-03-07 19:01:55 +01:00
Ayke van Laethem
14bb90c3c0 cgo: add support for stdio in picolibc and wasi-libc
This adds support for stdio in picolibc and fixes wasm_exec.js so that
it can also support C puts. With this, C stdout works on all supported
platforms.
2021-10-26 17:08:30 +02:00
Ayke van Laethem
478c592b13 wasm: add support for the crypto/rand package
This is done via wasi-libc and the WASI interface, for ease of
maintenance (only one implementation for both WASI and JS/browsers).
2021-08-05 19:01:14 +02:00
Ayke van Laethem
6dd5666ed1 wasm: use WASI ABI for exit function
This improves compatibility between the regular browser target
(-target=wasm) and the WASI target (-target=wasi). Specifically, it
allows running WASI tests like this:

    tinygo test -target=wasi encoding/base32
2021-04-15 08:45:08 +02:00
Federico G. Schwindt
303acf5ed6
Upgrade WASI version to wasi_snapshot_preview1 (#1691)
wasm: Upgrade WASI version to wasi_snapshot_preview1

Addresses #1647.
2021-03-15 12:41:37 +01:00
Yongbin Kim
9f06798cb9 Fix typo in wasm_exec.js, syscall/js.valueLoadString() 2021-02-21 09:18:44 +01:00
蒼時弦也
e690ff0d8c Add instanceof support for WebAssembly 2020-10-18 22:15:47 +02:00
Ayke van Laethem
b713001313 test: support non-host tests
For example, for running tests with -target=wasm or
-target=cortex-m-qemu. It looks at the output to determine whether tests
were successful in the absence of a status code.
2020-09-24 21:17:26 +02:00
Elliott Sales de Andrade
471cb4cfd7 wasm_exec: Implement syscall/js.valueDelete.
This is only useful on Go 1.14, and is a port of:
60f271358f
2020-04-13 08:47:34 +02:00
Elliott Sales de Andrade
5706b062e9 wasm_exec: Add copyBytesToGo.
This is basically just a copy of copyBytesToJS, but with arguments
reversed.
2020-04-13 08:47:34 +02:00
Elliott Sales de Andrade
4347496623 wasm_exec: Cross-port exit with code 1 change.
This cross-ports the following commit:
9eef964800
2020-04-13 08:47:34 +02:00
Ayke van Laethem
5674c35e14 wasm: backport "garbage collect references to JavaScript values"
See commit:
54e6ba6724

Warning: this will drop support for Go 1.13 for WebAssembly targets!
I have modified the integration tests to specifically blacklist Go 1.13
instead of whitelisting any other version, to avoid accidentally not
testing WebAssembly.
2020-04-12 18:41:34 +02:00
Ayke van Laethem
0f9038ad2e wasm: remove _callbackShutdown
It doesn't seem to be used.

This commit is somewhat related to this commit:
6dd70fc5e3
Most of the things don't port over nicely.
2020-04-12 18:41:34 +02:00
Elliott Sales de Andrade
7446413dc9 wasm_exec: Sync polyfills with Go 1.14.1.
This ports over the following three commits:
9627180f0f
aff2f6ece8
42b79f0823
ecba83520d
2020-03-25 14:37:49 +01:00
Justin Clift
aeb7539f67 wasm: add js.copyBytesToJS() 2020-03-01 13:51:57 +01:00
Johann Freymuth
c0b8716d7f targets/wasm: update wasm_exec.js for go 1.13
This fixes the wasm examples for go 1.13, but breaks them for older go versions.
2020-02-23 23:55:04 +01:00
Ayke van Laethem
24a0f237d8 wasm: use wasi ABI for basic startup/stdout
This allows TinyGo-built binaries to run under wasmtime, for example:

    tinygo build -o test.wasm -no-debug -target=wasm examples/test
    wasmtime run test.wasm 0
2020-01-28 20:31:09 +01:00
Konstantin Itskov
4eb34b36f8 Add syscall/js.valueInvoke support 2019-09-16 13:36:37 +02:00
Konstantin Itskov
61750be9aa Add syscall/js.valueSetIndex support 2019-09-16 13:32:31 +02:00
Ayke van Laethem
eb1d834dd4 wasm: add support for js.FuncOf 2019-05-27 13:35:59 +02:00
Ayke van Laethem
4ad9bd8643 wasm: ignore arguments and environment variables
The wasm_exec.js file copied from the main Go repository did write those
values to address 4096 in linear memory, which led to memory corruption
in linear memory. Remove these things for now, until they're actually
supported, if support is ever added.
2019-03-07 13:13:11 +01:00
Ayke van Laethem
41e093d7bb wasm: switch emulator to node.js
Unfortunately, the olin/cwa emulator does not handle floats correctly.
Node.js does, and because it is also supported by the Go WebAssembly
implementation it has better support in general.
2019-03-04 21:58:40 +01:00
Ayke van Laethem
602c264749
all: rewrite goroutine lowering
Before this commit, goroutine support was spread through the compiler.
This commit changes this support, so that the compiler itself only
generates simple intrinsics and leaves the real support to a compiler
pass that runs as one of the TinyGo-specific optimization passes.

The biggest change, that was done together with the rewrite, was support
for goroutines in WebAssembly for JavaScript. The challenge in
JavaScript is that in general no blocking operations are allowed, which
means that programs that call time.Sleep() but do not start goroutines
also have to be scheduled by the scheduler.
2019-01-21 22:09:33 +01:00
Seth Junot
c9f4e41073
wasm: fix typo in wasm_exec.js preventing memory import
Seems to have been left over from the original copy. This correction
should fix calls to the "memory" variable in syscall/js.
2019-01-18 13:30:17 +01:00
Ayke van Laethem
05d70d288d
wasm: fix printing from Go code 2018-11-25 18:07:24 +01:00
Ayke van Laethem
dbb3211485
wasm: add glue JS code
The file wasm_glue.js was copied from the Go wasm port and was modified,
most importantly to match the TinyGo calling convention.
2018-11-24 19:03:58 +01:00