Skip to content

Commit 21d82e6

Browse files
committed
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 <[email protected]> Run-TryBot: Keith Randall <[email protected]> TryBot-Bypass: Keith Randall <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
1 parent f684f3d commit 21d82e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+711
-394
lines changed

src/cmd/compile/internal/amd64/ssa.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1116,8 +1116,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
11161116
p := s.Prog(obj.ACALL)
11171117
p.To.Type = obj.TYPE_MEM
11181118
p.To.Name = obj.NAME_EXTERN
1119-
// arg0 is in DI. Set sym to match where regalloc put arg1.
1120-
p.To.Sym = ssagen.GCWriteBarrierReg[v.Args[1].Reg()]
1119+
// AuxInt encodes how many buffer entries we need.
1120+
p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1]
11211121

11221122
case ssa.OpAMD64LoweredPanicBoundsA, ssa.OpAMD64LoweredPanicBoundsB, ssa.OpAMD64LoweredPanicBoundsC:
11231123
p := s.Prog(obj.ACALL)

src/cmd/compile/internal/arm/ssa.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
710710
p := s.Prog(obj.ACALL)
711711
p.To.Type = obj.TYPE_MEM
712712
p.To.Name = obj.NAME_EXTERN
713-
p.To.Sym = v.Aux.(*obj.LSym)
713+
// AuxInt encodes how many buffer entries we need.
714+
p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1]
714715
case ssa.OpARMLoweredPanicBoundsA, ssa.OpARMLoweredPanicBoundsB, ssa.OpARMLoweredPanicBoundsC:
715716
p := s.Prog(obj.ACALL)
716717
p.To.Type = obj.TYPE_MEM

src/cmd/compile/internal/arm64/ssa.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,9 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
10651065
p := s.Prog(obj.ACALL)
10661066
p.To.Type = obj.TYPE_MEM
10671067
p.To.Name = obj.NAME_EXTERN
1068-
p.To.Sym = v.Aux.(*obj.LSym)
1068+
// AuxInt encodes how many buffer entries we need.
1069+
p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1]
1070+
10691071
case ssa.OpARM64LoweredPanicBoundsA, ssa.OpARM64LoweredPanicBoundsB, ssa.OpARM64LoweredPanicBoundsC:
10701072
p := s.Prog(obj.ACALL)
10711073
p.To.Type = obj.TYPE_MEM

src/cmd/compile/internal/ir/symtab.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var Syms struct {
2525
Deferreturn *obj.LSym
2626
Duffcopy *obj.LSym
2727
Duffzero *obj.LSym
28-
GCWriteBarrier *obj.LSym
28+
GCWriteBarrier [8]*obj.LSym
2929
Goschedguarded *obj.LSym
3030
Growslice *obj.LSym
3131
Memmove *obj.LSym

src/cmd/compile/internal/loong64/ssa.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
516516
p := s.Prog(obj.ACALL)
517517
p.To.Type = obj.TYPE_MEM
518518
p.To.Name = obj.NAME_EXTERN
519-
p.To.Sym = v.Aux.(*obj.LSym)
519+
// AuxInt encodes how many buffer entries we need.
520+
p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1]
520521
case ssa.OpLOONG64LoweredPanicBoundsA, ssa.OpLOONG64LoweredPanicBoundsB, ssa.OpLOONG64LoweredPanicBoundsC:
521522
p := s.Prog(obj.ACALL)
522523
p.To.Type = obj.TYPE_MEM

src/cmd/compile/internal/mips/ssa.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
481481
p := s.Prog(obj.ACALL)
482482
p.To.Type = obj.TYPE_MEM
483483
p.To.Name = obj.NAME_EXTERN
484-
p.To.Sym = v.Aux.(*obj.LSym)
484+
// AuxInt encodes how many buffer entries we need.
485+
p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1]
485486
case ssa.OpMIPSLoweredPanicBoundsA, ssa.OpMIPSLoweredPanicBoundsB, ssa.OpMIPSLoweredPanicBoundsC:
486487
p := s.Prog(obj.ACALL)
487488
p.To.Type = obj.TYPE_MEM

src/cmd/compile/internal/mips64/ssa.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
500500
p := s.Prog(obj.ACALL)
501501
p.To.Type = obj.TYPE_MEM
502502
p.To.Name = obj.NAME_EXTERN
503-
p.To.Sym = v.Aux.(*obj.LSym)
503+
// AuxInt encodes how many buffer entries we need.
504+
p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1]
504505
case ssa.OpMIPS64LoweredPanicBoundsA, ssa.OpMIPS64LoweredPanicBoundsB, ssa.OpMIPS64LoweredPanicBoundsC:
505506
p := s.Prog(obj.ACALL)
506507
p.To.Type = obj.TYPE_MEM

src/cmd/compile/internal/ppc64/ssa.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
18861886
p := s.Prog(obj.ACALL)
18871887
p.To.Type = obj.TYPE_MEM
18881888
p.To.Name = obj.NAME_EXTERN
1889-
p.To.Sym = v.Aux.(*obj.LSym)
1889+
// AuxInt encodes how many buffer entries we need.
1890+
p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1]
18901891

18911892
case ssa.OpPPC64LoweredPanicBoundsA, ssa.OpPPC64LoweredPanicBoundsB, ssa.OpPPC64LoweredPanicBoundsC:
18921893
p := s.Prog(obj.ACALL)

src/cmd/compile/internal/riscv64/ssa.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
433433
p := s.Prog(obj.ACALL)
434434
p.To.Type = obj.TYPE_MEM
435435
p.To.Name = obj.NAME_EXTERN
436-
p.To.Sym = v.Aux.(*obj.LSym)
436+
// AuxInt encodes how many buffer entries we need.
437+
p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1]
437438
case ssa.OpRISCV64LoweredPanicBoundsA, ssa.OpRISCV64LoweredPanicBoundsB, ssa.OpRISCV64LoweredPanicBoundsC:
438439
p := s.Prog(obj.ACALL)
439440
p.To.Type = obj.TYPE_MEM

src/cmd/compile/internal/s390x/ssa.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"math"
99

1010
"cmd/compile/internal/base"
11+
"cmd/compile/internal/ir"
1112
"cmd/compile/internal/logopt"
1213
"cmd/compile/internal/ssa"
1314
"cmd/compile/internal/ssagen"
@@ -566,7 +567,8 @@ func ssaGenValue(s *ssagen.State, v *ssa.Value) {
566567
p := s.Prog(obj.ACALL)
567568
p.To.Type = obj.TYPE_MEM
568569
p.To.Name = obj.NAME_EXTERN
569-
p.To.Sym = v.Aux.(*obj.LSym)
570+
// AuxInt encodes how many buffer entries we need.
571+
p.To.Sym = ir.Syms.GCWriteBarrier[v.AuxInt-1]
570572
case ssa.OpS390XLoweredPanicBoundsA, ssa.OpS390XLoweredPanicBoundsB, ssa.OpS390XLoweredPanicBoundsC:
571573
p := s.Prog(obj.ACALL)
572574
p.To.Type = obj.TYPE_MEM

src/cmd/compile/internal/ssa/_gen/386Ops.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,10 @@ func init() {
516516
//arg0=ptr,arg1=mem, returns void. Faults if ptr is nil.
517517
{name: "LoweredNilCheck", argLength: 2, reg: regInfo{inputs: []regMask{gpsp}}, clobberFlags: true, nilCheck: true, faultOnNilArg0: true},
518518

519-
// LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
519+
// LoweredWB invokes runtime.gcWriteBarrier. arg0=mem, auxint=# of write barrier slots
520520
// It saves all GP registers if necessary, but may clobber others.
521-
{name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("DI"), ax}, clobbers: callerSave &^ gp}, clobberFlags: true, aux: "Sym", symEffect: "None"},
521+
// Returns a pointer to a write barrier buffer in DI.
522+
{name: "LoweredWB", argLength: 1, reg: regInfo{clobbers: callerSave &^ gp, outputs: []regMask{buildReg("DI")}}, clobberFlags: true, aux: "Int64"},
522523

523524
// There are three of these functions so that they can have three different register inputs.
524525
// When we check 0 <= c <= cap (A), then 0 <= b <= c (B), then 0 <= a <= b (C), we want the

src/cmd/compile/internal/ssa/_gen/AMD64Ops.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -934,9 +934,10 @@ func init() {
934934
{name: "LoweredGetCallerSP", argLength: 1, reg: gp01, rematerializeable: true},
935935
//arg0=ptr,arg1=mem, returns void. Faults if ptr is nil.
936936
{name: "LoweredNilCheck", argLength: 2, reg: regInfo{inputs: []regMask{gpsp}}, clobberFlags: true, nilCheck: true, faultOnNilArg0: true},
937-
// LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
937+
// LoweredWB invokes runtime.gcWriteBarrier{auxint}. arg0=mem, auxint=# of buffer entries needed.
938938
// It saves all GP registers if necessary, but may clobber others.
939-
{name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("DI"), buildReg("AX CX DX BX BP SI R8 R9")}, clobbers: callerSave &^ (gp | g)}, clobberFlags: true, aux: "Sym", symEffect: "None"},
939+
// Returns a pointer to a write barrier buffer in R11.
940+
{name: "LoweredWB", argLength: 1, reg: regInfo{clobbers: callerSave &^ (gp | g), outputs: []regMask{buildReg("R11")}}, clobberFlags: true, aux: "Int64"},
940941

941942
{name: "LoweredHasCPUFeature", argLength: 0, reg: gp01, rematerializeable: true, typ: "UInt64", aux: "Sym", symEffect: "None"},
942943

src/cmd/compile/internal/ssa/_gen/ARM64Ops.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -723,11 +723,12 @@ func init() {
723723
{name: "LoweredAtomicOr8Variant", argLength: 3, reg: gpxchg, resultNotInArgs: true, typ: "(UInt8,Mem)", faultOnNilArg0: true, hasSideEffects: true},
724724
{name: "LoweredAtomicOr32Variant", argLength: 3, reg: gpxchg, resultNotInArgs: true, typ: "(UInt32,Mem)", faultOnNilArg0: true, hasSideEffects: true},
725725

726-
// LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
726+
// LoweredWB invokes runtime.gcWriteBarrier. arg0=mem, auxint=# of buffer entries needed
727727
// It saves all GP registers if necessary,
728728
// but clobbers R30 (LR) because it's a call.
729729
// R16 and R17 may be clobbered by linker trampoline.
730-
{name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R2"), buildReg("R3")}, clobbers: (callerSave &^ gpg) | buildReg("R16 R17 R30")}, clobberFlags: true, aux: "Sym", symEffect: "None"},
730+
// Returns a pointer to a write barrier buffer in R25.
731+
{name: "LoweredWB", argLength: 1, reg: regInfo{clobbers: (callerSave &^ gpg) | buildReg("R16 R17 R30"), outputs: []regMask{buildReg("R25")}}, clobberFlags: true, aux: "Int64"},
731732

732733
// There are three of these functions so that they can have three different register inputs.
733734
// When we check 0 <= c <= cap (A), then 0 <= b <= c (B), then 0 <= a <= b (C), we want the

src/cmd/compile/internal/ssa/_gen/ARMOps.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,11 @@ func init() {
562562
// InvertFlags is a pseudo-op which can't appear in assembly output.
563563
{name: "InvertFlags", argLength: 1}, // reverse direction of arg0
564564

565-
// LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
565+
// LoweredWB invokes runtime.gcWriteBarrier. arg0=mem, auxint=# of buffer entries needed
566566
// It saves all GP registers if necessary,
567567
// but clobbers R14 (LR) because it's a call, and R12 which is linker trampoline scratch register.
568-
{name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R2"), buildReg("R3")}, clobbers: (callerSave &^ gpg) | buildReg("R12 R14")}, clobberFlags: true, aux: "Sym", symEffect: "None"},
569-
}
568+
// Returns a pointer to a write barrier buffer in R8.
569+
{name: "LoweredWB", argLength: 1, reg: regInfo{clobbers: (callerSave &^ gpg) | buildReg("R12 R14"), outputs: []regMask{buildReg("R8")}}, clobberFlags: true, aux: "Int64"}}
570570

571571
blocks := []blockData{
572572
{name: "EQ", controls: 1},

src/cmd/compile/internal/ssa/_gen/LOONG64Ops.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,12 @@ func init() {
441441
// See runtime/stubs.go for a more detailed discussion.
442442
{name: "LoweredGetCallerPC", reg: gp01, rematerializeable: true},
443443

444-
// LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
444+
// LoweredWB invokes runtime.gcWriteBarrier. arg0=mem, auxint=# of buffer entries needed
445445
// It saves all GP registers if necessary,
446446
// but clobbers R1 (LR) because it's a call
447447
// and R30 (REGTMP).
448-
{name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R27"), buildReg("R28")}, clobbers: (callerSave &^ gpg) | buildReg("R1")}, clobberFlags: true, aux: "Sym", symEffect: "None"},
448+
// Returns a pointer to a write barrier buffer in R29.
449+
{name: "LoweredWB", argLength: 1, reg: regInfo{clobbers: (callerSave &^ gpg) | buildReg("R1"), outputs: []regMask{buildReg("R29")}}, clobberFlags: true, aux: "Int64"},
449450

450451
// There are three of these functions so that they can have three different register inputs.
451452
// When we check 0 <= c <= cap (A), then 0 <= b <= c (B), then 0 <= a <= b (C), we want the

src/cmd/compile/internal/ssa/_gen/MIPS64Ops.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -441,11 +441,12 @@ func init() {
441441
// See runtime/stubs.go for a more detailed discussion.
442442
{name: "LoweredGetCallerPC", reg: gp01, rematerializeable: true},
443443

444-
// LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
444+
// LoweredWB invokes runtime.gcWriteBarrier. arg0=mem, auxint=# of buffer entries needed
445445
// It saves all GP registers if necessary,
446446
// but clobbers R31 (LR) because it's a call
447447
// and R23 (REGTMP).
448-
{name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R20"), buildReg("R21")}, clobbers: (callerSave &^ gpg) | buildReg("R31")}, clobberFlags: true, aux: "Sym", symEffect: "None"},
448+
// Returns a pointer to a write barrier buffer in R25.
449+
{name: "LoweredWB", argLength: 1, reg: regInfo{clobbers: (callerSave &^ gpg) | buildReg("R31"), outputs: []regMask{buildReg("R25")}}, clobberFlags: true, aux: "Int64"},
449450

450451
// There are three of these functions so that they can have three different register inputs.
451452
// When we check 0 <= c <= cap (A), then 0 <= b <= c (B), then 0 <= a <= b (C), we want the

src/cmd/compile/internal/ssa/_gen/MIPSOps.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,12 @@ func init() {
394394
// See runtime/stubs.go for a more detailed discussion.
395395
{name: "LoweredGetCallerPC", reg: gp01, rematerializeable: true},
396396

397-
// LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
397+
// LoweredWB invokes runtime.gcWriteBarrier. arg0=mem, auxint=# of buffer entries needed
398398
// It saves all GP registers if necessary,
399399
// but clobbers R31 (LR) because it's a call
400400
// and R23 (REGTMP).
401-
{name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R20"), buildReg("R21")}, clobbers: (callerSave &^ gpg) | buildReg("R31")}, clobberFlags: true, aux: "Sym", symEffect: "None"},
401+
// Returns a pointer to a write barrier buffer in R25.
402+
{name: "LoweredWB", argLength: 1, reg: regInfo{clobbers: (callerSave &^ gpg) | buildReg("R31"), outputs: []regMask{buildReg("R25")}}, clobberFlags: true, aux: "Int64"},
402403

403404
// There are three of these functions so that they can have three different register inputs.
404405
// When we check 0 <= c <= cap (A), then 0 <= b <= c (B), then 0 <= a <= b (C), we want the

src/cmd/compile/internal/ssa/_gen/PPC64Ops.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,11 @@ func init() {
681681
{name: "LoweredAtomicOr8", argLength: 3, reg: gpstore, asm: "OR", faultOnNilArg0: true, hasSideEffects: true},
682682
{name: "LoweredAtomicOr32", argLength: 3, reg: gpstore, asm: "OR", faultOnNilArg0: true, hasSideEffects: true},
683683

684-
// LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
685-
// It preserves R0 through R17 (except special registers R1, R2, R11, R12, R13), g, and its arguments R20 and R21,
684+
// LoweredWB invokes runtime.gcWriteBarrier. arg0=mem, auxint=# of buffer entries needed
685+
// It preserves R0 through R17 (except special registers R1, R2, R11, R12, R13), g, and R20 and R21,
686686
// but may clobber anything else, including R31 (REGTMP).
687-
{name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R20"), buildReg("R21")}, clobbers: (callerSave &^ buildReg("R0 R3 R4 R5 R6 R7 R8 R9 R10 R14 R15 R16 R17 R20 R21 g")) | buildReg("R31")}, clobberFlags: true, aux: "Sym", symEffect: "None"},
687+
// Returns a pointer to a write barrier buffer in R29.
688+
{name: "LoweredWB", argLength: 1, reg: regInfo{clobbers: (callerSave &^ buildReg("R0 R3 R4 R5 R6 R7 R8 R9 R10 R14 R15 R16 R17 R20 R21 g")) | buildReg("R31"), outputs: []regMask{buildReg("R29")}}, clobberFlags: true, aux: "Int64"},
688689

689690
{name: "LoweredPubBarrier", argLength: 1, asm: "LWSYNC", hasSideEffects: true}, // Do data barrier. arg0=memory
690691
// There are three of these functions so that they can have three different register inputs.

src/cmd/compile/internal/ssa/_gen/RISCV64Ops.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,12 @@ func init() {
388388
// See runtime/stubs.go for a more detailed discussion.
389389
{name: "LoweredGetCallerPC", reg: gp01, rematerializeable: true},
390390

391-
// LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
391+
// LoweredWB invokes runtime.gcWriteBarrier. arg0=mem, auxint=# of buffer entries needed
392392
// It saves all GP registers if necessary,
393393
// but clobbers RA (LR) because it's a call
394394
// and T6 (REG_TMP).
395-
{name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{regNamed["X5"], regNamed["X6"]}, clobbers: (callerSave &^ (gpMask | regNamed["g"])) | regNamed["X1"]}, clobberFlags: true, aux: "Sym", symEffect: "None"},
395+
// Returns a pointer to a write barrier buffer in X24.
396+
{name: "LoweredWB", argLength: 1, reg: regInfo{clobbers: (callerSave &^ (gpMask | regNamed["g"])) | regNamed["X1"], outputs: []regMask{regNamed["X24"]}}, clobberFlags: true, aux: "Int64"},
396397

397398
// There are three of these functions so that they can have three different register inputs.
398399
// When we check 0 <= c <= cap (A), then 0 <= b <= c (B), then 0 <= a <= b (C), we want the

src/cmd/compile/internal/ssa/_gen/S390XOps.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ func init() {
130130
r1 = buildReg("R1")
131131
r2 = buildReg("R2")
132132
r3 = buildReg("R3")
133+
r9 = buildReg("R9")
133134
)
134135
// Common slices of register masks
135136
var (
@@ -504,11 +505,12 @@ func init() {
504505
{name: "LoweredRound32F", argLength: 1, reg: fp11, resultInArg0: true, zeroWidth: true},
505506
{name: "LoweredRound64F", argLength: 1, reg: fp11, resultInArg0: true, zeroWidth: true},
506507

507-
// LoweredWB invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
508+
// LoweredWB invokes runtime.gcWriteBarrier. arg0=mem, aux=# of buffer entries needed
508509
// It saves all GP registers if necessary,
509510
// but clobbers R14 (LR) because it's a call,
510511
// and also clobbers R1 as the PLT stub does.
511-
{name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{buildReg("R2"), buildReg("R3")}, clobbers: (callerSave &^ gpg) | buildReg("R14") | r1}, clobberFlags: true, aux: "Sym", symEffect: "None"},
512+
// Returns a pointer to a write barrier buffer in R9.
513+
{name: "LoweredWB", argLength: 1, reg: regInfo{clobbers: (callerSave &^ gpg) | buildReg("R14") | r1, outputs: []regMask{r9}}, clobberFlags: true, aux: "Int64"},
512514

513515
// There are three of these functions so that they can have three different register inputs.
514516
// When we check 0 <= c <= cap (A), then 0 <= b <= c (B), then 0 <= a <= b (C), we want the

src/cmd/compile/internal/ssa/_gen/WasmOps.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func init() {
133133
{name: "LoweredGetCallerPC", reg: gp01, rematerializeable: true}, // returns the PC of the caller of the current function
134134
{name: "LoweredGetCallerSP", argLength: 1, reg: gp01, rematerializeable: true}, // returns the SP of the caller of the current function. arg0=mem.
135135
{name: "LoweredNilCheck", argLength: 2, reg: regInfo{inputs: []regMask{gp}}, nilCheck: true, faultOnNilArg0: true}, // panic if arg0 is nil. arg1=mem
136-
{name: "LoweredWB", argLength: 3, reg: regInfo{inputs: []regMask{gp, gp}}, aux: "Sym", symEffect: "None"}, // invokes runtime.gcWriteBarrier. arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
136+
{name: "LoweredWB", argLength: 1, reg: regInfo{clobbers: callerSave, outputs: []regMask{gp}}, aux: "Int64"}, // invokes runtime.gcWriteBarrier{auxint}. arg0=mem, auxint=# of buffer entries needed. Returns a pointer to a write barrier buffer.
137137

138138
// LoweredConvert converts between pointers and integers.
139139
// We have a special op for this so as to not confuse GCCallOff

src/cmd/compile/internal/ssa/_gen/genericOps.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,11 @@ var genericOps = []opData{
381381
{name: "ZeroWB", argLength: 2, typ: "Mem", aux: "TypSize"}, // arg0=destptr, arg1=mem, auxint=size, aux=type. Returns memory.
382382
{name: "WBend", argLength: 1, typ: "Mem"}, // Write barrier code is done, interrupting is now allowed.
383383

384-
// WB invokes runtime.gcWriteBarrier. This is not a normal
384+
// WB invokes runtime.gcWriteBarrier. This is not a normal
385385
// call: it takes arguments in registers, doesn't clobber
386386
// general-purpose registers (the exact clobber set is
387387
// arch-dependent), and is not a safe-point.
388-
{name: "WB", argLength: 3, typ: "Mem", aux: "Sym", symEffect: "None"}, // arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier
388+
{name: "WB", argLength: 1, typ: "(BytePtr,Mem)", aux: "Int64"}, // arg0=mem, auxint=# of buffer entries needed. Returns buffer pointer and memory.
389389

390390
{name: "HasCPUFeature", argLength: 0, typ: "bool", aux: "Sym", symEffect: "None"}, // aux=place that this feature flag can be loaded from
391391

0 commit comments

Comments
 (0)