github.com/vc42/parquet-go@v0.0.0-20240320194221-1a9adb5f23f5/encoding/plain/plain_amd64.s (about) 1 //go:build !purego 2 3 #include "textflag.h" 4 5 // validateByteArray is implemented in assembly because it is the bottleneck in 6 // many cases when encoding byte arrays. This version of the function yields 7 // ~50% better throughput than the code generated by the Go compiler. 8 // 9 // func validateByteArray([]byte) status 10 TEXT ·validateByteArray(SB), NOSPLIT, $0-32 11 MOVQ arg_base+0(FP), AX 12 MOVQ arg_len+8(FP), BX 13 14 CMPQ BX, $0 15 JE done 16 17 CMPQ BX, $4 18 JB errTooShort 19 20 ADDQ AX, BX // end 21 loop: 22 MOVL (AX), CX 23 24 CMPL CX, $0x7FFFFFFF 25 JA errTooLarge 26 27 LEAQ 4(AX)(CX*1), AX 28 CMPQ AX, BX 29 JA errTooShort 30 JB loop 31 done: 32 XORQ AX, AX 33 return: 34 MOVQ AX, ret+24(FP) 35 RET 36 errTooShort: 37 MOVQ $1, AX 38 JMP return 39 errTooLarge: 40 MOVQ $2, AX 41 JMP return