当前位置: 首页>>代码示例>>Golang>>正文


Golang Prog.Pcond方法代码示例

本文整理汇总了Golang中rsc/io/tmp/slowgc/liblink.Prog.Pcond方法的典型用法代码示例。如果您正苦于以下问题:Golang Prog.Pcond方法的具体用法?Golang Prog.Pcond怎么用?Golang Prog.Pcond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rsc/io/tmp/slowgc/liblink.Prog的用法示例。


在下文中一共展示了Prog.Pcond方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: stacksplit


//.........这里部分代码省略.........
		//	MOVW $-framesize(SP), R2
		//	CMP stackguard, R2
		p = liblink.Appendp(ctxt, p)

		p.As = AMOVW
		p.From.Type_ = D_CONST
		p.From.Reg = REGSP
		p.From.Offset = int64(-framesize)
		p.To.Type_ = D_REG
		p.To.Reg = 2

		p = liblink.Appendp(ctxt, p)
		p.As = ACMP
		p.From.Type_ = D_REG
		p.From.Reg = 1
		p.Reg = 2
	} else {

		// Such a large stack we need to protect against wraparound
		// if SP is close to zero.
		//	SP-stackguard+StackGuard < framesize + (StackGuard-StackSmall)
		// The +StackGuard on both sides is required to keep the left side positive:
		// SP is allowed to be slightly below stackguard. See stack.h.
		//	CMP $StackPreempt, R1
		//	MOVW.NE $StackGuard(SP), R2
		//	SUB.NE R1, R2
		//	MOVW.NE $(framesize+(StackGuard-StackSmall)), R3
		//	CMP.NE R3, R2
		p = liblink.Appendp(ctxt, p)

		p.As = ACMP
		p.From.Type_ = D_CONST
		p.From.Offset = int64(uint32(liblink.StackPreempt & (1<<32 - 1)))
		p.Reg = 1

		p = liblink.Appendp(ctxt, p)
		p.As = AMOVW
		p.From.Type_ = D_CONST
		p.From.Reg = REGSP
		p.From.Offset = liblink.StackGuard
		p.To.Type_ = D_REG
		p.To.Reg = 2
		p.Scond = C_SCOND_NE

		p = liblink.Appendp(ctxt, p)
		p.As = ASUB
		p.From.Type_ = D_REG
		p.From.Reg = 1
		p.To.Type_ = D_REG
		p.To.Reg = 2
		p.Scond = C_SCOND_NE

		p = liblink.Appendp(ctxt, p)
		p.As = AMOVW
		p.From.Type_ = D_CONST
		p.From.Offset = int64(framesize) + (liblink.StackGuard - liblink.StackSmall)
		p.To.Type_ = D_REG
		p.To.Reg = 3
		p.Scond = C_SCOND_NE

		p = liblink.Appendp(ctxt, p)
		p.As = ACMP
		p.From.Type_ = D_REG
		p.From.Reg = 3
		p.Reg = 2
		p.Scond = C_SCOND_NE
	}

	// MOVW.LS	R14, R3
	p = liblink.Appendp(ctxt, p)

	p.As = AMOVW
	p.Scond = C_SCOND_LS
	p.From.Type_ = D_REG
	p.From.Reg = REGLINK
	p.To.Type_ = D_REG
	p.To.Reg = 3

	// BL.LS		runtime.morestack(SB) // modifies LR, returns with LO still asserted
	p = liblink.Appendp(ctxt, p)

	p.As = ABL
	p.Scond = C_SCOND_LS
	p.To.Type_ = D_BRANCH
	if ctxt.Cursym.Cfunc != 0 {
		p.To.Sym = liblink.Linklookup(ctxt, "runtime.morestackc", 0)
	} else {

		p.To.Sym = ctxt.Symmorestack[noctxt]
	}

	// BLS	start
	p = liblink.Appendp(ctxt, p)

	p.As = ABLS
	p.To.Type_ = D_BRANCH
	p.Pcond = ctxt.Cursym.Text.Link

	return p
}
开发者ID:rsc,项目名称:tmp,代码行数:101,代码来源:obj5.go

示例2: xfol

func xfol(ctxt *liblink.Link, p *liblink.Prog, last **liblink.Prog) {
	var q *liblink.Prog
	var r *liblink.Prog
	var a int
	var i int

loop:
	if p == nil {
		return
	}
	a = int(p.As)
	if a == AB {
		q = p.Pcond
		if q != nil && q.As != ATEXT {
			p.Mark |= FOLL
			p = q
			if !(p.Mark&FOLL != 0) {
				goto loop
			}
		}
	}

	if p.Mark&FOLL != 0 {
		i = 0
		q = p
		for ; i < 4; (func() { i++; q = q.Link })() {
			if q == *last || q == nil {
				break
			}
			a = int(q.As)
			if a == ANOP {
				i--
				continue
			}

			if a == AB || (a == ARET && q.Scond == C_SCOND_NONE) || a == ARFE || a == AUNDEF {
				goto copy
			}
			if q.Pcond == nil || (q.Pcond.Mark&FOLL != 0) {
				continue
			}
			if a != ABEQ && a != ABNE {
				continue
			}

		copy:
			for {
				r = ctxt.Arch.Prg()
				*r = *p
				if !(r.Mark&FOLL != 0) {
					fmt.Printf("can't happen 1\n")
				}
				r.Mark |= FOLL
				if p != q {
					p = p.Link
					(*last).Link = r
					*last = r
					continue
				}

				(*last).Link = r
				*last = r
				if a == AB || (a == ARET && q.Scond == C_SCOND_NONE) || a == ARFE || a == AUNDEF {
					return
				}
				r.As = ABNE
				if a == ABNE {
					r.As = ABEQ
				}
				r.Pcond = p.Link
				r.Link = p.Pcond
				if !(r.Link.Mark&FOLL != 0) {
					xfol(ctxt, r.Link, last)
				}
				if !(r.Pcond.Mark&FOLL != 0) {
					fmt.Printf("can't happen 2\n")
				}
				return
			}
		}

		a = AB
		q = ctxt.Arch.Prg()
		q.As = int16(a)
		q.Lineno = p.Lineno
		q.To.Type_ = D_BRANCH
		q.To.Offset = p.Pc
		q.Pcond = p
		p = q
	}

	p.Mark |= FOLL
	(*last).Link = p
	*last = p
	if a == AB || (a == ARET && p.Scond == C_SCOND_NONE) || a == ARFE || a == AUNDEF {
		return
	}

	if p.Pcond != nil {
		if a != ABL && a != ABX && p.Link != nil {
//.........这里部分代码省略.........
开发者ID:rsc,项目名称:tmp,代码行数:101,代码来源:obj5.go

示例3: addstacksplit

func addstacksplit(ctxt *liblink.Link, cursym *liblink.LSym) {
	var p *liblink.Prog
	var pl *liblink.Prog
	var p1 *liblink.Prog
	var p2 *liblink.Prog
	var q *liblink.Prog
	var q1 *liblink.Prog
	var q2 *liblink.Prog
	var o int
	var autosize int32
	var autoffset int32

	autosize = 0

	if ctxt.Symmorestack[0] == nil {
		ctxt.Symmorestack[0] = liblink.Linklookup(ctxt, "runtime.morestack", 0)
		ctxt.Symmorestack[1] = liblink.Linklookup(ctxt, "runtime.morestack_noctxt", 0)
	}

	q = nil

	ctxt.Cursym = cursym

	if cursym.Text == nil || cursym.Text.Link == nil {
		return
	}

	softfloat(ctxt, cursym)

	p = cursym.Text
	autoffset = int32(p.To.Offset)
	if autoffset < 0 {
		autoffset = 0
	}
	cursym.Locals = autoffset
	cursym.Args = p.To.Offset2

	if ctxt.Debugzerostack != 0 {
		if autoffset != 0 && !(p.Reg&liblink.NOSPLIT != 0) {
			// MOVW $4(R13), R1
			p = liblink.Appendp(ctxt, p)

			p.As = AMOVW
			p.From.Type_ = D_CONST
			p.From.Reg = 13
			p.From.Offset = 4
			p.To.Type_ = D_REG
			p.To.Reg = 1

			// MOVW $n(R13), R2
			p = liblink.Appendp(ctxt, p)

			p.As = AMOVW
			p.From.Type_ = D_CONST
			p.From.Reg = 13
			p.From.Offset = 4 + int64(autoffset)
			p.To.Type_ = D_REG
			p.To.Reg = 2

			// MOVW $0, R3
			p = liblink.Appendp(ctxt, p)

			p.As = AMOVW
			p.From.Type_ = D_CONST
			p.From.Offset = 0
			p.To.Type_ = D_REG
			p.To.Reg = 3

			// L:
			//	MOVW.nil R3, 0(R1) +4
			//	CMP R1, R2
			//	BNE L
			pl = liblink.Appendp(ctxt, p)
			p = pl

			p.As = AMOVW
			p.From.Type_ = D_REG
			p.From.Reg = 3
			p.To.Type_ = D_OREG
			p.To.Reg = 1
			p.To.Offset = 4
			p.Scond |= C_PBIT

			p = liblink.Appendp(ctxt, p)
			p.As = ACMP
			p.From.Type_ = D_REG
			p.From.Reg = 1
			p.Reg = 2

			p = liblink.Appendp(ctxt, p)
			p.As = ABNE
			p.To.Type_ = D_BRANCH
			p.Pcond = pl
		}
	}

	/*
	 * find leaf subroutines
	 * strip NOPs
	 * expand RET
//.........这里部分代码省略.........
开发者ID:rsc,项目名称:tmp,代码行数:101,代码来源:obj5.go

示例4: stacksplit


//.........这里部分代码省略.........
		// SP is allowed to be slightly below stackguard. See stack.h.
		//
		// Preemption sets stackguard to StackPreempt, a very large value.
		// That breaks the math above, so we have to check for that explicitly.
		//	// stackguard is R3
		//	CMP	R3, $StackPreempt
		//	BEQ	label-of-call-to-morestack
		//	ADD	$StackGuard, SP, R4
		//	SUB	R3, R4
		//	MOVD	$(framesize+(StackGuard-StackSmall)), R31
		//	CMPU	R31, R4
		p = liblink.Appendp(ctxt, p)

		p.As = ACMP
		p.From.Type_ = D_REG
		p.From.Reg = 3
		p.To.Type_ = D_CONST
		p.To.Offset = liblink.StackPreempt

		p = liblink.Appendp(ctxt, p)
		q = p
		p.As = ABEQ
		p.To.Type_ = D_BRANCH

		p = liblink.Appendp(ctxt, p)
		p.As = AADD
		p.From.Type_ = D_CONST
		p.From.Offset = liblink.StackGuard
		p.Reg = REGSP
		p.To.Type_ = D_REG
		p.To.Reg = 4

		p = liblink.Appendp(ctxt, p)
		p.As = ASUB
		p.From.Type_ = D_REG
		p.From.Reg = 3
		p.To.Type_ = D_REG
		p.To.Reg = 4

		p = liblink.Appendp(ctxt, p)
		p.As = AMOVD
		p.From.Type_ = D_CONST
		p.From.Offset = int64(framesize) + liblink.StackGuard - liblink.StackSmall
		p.To.Type_ = D_REG
		p.To.Reg = REGTMP

		p = liblink.Appendp(ctxt, p)
		p.As = ACMPU
		p.From.Type_ = D_REG
		p.From.Reg = REGTMP
		p.To.Type_ = D_REG
		p.To.Reg = 4
	}

	// q1: BLT	done
	p = liblink.Appendp(ctxt, p)
	q1 = p

	p.As = ABLT
	p.To.Type_ = D_BRANCH

	// MOVD	LR, R5
	p = liblink.Appendp(ctxt, p)

	p.As = AMOVD
	p.From.Type_ = D_SPR
	p.From.Offset = D_LR
	p.To.Type_ = D_REG
	p.To.Reg = 5
	if q != nil {
		q.Pcond = p
	}

	// BL	runtime.morestack(SB)
	p = liblink.Appendp(ctxt, p)

	p.As = ABL
	p.To.Type_ = D_BRANCH
	if ctxt.Cursym.Cfunc != 0 {
		p.To.Sym = liblink.Linklookup(ctxt, "runtime.morestackc", 0)
	} else {

		p.To.Sym = ctxt.Symmorestack[noctxt]
	}

	// BR	start
	p = liblink.Appendp(ctxt, p)

	p.As = ABR
	p.To.Type_ = D_BRANCH
	p.Pcond = ctxt.Cursym.Text.Link

	// placeholder for q1's jump target
	p = liblink.Appendp(ctxt, p)

	p.As = ANOP // zero-width place holder
	q1.Pcond = p

	return p
}
开发者ID:rsc,项目名称:tmp,代码行数:101,代码来源:obj9.go

示例5: xfol

func xfol(ctxt *liblink.Link, p *liblink.Prog, last **liblink.Prog) {
	var q *liblink.Prog
	var r *liblink.Prog
	var a int
	var b int
	var i int

loop:
	if p == nil {
		return
	}
	a = int(p.As)
	if a == ABR {
		q = p.Pcond
		if (p.Mark&NOSCHED != 0) || q != nil && (q.Mark&NOSCHED != 0) {
			p.Mark |= FOLL
			(*last).Link = p
			*last = p
			p = p.Link
			xfol(ctxt, p, last)
			p = q
			if p != nil && !(p.Mark&FOLL != 0) {
				goto loop
			}
			return
		}

		if q != nil {
			p.Mark |= FOLL
			p = q
			if !(p.Mark&FOLL != 0) {
				goto loop
			}
		}
	}

	if p.Mark&FOLL != 0 {
		i = 0
		q = p
		for ; i < 4; (func() { i++; q = q.Link })() {
			if q == *last || (q.Mark&NOSCHED != 0) {
				break
			}
			b = 0 /* set */
			a = int(q.As)
			if a == ANOP {
				i--
				continue
			}

			if a == ABR || a == ARETURN || a == ARFI || a == ARFCI || a == ARFID || a == AHRFID {
				goto copy
			}
			if !(q.Pcond != nil) || (q.Pcond.Mark&FOLL != 0) {
				continue
			}
			b = relinv(a)
			if !(b != 0) {
				continue
			}

		copy:
			for {
				r = ctxt.Arch.Prg()
				*r = *p
				if !(r.Mark&FOLL != 0) {
					fmt.Printf("cant happen 1\n")
				}
				r.Mark |= FOLL
				if p != q {
					p = p.Link
					(*last).Link = r
					*last = r
					continue
				}

				(*last).Link = r
				*last = r
				if a == ABR || a == ARETURN || a == ARFI || a == ARFCI || a == ARFID || a == AHRFID {
					return
				}
				r.As = int16(b)
				r.Pcond = p.Link
				r.Link = p.Pcond
				if !(r.Link.Mark&FOLL != 0) {
					xfol(ctxt, r.Link, last)
				}
				if !(r.Pcond.Mark&FOLL != 0) {
					fmt.Printf("cant happen 2\n")
				}
				return
			}
		}

		a = ABR
		q = ctxt.Arch.Prg()
		q.As = int16(a)
		q.Lineno = p.Lineno
		q.To.Type_ = D_BRANCH
		q.To.Offset = p.Pc
//.........这里部分代码省略.........
开发者ID:rsc,项目名称:tmp,代码行数:101,代码来源:obj9.go

示例6: addstacksplit


//.........这里部分代码省略.........
			AFNEGCC,
			AFNMADD,
			AFNMADDCC,
			AFNMSUB,
			AFNMSUBCC,
			AFRSP,
			AFRSPCC,
			AFSUB,
			AFSUBCC:
			q = p

			p.Mark |= FLOAT
			continue

		case ABL,
			ABCL,
			ADUFFZERO,
			ADUFFCOPY:
			cursym.Text.Mark &^= LEAF
			fallthrough

		case ABC,
			ABEQ,
			ABGE,
			ABGT,
			ABLE,
			ABLT,
			ABNE,
			ABR,
			ABVC,
			ABVS:
			p.Mark |= BRANCH
			q = p
			q1 = p.Pcond
			if q1 != nil {
				for q1.As == ANOP {
					q1 = q1.Link
					p.Pcond = q1
				}

				if !(q1.Mark&LEAF != 0) {
					q1.Mark |= LABEL
				}
			} else {

				p.Mark |= LABEL
			}
			q1 = p.Link
			if q1 != nil {
				q1.Mark |= LABEL
			}
			continue

		case AFCMPO,
			AFCMPU:
			q = p
			p.Mark |= FCMP | FLOAT
			continue

		case ARETURN:
			q = p
			if p.Link != nil {
				p.Link.Mark |= LABEL
			}
			continue
开发者ID:rsc,项目名称:tmp,代码行数:66,代码来源:obj9.go

示例7: xfol

func xfol(ctxt *liblink.Link, p *liblink.Prog, last **liblink.Prog) {
	var q *liblink.Prog
	var i int
	var a int

loop:
	if p == nil {
		return
	}
	if p.As == AJMP {
		q = p.Pcond
		if q != nil && q.As != ATEXT {
			/* mark instruction as done and continue layout at target of jump */
			p.Mark = 1

			p = q
			if p.Mark == 0 {
				goto loop
			}
		}
	}

	if p.Mark != 0 {
		/*
		 * p goes here, but already used it elsewhere.
		 * copy up to 4 instructions or else branch to other copy.
		 */
		i = 0
		q = p
		for ; i < 4; (func() { i++; q = q.Link })() {

			if q == nil {
				break
			}
			if q == *last {
				break
			}
			a = int(q.As)
			if a == ANOP {
				i--
				continue
			}

			if nofollow(a) != 0 || pushpop(a) != 0 {
				break // NOTE(rsc): arm does goto copy
			}
			if q.Pcond == nil || q.Pcond.Mark != 0 {
				continue
			}
			if a == ACALL || a == ALOOP {
				continue
			}
			for {
				if p.As == ANOP {
					p = p.Link
					continue
				}

				q = liblink.Copyp(ctxt, p)
				p = p.Link
				q.Mark = 1
				(*last).Link = q
				*last = q
				if int(q.As) != a || q.Pcond == nil || q.Pcond.Mark != 0 {
					continue
				}

				q.As = int16(relinv(int(q.As)))
				p = q.Pcond
				q.Pcond = q.Link
				q.Link = p
				xfol(ctxt, q.Link, last)
				p = q.Link
				if p.Mark != 0 {
					return
				}
				goto loop
				/* */
			}
		}
		q = ctxt.Arch.Prg()
		q.As = AJMP
		q.Lineno = p.Lineno
		q.To.Type_ = D_BRANCH
		q.To.Offset = p.Pc
		q.Pcond = p
		p = q
	}

	/* emit p */
	p.Mark = 1

	(*last).Link = p
	*last = p
	a = int(p.As)

	/* continue loop with what comes after p */
	if nofollow(a) != 0 {

		return
//.........这里部分代码省略.........
开发者ID:rsc,项目名称:tmp,代码行数:101,代码来源:obj8.go

示例8: stacksplit

// Append code to p to check for stack split.
// Appends to (does not overwrite) p.
// Assumes g is in CX.
// Returns last new instruction.
// On return, *jmpok is the instruction that should jump
// to the stack frame allocation if no split is needed.
func stacksplit(ctxt *liblink.Link, p *liblink.Prog, framesize int32, noctxt int, jmpok **liblink.Prog) *liblink.Prog {

	var q *liblink.Prog
	var q1 *liblink.Prog

	if ctxt.Debugstack != 0 {
		// 8l -K means check not only for stack
		// overflow but stack underflow.
		// On underflow, INT 3 (breakpoint).
		// Underflow itself is rare but this also
		// catches out-of-sync stack guard info.
		p = liblink.Appendp(ctxt, p)

		p.As = ACMPL
		p.From.Type_ = D_INDIR + D_CX
		p.From.Offset = 4
		p.To.Type_ = D_SP

		p = liblink.Appendp(ctxt, p)
		p.As = AJCC
		p.To.Type_ = D_BRANCH
		p.To.Offset = 4
		q1 = p

		p = liblink.Appendp(ctxt, p)
		p.As = AINT
		p.From.Type_ = D_CONST
		p.From.Offset = 3

		p = liblink.Appendp(ctxt, p)
		p.As = ANOP
		q1.Pcond = p
	}

	q1 = nil

	if framesize <= liblink.StackSmall {
		// small stack: SP <= stackguard
		//	CMPL SP, stackguard
		p = liblink.Appendp(ctxt, p)

		p.As = ACMPL
		p.From.Type_ = D_SP
		p.To.Type_ = D_INDIR + D_CX
		p.To.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0
		if ctxt.Cursym.Cfunc != 0 {
			p.To.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1
		}
	} else if framesize <= liblink.StackBig {
		// large stack: SP-framesize <= stackguard-StackSmall
		//	LEAL -(framesize-StackSmall)(SP), AX
		//	CMPL AX, stackguard
		p = liblink.Appendp(ctxt, p)

		p.As = ALEAL
		p.From.Type_ = D_INDIR + D_SP
		p.From.Offset = -(int64(framesize) - liblink.StackSmall)
		p.To.Type_ = D_AX

		p = liblink.Appendp(ctxt, p)
		p.As = ACMPL
		p.From.Type_ = D_AX
		p.To.Type_ = D_INDIR + D_CX
		p.To.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0
		if ctxt.Cursym.Cfunc != 0 {
			p.To.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1
		}
	} else {

		// Such a large stack we need to protect against wraparound
		// if SP is close to zero.
		//	SP-stackguard+StackGuard <= framesize + (StackGuard-StackSmall)
		// The +StackGuard on both sides is required to keep the left side positive:
		// SP is allowed to be slightly below stackguard. See stack.h.
		//
		// Preemption sets stackguard to StackPreempt, a very large value.
		// That breaks the math above, so we have to check for that explicitly.
		//	MOVL	stackguard, CX
		//	CMPL	CX, $StackPreempt
		//	JEQ	label-of-call-to-morestack
		//	LEAL	StackGuard(SP), AX
		//	SUBL	stackguard, AX
		//	CMPL	AX, $(framesize+(StackGuard-StackSmall))
		p = liblink.Appendp(ctxt, p)

		p.As = AMOVL
		p.From.Type_ = D_INDIR + D_CX
		p.From.Offset = 0
		p.From.Offset = 2 * int64(ctxt.Arch.Ptrsize) // G.stackguard0
		if ctxt.Cursym.Cfunc != 0 {
			p.From.Offset = 3 * int64(ctxt.Arch.Ptrsize) // G.stackguard1
		}
		p.To.Type_ = D_SI

//.........这里部分代码省略.........
开发者ID:rsc,项目名称:tmp,代码行数:101,代码来源:obj8.go

示例9: addstacksplit

func addstacksplit(ctxt *liblink.Link, cursym *liblink.LSym) {
	var p *liblink.Prog
	var q *liblink.Prog
	var p1 *liblink.Prog
	var p2 *liblink.Prog
	var autoffset int32
	var deltasp int32
	var a int

	if ctxt.Symmorestack[0] == nil {
		ctxt.Symmorestack[0] = liblink.Linklookup(ctxt, "runtime.morestack", 0)
		ctxt.Symmorestack[1] = liblink.Linklookup(ctxt, "runtime.morestack_noctxt", 0)
	}

	if ctxt.Headtype == liblink.Hplan9 && ctxt.Plan9privates == nil {
		ctxt.Plan9privates = liblink.Linklookup(ctxt, "_privates", 0)
	}

	ctxt.Cursym = cursym

	if cursym.Text == nil || cursym.Text.Link == nil {
		return
	}

	p = cursym.Text
	autoffset = int32(p.To.Offset)
	if autoffset < 0 {
		autoffset = 0
	}

	cursym.Locals = autoffset
	cursym.Args = p.To.Offset2

	q = nil

	if !(p.From.Scale&liblink.NOSPLIT != 0) || (p.From.Scale&liblink.WRAPPER != 0) {
		p = liblink.Appendp(ctxt, p)
		p = load_g_cx(ctxt, p) // load g into CX
	}

	if !(cursym.Text.From.Scale&liblink.NOSPLIT != 0) {
		p = stacksplit(ctxt, p, autoffset, bool2int(!(cursym.Text.From.Scale&liblink.NEEDCTXT != 0)), &q) // emit split check
	}

	if autoffset != 0 {

		p = liblink.Appendp(ctxt, p)
		p.As = AADJSP
		p.From.Type_ = D_CONST
		p.From.Offset = int64(autoffset)
		p.Spadj = autoffset
	} else {

		// zero-byte stack adjustment.
		// Insert a fake non-zero adjustment so that stkcheck can
		// recognize the end of the stack-splitting prolog.
		p = liblink.Appendp(ctxt, p)

		p.As = ANOP
		p.Spadj = int32(-ctxt.Arch.Ptrsize)
		p = liblink.Appendp(ctxt, p)
		p.As = ANOP
		p.Spadj = int32(ctxt.Arch.Ptrsize)
	}

	if q != nil {
		q.Pcond = p
	}
	deltasp = autoffset

	if cursym.Text.From.Scale&liblink.WRAPPER != 0 {
		// if(g->panic != nil && g->panic->argp == FP) g->panic->argp = bottom-of-frame
		//
		//	MOVL g_panic(CX), BX
		//	TESTL BX, BX
		//	JEQ end
		//	LEAL (autoffset+4)(SP), DI
		//	CMPL panic_argp(BX), DI
		//	JNE end
		//	MOVL SP, panic_argp(BX)
		// end:
		//	NOP
		//
		// 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.

		p = liblink.Appendp(ctxt, p)

		p.As = AMOVL
		p.From.Type_ = D_INDIR + D_CX
		p.From.Offset = 4 * int64(ctxt.Arch.Ptrsize) // G.panic
		p.To.Type_ = D_BX

		p = liblink.Appendp(ctxt, p)
		p.As = ATESTL
		p.From.Type_ = D_BX
		p.To.Type_ = D_BX

		p = liblink.Appendp(ctxt, p)
		p.As = AJEQ
//.........这里部分代码省略.........
开发者ID:rsc,项目名称:tmp,代码行数:101,代码来源:obj8.go

示例10: addstacksplit

func addstacksplit(ctxt *liblink.Link, cursym *liblink.LSym) {
	var p *liblink.Prog
	var q *liblink.Prog
	var p1 *liblink.Prog
	var p2 *liblink.Prog
	var autoffset int32
	var deltasp int32
	var a int
	var pcsize int
	var textstksiz int64
	var textarg int64

	if ctxt.Tlsg == nil {
		ctxt.Tlsg = liblink.Linklookup(ctxt, "runtime.tlsg", 0)
	}
	if ctxt.Symmorestack[0] == nil {
		ctxt.Symmorestack[0] = liblink.Linklookup(ctxt, "runtime.morestack", 0)
		ctxt.Symmorestack[1] = liblink.Linklookup(ctxt, "runtime.morestack_noctxt", 0)
	}

	if ctxt.Headtype == liblink.Hplan9 && ctxt.Plan9privates == nil {
		ctxt.Plan9privates = liblink.Linklookup(ctxt, "_privates", 0)
	}

	ctxt.Cursym = cursym

	if cursym.Text == nil || cursym.Text.Link == nil {
		return
	}

	p = cursym.Text
	parsetextconst(p.To.Offset, &textstksiz, &textarg)
	autoffset = int32(textstksiz)
	if autoffset < 0 {
		autoffset = 0
	}

	cursym.Args = int32(p.To.Offset >> 32)
	cursym.Locals = int32(textstksiz)

	if autoffset < liblink.StackSmall && !(p.From.Scale&liblink.NOSPLIT != 0) {
		for q = p; q != nil; q = q.Link {
			if q.As == ACALL {
				goto noleaf
			}
			if (q.As == ADUFFCOPY || q.As == ADUFFZERO) && autoffset >= liblink.StackSmall-8 {
				goto noleaf
			}
		}

		p.From.Scale |= liblink.NOSPLIT
	noleaf:
	}

	q = nil
	if !(p.From.Scale&liblink.NOSPLIT != 0) || (p.From.Scale&liblink.WRAPPER != 0) {
		p = liblink.Appendp(ctxt, p)
		p = load_g_cx(ctxt, p) // load g into CX
	}

	if !(cursym.Text.From.Scale&liblink.NOSPLIT != 0) {
		p = stacksplit(ctxt, p, autoffset, int32(textarg), bool2int(!(cursym.Text.From.Scale&liblink.NEEDCTXT != 0)), &q) // emit split check
	}

	if autoffset != 0 {

		if autoffset%int32(ctxt.Arch.Regsize) != 0 {
			ctxt.Diag("unaligned stack size %d", autoffset)
		}
		p = liblink.Appendp(ctxt, p)
		p.As = AADJSP
		p.From.Type_ = D_CONST
		p.From.Offset = int64(autoffset)
		p.Spadj = autoffset
	} else {

		// zero-byte stack adjustment.
		// Insert a fake non-zero adjustment so that stkcheck can
		// recognize the end of the stack-splitting prolog.
		p = liblink.Appendp(ctxt, p)

		p.As = ANOP
		p.Spadj = int32(-ctxt.Arch.Ptrsize)
		p = liblink.Appendp(ctxt, p)
		p.As = ANOP
		p.Spadj = int32(ctxt.Arch.Ptrsize)
	}

	if q != nil {
		q.Pcond = p
	}
	deltasp = autoffset

	if cursym.Text.From.Scale&liblink.WRAPPER != 0 {
		// if(g->panic != nil && g->panic->argp == FP) g->panic->argp = bottom-of-frame
		//
		//	MOVQ g_panic(CX), BX
		//	TESTQ BX, BX
		//	JEQ end
		//	LEAQ (autoffset+8)(SP), DI
//.........这里部分代码省略.........
开发者ID:rsc,项目名称:tmp,代码行数:101,代码来源:obj6.go


注:本文中的rsc/io/tmp/slowgc/liblink.Prog.Pcond方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。