Open aclements opened 4 years ago
I've submitted the ABI spec. It may continue to evolve in small ways, but reflects what all of the code is converging around.
I've submitted the ABI spec. It may continue to evolve in small ways, but reflects what all of the code is converging around.
@aclements - In case you didn't see this, https://groups.google.com/g/golang-dev/c/2oHi8t1s0Z8 might be worth considering.
Change https://golang.org/cl/292709 mentions this issue: all: merge branch dev.regabi (d3cd4830ad) into master
Change https://golang.org/cl/260539 mentions this issue: cmd/compile: add AMD64 parameter register defs, Arg ops, plumb to ssa.Config
Change https://golang.org/cl/295789 mentions this issue: cmd/compile/internal-abi: use x87 mode, not MMX mode
Change https://golang.org/cl/295792 mentions this issue: cmd/compile/internal-abi: fix ABI0-equivalence for zero-sized values
Change https://golang.org/cl/295791 mentions this issue: cmd/compile/internal-abi: fix ABI0-equivalence for zero-sized values
Change https://golang.org/cl/295790 mentions this issue: cmd/compile/internal-abi: update internal ABI spec for g register
@aclements - In case you didn't see this, https://groups.google.com/g/golang-dev/c/2oHi8t1s0Z8 might be worth considering.
Thanks @zx2c4 , I just sent a fix. (I'm still catching up from being away for a few weeks.)
Change https://golang.org/cl/293390 mentions this issue: cmd/compile: plumb abi info into expandCalls
Change https://golang.org/cl/293391 mentions this issue: cmd/compile: change StaticCall to return a "Results"
Change https://golang.org/cl/293389 mentions this issue: cmd/compile: plumb abi info into ssagen/ssa
Change https://golang.org/cl/293396 mentions this issue: cmd/compile: handle aggregate OpArg in registers
Change https://golang.org/cl/293393 mentions this issue: cmd/compile: use abiutils for all rcvr/in/out frame offsets.
Change https://golang.org/cl/293394 mentions this issue: cmd/compile: retrieve Args from registers
Change https://golang.org/cl/293397 mentions this issue: cmd/compile: refactor out an almost-superfluous arg
Change https://golang.org/cl/293392 mentions this issue: cmd/compile: check frame offsets against abi
Change https://golang.org/cl/294429 mentions this issue: cmd/compile: pointer maps seem to be right for morestack
Change https://golang.org/cl/295309 mentions this issue: cmd/compile: register results seem to work
Change https://golang.org/cl/294410 mentions this issue: cmd/compile: register abi, morestack work and mole whacking
Change https://golang.org/cl/293889 mentions this issue: cmd/compile: pass register parameters to called function
Change https://golang.org/cl/293398 mentions this issue: cmd/compile: pass arguments as register parameters to StaticCall.
Change https://golang.org/cl/297637 mentions this issue: cmd/compile: better version of check frame offsets against abi
Change https://golang.org/cl/297911 mentions this issue: cmd/compile: make modified Aux type for OpArgXXXX pass ssa/check
Change https://golang.org/cl/299269 mentions this issue: reflect: add tests for reflect.Value.Call for the new ABI
Change https://golang.org/cl/300113 mentions this issue: runtime: support register ABI Go functions from Windows callbacks
Change https://golang.org/cl/298670 mentions this issue: reflect: add register ABI support for makeFuncStub and methodValueCall
Change https://golang.org/cl/300112 mentions this issue: runtime: support register ABI for finalizers
Change https://golang.org/cl/302049 mentions this issue: cmd/internal/objabi: centralize GOEXPERIMENT parsing
Change https://golang.org/cl/302050 mentions this issue: cmd/dist: build bootstrap without GOEXPERIMENT
Change https://golang.org/cl/302070 mentions this issue: all: explode GOEXPIREMENT=regabi into 5 sub-experiments
Change https://golang.org/cl/302109 mentions this issue: runtime: mark Windows' address-taken asm routines as ABIInternal
Change https://golang.org/cl/302071 mentions this issue: cmd/compile: (fixed) spill output parameters passed in registers as autos
Change https://golang.org/cl/302249 mentions this issue: cmd/compile: fix open defer of method call
Change https://golang.org/cl/302772 mentions this issue: test: make nosplit test invariant to ABI wrappers
Change https://golang.org/cl/303069 mentions this issue: runtime: call nanotimeQPC from nanotime1 without a wrapper
Change https://golang.org/cl/303070 mentions this issue: runtime: bypass ABI wrapper when calling needm on Windows
Change https://golang.org/cl/303314 mentions this issue: cmd/internal/obj/x86: use ABI scratch registers for WRAPPER prologue
Change https://golang.org/cl/303432 mentions this issue: cmd/compile: remove now-redundant AuxCall.args
Change https://golang.org/cl/303433 mentions this issue: cmd/compile: remove AuxCall.results, cleanup ssagen/ssa.go
Change https://golang.org/cl/304189 mentions this issue: cmd/compile: remove more dead code and data structures
Change https://golang.org/cl/304233 mentions this issue: cmd/compile: fix array case in types-for-register parameter
Change https://golang.org/cl/304549 mentions this issue: cmd/compile: update default ABI choices for calls and bodyless fn stack maps
@alexbrainman
@aclements I reckon there are very few instances of syscall.NewCallback usage. But they are used a lot. ... These two pretty much cover syscall.NewCallback usage. ... I reckon, that is about it. For Microsoft APIs (maybe google code for syscall.NewCallback or windows.NewCallback).
Actually there are other instances where NewCallback is used. One example is to interface with the Core Audio APIs. In this specific case, the support for callbacks with floating point argument is needed. See for example this callback. I think the situation may be similar in graphics APIs, as mentioned in this issue about syscalls https://github.com/golang/go/issues/37273
Would be great if we could get support for floats args (also) in callbacks.
PS: This is beyond the scope of this issue, but a full support of Windows syscall/callbacks could be useful since Microsoft is now trying to make APIs more accessible to other languages by describing them in metadata (announcement).
@emarj
@alexbrainman
@aclements I reckon there are very few instances of syscall.NewCallback usage. But they are used a lot. ... These two pretty much cover syscall.NewCallback usage. ... I reckon, that is about it. For Microsoft APIs (maybe google code for syscall.NewCallback or windows.NewCallback).
Actually there are other instances where NewCallback is used.
No argument.
One example is to interface with the Core Audio APIs.
I did not know about that one. And I would argue that this API is rarely used comparing to building a Windows service or a Windows GUI.
Alex
These two pretty much cover syscall.NewCallback usage.
WinHTTP uses them too.
Change https://golang.org/cl/305271 mentions this issue: cmd/compile: set ir.Name.Func in more cases
Change https://golang.org/cl/305273 mentions this issue: cmd/compile: eliminate -abiwraplimit
Change https://golang.org/cl/305274 mentions this issue: cmd/compile: restructure ABI wrapper generation, export ABI
Change https://golang.org/cl/305272 mentions this issue: cmd/compile: assert that function values reference ABIInternal
I propose that we switch the Go internal ABI (used between Go functions) from stack-based to register-based argument and result passing for Go ~1.16~ 1.17.
I lay out the details of our proposal and the work required in this document.
The ABI specification can be found here.
This was previously proposed in #18597, where @dr2chase did some excellent prototyping work that our new proposal builds on. With multiple ABI support, we’re now in a much better position to execute on this without breaking compatibility with the existing body of Go assembly code. I’ve opened this new issue to focus on discussion of our new proposal.
/cc @dr2chase @danscales @thanm @cherrymui @mknyszek @prattmic @randall77
An incomplete and evolving list of tasks:
defer recover()
(@cherrymui, CL)RegEntryTmp
registers in prologue (@mknyszek, CL)WriteFuncMap
) (@dr2chase, CL)cgo_unsafe_args
generate an ABI0 function (or an ABIInternal-with-no-registers function) (@cherrymui, CL)High-priority non-critical path
funcPC
always return the "native" PC of a function (maybe also introduceABIOther
) (@cherrymui, CL)funcPC
is inargs_stackmap
in ABIInternal functions (because it's for ABI0) (CL)reflect.ValueOf(fn).Pointer()
to get the PC of an assembly function will now return the PC of the ABI wrapperEnabling steps
Testing
reflect.{ValueOf(target),MakeFunc(x, target),Method(x)}.{Call,Interface}
, called fromdefer
, called fromgo
, called as a finalizerdefer
in a test function (check arguments, modify results)MoveStackOnNextCall
, assertions for pointer-to-stack/pointer-to-heap, assertions for live/dead (@aclements, CL)Post-MVP
Cleanup (can be done later)
go
in runtime (context)ir.Func
to functionir.Name
s (context)firstpos
inssa.go
– sometimes it's late.