diff options
author | Austin Clements <austin@google.com> | 2018-01-15 12:27:17 -0500 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2018-02-13 16:34:46 +0000 |
commit | 20101894078199a3a9014ca99ec4e2a0a16a0869 (patch) | |
tree | 8e7ff5c0fcc37243fcd39ba23ea2976503712f63 /src/cmd/compile | |
parent | 245310883dcae717bb662b22d5b1fd07fdd59b76 (diff) | |
download | go-20101894078199a3a9014ca99ec4e2a0a16a0869.tar.gz go-20101894078199a3a9014ca99ec4e2a0a16a0869.zip |
runtime: remove legacy eager write barrier
Now that the buffered write barrier is implemented for all
architectures, we can remove the old eager write barrier
implementation. This CL removes the implementation from the runtime,
support in the compiler for calling it, and updates some compiler
tests that relied on the old eager barrier support. It also makes sure
that all of the useful comments from the old write barrier
implementation still have a place to live.
Fixes #22460.
Updates #21640 since this fixes the layering concerns of the write
barrier (but not the other things in that issue).
Change-Id: I580f93c152e89607e0a72fe43370237ba97bae74
Reviewed-on: https://go-review.googlesource.com/92705
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Rick Hudson <rlh@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/cmd/compile')
-rw-r--r-- | src/cmd/compile/internal/gc/asm_test.go | 2 | ||||
-rw-r--r-- | src/cmd/compile/internal/gc/builtin.go | 144 | ||||
-rw-r--r-- | src/cmd/compile/internal/gc/builtin/runtime.go | 2 | ||||
-rw-r--r-- | src/cmd/compile/internal/gc/go.go | 1 | ||||
-rw-r--r-- | src/cmd/compile/internal/gc/main.go | 10 | ||||
-rw-r--r-- | src/cmd/compile/internal/gc/ssa.go | 7 | ||||
-rw-r--r-- | src/cmd/compile/internal/ssa/config.go | 1 | ||||
-rw-r--r-- | src/cmd/compile/internal/ssa/export_test.go | 1 | ||||
-rw-r--r-- | src/cmd/compile/internal/ssa/writebarrier.go | 19 |
9 files changed, 78 insertions, 109 deletions
diff --git a/src/cmd/compile/internal/gc/asm_test.go b/src/cmd/compile/internal/gc/asm_test.go index 50857e6533..73c55018f9 100644 --- a/src/cmd/compile/internal/gc/asm_test.go +++ b/src/cmd/compile/internal/gc/asm_test.go @@ -468,7 +468,7 @@ var linuxAMD64Tests = []*asmTest{ *t = T2{} } `, - pos: []string{"\tXORPS\tX., X", "\tMOVUPS\tX., \\(.*\\)", "\tMOVQ\t\\$0, 16\\(.*\\)", "\tCALL\truntime\\.(writebarrierptr|gcWriteBarrier)\\(SB\\)"}, + pos: []string{"\tXORPS\tX., X", "\tMOVUPS\tX., \\(.*\\)", "\tMOVQ\t\\$0, 16\\(.*\\)", "\tCALL\truntime\\.gcWriteBarrier\\(SB\\)"}, }, // Rotate tests { diff --git a/src/cmd/compile/internal/gc/builtin.go b/src/cmd/compile/internal/gc/builtin.go index 0733a460d5..3bb17673a5 100644 --- a/src/cmd/compile/internal/gc/builtin.go +++ b/src/cmd/compile/internal/gc/builtin.go @@ -105,56 +105,55 @@ var runtimeDecls = [...]struct { {"chansend1", funcTag, 81}, {"closechan", funcTag, 23}, {"writeBarrier", varTag, 83}, - {"writebarrierptr", funcTag, 84}, - {"typedmemmove", funcTag, 85}, - {"typedmemclr", funcTag, 86}, - {"typedslicecopy", funcTag, 87}, - {"selectnbsend", funcTag, 88}, - {"selectnbrecv", funcTag, 89}, - {"selectnbrecv2", funcTag, 91}, - {"newselect", funcTag, 92}, - {"selectsend", funcTag, 93}, - {"selectrecv", funcTag, 94}, + {"typedmemmove", funcTag, 84}, + {"typedmemclr", funcTag, 85}, + {"typedslicecopy", funcTag, 86}, + {"selectnbsend", funcTag, 87}, + {"selectnbrecv", funcTag, 88}, + {"selectnbrecv2", funcTag, 90}, + {"newselect", funcTag, 91}, + {"selectsend", funcTag, 92}, + {"selectrecv", funcTag, 93}, {"selectdefault", funcTag, 55}, - {"selectgo", funcTag, 95}, + {"selectgo", funcTag, 94}, {"block", funcTag, 5}, - {"makeslice", funcTag, 97}, - {"makeslice64", funcTag, 98}, - {"growslice", funcTag, 99}, - {"memmove", funcTag, 100}, - {"memclrNoHeapPointers", funcTag, 101}, - {"memclrHasPointers", funcTag, 101}, - {"memequal", funcTag, 102}, - {"memequal8", funcTag, 103}, - {"memequal16", funcTag, 103}, - {"memequal32", funcTag, 103}, - {"memequal64", funcTag, 103}, - {"memequal128", funcTag, 103}, - {"int64div", funcTag, 104}, - {"uint64div", funcTag, 105}, - {"int64mod", funcTag, 104}, - {"uint64mod", funcTag, 105}, - {"float64toint64", funcTag, 106}, - {"float64touint64", funcTag, 107}, - {"float64touint32", funcTag, 108}, - {"int64tofloat64", funcTag, 109}, - {"uint64tofloat64", funcTag, 110}, - {"uint32tofloat64", funcTag, 111}, - {"complex128div", funcTag, 112}, - {"racefuncenter", funcTag, 113}, + {"makeslice", funcTag, 96}, + {"makeslice64", funcTag, 97}, + {"growslice", funcTag, 98}, + {"memmove", funcTag, 99}, + {"memclrNoHeapPointers", funcTag, 100}, + {"memclrHasPointers", funcTag, 100}, + {"memequal", funcTag, 101}, + {"memequal8", funcTag, 102}, + {"memequal16", funcTag, 102}, + {"memequal32", funcTag, 102}, + {"memequal64", funcTag, 102}, + {"memequal128", funcTag, 102}, + {"int64div", funcTag, 103}, + {"uint64div", funcTag, 104}, + {"int64mod", funcTag, 103}, + {"uint64mod", funcTag, 104}, + {"float64toint64", funcTag, 105}, + {"float64touint64", funcTag, 106}, + {"float64touint32", funcTag, 107}, + {"int64tofloat64", funcTag, 108}, + {"uint64tofloat64", funcTag, 109}, + {"uint32tofloat64", funcTag, 110}, + {"complex128div", funcTag, 111}, + {"racefuncenter", funcTag, 112}, {"racefuncexit", funcTag, 5}, - {"raceread", funcTag, 113}, - {"racewrite", funcTag, 113}, - {"racereadrange", funcTag, 114}, - {"racewriterange", funcTag, 114}, - {"msanread", funcTag, 114}, - {"msanwrite", funcTag, 114}, + {"raceread", funcTag, 112}, + {"racewrite", funcTag, 112}, + {"racereadrange", funcTag, 113}, + {"racewriterange", funcTag, 113}, + {"msanread", funcTag, 113}, + {"msanwrite", funcTag, 113}, {"support_popcnt", varTag, 11}, {"support_sse41", varTag, 11}, } func runtimeTypes() []*types.Type { - var typs [115]*types.Type + var typs [114]*types.Type typs[0] = types.Bytetype typs[1] = types.NewPtr(typs[0]) typs[2] = types.Types[TANY] @@ -239,36 +238,35 @@ func runtimeTypes() []*types.Type { typs[81] = functype(nil, []*Node{anonfield(typs[80]), anonfield(typs[3])}, nil) typs[82] = types.NewArray(typs[0], 3) typs[83] = tostruct([]*Node{namedfield("enabled", typs[11]), namedfield("pad", typs[82]), namedfield("needed", typs[11]), namedfield("cgo", typs[11]), namedfield("alignme", typs[17])}) - typs[84] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[2])}, nil) - typs[85] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[3]), anonfield(typs[3])}, nil) - typs[86] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[3])}, nil) - typs[87] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[2]), anonfield(typs[2])}, []*Node{anonfield(typs[32])}) - typs[88] = functype(nil, []*Node{anonfield(typs[80]), anonfield(typs[3])}, []*Node{anonfield(typs[11])}) - typs[89] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[77])}, []*Node{anonfield(typs[11])}) - typs[90] = types.NewPtr(typs[11]) - typs[91] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[90]), anonfield(typs[77])}, []*Node{anonfield(typs[11])}) - typs[92] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[15]), anonfield(typs[8])}, nil) - typs[93] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[80]), anonfield(typs[3])}, nil) - typs[94] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[77]), anonfield(typs[3]), anonfield(typs[90])}, nil) - typs[95] = functype(nil, []*Node{anonfield(typs[1])}, []*Node{anonfield(typs[32])}) - typs[96] = types.NewSlice(typs[2]) - typs[97] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[32]), anonfield(typs[32])}, []*Node{anonfield(typs[96])}) - typs[98] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[15]), anonfield(typs[15])}, []*Node{anonfield(typs[96])}) - typs[99] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[96]), anonfield(typs[32])}, []*Node{anonfield(typs[96])}) - typs[100] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[3]), anonfield(typs[48])}, nil) - typs[101] = functype(nil, []*Node{anonfield(typs[57]), anonfield(typs[48])}, nil) - typs[102] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[3]), anonfield(typs[48])}, []*Node{anonfield(typs[11])}) - typs[103] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[3])}, []*Node{anonfield(typs[11])}) - typs[104] = functype(nil, []*Node{anonfield(typs[15]), anonfield(typs[15])}, []*Node{anonfield(typs[15])}) - typs[105] = functype(nil, []*Node{anonfield(typs[17]), anonfield(typs[17])}, []*Node{anonfield(typs[17])}) - typs[106] = functype(nil, []*Node{anonfield(typs[13])}, []*Node{anonfield(typs[15])}) - typs[107] = functype(nil, []*Node{anonfield(typs[13])}, []*Node{anonfield(typs[17])}) - typs[108] = functype(nil, []*Node{anonfield(typs[13])}, []*Node{anonfield(typs[59])}) - typs[109] = functype(nil, []*Node{anonfield(typs[15])}, []*Node{anonfield(typs[13])}) - typs[110] = functype(nil, []*Node{anonfield(typs[17])}, []*Node{anonfield(typs[13])}) - typs[111] = functype(nil, []*Node{anonfield(typs[59])}, []*Node{anonfield(typs[13])}) - typs[112] = functype(nil, []*Node{anonfield(typs[19]), anonfield(typs[19])}, []*Node{anonfield(typs[19])}) - typs[113] = functype(nil, []*Node{anonfield(typs[48])}, nil) - typs[114] = functype(nil, []*Node{anonfield(typs[48]), anonfield(typs[48])}, nil) + typs[84] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[3]), anonfield(typs[3])}, nil) + typs[85] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[3])}, nil) + typs[86] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[2]), anonfield(typs[2])}, []*Node{anonfield(typs[32])}) + typs[87] = functype(nil, []*Node{anonfield(typs[80]), anonfield(typs[3])}, []*Node{anonfield(typs[11])}) + typs[88] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[77])}, []*Node{anonfield(typs[11])}) + typs[89] = types.NewPtr(typs[11]) + typs[90] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[89]), anonfield(typs[77])}, []*Node{anonfield(typs[11])}) + typs[91] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[15]), anonfield(typs[8])}, nil) + typs[92] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[80]), anonfield(typs[3])}, nil) + typs[93] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[77]), anonfield(typs[3]), anonfield(typs[89])}, nil) + typs[94] = functype(nil, []*Node{anonfield(typs[1])}, []*Node{anonfield(typs[32])}) + typs[95] = types.NewSlice(typs[2]) + typs[96] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[32]), anonfield(typs[32])}, []*Node{anonfield(typs[95])}) + typs[97] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[15]), anonfield(typs[15])}, []*Node{anonfield(typs[95])}) + typs[98] = functype(nil, []*Node{anonfield(typs[1]), anonfield(typs[95]), anonfield(typs[32])}, []*Node{anonfield(typs[95])}) + typs[99] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[3]), anonfield(typs[48])}, nil) + typs[100] = functype(nil, []*Node{anonfield(typs[57]), anonfield(typs[48])}, nil) + typs[101] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[3]), anonfield(typs[48])}, []*Node{anonfield(typs[11])}) + typs[102] = functype(nil, []*Node{anonfield(typs[3]), anonfield(typs[3])}, []*Node{anonfield(typs[11])}) + typs[103] = functype(nil, []*Node{anonfield(typs[15]), anonfield(typs[15])}, []*Node{anonfield(typs[15])}) + typs[104] = functype(nil, []*Node{anonfield(typs[17]), anonfield(typs[17])}, []*Node{anonfield(typs[17])}) + typs[105] = functype(nil, []*Node{anonfield(typs[13])}, []*Node{anonfield(typs[15])}) + typs[106] = functype(nil, []*Node{anonfield(typs[13])}, []*Node{anonfield(typs[17])}) + typs[107] = functype(nil, []*Node{anonfield(typs[13])}, []*Node{anonfield(typs[59])}) + typs[108] = functype(nil, []*Node{anonfield(typs[15])}, []*Node{anonfield(typs[13])}) + typs[109] = functype(nil, []*Node{anonfield(typs[17])}, []*Node{anonfield(typs[13])}) + typs[110] = functype(nil, []*Node{anonfield(typs[59])}, []*Node{anonfield(typs[13])}) + typs[111] = functype(nil, []*Node{anonfield(typs[19]), anonfield(typs[19])}, []*Node{anonfield(typs[19])}) + typs[112] = functype(nil, []*Node{anonfield(typs[48])}, nil) + typs[113] = functype(nil, []*Node{anonfield(typs[48]), anonfield(typs[48])}, nil) return typs[:] } diff --git a/src/cmd/compile/internal/gc/builtin/runtime.go b/src/cmd/compile/internal/gc/builtin/runtime.go index de17d51d8a..bda9d1d03c 100644 --- a/src/cmd/compile/internal/gc/builtin/runtime.go +++ b/src/cmd/compile/internal/gc/builtin/runtime.go @@ -136,8 +136,6 @@ var writeBarrier struct { alignme uint64 } -func writebarrierptr(dst *any, src any) - // *byte is really *runtime.Type func typedmemmove(typ *byte, dst *any, src *any) func typedmemclr(typ *byte, dst *any) diff --git a/src/cmd/compile/internal/gc/go.go b/src/cmd/compile/internal/gc/go.go index dc94cf4f98..d6db7acc59 100644 --- a/src/cmd/compile/internal/gc/go.go +++ b/src/cmd/compile/internal/gc/go.go @@ -292,7 +292,6 @@ var ( assertI2I2, goschedguarded, writeBarrier, - writebarrierptr, gcWriteBarrier, typedmemmove, typedmemclr, diff --git a/src/cmd/compile/internal/gc/main.go b/src/cmd/compile/internal/gc/main.go index 7f947530b1..f1591c16d2 100644 --- a/src/cmd/compile/internal/gc/main.go +++ b/src/cmd/compile/internal/gc/main.go @@ -44,7 +44,6 @@ var ( Debug_slice int Debug_vlog bool Debug_wb int - Debug_eagerwb int Debug_pctab string Debug_locationlist int Debug_typecheckinl int @@ -73,7 +72,6 @@ var debugtab = []struct { {"slice", "print information about slice compilation", &Debug_slice}, {"typeassert", "print information about type assertion inlining", &Debug_typeassert}, {"wb", "print information about write barriers", &Debug_wb}, - {"eagerwb", "use unbuffered write barrier", &Debug_eagerwb}, {"export", "print export data", &Debug_export}, {"pctab", "print named pc-value table", &Debug_pctab}, {"locationlists", "print information about DWARF location list creation", &Debug_locationlist}, @@ -407,14 +405,6 @@ func Main(archInit func(*Arch)) { Debug['l'] = 1 - Debug['l'] } - switch objabi.GOARCH { - case "amd64", "amd64p32", "386", "arm", "arm64", "ppc64", "ppc64le", "mips64", "mips64le", "mips", "mipsle", "s390x": - default: - // Other architectures don't support the buffered - // write barrier yet. - Debug_eagerwb = 1 - } - trackScopes = flagDWARF && ((Debug['l'] == 0 && Debug['N'] != 0) || Ctxt.Flag_locationlists) Widthptr = thearch.LinkArch.PtrSize diff --git a/src/cmd/compile/internal/gc/ssa.go b/src/cmd/compile/internal/gc/ssa.go index fe062da409..5ec01b6a61 100644 --- a/src/cmd/compile/internal/gc/ssa.go +++ b/src/cmd/compile/internal/gc/ssa.go @@ -95,7 +95,6 @@ func initssaconfig() { assertI2I2 = sysfunc("assertI2I2") goschedguarded = sysfunc("goschedguarded") writeBarrier = sysfunc("writeBarrier") - writebarrierptr = sysfunc("writebarrierptr") gcWriteBarrier = sysfunc("gcWriteBarrier") typedmemmove = sysfunc("typedmemmove") typedmemclr = sysfunc("typedmemclr") @@ -5380,10 +5379,6 @@ func (e *ssafn) Debug_checknil() bool { return Debug_checknil != 0 } -func (e *ssafn) Debug_eagerwb() bool { - return Debug_eagerwb != 0 -} - func (e *ssafn) UseWriteBarrier() bool { return use_writebarrier } @@ -5394,8 +5389,6 @@ func (e *ssafn) Syslook(name string) *obj.LSym { return goschedguarded case "writeBarrier": return writeBarrier - case "writebarrierptr": - return writebarrierptr case "gcWriteBarrier": return gcWriteBarrier case "typedmemmove": diff --git a/src/cmd/compile/internal/ssa/config.go b/src/cmd/compile/internal/ssa/config.go index 725cdcd9a4..13e5c50da1 100644 --- a/src/cmd/compile/internal/ssa/config.go +++ b/src/cmd/compile/internal/ssa/config.go @@ -89,7 +89,6 @@ type Logger interface { // Forwards the Debug flags from gc Debug_checknil() bool - Debug_eagerwb() bool } type Frontend interface { diff --git a/src/cmd/compile/internal/ssa/export_test.go b/src/cmd/compile/internal/ssa/export_test.go index 28ae494505..d1d6831eb3 100644 --- a/src/cmd/compile/internal/ssa/export_test.go +++ b/src/cmd/compile/internal/ssa/export_test.go @@ -134,7 +134,6 @@ func (d DummyFrontend) Log() bool { return true } func (d DummyFrontend) Fatalf(_ src.XPos, msg string, args ...interface{}) { d.t.Fatalf(msg, args...) } func (d DummyFrontend) Warnl(_ src.XPos, msg string, args ...interface{}) { d.t.Logf(msg, args...) } func (d DummyFrontend) Debug_checknil() bool { return false } -func (d DummyFrontend) Debug_eagerwb() bool { return false } var dummyTypes Types diff --git a/src/cmd/compile/internal/ssa/writebarrier.go b/src/cmd/compile/internal/ssa/writebarrier.go index b711d8d2bf..c41a677159 100644 --- a/src/cmd/compile/internal/ssa/writebarrier.go +++ b/src/cmd/compile/internal/ssa/writebarrier.go @@ -31,7 +31,7 @@ func needwb(v *Value) bool { // and runtime calls, like // // if writeBarrier.enabled { -// writebarrierptr(ptr, val) +// gcWriteBarrier(ptr, val) // Not a regular Go call // } else { // *ptr = val // } @@ -44,7 +44,7 @@ func writebarrier(f *Func) { } var sb, sp, wbaddr, const0 *Value - var writebarrierptr, typedmemmove, typedmemclr, gcWriteBarrier *obj.LSym + var typedmemmove, typedmemclr, gcWriteBarrier *obj.LSym var stores, after []*Value var sset *sparseSet var storeNumber []int32 @@ -96,10 +96,7 @@ func writebarrier(f *Func) { } wbsym := f.fe.Syslook("writeBarrier") wbaddr = f.Entry.NewValue1A(initpos, OpAddr, f.Config.Types.UInt32Ptr, wbsym, sb) - writebarrierptr = f.fe.Syslook("writebarrierptr") - if !f.fe.Debug_eagerwb() { - gcWriteBarrier = f.fe.Syslook("gcWriteBarrier") - } + gcWriteBarrier = f.fe.Syslook("gcWriteBarrier") typedmemmove = f.fe.Syslook("typedmemmove") typedmemclr = f.fe.Syslook("typedmemclr") const0 = f.ConstInt32(initpos, f.Config.Types.UInt32, 0) @@ -198,7 +195,6 @@ func writebarrier(f *Func) { var val *Value switch w.Op { case OpStoreWB: - fn = writebarrierptr val = w.Args[1] nWBops-- case OpMoveWB: @@ -217,11 +213,13 @@ func writebarrier(f *Func) { switch w.Op { case OpStoreWB, OpMoveWB, OpZeroWB: volatile := w.Op == OpMoveWB && isVolatile(val) - if w.Op == OpStoreWB && !f.fe.Debug_eagerwb() { + if w.Op == OpStoreWB { memThen = bThen.NewValue3A(pos, OpWB, types.TypeMem, gcWriteBarrier, ptr, val, memThen) } else { memThen = wbcall(pos, bThen, fn, typ, ptr, val, memThen, sp, sb, volatile) } + // Note that we set up a writebarrier function call. + f.fe.SetWBPos(pos) case OpVarDef, OpVarLive, OpVarKill: memThen = bThen.NewValue1A(pos, w.Op, types.TypeMem, w.Aux, memThen) } @@ -239,11 +237,6 @@ func writebarrier(f *Func) { case OpVarDef, OpVarLive, OpVarKill: memElse = bElse.NewValue1A(pos, w.Op, types.TypeMem, w.Aux, memElse) } - - if fn != nil { - // Note that we set up a writebarrier function call. - f.fe.SetWBPos(pos) - } } // merge memory |