Skip to content

Instantly share code, notes, and snippets.

@aclements

aclements/reg.s Secret

Created Jul 25, 2020
Embed
What would you like to do?
Microbenchmark of stack- and register-based calling convention
// Copyright 2020 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.
#include "textflag.h"
TEXT ·stack(SB),NOSPLIT,$16-4
MOVD n+0(FP), CX
loop:
MOVQ CX, 0(SP)
CALL stackSub1<>(SB)
MOVQ 8(SP), CX
TESTQ CX, CX
JHI loop
RET
TEXT stackSub1<>(SB),NOSPLIT,$0-16
MOVQ x+0(FP), AX
DECQ AX
MOVQ AX, ret+8(FP)
RET
TEXT ·reg(SB),NOSPLIT,$0-4
MOVD n+0(FP), AX
loop:
CALL regSub1<>(SB)
TESTQ AX, AX
JHI loop
RET
TEXT regSub1<>(SB),NOSPLIT,$0-0
DECQ AX
RET
// Copyright 2020 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.
package stackreg
import "testing"
func BenchmarkStack(b *testing.B) {
stack(uint32(b.N))
}
func stack(n uint32)
func BenchmarkReg(b *testing.B) {
reg(uint32(b.N))
}
func reg(n uint32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.