Skip to content

Commit 6dda16a

Browse files
purego: use sync.Pool in syscall_syscall15X (#328)
This works around the stack growth issue in 05d8da4 by not marking the function as nosplit. This commit uses a pool to cache syscall15Args instances. Otherwise a new instance was allocated on the heap for each purego call.
1 parent cdb93a8 commit 6dda16a

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

syscall_sysv.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ import (
1414

1515
var syscall15XABI0 uintptr
1616

17-
//go:nosplit
1817
func syscall_syscall15X(fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15 uintptr) (r1, r2, err uintptr) {
19-
args := syscall15Args{
18+
args := thePool.Get().(*syscall15Args)
19+
defer thePool.Put(args)
20+
21+
*args = syscall15Args{
2022
fn, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15,
2123
a1, a2, a3, a4, a5, a6, a7, a8,
2224
0,
2325
}
24-
runtime_cgocall(syscall15XABI0, unsafe.Pointer(&args))
26+
27+
runtime_cgocall(syscall15XABI0, unsafe.Pointer(args))
2528
return args.a1, args.a2, 0
2629
}
2730

0 commit comments

Comments
 (0)