From 47410a2490f4d16f44d4724e34588a2a0de0e8f1 Mon Sep 17 00:00:00 2001 From: Quan Yong Zhai Date: Sat, 23 Jul 2011 15:46:58 -0400 Subject: [PATCH] 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 --- src/pkg/runtime/386/asm.s | 6 +++++- src/pkg/runtime/amd64/asm.s | 6 +++++- src/pkg/runtime/runtime.c | 13 +++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/pkg/runtime/386/asm.s b/src/pkg/runtime/386/asm.s index c6df4f069a7..add14be964f 100644 --- a/src/pkg/runtime/386/asm.s +++ b/src/pkg/runtime/386/asm.s @@ -479,12 +479,16 @@ TEXT runtime·stackcheck(SB), 7, $0 TEXT runtime·memclr(SB),7,$0 MOVL 4(SP), DI // arg 1 addr MOVL 8(SP), CX // arg 2 count - ADDL $3, CX + MOVL CX, BX + ANDL $3, BX SHRL $2, CX MOVL $0, AX CLD REP STOSL + MOVL BX, CX + REP + STOSB RET TEXT runtime·getcallerpc(SB),7,$0 diff --git a/src/pkg/runtime/amd64/asm.s b/src/pkg/runtime/amd64/asm.s index 2b16587f8cf..6ac84c408d6 100644 --- a/src/pkg/runtime/amd64/asm.s +++ b/src/pkg/runtime/amd64/asm.s @@ -527,12 +527,16 @@ TEXT runtime·stackcheck(SB), 7, $0 TEXT runtime·memclr(SB),7,$0 MOVQ 8(SP), DI // arg 1 addr MOVQ 16(SP), CX // arg 2 count - ADDQ $7, CX + MOVQ CX, BX + ANDQ $7, BX SHRQ $3, CX MOVQ $0, AX CLD REP STOSQ + MOVQ BX, CX + REP + STOSB RET TEXT runtime·getcallerpc(SB),7,$0 diff --git a/src/pkg/runtime/runtime.c b/src/pkg/runtime/runtime.c index a16ca417e6f..00116c001a0 100644 --- a/src/pkg/runtime/runtime.c +++ b/src/pkg/runtime/runtime.c @@ -381,18 +381,11 @@ memprint(uint32 s, void *a) static void memcopy(uint32 s, void *a, void *b) { - byte *ba, *bb; - uint32 i; - - ba = a; - bb = b; - if(bb == nil) { - for(i=0; i