mirror of
https://github.com/golang/go
synced 2024-09-30 03:24:39 -06:00
02411bcd7c
Go programs can now use the //go:wasmimport module_name function_name directive to import functions from the WebAssembly runtime. For now, the directive is restricted to the runtime and syscall/js packages. * Derived from CL 350737 * Original work modified to work with changes to the IR conversion code. * Modification of CL 350737 changes to fully exist in Unified IR path (emp) * Original work modified to work with changes to the ABI configuration code. * Fixes #38248 Co-authored-by: Vedant Roy <vroy101@gmail.com> Co-authored-by: Richard Musiol <mail@richard-musiol.de> Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Change-Id: I740719735d91c306ac718a435a78e1ee9686bc16 Reviewed-on: https://go-review.googlesource.com/c/go/+/463018 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
37 lines
758 B
Go
37 lines
758 B
Go
// Copyright 2018 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package runtime
|
|
|
|
import (
|
|
"internal/goarch"
|
|
"runtime/internal/sys"
|
|
"unsafe"
|
|
)
|
|
|
|
type m0Stack struct {
|
|
_ [8192 * sys.StackGuardMultiplier]byte
|
|
}
|
|
|
|
var wasmStack m0Stack
|
|
|
|
func wasmDiv()
|
|
|
|
func wasmTruncS()
|
|
func wasmTruncU()
|
|
|
|
//go:wasmimport gojs runtime.wasmExit
|
|
func wasmExit(code int32)
|
|
|
|
// adjust Gobuf as it if executed a call to fn with context ctxt
|
|
// and then stopped before the first instruction in fn.
|
|
func gostartcall(buf *gobuf, fn, ctxt unsafe.Pointer) {
|
|
sp := buf.sp
|
|
sp -= goarch.PtrSize
|
|
*(*uintptr)(unsafe.Pointer(sp)) = buf.pc
|
|
buf.sp = sp
|
|
buf.pc = uintptr(fn)
|
|
buf.ctxt = ctxt
|
|
}
|