Drop 1.15 Support (#45)
* Revert "fix arm64 (#35)" This reverts commit cf3e27c364c7cdd4ddc620984df246a84a87e477. * Revert "fix callbacks on go 1.15 (#34)" This reverts commit 3aa994fcbff60ba81dc1120e4fd38dd6d8546c24. * match test with current version the test file changed when I reverted the Go 1.15 changes. It should now match that of what is currently on the tree. * renamed isios_darwin.go to is_ios.go 1.16 has support for _ios in the filename Closes #43
- commit
- 02d7b30ab071867225afcd60714c65bc6abf5dc1
- author
- TotallyGamerJet · · 2022-09-13 15:26 UTC
- committer
- GitHub · · 2022-09-13 15:26 UTC
- parent
- 1865347
- signature
- GPG Unverified
4AEE18F83AFDEB23The key is unknown
6 files · +25 -76
D callback_go1_15_darwin_amd64.go +0 -16
| @@ -1,16 +0,0 @@ | |||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | - | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |
| 3 | - | ||
| 4 | - | //go:build !go1.16 | |
| 5 | - | // +build !go1.16 | |
| 6 | - | ||
| 7 | - | package purego | |
| 8 | - | ||
| 9 | - | // callbackWrapPicker is here because Go 1.16+ needs it | |
| 10 | - | // to decide between stack and register arguments. | |
| 11 | - | // This only has a single pointer because Go 1.15 runtime.cgocallback | |
| 12 | - | // dereferences the argument once before passing it to this | |
| 13 | - | // function. | |
| 14 | - | func callbackWrapPicker(stack, _ *callbackArgs) { | |
| 15 | - | callbackWrap(stack) | |
| 16 | - | } | |
| @@ -1,16 +0,0 @@ | |||||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |||
| 2 | - | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |||
| 3 | - | ||||
| 4 | - | //go:build !go1.16 | |||
| 5 | - | // +build !go1.16 | |||
| 6 | - | ||||
| 7 | - | package purego | |||
| 8 | - | ||||
| 9 | - | // callbackWrapPicker is here because Go 1.16+ needs it | |||
| 10 | - | // to decide between stack and register arguments. | |||
| 11 | - | // This only has a single pointer because Go 1.15 runtime.cgocallback | |||
| 12 | - | // dereferences the argument once before passing it to this | |||
| 13 | - | // function. | |||
| 14 | - | func callbackWrapPicker(stack, _ *callbackArgs) { | |||
| 15 | - | callbackWrap(stack) | |||
| 16 | - | } | |||
D callback_go1_16_darwin_amd64.go +0 -24
| @@ -1,24 +0,0 @@ | |||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | - | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |
| 3 | - | ||
| 4 | - | //go:build go1.16 | |
| 5 | - | // +build go1.16 | |
| 6 | - | ||
| 7 | - | package purego | |
| 8 | - | ||
| 9 | - | // callbackWrapPicker gets called with whatever is on the stack and in the first register. | |
| 10 | - | // Depending on which version of Go that uses stack or register-based | |
| 11 | - | // calling it passes the respective argument to the real calbackWrap function. | |
| 12 | - | // The other argument is therefore invalid and points to undefined memory so don't use it. | |
| 13 | - | // This function is necessary since we can't use the ABIInternal selector which is only | |
| 14 | - | // valid in the runtime. | |
| 15 | - | // | |
| 16 | - | // the double indirection is because Go 1.15 will do that in runtime.cgocallback | |
| 17 | - | // but in 1.16+ it doesn't so we do it here. | |
| 18 | - | func callbackWrapPicker(stack, register **callbackArgs) { | |
| 19 | - | if stackCallingConvention { | |
| 20 | - | callbackWrap(*stack) | |
| 21 | - | } else { | |
| 22 | - | callbackWrap(*register) | |
| 23 | - | } | |
| 24 | - | } | |
| @@ -1,24 +0,0 @@ | |||||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |||
| 2 | - | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |||
| 3 | - | ||||
| 4 | - | //go:build go1.16 | |||
| 5 | - | // +build go1.16 | |||
| 6 | - | ||||
| 7 | - | package purego | |||
| 8 | - | ||||
| 9 | - | // callbackWrapPicker gets called with whatever is on the stack and in the first register. | |||
| 10 | - | // Depending on which version of Go that uses stack or register-based | |||
| 11 | - | // calling it passes the respective argument to the real calbackWrap function. | |||
| 12 | - | // The other argument is therefore invalid and points to undefined memory so don't use it. | |||
| 13 | - | // This function is necessary since we can't use the ABIInternal selector which is only | |||
| 14 | - | // valid in the runtime. | |||
| 15 | - | // | |||
| 16 | - | // the double indirection is because Go 1.15 will do that in runtime.cgocallback | |||
| 17 | - | // but in 1.16+ it doesn't so we do it here. | |||
| 18 | - | func callbackWrapPicker(stack, register **callbackArgs) { | |||
| 19 | - | if stackCallingConvention { | |||
| 20 | - | callbackWrap(*stack) | |||
| 21 | - | } else { | |||
| 22 | - | callbackWrap(*register) | |||
| 23 | - | } | |||
| 24 | - | } | |||
D callback_go1_16_darwin_arm64.go +0 -21
| @@ -1,21 +0,0 @@ | |||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | - | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |
| 3 | - | ||
| 4 | - | //go:build go1.16 | |
| 5 | - | // +build go1.16 | |
| 6 | - | ||
| 7 | - | package purego | |
| 8 | - | ||
| 9 | - | // callbackWrapPicker gets called with whatever is on the stack and in the first register. | |
| 10 | - | // Depending on which version of Go that uses stack or register-based | |
| 11 | - | // calling it passes the respective argument to the real calbackWrap function. | |
| 12 | - | // The other argument is therefore invalid and points to undefined memory so don't use it. | |
| 13 | - | // This function is necessary since we can't use the ABIInternal selector which is only | |
| 14 | - | // valid in the runtime. | |
| 15 | - | func callbackWrapPicker(stack, register *callbackArgs) { | |
| 16 | - | if stackCallingConvention { | |
| 17 | - | callbackWrap(stack) | |
| 18 | - | } else { | |
| 19 | - | callbackWrap(register) | |
| 20 | - | } | |
| 21 | - | } | |
| @@ -1,21 +0,0 @@ | |||||
| 1 | - | // SPDX-License-Identifier: Apache-2.0 | |||
| 2 | - | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |||
| 3 | - | ||||
| 4 | - | //go:build go1.16 | |||
| 5 | - | // +build go1.16 | |||
| 6 | - | ||||
| 7 | - | package purego | |||
| 8 | - | ||||
| 9 | - | // callbackWrapPicker gets called with whatever is on the stack and in the first register. | |||
| 10 | - | // Depending on which version of Go that uses stack or register-based | |||
| 11 | - | // calling it passes the respective argument to the real calbackWrap function. | |||
| 12 | - | // The other argument is therefore invalid and points to undefined memory so don't use it. | |||
| 13 | - | // This function is necessary since we can't use the ABIInternal selector which is only | |||
| 14 | - | // valid in the runtime. | |||
| 15 | - | func callbackWrapPicker(stack, register *callbackArgs) { | |||
| 16 | - | if stackCallingConvention { | |||
| 17 | - | callbackWrap(stack) | |||
| 18 | - | } else { | |||
| 19 | - | callbackWrap(register) | |||
| 20 | - | } | |||
| 21 | - | } | |||
R isios_darwin.go → is_ios.go +2 -2 renamed, 89% similar
| @@ -1,8 +1,8 @@ | |||
| 1 | 1 | // SPDX-License-Identifier: Apache-2.0 | |
| 2 | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | |
| 3 | 3 | ||
| 4 | - | //go:build !cgo && ios | |
| 5 | - | // +build !cgo,ios | |
| 4 | + | //go:build !cgo | |
| 5 | + | // +build !cgo | |
| 6 | 6 | ||
| 7 | 7 | package purego | |
| 8 | 8 | ||
| @@ -1,8 +1,8 @@ | |||||
| 1 | // SPDX-License-Identifier: Apache-2.0 | 1 | // SPDX-License-Identifier: Apache-2.0 | ||
| 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | 2 | // SPDX-FileCopyrightText: 2022 The Ebitengine Authors | ||
| 3 | 3 | ||||
| 4 | - | //go:build !cgo && ios | 4 | + | //go:build !cgo |
| 5 | - | // +build !cgo,ios | 5 | + | // +build !cgo |
| 6 | 6 | ||||
| 7 | package purego | 7 | package purego | ||
| 8 | 8 | ||||
M sys_darwin_amd64.s +9 -13
| @@ -115,27 +115,23 @@ TEXT callbackasm1(SB), NOSPLIT, $0 | |||
| 115 | 115 | ||
| 116 | 116 | // Create a struct callbackArgs on our stack to be passed as | |
| 117 | 117 | // the "frame" to cgocallback and on to callbackWrap. | |
| 118 | - | // $32 to make enough room for the arguments to runtime.cgocallback | |
| 119 | - | // and on Go 1.15 to take a pointer to the pointer to callbackArgs | |
| 120 | - | SUBQ $(32+callbackArgs__size), SP | |
| 121 | - | MOVQ AX, (32+callbackArgs_index)(SP) // callback index | |
| 122 | - | MOVQ R8, (32+callbackArgs_args)(SP) // address of args vector | |
| 123 | - | MOVQ $0, (32+callbackArgs_result)(SP) // result | |
| 124 | - | LEAQ 32(SP), AX // take the address of callbackArgs | |
| 125 | - | ||
| 126 | - | MOVQ AX, 24(SP) // get a **callbackArgs for go 1.15 | |
| 127 | - | LEAQ 24(SP), AX // ^^^^ | |
| 118 | + | // $24 to make enough room for the arguments to runtime.cgocallback | |
| 119 | + | SUBQ $(24+callbackArgs__size), SP | |
| 120 | + | MOVQ AX, (24+callbackArgs_index)(SP) // callback index | |
| 121 | + | MOVQ R8, (24+callbackArgs_args)(SP) // address of args vector | |
| 122 | + | MOVQ $0, (24+callbackArgs_result)(SP) // result | |
| 123 | + | LEAQ 24(SP), AX // take the address of callbackArgs | |
| 128 | 124 | ||
| 129 | 125 | // Call cgocallback, which will call callbackWrap(frame). | |
| 130 | - | MOVQ $8, 16(SP) // context is 0 or argsize (including return value) for Go 1.15 | |
| 126 | + | MOVQ $0, 16(SP) // context | |
| 131 | 127 | MOVQ AX, 8(SP) // frame (address of callbackArgs) | |
| 132 | 128 | MOVQ $callbackWrapInternal<>(SB), BX | |
| 133 | 129 | MOVQ BX, 0(SP) // PC of function value to call (callbackWrap) | |
| 134 | 130 | CALL runtime·cgocallback(SB) // runtime.cgocallback(fn, frame, ctxt uintptr) | |
| 135 | 131 | ||
| 136 | 132 | // Get callback result. | |
| 137 | - | MOVQ (32+callbackArgs_result)(SP), AX | |
| 138 | - | ADDQ $(32+callbackArgs__size), SP // remove callbackArgs struct | |
| 133 | + | MOVQ (24+callbackArgs_result)(SP), AX | |
| 134 | + | ADDQ $(24+callbackArgs__size), SP // remove callbackArgs struct | |
| 139 | 135 | ||
| 140 | 136 | POP_REGS_HOST_TO_ABI0() | |
| 141 | 137 | ||
| @@ -115,27 +115,23 @@ TEXT callbackasm1(SB), NOSPLIT, $0 | |||||
| 115 | 115 | ||||
| 116 | // Create a struct callbackArgs on our stack to be passed as | 116 | // Create a struct callbackArgs on our stack to be passed as | ||
| 117 | // the "frame" to cgocallback and on to callbackWrap. | 117 | // the "frame" to cgocallback and on to callbackWrap. | ||
| 118 | - | // $32 to make enough room for the arguments to runtime.cgocallback | 118 | + | // $24 to make enough room for the arguments to runtime.cgocallback |
| 119 | - | // and on Go 1.15 to take a pointer to the pointer to callbackArgs | 119 | + | SUBQ $(24+callbackArgs__size), SP |
| 120 | - | SUBQ $(32+callbackArgs__size), SP | 120 | + | MOVQ AX, (24+callbackArgs_index)(SP) // callback index |
| 121 | - | MOVQ AX, (32+callbackArgs_index)(SP) // callback index | 121 | + | MOVQ R8, (24+callbackArgs_args)(SP) // address of args vector |
| 122 | - | MOVQ R8, (32+callbackArgs_args)(SP) // address of args vector | 122 | + | MOVQ $0, (24+callbackArgs_result)(SP) // result |
| 123 | - | MOVQ $0, (32+callbackArgs_result)(SP) // result | 123 | + | LEAQ 24(SP), AX // take the address of callbackArgs |
| 124 | - | LEAQ 32(SP), AX // take the address of callbackArgs | |||
| 125 | - | ||||
| 126 | - | MOVQ AX, 24(SP) // get a **callbackArgs for go 1.15 | |||
| 127 | - | LEAQ 24(SP), AX // ^^^^ | |||
| 128 | 124 | ||||
| 129 | // Call cgocallback, which will call callbackWrap(frame). | 125 | // Call cgocallback, which will call callbackWrap(frame). | ||
| 130 | - | MOVQ $8, 16(SP) // context is 0 or argsize (including return value) for Go 1.15 | 126 | + | MOVQ $0, 16(SP) // context |
| 131 | MOVQ AX, 8(SP) // frame (address of callbackArgs) | 127 | MOVQ AX, 8(SP) // frame (address of callbackArgs) | ||
| 132 | MOVQ $callbackWrapInternal<>(SB), BX | 128 | MOVQ $callbackWrapInternal<>(SB), BX | ||
| 133 | MOVQ BX, 0(SP) // PC of function value to call (callbackWrap) | 129 | MOVQ BX, 0(SP) // PC of function value to call (callbackWrap) | ||
| 134 | CALL runtime·cgocallback(SB) // runtime.cgocallback(fn, frame, ctxt uintptr) | 130 | CALL runtime·cgocallback(SB) // runtime.cgocallback(fn, frame, ctxt uintptr) | ||
| 135 | 131 | ||||
| 136 | // Get callback result. | 132 | // Get callback result. | ||
| 137 | - | MOVQ (32+callbackArgs_result)(SP), AX | 133 | + | MOVQ (24+callbackArgs_result)(SP), AX |
| 138 | - | ADDQ $(32+callbackArgs__size), SP // remove callbackArgs struct | 134 | + | ADDQ $(24+callbackArgs__size), SP // remove callbackArgs struct |
| 139 | 135 | ||||
| 140 | POP_REGS_HOST_TO_ABI0() | 136 | POP_REGS_HOST_TO_ABI0() | ||
| 141 | 137 | ||||
M syscall_darwin.go +14 -0
| @@ -95,6 +95,20 @@ const callbackMaxFrame = 64 * ptrSize | |||
| 95 | 95 | // callbackasmABI0 is implemented in zcallback_GOOS_GOARCH.s | |
| 96 | 96 | var callbackasmABI0 uintptr | |
| 97 | 97 | ||
| 98 | + | // callbackWrapPicker gets whatever is on the stack and in the first register. | |
| 99 | + | // Depending on which version of Go that uses stack or register-based | |
| 100 | + | // calling it passes the respective argument to the real calbackWrap function. | |
| 101 | + | // The other argument is therefore invalid and points to undefined memory so don't use it. | |
| 102 | + | // This function is necessary since we can't use the ABIInternal selector which is only | |
| 103 | + | // valid in the runtime. | |
| 104 | + | func callbackWrapPicker(stack, register *callbackArgs) { | |
| 105 | + | if stackCallingConvention { | |
| 106 | + | callbackWrap(stack) | |
| 107 | + | } else { | |
| 108 | + | callbackWrap(register) | |
| 109 | + | } | |
| 110 | + | } | |
| 111 | + | ||
| 98 | 112 | // callbackWrap is called by assembly code which determines which Go function to call. | |
| 99 | 113 | // This function takes the arguments and passes them to the Go function and returns the result. | |
| 100 | 114 | func callbackWrap(a *callbackArgs) { | |
| @@ -95,6 +95,20 @@ const callbackMaxFrame = 64 * ptrSize | |||||
| 95 | // callbackasmABI0 is implemented in zcallback_GOOS_GOARCH.s | 95 | // callbackasmABI0 is implemented in zcallback_GOOS_GOARCH.s | ||
| 96 | var callbackasmABI0 uintptr | 96 | var callbackasmABI0 uintptr | ||
| 97 | 97 | ||||
| 98 | + | // callbackWrapPicker gets whatever is on the stack and in the first register. | |||
| 99 | + | // Depending on which version of Go that uses stack or register-based | |||
| 100 | + | // calling it passes the respective argument to the real calbackWrap function. | |||
| 101 | + | // The other argument is therefore invalid and points to undefined memory so don't use it. | |||
| 102 | + | // This function is necessary since we can't use the ABIInternal selector which is only | |||
| 103 | + | // valid in the runtime. | |||
| 104 | + | func callbackWrapPicker(stack, register *callbackArgs) { | |||
| 105 | + | if stackCallingConvention { | |||
| 106 | + | callbackWrap(stack) | |||
| 107 | + | } else { | |||
| 108 | + | callbackWrap(register) | |||
| 109 | + | } | |||
| 110 | + | } | |||
| 111 | + | ||||
| 98 | // callbackWrap is called by assembly code which determines which Go function to call. | 112 | // callbackWrap is called by assembly code which determines which Go function to call. | ||
| 99 | // This function takes the arguments and passes them to the Go function and returns the result. | 113 | // This function takes the arguments and passes them to the Go function and returns the result. | ||
| 100 | func callbackWrap(a *callbackArgs) { | 114 | func callbackWrap(a *callbackArgs) { | ||