1
0
mirror of https://github.com/golang/go synced 2024-09-24 21:10:12 -06:00
Commit Graph

7 Commits

Author SHA1 Message Date
Richard Musiol
e5489cfc12 misc/wasm: add mention of polyfill for Edge support
Edge supports WebAssembly but not TextEncoder or TextDecoder.
This change adds a comment pointing to a polyfill that could
be used. The polyfill is not added by default, because we want to
let the user decide if/how to include the polyfill.

Fixes #27295

Change-Id: I375f58f2168665f549997b368428c398dfbbca1c
Reviewed-on: https://go-review.googlesource.com/139037
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-02 17:25:11 +00:00
Brad Fitzpatrick
ed969a0c27 Revert "misc/wasm: add polyfill for TextEncoder/TextDecoder for Edge support"
This reverts CL 131718, commit a0e7f12771.

Reason for revert: adds request overhead & dependency on third-party service for all users regardless of whether it's necessary.

Updates #27295

Change-Id: I4a8a9b0c8e4a3198c884dfbd90ba36734f70a9a9
Reviewed-on: https://go-review.googlesource.com/138937
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-02 17:25:00 +00:00
Jake B
a0e7f12771 misc/wasm: add polyfill for TextEncoder/TextDecoder for Edge support
Edge supports WASM but not TextEncoder or TextDecoder.
This PR adds a polyfill to `misc/wasm/wasm_exec.js` to fix this.

Fixes #27295

Change-Id: Ie35ee5604529b170a5dc380eb286f71bdd691d3e
GitHub-Last-Rev: a587edae28
GitHub-Pull-Request: golang/go#27296
Reviewed-on: https://go-review.googlesource.com/131718
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
Reviewed-by: Richard Musiol <neelance@gmail.com>
2018-09-29 10:07:58 +00:00
Agniva De Sarker
e2e44a5d16 misc/wasm: handle error during instantiateStreaming
The same catch block is there in wasm_exec.js for node processes.
Added it in browser invocations too, to prevent uncaught exceptions.

Change-Id: Icab577ec585fa86df3c76db508b49401bcdb52ae
Reviewed-on: https://go-review.googlesource.com/132916
Reviewed-by: Richard Musiol <neelance@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-09-04 07:02:45 +00:00
Richard Musiol
1771edb590 misc/wasm: make wasm_exec.js more flexible
This commit improves wasm_exec.js to give more control to the
code that uses this helper:
- Allow to load and run more than one Go program at the same time.
- Move WebAssembly.instantiate out of wasm_exec.js so the caller
  can optimize for load-time performance, e.g. by using
  instantiateStreaming.
- Allow caller to provide argv, env and exit callback.

Updates #18892

Change-Id: Ib582e6f43848c0118ea5c89f2e24b371c45c2050
Reviewed-on: https://go-review.googlesource.com/113515
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-18 18:16:50 +00:00
Richard Musiol
db91ee3651 misc/wasm: pollute global JS namespace less
This commit changes wasm_exec.js so it only puts the single
name "go" into the global namespace. Other names became private
or were turned into a property/method of "go".

Change-Id: I633829dfd3c06936f092c0a14b9978bf855e41fe
Reviewed-on: https://go-review.googlesource.com/112980
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
2018-05-15 14:15:07 +00:00
Richard Musiol
f63250238b misc/wasm: add scripts for running WebAssembly binaries
This commit adds scripts for running the WebAssembly binaries that the
Go compiler will produce.

The script go_js_wasm_exec uses Node.js to run the binaries. Adding it
to PATH will enable "go run" and "go test" to work for js/wasm
without having to manually provide the -exec flag.
See https://golang.org/cmd/go/#hdr-Compile_and_run_Go_program
for more information.

The web page wasm_exec.html is an example on how to run the same
binaries in a web browser.

Both scripts use wasm_exec.js as a shared library.

Updates #18892

Change-Id: Ia4d9bea025957750baa0d0651243dc88f156f85d
Reviewed-on: https://go-review.googlesource.com/103255
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-30 05:13:31 +00:00