Hello email@example.com (cc: firstname.lastname@example.org),
I'd like you to review this change to
runtime: store asmcgocall return PC where the ARM unwind expects it
The ARM implementation of runtime.cgocallback_gofunc diverged
from the calling convention by leaving a word of garbage at
the top of the stack and storing the return PC above the
locals. This change stores the return PC at the top of the
stack and removes the save area above the locals.
Please review this at https://codereview.appspot.com/7728045/
@@ -326,7 +326,7 @@
// cgocallback_gofunc(void (*fn)(void*), void *frame, uintptr framesize)
// See cgocall.c for more details.
// Load m and g from thread-local storage.
MOVW _cgo_load_gm(SB), R0
CMP $0, R0
@@ -337,21 +337,21 @@
// In this case, we're running on the thread stack, so there's
// lots of space, but the linker doesn't know. Hide the call from
// the linker analysis by using an indirect call.
- MOVW m, savedm-16(SP)
+ MOVW m, savedm-12(SP)
CMP $0, m
MOVW $runtime·needm(SB), R0
+ MOVW fn+0(FP), R0
+ MOVW frame+4(FP), R1
+ MOVW framesize+8(FP), R2
// Now there's a valid m, and we're running on its m->g0.
// Save current m->g0->sched.sp on stack and then set it to SP.
// Save current sp in m->g0->sched.sp in preparation for
// switch back to m->curg stack.
- MOVW fn+0(FP), R0
- MOVW frame+4(FP), R1
- MOVW framesize+8(FP), R2
MOVW m_g0(m), R3
MOVW (g_sched+gobuf_sp)(R3), R4
MOVW.W R4, -4(R13)
@@ -368,23 +368,20 @@
// This has the added benefit that it looks to the traceback
// routine like cgocallbackg is going to return to that
// PC (because we defined cgocallbackg to have
- // a frame size of 16, the same amount that we use below),
+ // a frame size of 12, the same amount that we use below),
// so that the traceback will seamlessly trace back into
// the earlier calls.
- // Save current m->g0->sched.sp on stack and then set it to SP.
MOVW m_curg(m), g
MOVW (g_sched+gobuf_sp)(g), R4 // prepare stack as R4
// Push gobuf.pc
MOVW (g_sched+gobuf_pc)(g), R5
- SUB $4, R4
- MOVW R5, 0(R4)
+ MOVW.W R5, -16(R4)
// Push arguments to cgocallbackg.
// Frame size here must match the frame size above
// to trick traceback routines into doing the right thing.
- SUB $16, R4
MOVW R0, 4(R4)
MOVW R1, 8(R4)
MOVW R2, 12(R4)
@@ -394,9 +391,9 @@
// Restore g->gobuf (== m->curg->gobuf) from saved values.
- MOVW 16(R13), R5
+ MOVW 0(R13), R5
MOVW R5, (g_sched+gobuf_pc)(g)
- ADD $(16+4), R13 // SP clobbered! It is ok!
+ ADD $(12+4), R13 // SP clobbered! It is ok!
MOVW R13, (g_sched+gobuf_sp)(g)
// Switch back to m->g0's stack and restore m->g0->sched.sp.
@@ -411,7 +408,7 @@
// If the m on entry was nil, we called needm above to borrow an m
// for the duration of the call. Since the call is over, return it with
- MOVW savedm-16(SP), R6
+ MOVW savedm-12(SP), R6
CMP $0, R6
MOVW $runtime·dropm(SB), R0
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to email@example.com.
For more options, visit https://groups.google.com/groups/opt_out.