2
typedef void (*fn_t) (void *);
8
struct defer_stack *prev;
9
struct defer_stack *next;
12
// FIXME: invisible for the GC.
13
static fibril_local defer_stack *dstack = NULL;
4
void __go_panic(struct __go_empty_interface arg);
5
void __go_defer(void *frame, void (*pfn) (void *), void *arg);
6
void __go_undefer(void *frame);
7
bool __go_set_defer_retaddr(void *retaddr);
8
struct __go_empty_interface __go_recover();
9
struct __go_empty_interface __go_deferred_recover();
10
bool __go_can_recover(const void* retaddr);
11
void *__go_return_address(intgo blah);
12
void __go_check_defer(void *frame);
13
void __go_runtime_error (int32 i);
17
16
__go_panic(struct __go_empty_interface arg)
23
22
__go_defer(void *frame, void (*pfn) (void *), void *arg)
26
dstack = gocore_mallocgc(sizeof(struct defer_stack));
28
if (dstack->next == NULL) {
29
dstack->next = gocore_mallocgc(sizeof(struct defer_stack));
30
dstack->next->prev = dstack;
32
dstack = dstack->next;
35
dstack->frame = frame;
24
gocore_defer(frame, void (*pfn) (void *), void *arg);
39
28
__go_undefer(void *frame)
41
while (dstack->frame == frame) {
42
dstack = dstack->prev;
43
dstack->next->fn(dstack->next->arg);
30
gocore_undefer(frame);
47
33
/* This function is called to record the address to which the deferred
114
100
case SLICE_INDEX_OUT_OF_BOUNDS:
115
101
case ARRAY_INDEX_OUT_OF_BOUNDS:
116
102
case STRING_INDEX_OUT_OF_BOUNDS:
117
runtime_panic("index out of range");
103
gocore_panic("index out of range");
119
105
case SLICE_SLICE_OUT_OF_BOUNDS:
120
106
case ARRAY_SLICE_OUT_OF_BOUNDS:
121
107
case STRING_SLICE_OUT_OF_BOUNDS:
122
runtime_panic("slice bounds out of range");
108
gocore_panic("slice bounds out of range");
124
110
case NIL_DEREFERENCE:
125
runtime_panic("nil pointer dereference");
111
gocore_panic("nil pointer dereference");
127
113
case MAKE_SLICE_OUT_OF_BOUNDS:
128
runtime_panic("make slice len or cap out of range");
114
gocore_panic("make slice len or cap out of range");
130
116
case MAKE_MAP_OUT_OF_BOUNDS:
131
runtime_panic("make map len out of range");
117
gocore_panic("make map len out of range");
133
119
case MAKE_CHAN_OUT_OF_BOUNDS:
134
runtime_panic("make chan len out of range");
120
gocore_panic("make chan len out of range");
136
122
case DIVISION_BY_ZERO:
137
runtime_panic("integer divide by zero");
123
gocore_panic("integer divide by zero");
140
runtime_panic("unknown runtime error");
126
gocore_panic("unknown runtime error");