Home | History | Annotate | Download | only in runtime
      1 // Copyright 2014 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 // +build ppc64 ppc64le
      6 
      7 package runtime
      8 
      9 import "unsafe"
     10 
     11 // adjust Gobuf as if it executed a call to fn with context ctxt
     12 // and then did an immediate Gosave.
     13 func gostartcall(buf *gobuf, fn, ctxt unsafe.Pointer) {
     14 	if buf.lr != 0 {
     15 		throw("invalid use of gostartcall")
     16 	}
     17 	buf.lr = buf.pc
     18 	buf.pc = uintptr(fn)
     19 	buf.ctxt = ctxt
     20 }
     21 
     22 // Called to rewind context saved during morestack back to beginning of function.
     23 // To help us, the linker emits a jmp back to the beginning right after the
     24 // call to morestack. We just have to decode and apply that jump.
     25 func rewindmorestack(buf *gobuf) {
     26 	var inst uint32
     27 	if buf.pc&3 == 0 && buf.pc != 0 {
     28 		inst = *(*uint32)(unsafe.Pointer(buf.pc))
     29 		if inst>>26 == 18 && inst&3 == 0 {
     30 			//print("runtime: rewind pc=", hex(buf.pc), " to pc=", hex(uintptr(buf.pc + int32(inst<<6)>>6)), "\n");
     31 			buf.pc += uintptr(int32(inst<<6) >> 6)
     32 			return
     33 		}
     34 	}
     35 	print("runtime: pc=", hex(buf.pc), " ", hex(inst), "\n")
     36 	throw("runtime: misuse of rewindmorestack")
     37 }
     38