This flag controls whether to convert external i64 parameters for use in
a browser-like environment.

This flag was needed in the past because back then we only supported
wasm on browsers but no WASI. Now, I can't think of a reason why anybody
would want to change the default. For `-target=wasm` (used for
browser-like environments), the wasm_exec.js file expects this
i64-via-stack ABI. For WASI, there is no limitation on i64 values and
`-wasm-abi=generic` is the default.
Этот коммит содержится в:
Ayke van Laethem 2022-11-03 22:26:22 +01:00 коммит произвёл Ron Evans
родитель 8906584fb9
коммит 268140ae40
5 изменённых файлов: 3 добавлений и 12 удалений

Просмотреть файл

@ -1077,7 +1077,6 @@ func optimizeProgram(mod llvm.Module, config *compileopts.Config) error {
// cannot be represented exactly in JavaScript (JS only has doubles). To // cannot be represented exactly in JavaScript (JS only has doubles). To
// keep functions interoperable, pass int64 types as pointers to // keep functions interoperable, pass int64 types as pointers to
// stack-allocated values. // stack-allocated values.
// Use -wasm-abi=generic to disable this behaviour.
if config.WasmAbi() == "js" { if config.WasmAbi() == "js" {
err := transform.ExternalInt64AsPtr(mod, config) err := transform.ExternalInt64AsPtr(mod, config)
if err != nil { if err != nil {

Просмотреть файл

@ -511,12 +511,8 @@ func (c *Config) RelocationModel() string {
return "static" return "static"
} }
// WasmAbi returns the WASM ABI which is specified in the target JSON file, and // WasmAbi returns the WASM ABI which is specified in the target JSON file.
// the value is overridden by `-wasm-abi` flag if it is provided
func (c *Config) WasmAbi() string { func (c *Config) WasmAbi() string {
if c.Options.WasmAbi != "" {
return c.Options.WasmAbi
}
return c.Target.WasmAbi return c.Target.WasmAbi
} }

Просмотреть файл

@ -42,7 +42,6 @@ type Options struct {
PrintAllocs *regexp.Regexp // regexp string PrintAllocs *regexp.Regexp // regexp string
PrintStacks bool PrintStacks bool
Tags []string Tags []string
WasmAbi string
GlobalValues map[string]map[string]string // map[pkgpath]map[varname]value GlobalValues map[string]map[string]string // map[pkgpath]map[varname]value
TestConfig TestConfig TestConfig TestConfig
Programmer string Programmer string

Просмотреть файл

@ -1392,7 +1392,6 @@ func main() {
port := flag.String("port", "", "flash port (can specify multiple candidates separated by commas)") port := flag.String("port", "", "flash port (can specify multiple candidates separated by commas)")
programmer := flag.String("programmer", "", "which hardware programmer to use") programmer := flag.String("programmer", "", "which hardware programmer to use")
ldflags := flag.String("ldflags", "", "Go link tool compatible ldflags") ldflags := flag.String("ldflags", "", "Go link tool compatible ldflags")
wasmAbi := flag.String("wasm-abi", "", "WebAssembly ABI conventions: js (no i64 params) or generic")
llvmFeatures := flag.String("llvm-features", "", "comma separated LLVM features to enable") llvmFeatures := flag.String("llvm-features", "", "comma separated LLVM features to enable")
cpuprofile := flag.String("cpuprofile", "", "cpuprofile output") cpuprofile := flag.String("cpuprofile", "", "cpuprofile output")
monitor := flag.Bool("monitor", false, "enable serial monitor") monitor := flag.Bool("monitor", false, "enable serial monitor")
@ -1481,7 +1480,6 @@ func main() {
PrintAllocs: printAllocs, PrintAllocs: printAllocs,
Tags: []string(tags), Tags: []string(tags),
GlobalValues: globalVarValues, GlobalValues: globalVarValues,
WasmAbi: *wasmAbi,
Programmer: *programmer, Programmer: *programmer,
OpenOCDCommands: ocdCommands, OpenOCDCommands: ocdCommands,
LLVMFeatures: *llvmFeatures, LLVMFeatures: *llvmFeatures,

Просмотреть файл

@ -14,8 +14,7 @@ import (
// resolved, this pass may be avoided. For more details: // resolved, this pass may be avoided. For more details:
// https://github.com/WebAssembly/design/issues/1172 // https://github.com/WebAssembly/design/issues/1172
// //
// This pass can be enabled/disabled with the -wasm-abi flag, and is enabled by // This pass is enabled via the wasm-abi JSON target key.
// default as of december 2019.
func ExternalInt64AsPtr(mod llvm.Module, config *compileopts.Config) error { func ExternalInt64AsPtr(mod llvm.Module, config *compileopts.Config) error {
ctx := mod.Context() ctx := mod.Context()
builder := ctx.NewBuilder() builder := ctx.NewBuilder()
@ -145,7 +144,7 @@ func ExternalInt64AsPtr(mod llvm.Module, config *compileopts.Config) error {
builder.SetInsertPointAtEnd(entryBlock) builder.SetInsertPointAtEnd(entryBlock)
var callParams []llvm.Value var callParams []llvm.Value
if fnType.ReturnType() == int64Type { if fnType.ReturnType() == int64Type {
return errors.New("not yet implemented: exported function returns i64 with -wasm-abi=js; " + return errors.New("not yet implemented: exported function returns i64 with the JS wasm-abi; " +
"see https://tinygo.org/compiler-internals/calling-convention/") "see https://tinygo.org/compiler-internals/calling-convention/")
} }
for i, origParam := range fn.Params() { for i, origParam := range fn.Params() {