-
-
Save aclements/ded22bb8451eead8249d22d3cd873566 to your computer and use it in GitHub Desktop.
Microbenchmark of stack- and register-based calling convention
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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