|
|
In the following example function, there is one entry point $$foo. A
frame of 64 bytes is allocated, and there is an instruction that will cause a
trap to be taken. Notice that this is a millicode routine, which uses
non-standard entry/exit sequences. Please read through the assembler manual and
familiarize yourself with assembler directives before reading the example.
;-----------------------------------------------------------------
;; Control does not start here. This is not the entry point to the
;; example. See below for entry point $$foo.
;; Note that callinfo, tells that this is a millicode region, and
;; that stack has gr3 stored into it.
;; First Unwind region, Stack has a 64 byte frame.
.PROC
.CALLINFO millicode, entry_gr=3, frame=60
r3_zero_trap
ldwm -64(sp),r3
.PROCEND
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This not the entry point. Control falls through here from the
;; region defined above. The only change here, is that the stack
;; has been killed.
;; This is communicated by a callinfo without any frame
;; information.
;; Second Unwind region. Stack is empty.
.PROC
.CALLINFO millicode
region_two
be 0(sr0,r31)
addito,= 0,r0,r0
.EXIT
.PROCEND
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;-------------------MILLICODE ENTRY POINT, $$foo
;; Control starts here. The callinfo tells that the stack has gr3
;; in it.
;; By default this means that the stack has been bumped up by 64
;; bytes.
.PROC
.CALLINFO millicode, entry_gr=3, frame=60
.ENTRY
$$foo
;; Store r3 on stack.
stwm r3,64(sp)
;;
;; Assume a benign body for this routine, i.e neither the stack,
;; nor RP, DP get changed.
;;
;; Trap if r3 is zero.
comb,= 0,r3,r3_zero_trap
nop
;; Restore r3 and exit.
be 0(sr0,r31)
ldwm -64(sp),r3
.EXIT
.PROCEND
;;----------------------------------------------------------------
This example illustrates:
Non-standard entry-exit sequences, notice .ENTER and
.LEAVE are not used.
A need to create multiple unwind regions to maintain
unwindability.
Control enters at $$f00. The non-standard entry code bumps the stack up
by 64 bytes and stores gr3 in the stack. The .CALLINFO indicates that
that there is a 64 byte stack frame. If the conditional branch (COMB) is not
taken, then gr3 is restored from the stack and the stack is decremented
properly. Note that in this region the stack always has a frame. If the
condition succeeds, then we branch to r3_zero_trap. This region is
physically above the entry point and is also marked as a region with a 64 byte
frame. The stack is decremented in this region, and control flows into the
third region. Note that in this region, the stack will be empty. To indicate
this change to the state of the stack, another .CALLINFO directive is
used. When the ADDITO instruction traps, the trap handler can successfully
complete a stack trace or resume execution in the context of a procedure
somewhere below the current stack pointer.
|