mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/obj: minor refactor of wasmimport code
This CL does some minor refactoring of the code handling wasmimport. - Put the WasmImport aux reading and writing code together for symmetry. - Define WasmFuncType, embedded in WasmImport. WasmFuncType could also be used (later) for wasmexport. - Move code generation code to a separate function. The containing function is already pretty large. - Simplify linker code a little bit. The loader convention is to return the 0 Sym for nonexistent symbol, instead of a separate boolean. No change in generated code. Passes toolstash -cmp (GOARCH=wasm GOOS=wasip1 go build -toolexec "toolstash -cmp" -a std cmd). Change-Id: Idc2514f84a08621333841ae4034b81130e0ce411 Reviewed-on: https://go-review.googlesource.com/c/go/+/603135 Reviewed-by: Than McIntosh <thanm@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
a7c7ec5995
commit
03e5d83ca7
6 changed files with 222 additions and 194 deletions
|
|
@ -1620,21 +1620,11 @@ func (l *Loader) Aux(i Sym, j int) Aux {
|
|||
// contains the information necessary for the linker to add a WebAssembly
|
||||
// import statement.
|
||||
// (https://webassembly.github.io/spec/core/syntax/modules.html#imports)
|
||||
func (l *Loader) WasmImportSym(fnSymIdx Sym) (Sym, bool) {
|
||||
func (l *Loader) WasmImportSym(fnSymIdx Sym) Sym {
|
||||
if l.SymType(fnSymIdx) != sym.STEXT {
|
||||
log.Fatalf("error: non-function sym %d/%s t=%s passed to WasmImportSym", fnSymIdx, l.SymName(fnSymIdx), l.SymType(fnSymIdx).String())
|
||||
}
|
||||
r, li := l.toLocal(fnSymIdx)
|
||||
auxs := r.Auxs(li)
|
||||
for i := range auxs {
|
||||
a := &auxs[i]
|
||||
switch a.Type() {
|
||||
case goobj.AuxWasmImport:
|
||||
return l.resolve(r, a.Sym()), true
|
||||
}
|
||||
}
|
||||
|
||||
return 0, false
|
||||
return l.aux1(fnSymIdx, goobj.AuxWasmImport)
|
||||
}
|
||||
|
||||
// SEHUnwindSym returns the auxiliary SEH unwind symbol associated with
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue