@@ -5,17 +5,9 @@ package purego
55
66import (
77 "fmt"
8- "runtime"
98 "testing"
109)
1110
12- // shouldSkipCallback returns true if callback tests should be skipped for the given arg count
13- func shouldSkipCallback (nargs int ) bool {
14- // Callbacks with >15 args have architectural limitations on all platforms
15- // The callback assembly only saves register arguments, not stack arguments
16- return nargs > 15
17- }
18-
1911// BenchmarkCallingMethods compares RegisterFunc, SyscallN, and Callback methods
2012func BenchmarkCallingMethods (b * testing.B ) {
2113 testCases := []struct {
@@ -30,11 +22,6 @@ func BenchmarkCallingMethods(b *testing.B) {
3022 {5 , noop5 , 0 , []uintptr {1 , 2 , 3 , 4 , 5 }},
3123 {10 , noop10 , 0 , []uintptr {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 }},
3224 {15 , noop15 , 0 , []uintptr {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 }},
33- {16 , noop16 , 0 , []uintptr {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 }},
34- {17 , noop17 , 0 , []uintptr {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 }},
35- {18 , noop18 , 0 , []uintptr {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 }},
36- {19 , noop19 , 0 , []uintptr {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 }},
37- {20 , noop20 , 0 , []uintptr {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 }},
3825 }
3926
4027 // Create callbacks once for all tests
@@ -46,13 +33,6 @@ func BenchmarkCallingMethods(b *testing.B) {
4633 b .Run ("RegisterFunc" , func (b * testing.B ) {
4734 for _ , tc := range testCases {
4835 b .Run (fmt .Sprintf ("%dargs" , tc .n ), func (b * testing.B ) {
49- if tc .n > 15 {
50- b .Skipf ("RegisterFunc with >15 args requires custom implementation" )
51- }
52- if shouldSkipCallback (tc .n ) {
53- b .Skipf ("Callbacks with %d args not supported (callback assembly limitation on %s/%s)" , tc .n , runtime .GOOS , runtime .GOARCH )
54- }
55-
5636 var registerFn any
5737 switch tc .n {
5838 case 1 :
@@ -115,9 +95,6 @@ func BenchmarkCallingMethods(b *testing.B) {
11595 b .Run ("SyscallN" , func (b * testing.B ) {
11696 for _ , tc := range testCases {
11797 b .Run (fmt .Sprintf ("%dargs" , tc .n ), func (b * testing.B ) {
118- if shouldSkipCallback (tc .n ) {
119- b .Skipf ("Callbacks with %d args not supported (callback assembly limitation on %s/%s)" , tc .n , runtime .GOOS , runtime .GOARCH )
120- }
12198 b .ResetTimer ()
12299 for i := 0 ; i < b .N ; i ++ {
123100 SyscallN (tc .fnPtr , tc .args ... )
@@ -130,9 +107,6 @@ func BenchmarkCallingMethods(b *testing.B) {
130107 b .Run ("Callback" , func (b * testing.B ) {
131108 for _ , tc := range testCases {
132109 b .Run (fmt .Sprintf ("%dargs" , tc .n ), func (b * testing.B ) {
133- if shouldSkipCallback (tc .n ) {
134- b .Skipf ("Callbacks with %d args not supported (callback assembly limitation on %s/%s)" , tc .n , runtime .GOOS , runtime .GOARCH )
135- }
136110 b .ResetTimer ()
137111 for i := 0 ; i < b .N ; i ++ {
138112 SyscallN (tc .fnPtr , tc .args ... )
0 commit comments