Skip to content

Commit

Permalink
cmd/gc, runtime: rename writebarrierfat to typedmemmove
Browse files Browse the repository at this point in the history
Preparation for replacing many memmove calls in runtime
with typedmemmove, which is a clearer description of what
the routine is doing.

For the same reason, rename writebarriercopy to typedslicecopy.

Change-Id: I6f23bef2c2215509fefba175b16908f76dc7538c
Reviewed-on: https://go-review.googlesource.com/2276
Reviewed-by: Rick Hudson <rlh@golang.org>
  • Loading branch information
rsc committed Jan 6, 2015
1 parent 7b4df8f commit bcadab9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/cmd/gc/builtin.c
Expand Up @@ -113,8 +113,8 @@ char *runtimeimport =
"func @\"\".writebarrierfat1101 (@\"\".dst·1 *any, _ *byte, @\"\".src·3 any)\n"
"func @\"\".writebarrierfat1110 (@\"\".dst·1 *any, _ *byte, @\"\".src·3 any)\n"
"func @\"\".writebarrierfat1111 (@\"\".dst·1 *any, _ *byte, @\"\".src·3 any)\n"
"func @\"\".writebarrierfat (@\"\".typ·1 *byte, @\"\".dst·2 *any, @\"\".src·3 *any)\n"
"func @\"\".writebarriercopy (@\"\".typ·2 *byte, @\"\".dst·3 any, @\"\".src·4 any) (? int)\n"
"func @\"\".typedmemmove (@\"\".typ·1 *byte, @\"\".dst·2 *any, @\"\".src·3 *any)\n"
"func @\"\".typedslicecopy (@\"\".typ·2 *byte, @\"\".dst·3 any, @\"\".src·4 any) (? int)\n"
"func @\"\".selectnbsend (@\"\".chanType·2 *byte, @\"\".hchan·3 chan<- any, @\"\".elem·4 *any) (? bool)\n"
"func @\"\".selectnbrecv (@\"\".chanType·2 *byte, @\"\".elem·3 *any, @\"\".hchan·4 <-chan any) (? bool)\n"
"func @\"\".selectnbrecv2 (@\"\".chanType·2 *byte, @\"\".elem·3 *any, @\"\".received·4 *bool, @\"\".hchan·5 <-chan any) (? bool)\n"
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/gc/runtime.go
Expand Up @@ -144,8 +144,8 @@ func writebarrierfat1101(dst *any, _ *byte, src any)
func writebarrierfat1110(dst *any, _ *byte, src any)
func writebarrierfat1111(dst *any, _ *byte, src any)

func writebarrierfat(typ *byte, dst *any, src *any)
func writebarriercopy(typ *byte, dst any, src any) int
func typedmemmove(typ *byte, dst *any, src *any)
func typedslicecopy(typ *byte, dst any, src any) int

func selectnbsend(chanType *byte, hchan chan<- any, elem *any) bool
func selectnbrecv(chanType *byte, elem *any, hchan <-chan any) bool
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/gc/walk.c
Expand Up @@ -2096,8 +2096,8 @@ applywritebarrier(Node *n, NodeList **init)
r = r->left;
r = nod(OADDR, r, N);
r->etype = 1; // addr does not escape
//warnl(n->lineno, "writebarrierfat %T %N", t, r);
n = mkcall1(writebarrierfn("writebarrierfat", t, r->left->type), T, init,
//warnl(n->lineno, "typedmemmove %T %N", t, r);
n = mkcall1(writebarrierfn("typedmemmove", t, r->left->type), T, init,
typename(t), l, r);
}
}
Expand Down Expand Up @@ -2952,7 +2952,7 @@ copyany(Node *n, NodeList **init, int runtimecall)
NodeList *l;

if(haspointers(n->left->type->type)) {
fn = writebarrierfn("writebarriercopy", n->left->type, n->right->type);
fn = writebarrierfn("typedslicecopy", n->left->type, n->right->type);
return mkcall1(fn, n->type, init, typename(n->left->type->type), n->left, n->right);
}

Expand Down
10 changes: 5 additions & 5 deletions src/runtime/mgc0.go
Expand Up @@ -288,8 +288,8 @@ func writebarrieriface(dst *[2]uintptr, src [2]uintptr) {
// The implementations are written to wbfat.go.

//go:nosplit
func writebarrierfat(typ *_type, dst, src unsafe.Pointer) {
if !needwb() {
func typedmemmove(typ *_type, dst, src unsafe.Pointer) {
if !needwb() || (typ.kind&kindNoPointers) != 0 {
memmove(dst, src, typ.size)
return
}
Expand Down Expand Up @@ -322,7 +322,7 @@ func writebarrierfat(typ *_type, dst, src unsafe.Pointer) {
}

//go:nosplit
func writebarriercopy(typ *_type, dst, src slice) int {
func typedslicecopy(typ *_type, dst, src slice) int {
n := dst.len
if n > src.len {
n = src.len
Expand All @@ -347,7 +347,7 @@ func writebarriercopy(typ *_type, dst, src slice) int {
srcp = add(srcp, uintptr(n-1)*typ.size)
i := uint(0)
for {
writebarrierfat(typ, dstp, srcp)
typedmemmove(typ, dstp, srcp)
if i++; i >= n {
break
}
Expand All @@ -359,7 +359,7 @@ func writebarriercopy(typ *_type, dst, src slice) int {
// out of the array they point into.
i := uint(0)
for {
writebarrierfat(typ, dstp, srcp)
typedmemmove(typ, dstp, srcp)
if i++; i >= n {
break
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/slice.go
Expand Up @@ -88,7 +88,7 @@ func growslice(t *slicetype, old sliceStruct, n int64) sliceStruct {
// TODO(rsc): Use memmove when !needwb().
p = newarray(et, uintptr(newcap))
for i := 0; i < old.len; i++ {
writebarrierfat(et, add(p, uintptr(i)*et.size), add(old.array, uintptr(i)*et.size))
typedmemmove(et, add(p, uintptr(i)*et.size), add(old.array, uintptr(i)*et.size))
}
}

Expand Down

0 comments on commit bcadab9

Please sign in to comment.