1
0
mirror of https://github.com/golang/go synced 2024-11-19 15:24:46 -07:00
go/src/runtime/memclr_mips64x.s
Austin Clements 87e48c5afd runtime, cmd/compile: rename memclr -> memclrNoHeapPointers
Since barrier-less memclr is only safe in very narrow circumstances,
this commit renames memclr to avoid accidentally calling memclr on
typed memory. This can cause subtle, non-deterministic bugs, so it's
worth some effort to prevent. In the near term, this will also prevent
bugs creeping in from any concurrent CLs that add calls to memclr; if
this happens, whichever patch hits master second will fail to compile.

This also adds the other new memclr variants to the compiler's
builtin.go to minimize the churn on that binary blob. We'll use these
in future commits.

Updates #17503.

Change-Id: I00eead049f5bd35ca107ea525966831f3d1ed9ca
Reviewed-on: https://go-review.googlesource.com/31369
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
2016-10-28 18:20:33 +00:00

43 lines
779 B
ArmAsm

// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build mips64 mips64le
#include "textflag.h"
// void runtime·memclrNoHeapPointers(void*, uintptr)
TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16
MOVV ptr+0(FP), R1
MOVV n+8(FP), R2
ADDV R1, R2, R4
// if less than 8 bytes, do one byte at a time
SGTU $8, R2, R3
BNE R3, out
// do one byte at a time until 8-aligned
AND $7, R1, R3
BEQ R3, words
MOVB R0, (R1)
ADDV $1, R1
JMP -4(PC)
words:
// do 8 bytes at a time if there is room
ADDV $-7, R4, R2
SGTU R2, R1, R3
BEQ R3, out
MOVV R0, (R1)
ADDV $8, R1
JMP -4(PC)
out:
BEQ R1, R4, done
MOVB R0, (R1)
ADDV $1, R1
JMP -3(PC)
done:
RET