Commit 47410a24 authored by Quan Yong Zhai's avatar Quan Yong Zhai Committed by Russ Cox

runtime: replace byte-at-a-time zeroing loop with memclr

R=golang-dev, r, r, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/4813043
parent ba134539
...@@ -479,12 +479,16 @@ TEXT runtime·stackcheck(SB), 7, $0 ...@@ -479,12 +479,16 @@ TEXT runtime·stackcheck(SB), 7, $0
TEXT runtime·memclr(SB),7,$0 TEXT runtime·memclr(SB),7,$0
MOVL 4(SP), DI // arg 1 addr MOVL 4(SP), DI // arg 1 addr
MOVL 8(SP), CX // arg 2 count MOVL 8(SP), CX // arg 2 count
ADDL $3, CX MOVL CX, BX
ANDL $3, BX
SHRL $2, CX SHRL $2, CX
MOVL $0, AX MOVL $0, AX
CLD CLD
REP REP
STOSL STOSL
MOVL BX, CX
REP
STOSB
RET RET
TEXT runtime·getcallerpc(SB),7,$0 TEXT runtime·getcallerpc(SB),7,$0
......
...@@ -527,12 +527,16 @@ TEXT runtime·stackcheck(SB), 7, $0 ...@@ -527,12 +527,16 @@ TEXT runtime·stackcheck(SB), 7, $0
TEXT runtime·memclr(SB),7,$0 TEXT runtime·memclr(SB),7,$0
MOVQ 8(SP), DI // arg 1 addr MOVQ 8(SP), DI // arg 1 addr
MOVQ 16(SP), CX // arg 2 count MOVQ 16(SP), CX // arg 2 count
ADDQ $7, CX MOVQ CX, BX
ANDQ $7, BX
SHRQ $3, CX SHRQ $3, CX
MOVQ $0, AX MOVQ $0, AX
CLD CLD
REP REP
STOSQ STOSQ
MOVQ BX, CX
REP
STOSB
RET RET
TEXT runtime·getcallerpc(SB),7,$0 TEXT runtime·getcallerpc(SB),7,$0
......
...@@ -381,18 +381,11 @@ memprint(uint32 s, void *a) ...@@ -381,18 +381,11 @@ memprint(uint32 s, void *a)
static void static void
memcopy(uint32 s, void *a, void *b) memcopy(uint32 s, void *a, void *b)
{ {
byte *ba, *bb; if(b == nil) {
uint32 i; runtime·memclr(a,s);
ba = a;
bb = b;
if(bb == nil) {
for(i=0; i<s; i++)
ba[i] = 0;
return; return;
} }
for(i=0; i<s; i++) runtime·memmove(a,b,s);
ba[i] = bb[i];
} }
static uint32 static uint32
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment