diff options
| author | Keith Randall <khr@golang.org> | 2022-11-01 16:46:43 -0700 |
|---|---|---|
| committer | Keith Randall <khr@golang.org> | 2023-02-24 00:21:13 +0000 |
| commit | 21d82e6ac80fc2aea1eac9c8eec9afdd79cb5bdd (patch) | |
| tree | 293b975ed4dc782a0d68ab64dc6167b6d6486066 /src/cmd/internal/obj/wasm | |
| parent | f684f3dc434f9199ceee175c07d28e8b2b0f28dc (diff) | |
| download | go-21d82e6ac80fc2aea1eac9c8eec9afdd79cb5bdd.tar.xz | |
cmd/compile: batch write barrier calls
Have the write barrier call return a pointer to a buffer into which
the generated code records pointers that need write barrier treatment.
Change-Id: I7871764298e0aa1513de417010c8d46b296b199e
Reviewed-on: https://go-review.googlesource.com/c/go/+/447781
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Bypass: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/cmd/internal/obj/wasm')
| -rw-r--r-- | src/cmd/internal/obj/wasm/wasmobj.go | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/src/cmd/internal/obj/wasm/wasmobj.go b/src/cmd/internal/obj/wasm/wasmobj.go index 9b0aabe919..96a2ef4a6f 100644 --- a/src/cmd/internal/obj/wasm/wasmobj.go +++ b/src/cmd/internal/obj/wasm/wasmobj.go @@ -127,7 +127,6 @@ var Linkwasm = obj.LinkArch{ var ( morestack *obj.LSym morestackNoCtxt *obj.LSym - gcWriteBarrier *obj.LSym sigpanic *obj.LSym ) @@ -139,7 +138,6 @@ const ( func instinit(ctxt *obj.Link) { morestack = ctxt.Lookup("runtime.morestack") morestackNoCtxt = ctxt.Lookup("runtime.morestack_noctxt") - gcWriteBarrier = ctxt.LookupABI("runtime.gcWriteBarrier", obj.ABIInternal) sigpanic = ctxt.LookupABI("runtime.sigpanic", obj.ABIInternal) } @@ -514,11 +512,6 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { panic("bad target for CALL") } - // gcWriteBarrier has no return value, it never unwinds the stack - if call.To.Sym == gcWriteBarrier { - break - } - // return value of call is on the top of the stack, indicating whether to unwind the WebAssembly stack if call.As == ACALLNORESUME && call.To.Sym != sigpanic { // sigpanic unwinds the stack, but it never resumes // trying to unwind WebAssembly stack but call has no resume point, terminate with error @@ -794,19 +787,27 @@ func regAddr(reg int16) obj.Addr { // Most of the Go functions has a single parameter (PC_B) in // Wasm ABI. This is a list of exceptions. var notUsePC_B = map[string]bool{ - "_rt0_wasm_js": true, - "wasm_export_run": true, - "wasm_export_resume": true, - "wasm_export_getsp": true, - "wasm_pc_f_loop": true, - "runtime.wasmDiv": true, - "runtime.wasmTruncS": true, - "runtime.wasmTruncU": true, - "runtime.gcWriteBarrier": true, - "cmpbody": true, - "memeqbody": true, - "memcmp": true, - "memchr": true, + "_rt0_wasm_js": true, + "wasm_export_run": true, + "wasm_export_resume": true, + "wasm_export_getsp": true, + "wasm_pc_f_loop": true, + "gcWriteBarrier": true, + "runtime.gcWriteBarrier1": true, + "runtime.gcWriteBarrier2": true, + "runtime.gcWriteBarrier3": true, + "runtime.gcWriteBarrier4": true, + "runtime.gcWriteBarrier5": true, + "runtime.gcWriteBarrier6": true, + "runtime.gcWriteBarrier7": true, + "runtime.gcWriteBarrier8": true, + "runtime.wasmDiv": true, + "runtime.wasmTruncS": true, + "runtime.wasmTruncU": true, + "cmpbody": true, + "memeqbody": true, + "memcmp": true, + "memchr": true, } func assemble(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { @@ -851,8 +852,18 @@ func assemble(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { case "cmpbody": varDecls = []*varDecl{{count: 2, typ: i64}} useAssemblyRegMap() - case "runtime.gcWriteBarrier": - varDecls = []*varDecl{{count: 4, typ: i64}} + case "gcWriteBarrier": + varDecls = []*varDecl{{count: 5, typ: i64}} + useAssemblyRegMap() + case "runtime.gcWriteBarrier1", + "runtime.gcWriteBarrier2", + "runtime.gcWriteBarrier3", + "runtime.gcWriteBarrier4", + "runtime.gcWriteBarrier5", + "runtime.gcWriteBarrier6", + "runtime.gcWriteBarrier7", + "runtime.gcWriteBarrier8": + // no locals useAssemblyRegMap() default: // Normal calling convention: PC_B as WebAssembly parameter. First local variable is local SP cache. |
