]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: document wasmexport directive, update permitted types for wasmimport
authorCherry Mui <cherryyz@google.com>
Thu, 5 Dec 2024 17:04:35 +0000 (12:04 -0500)
committerCherry Mui <cherryyz@google.com>
Thu, 5 Dec 2024 19:35:30 +0000 (19:35 +0000)
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>
src/cmd/compile/doc.go

index 507899e222eb1c45cb1142de4b2aa22092236000..f45df3f86a671db5a2f9cff2276cced41c537c44 100644 (file)
@@ -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