@@ -61,6 +61,8 @@ nlr_jump:
6161#endif
6262 movq %rdi , %rax # put return value in %rax
6363 movq nlr_top(%rip ), %rdi # get nlr_top into %rdi
64+ test %rdi , %rdi # check for nlr_top being NULL
65+ je .fail # fail if nlr_top is NULL
6466 movq %rax , 8 (%rdi ) # store return value
6567 movq (%rdi ), %rax # load prev nlr_buf
6668 movq %rax , nlr_top(%rip ) # store prev nlr_buf (to unlink list)
@@ -76,10 +78,14 @@ nlr_jump:
7678 xorq %rax , %rax # clear return register
7779 inc %al # increase to make 1, non-local return
7880 ret # return
81+ .fail:
82+ movq %rax , %rdi # put argument back in first-arg register
83+ je nlr_jump_fail # transfer control to nlr_jump_fail
7984#if !(defined(__APPLE__) && defined(__MACH__))
8085 .size nlr_jump, .-nlr_jump
8186#endif
8287
88+ .bss
8389#if !(defined(__APPLE__) && defined(__MACH__))
8490 .local nlr_top
8591#endif
@@ -107,12 +113,21 @@ nlr_push:
107113 xorq %rax , %rax # return 0, normal return
108114 ret # return
109115
110- /* void nlr_jump(rcx=uint val) */
116+ /* void nlr_pop() */
117+ .globl nlr_pop
118+ nlr_pop:
119+ movq nlr_top(%rip ), %rax # get nlr_top into %rax
120+ movq (%rax ), %rax # load prev nlr_buf
121+ movq %rax , nlr_top(%rip ) # store prev nlr_buf (to unlink list)
122+ ret # return
111123
124+ /* void nlr_jump(rcx=uint val) */
112125 .globl nlr_jump
113126nlr_jump:
114127 movq %rcx , %rax # put return value in %rax
115- movq nlr_top(%rip ), %rcx # get nlr_top into %rsi
128+ movq nlr_top(%rip ), %rcx # get nlr_top into %rcx
129+ test %rcx , %rcx # check for nlr_top being NULL
130+ je .fail # fail if nlr_top is NULL
116131 movq %rax , 8 (%rcx ) # store return value
117132 movq (%rcx ), %rax # load prev nlr_buf
118133 movq %rax , nlr_top(%rip ) # store prev nlr_buf (to unlink list)
@@ -130,17 +145,13 @@ nlr_jump:
130145 xorq %rax , %rax # clear return register
131146 inc %al # increase to make 1, non-local return
132147 ret # return
148+ .fail:
149+ movq %rax , %rcx # put argument back in first-arg register
150+ je nlr_jump_fail # transfer control to nlr_jump_fail
133151
152+ .bss
134153 .comm nlr_top,8 ,8
135154
136- /* void nlr_pop() */
137- .globl nlr_pop
138- nlr_pop:
139- movq nlr_top(%rip ), %rax # get nlr_top into %rax
140- movq (%rax ), %rax # load prev nlr_buf
141- movq %rax , nlr_top(%rip ) # store prev nlr_buf (to unlink list)
142- ret # return
143-
144155#endif // !defined(__CYGWIN__)
145156
146157#endif // __x86_64__
0 commit comments