Home | History | Annotate | Download | only in runtime
      1 // Copyright 2014 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 #include "textflag.h"
      6 
      7 // void runtimememclrNoHeapPointers(void*, uintptr)
      8 TEXT runtimememclrNoHeapPointers(SB),NOSPLIT,$0-16
      9 	MOVD	ptr+0(FP), R0
     10 	MOVD	n+8(FP), R1
     11 	// If size is less than 16 bytes, use tail_zero to zero what remains
     12 	CMP	$16, R1
     13 	BLT	tail_zero
     14 	// Get buffer offset into 16 byte aligned address for better performance
     15 	ANDS	$15, R0, ZR
     16 	BNE	unaligned_to_16
     17 aligned_to_16:
     18 	LSR	$4, R1, R2
     19 zero_by_16:
     20 	STP.P	(ZR, ZR), 16(R0)
     21 	SUBS	$1, R2, R2
     22 	BNE	zero_by_16
     23 
     24 	ANDS	$15, R1, R1
     25 	BEQ	ending
     26 
     27 	// Zero buffer with size=R1 < 16
     28 tail_zero:
     29 	TBZ	$3, R1, tail_zero_4
     30 	MOVD.P	ZR, 8(R0)
     31 
     32 tail_zero_4:
     33 	TBZ	$2, R1, tail_zero_2
     34 	MOVW.P	ZR, 4(R0)
     35 
     36 tail_zero_2:
     37 	TBZ	$1, R1, tail_zero_1
     38 	MOVH.P	ZR, 2(R0)
     39 
     40 tail_zero_1:
     41 	TBZ	$0, R1, ending
     42 	MOVB	ZR, (R0)
     43 
     44 ending:
     45 	RET
     46 
     47 unaligned_to_16:
     48 	MOVD	R0, R2
     49 head_loop:
     50 	MOVBU.P	ZR, 1(R0)
     51 	ANDS	$15, R0, ZR
     52 	BNE	head_loop
     53 	// Adjust length for what remains
     54 	SUB	R2, R0, R3
     55 	SUB	R3, R1
     56 	// If size is less than 16 bytes, use tail_zero to zero what remains
     57 	CMP	$16, R1
     58 	BLT	tail_zero
     59 	B	aligned_to_16
     60