aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/doc.go
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2024-12-05 12:04:35 -0500
committerCherry Mui <cherryyz@google.com>2024-12-05 19:35:30 +0000
commit32e19fc4397142b743646ff8a526d07c126bf89b (patch)
tree46c0a952b5b2db56fe21e3836db773415d69ad40 /src/cmd/compile/doc.go
parent1fe65836aca009343274443411f7120d70434ddb (diff)
downloadgo-32e19fc4397142b743646ff8a526d07c126bf89b.tar.xz
cmd/compile: document wasmexport directive, update permitted types for wasmimport
For #65199, #66984. Change-Id: I9b651a00265fa7d3438d8a73ff04ddca7c4bed99 Reviewed-on: https://go-review.googlesource.com/c/go/+/633776 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/cmd/compile/doc.go')
-rw-r--r--src/cmd/compile/doc.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/cmd/compile/doc.go b/src/cmd/compile/doc.go
index 507899e222..f45df3f86a 100644
--- a/src/cmd/compile/doc.go
+++ b/src/cmd/compile/doc.go
@@ -309,13 +309,33 @@ The types of parameters and return values to the Go function are translated to
Wasm according to the following table:
Go types Wasm types
+ bool i32
int32, uint32 i32
int64, uint64 i64
float32 f32
float64 f64
unsafe.Pointer i32
+ pointer i32 (more restrictions below)
+ string (i32, i32) (only permitted as a parameters, not a result)
+
+For a pointer type, its element type must be a bool, int8, uint8, int16, uint16,
+int32, uint32, int64, uint64, float32, float64, an array whose element type is
+a permitted pointer element type, or a struct, which, if non-empty, embeds
+structs.HostLayout, and contains only fields whose types are permitted pointer
+element types.
Any other parameter types are disallowed by the compiler.
+ //go:wasmexport exportname
+
+The //go:wasmexport directive is wasm-only and must be followed by a
+function definition.
+It specifies that the function is exported to the wasm host as ``exportname``.
+
+ //go:wasmexport f
+ func g()
+
+The types of parameters and return values to the Go function are permitted and
+translated to Wasm in the same way as //go:wasmimport functions.
*/
package main