mirror of https://github.com/golang/go.git
runtime: add load_g call in arm callback.
Need to restore the g register. Somehow this line vaporized from CL 144130043. Also cgo_topofstack -> _cgo_topofstack, that vaporized also. TBR=rsc CC=golang-codereviews https://golang.org/cl/150940044
This commit is contained in:
parent
1b6807bb06
commit
1aa65fe8d4
|
|
@ -44,7 +44,7 @@ func (p *Package) writeDefs() {
|
|||
fmt.Fprintf(fm, "int main() { return 0; }\n")
|
||||
if *importRuntimeCgo {
|
||||
fmt.Fprintf(fm, "void crosscall2(void(*fn)(void*, int), void *a, int c) { }\n")
|
||||
fmt.Fprintf(fm, "char* cgo_topofstack(void) { return (char*)0; }\n")
|
||||
fmt.Fprintf(fm, "char* _cgo_topofstack(void) { return (char*)0; }\n")
|
||||
} else {
|
||||
// If we're not importing runtime/cgo, we *are* runtime/cgo,
|
||||
// which provides crosscall2. We just need a prototype.
|
||||
|
|
@ -522,7 +522,7 @@ func (p *Package) writeOutputFunc(fgcc *os.File, n *Name) {
|
|||
fmt.Fprintf(fgcc, "\t%s %v *a = v;\n", ctype, p.packedAttribute())
|
||||
if n.FuncType.Result != nil {
|
||||
// Save the stack top for use below.
|
||||
fmt.Fprintf(fgcc, "\tchar *stktop = cgo_topofstack();\n")
|
||||
fmt.Fprintf(fgcc, "\tchar *stktop = _cgo_topofstack();\n")
|
||||
}
|
||||
fmt.Fprintf(fgcc, "\t")
|
||||
if t := n.FuncType.Result; t != nil {
|
||||
|
|
@ -552,7 +552,7 @@ func (p *Package) writeOutputFunc(fgcc *os.File, n *Name) {
|
|||
if n.FuncType.Result != nil {
|
||||
// The cgo call may have caused a stack copy (via a callback).
|
||||
// Adjust the return value pointer appropriately.
|
||||
fmt.Fprintf(fgcc, "\ta = (void*)((char*)a + (cgo_topofstack() - stktop));\n")
|
||||
fmt.Fprintf(fgcc, "\ta = (void*)((char*)a + (_cgo_topofstack() - stktop));\n")
|
||||
// Save the return value.
|
||||
fmt.Fprintf(fgcc, "\ta->r = r;\n")
|
||||
}
|
||||
|
|
@ -1143,7 +1143,7 @@ __cgo_size_assert(__cgo_long_long, 8)
|
|||
__cgo_size_assert(float, 4)
|
||||
__cgo_size_assert(double, 8)
|
||||
|
||||
extern char* cgo_topofstack(void);
|
||||
extern char* _cgo_topofstack(void);
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
|
|
|||
|
|
@ -2278,7 +2278,7 @@ TEXT runtime·return0(SB), NOSPLIT, $0
|
|||
|
||||
// Called from cgo wrappers, this function returns g->m->curg.stack.hi.
|
||||
// Must obey the gcc calling convention.
|
||||
TEXT cgo_topofstack(SB),NOSPLIT,$0
|
||||
TEXT _cgo_topofstack(SB),NOSPLIT,$0
|
||||
get_tls(CX)
|
||||
MOVL g(CX), AX
|
||||
MOVL g_m(AX), AX
|
||||
|
|
|
|||
|
|
@ -2224,7 +2224,7 @@ TEXT runtime·return0(SB), NOSPLIT, $0
|
|||
|
||||
// Called from cgo wrappers, this function returns g->m->curg.stack.hi.
|
||||
// Must obey the gcc calling convention.
|
||||
TEXT cgo_topofstack(SB),NOSPLIT,$0
|
||||
TEXT _cgo_topofstack(SB),NOSPLIT,$0
|
||||
get_tls(CX)
|
||||
MOVQ g(CX), AX
|
||||
MOVQ g_m(AX), AX
|
||||
|
|
|
|||
|
|
@ -1303,7 +1303,8 @@ yieldloop:
|
|||
|
||||
// Called from cgo wrappers, this function returns g->m->curg.stack.hi.
|
||||
// Must obey the gcc calling convention.
|
||||
TEXT cgo_topofstack(SB),NOSPLIT,$0
|
||||
TEXT _cgo_topofstack(SB),NOSPLIT,$0
|
||||
BL runtime·load_g(SB)
|
||||
MOVW g_m(g), R0
|
||||
MOVW m_curg(R0), R0
|
||||
MOVW (g_stack+stack_hi)(R0), R0
|
||||
|
|
|
|||
|
|
@ -79,5 +79,5 @@ void (*_cgo_free)(void*) = x_cgo_free;
|
|||
extern void x_cgo_thread_start(void*);
|
||||
void (*_cgo_thread_start)(void*) = x_cgo_thread_start;
|
||||
|
||||
#pragma cgo_export_static cgo_topofstack
|
||||
#pragma cgo_export_dynamic cgo_topofstack
|
||||
#pragma cgo_export_static _cgo_topofstack
|
||||
#pragma cgo_export_dynamic _cgo_topofstack
|
||||
|
|
|
|||
Loading…
Reference in New Issue