mirror of
https://github.com/golang/go
synced 2024-11-05 18:36:10 -07:00
cmd/internal/obj/x86: add comments to wrapper prologue insertion
Make the comments a bit clearer and more accurate, in anticipation of updating the code. Change-Id: I1111e6c3405a8688fcd29b809a48a762ff41edaa Reviewed-on: https://go-review.googlesource.com/36833 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
2c91bb4c8a
commit
5030bfdf81
@ -742,7 +742,9 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if cursym.Text.From3Offset()&obj.WRAPPER != 0 {
|
if cursym.Text.From3Offset()&obj.WRAPPER != 0 {
|
||||||
// if(g->panic != nil && g->panic->argp == FP) g->panic->argp = bottom-of-frame
|
// if g._panic != nil && g._panic.argp == FP {
|
||||||
|
// g._panic.argp = bottom-of-frame
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// MOVQ g_panic(CX), BX
|
// MOVQ g_panic(CX), BX
|
||||||
// TESTQ BX, BX
|
// TESTQ BX, BX
|
||||||
@ -757,12 +759,12 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
|
|||||||
// The NOP is needed to give the jumps somewhere to land.
|
// The NOP is needed to give the jumps somewhere to land.
|
||||||
// It is a liblink NOP, not an x86 NOP: it encodes to 0 instruction bytes.
|
// It is a liblink NOP, not an x86 NOP: it encodes to 0 instruction bytes.
|
||||||
|
|
||||||
|
// MOVQ g_panic(CX), BX
|
||||||
p = obj.Appendp(ctxt, p)
|
p = obj.Appendp(ctxt, p)
|
||||||
|
|
||||||
p.As = AMOVQ
|
p.As = AMOVQ
|
||||||
p.From.Type = obj.TYPE_MEM
|
p.From.Type = obj.TYPE_MEM
|
||||||
p.From.Reg = REG_CX
|
p.From.Reg = REG_CX
|
||||||
p.From.Offset = 4 * int64(ctxt.Arch.PtrSize) // G.panic
|
p.From.Offset = 4 * int64(ctxt.Arch.PtrSize) // g_panic
|
||||||
p.To.Type = obj.TYPE_REG
|
p.To.Type = obj.TYPE_REG
|
||||||
p.To.Reg = REG_BX
|
p.To.Reg = REG_BX
|
||||||
if ctxt.Headtype == obj.Hnacl && p.Mode == 64 {
|
if ctxt.Headtype == obj.Hnacl && p.Mode == 64 {
|
||||||
@ -776,6 +778,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
|
|||||||
p.As = AMOVL
|
p.As = AMOVL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TESTQ BX, BX
|
||||||
p = obj.Appendp(ctxt, p)
|
p = obj.Appendp(ctxt, p)
|
||||||
p.As = ATESTQ
|
p.As = ATESTQ
|
||||||
p.From.Type = obj.TYPE_REG
|
p.From.Type = obj.TYPE_REG
|
||||||
@ -786,11 +789,13 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
|
|||||||
p.As = ATESTL
|
p.As = ATESTL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JEQ end
|
||||||
p = obj.Appendp(ctxt, p)
|
p = obj.Appendp(ctxt, p)
|
||||||
p.As = AJEQ
|
p.As = AJEQ
|
||||||
p.To.Type = obj.TYPE_BRANCH
|
p.To.Type = obj.TYPE_BRANCH
|
||||||
p1 := p
|
p1 := p
|
||||||
|
|
||||||
|
// LEAQ (autoffset+8)(SP), DI
|
||||||
p = obj.Appendp(ctxt, p)
|
p = obj.Appendp(ctxt, p)
|
||||||
p.As = ALEAQ
|
p.As = ALEAQ
|
||||||
p.From.Type = obj.TYPE_MEM
|
p.From.Type = obj.TYPE_MEM
|
||||||
@ -802,6 +807,7 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
|
|||||||
p.As = ALEAL
|
p.As = ALEAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CMPQ panic_argp(BX), DI
|
||||||
p = obj.Appendp(ctxt, p)
|
p = obj.Appendp(ctxt, p)
|
||||||
p.As = ACMPQ
|
p.As = ACMPQ
|
||||||
p.From.Type = obj.TYPE_MEM
|
p.From.Type = obj.TYPE_MEM
|
||||||
@ -820,11 +826,13 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
|
|||||||
p.As = ACMPL
|
p.As = ACMPL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JNE end
|
||||||
p = obj.Appendp(ctxt, p)
|
p = obj.Appendp(ctxt, p)
|
||||||
p.As = AJNE
|
p.As = AJNE
|
||||||
p.To.Type = obj.TYPE_BRANCH
|
p.To.Type = obj.TYPE_BRANCH
|
||||||
p2 := p
|
p2 := p
|
||||||
|
|
||||||
|
// MOVQ SP, panic_argp(BX)
|
||||||
p = obj.Appendp(ctxt, p)
|
p = obj.Appendp(ctxt, p)
|
||||||
p.As = AMOVQ
|
p.As = AMOVQ
|
||||||
p.From.Type = obj.TYPE_REG
|
p.From.Type = obj.TYPE_REG
|
||||||
@ -843,8 +851,11 @@ func preprocess(ctxt *obj.Link, cursym *obj.LSym) {
|
|||||||
p.As = AMOVL
|
p.As = AMOVL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOP
|
||||||
p = obj.Appendp(ctxt, p)
|
p = obj.Appendp(ctxt, p)
|
||||||
p.As = obj.ANOP
|
p.As = obj.ANOP
|
||||||
|
|
||||||
|
// Set targets for jumps above to the NOP
|
||||||
p1.Pcond = p
|
p1.Pcond = p
|
||||||
p2.Pcond = p
|
p2.Pcond = p
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user