summaryrefslogtreecommitdiff
path: root/src/runtime/asm.s
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2014-09-12 00:18:20 -0400
committerRuss Cox <rsc@golang.org>2014-09-12 00:18:20 -0400
commit01cc50951b57fd695075fa8a7e53025cf6115da0 (patch)
tree470703fc67a92851fd65b76afa1e16a390a2ee59 /src/runtime/asm.s
parenta6669fa5e7d26c7e5f9d61a389450d2c1ef79f1c (diff)
downloadgo-01cc50951b57fd695075fa8a7e53025cf6115da0.tar.gz
cmd/gc: turn Go prototypes into ptr liveness maps for assembly functions
The goal here is to allow assembly functions to appear in the middle of a Go stack (having called other code) and still record enough information about their pointers so that stack copying and garbage collection can handle them precisely. Today, these frames are handled only conservatively. If you write func myfunc(x *float64) (y *int) (with no body, an 'extern' declaration), then the Go compiler now emits a liveness bitmap for use from the assembly definition of myfunc. The bitmap symbol is myfunc.args_stackmap and it contains two bitmaps. The first bitmap, in effect at function entry, marks all inputs as live. The second bitmap, not in effect at function entry, marks the outputs live as well. In funcdata.h, define new assembly macros: GO_ARGS opts in to using the Go compiler-generated liveness bitmap for the current function. GO_RESULTS_INITIALIZED indicates that the results have been initialized and need to be kept live for the remainder of the function; it causes a switch to the second generated bitmap for the assembly code that follows. NO_LOCAL_POINTERS indicates that there are no pointers in the local variables being stored in the function's stack frame. LGTM=khr R=khr CC=golang-codereviews https://codereview.appspot.com/137520043
Diffstat (limited to 'src/runtime/asm.s')
-rw-r--r--src/runtime/asm.s14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/runtime/asm.s b/src/runtime/asm.s
new file mode 100644
index 000000000..e6d782f37
--- /dev/null
+++ b/src/runtime/asm.s
@@ -0,0 +1,14 @@
+// Copyright 2014 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+#include "textflag.h"
+
+// funcdata for functions with no local variables in frame.
+// Define two zero-length bitmaps, because the same index is used
+// for the local variables as for the argument frame, and assembly
+// frames have two argument bitmaps, one without results and one with results.
+DATA runtime·no_pointers_stackmap+0x00(SB)/4, $2
+DATA runtime·no_pointers_stackmap+0x04(SB)/4, $0
+GLOBL runtime·no_pointers_stackmap(SB),RODATA, $8
+