On Sun, Jun 27, 2021 at 7:57 PM xie cui <cuiwei...@gmail.com> wrote: > > a defer call generate some code like: > > v42 (8) = StaticLECall <mem> {AuxCall{runtime.deferprocStack}} [8] v36 v41 > v43 (8) = SelectN <mem> [0] v42 > > Defer v42 → b2 b3 (likely) (8) > > b2: ← b1- > > v48 (7) = Copy <mem> v43 > v49 (7) = VarKill <mem> {.autotmp_0} v48 > v50 (9) = StaticLECall <mem> {AuxCall{runtime.deferreturn}} v49 > v51 (9) = SelectN <mem> [0] v50 > v52 (9) = MakeResult <mem> v51 > > Ret v52 (9) > > b3: ← b1- > > v44 (8) = Copy <mem> v43 > v45 (8) = StaticLECall <mem> {AuxCall{runtime.deferreturn}} v44 > v46 (8) = SelectN <mem> [0] v45 > v47 (8) = MakeResult <mem> v46 > > Ret v47 (8) > > my question is Under what circumstances the deferprocStack return 1? > some useful info: > https://github.com/golang/go/blob/master/src/cmd/compile/internal/amd64/ssa.go#L1287-L1289 > > https://github.com/golang/go/blob/master/src/runtime/panic.go#L290-L328, in > these lines it seems deferprocStack always return 0. i think i have miss some > thing, please help me to find when it get to branch return 1.
deferprocStack will appear to return 1 if the deferred function calls recover. This is implemented by the function "recovery" in runtime/panic.go, which resets the program counter and stack pointer and sets the return register to 1. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUuGBY1doLvmfd6LLpq9Khgg_GdSC-muuCdanboovW52A%40mail.gmail.com.