1 // Copyright 2013 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 package runtime 6 7 import "unsafe" 8 9 // adjust Gobuf as if it executed a call to fn with context ctxt 10 // and then did an immediate Gosave. 11 func gostartcall(buf *gobuf, fn, ctxt unsafe.Pointer) { 12 if buf.lr != 0 { 13 throw("invalid use of gostartcall") 14 } 15 buf.lr = buf.pc 16 buf.pc = uintptr(fn) 17 buf.ctxt = ctxt 18 } 19 20 // Called to rewind context saved during morestack back to beginning of function. 21 // To help us, the linker emits a jmp back to the beginning right after the 22 // call to morestack. We just have to decode and apply that jump. 23 func rewindmorestack(buf *gobuf) { 24 var inst uint32 25 if buf.pc&3 == 0 && buf.pc != 0 { 26 inst = *(*uint32)(unsafe.Pointer(buf.pc)) 27 if inst>>24 == 0x9a || inst>>24 == 0xea { 28 buf.pc += uintptr(int32(inst<<8)>>6) + 8 29 return 30 } 31 } 32 33 print("runtime: pc=", hex(buf.pc), " ", hex(inst), "\n") 34 throw("runtime: misuse of rewindmorestack") 35 } 36 37 // for testing 38 func usplit(x uint32) (q, r uint32) 39