runtime: generate windows/arm64 callback asm

This CL is part of a stack adding windows/arm64
support (#36439), intended to land in the Go 1.17 cycle.

Change-Id: I5e2b589797808626bcca771cdf860d5cb85586cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/288826
Trust: Russ Cox <rsc@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Russ Cox 2021-01-22 15:16:13 -05:00
parent f6c4b4bf96
commit 427bd7599d
3 changed files with 4043 additions and 2 deletions

View File

@ -71,8 +71,8 @@ func callbackasmAddr(i int) uintptr {
panic("unsupported architecture") panic("unsupported architecture")
case "386", "amd64": case "386", "amd64":
entrySize = 5 entrySize = 5
case "arm": case "arm", "arm64":
// On ARM, each entry is a MOV instruction // On ARM and ARM64, each entry is a MOV instruction
// followed by a branch instruction // followed by a branch instruction
entrySize = 8 entrySize = 8
} }

View File

@ -72,6 +72,34 @@ TEXT runtime·callbackasm(SB),NOSPLIT|NOFRAME,$0
} }
} }
func genasmArm64() {
var buf bytes.Buffer
buf.WriteString(`// Code generated by wincallback.go using 'go generate'. DO NOT EDIT.
// External code calls into callbackasm at an offset corresponding
// to the callback index. Callbackasm is a table of MOV and B instructions.
// The MOV instruction loads R12 with the callback index, and the
// B instruction branches to callbackasm1.
// callbackasm1 takes the callback index from R12 and
// indexes into an array that stores information about each callback.
// It then calls the Go implementation for that callback.
#include "textflag.h"
TEXT runtime·callbackasm(SB),NOSPLIT|NOFRAME,$0
`)
for i := 0; i < maxCallback; i++ {
buf.WriteString(fmt.Sprintf("\tMOVD\t$%d, R12\n", i))
buf.WriteString("\tB\truntime·callbackasm1(SB)\n")
}
err := os.WriteFile("zcallback_windows_arm64.s", buf.Bytes(), 0666)
if err != nil {
fmt.Fprintf(os.Stderr, "wincallback: %s\n", err)
os.Exit(2)
}
}
func gengo() { func gengo() {
var buf bytes.Buffer var buf bytes.Buffer
@ -91,5 +119,6 @@ const cb_max = %d // maximum number of windows callbacks allowed
func main() { func main() {
genasm386Amd64() genasm386Amd64()
genasmArm() genasmArm()
genasmArm64()
gengo() gengo()
} }

File diff suppressed because it is too large Load Diff