LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 #include "runtime.h" | 5 #include "runtime.h" |
6 #include "arch_GOARCH.h" | 6 #include "arch_GOARCH.h" |
7 #include "stack.h" | 7 #include "stack.h" |
8 #include "malloc.h" | 8 #include "malloc.h" |
9 #include "textflag.h" | 9 #include "textflag.h" |
10 | 10 |
11 // Code related to defer, panic and recover. | 11 // Code related to defer, panic and recover. |
12 | 12 |
13 // TODO: remove once code is moved to Go | 13 // TODO: remove once code is moved to Go |
14 extern Defer* runtime·newdefer(int32 siz); | 14 extern Defer* runtime·newdefer(int32 siz); |
15 extern runtime·freedefer(Defer *d); | 15 extern runtime·freedefer(Defer *d); |
16 | 16 |
17 uint32 runtime·panicking; | 17 uint32 runtime·panicking; |
18 static Mutex paniclk; | 18 static Mutex paniclk; |
19 | 19 |
20 void | 20 void |
21 runtime·deferproc_m(void) { | 21 runtime·deferproc_m(void) |
| 22 { |
22 int32 siz; | 23 int32 siz; |
23 FuncVal *fn; | 24 FuncVal *fn; |
24 uintptr argp; | 25 uintptr argp; |
25 uintptr callerpc; | 26 uintptr callerpc; |
26 Defer *d; | 27 Defer *d; |
27 | 28 |
28 siz = g->m->scalararg[0]; | 29 siz = g->m->scalararg[0]; |
29 fn = g->m->ptrarg[0]; | 30 fn = g->m->ptrarg[0]; |
30 argp = g->m->scalararg[1]; | 31 argp = g->m->scalararg[1]; |
31 callerpc = g->m->scalararg[2]; | 32 callerpc = g->m->scalararg[2]; |
32 g->m->ptrarg[0] = nil; | 33 g->m->ptrarg[0] = nil; |
33 | 34 |
34 d = runtime·newdefer(siz); | 35 d = runtime·newdefer(siz); |
35 d->fn = fn; | 36 d->fn = fn; |
36 d->pc = callerpc; | 37 d->pc = callerpc; |
37 d->argp = argp; | 38 d->argp = argp; |
38 » runtime·memmove(d->args, (void*)argp, siz); | 39 » runtime·memmove(d+1, (void*)argp, siz); |
39 } | 40 } |
40 | 41 |
41 // Unwind the stack after a deferred function calls recover | 42 // Unwind the stack after a deferred function calls recover |
42 // after a panic. Then arrange to continue running as though | 43 // after a panic. Then arrange to continue running as though |
43 // the caller of the deferred function returned normally. | 44 // the caller of the deferred function returned normally. |
44 void | 45 void |
45 runtime·recovery_m(G *gp) | 46 runtime·recovery_m(G *gp) |
46 { | 47 { |
47 void *argp; | 48 void *argp; |
48 uintptr pc; | 49 uintptr pc; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 return false; | 187 return false; |
187 status = runtime·readgstatus(gp); | 188 status = runtime·readgstatus(gp); |
188 if((status&~Gscan) != Grunning || gp->syscallsp != 0) | 189 if((status&~Gscan) != Grunning || gp->syscallsp != 0) |
189 return false; | 190 return false; |
190 #ifdef GOOS_windows | 191 #ifdef GOOS_windows |
191 if(m->libcallsp != 0) | 192 if(m->libcallsp != 0) |
192 return false; | 193 return false; |
193 #endif | 194 #endif |
194 return true; | 195 return true; |
195 } | 196 } |
LEFT | RIGHT |