1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
/*
* Copyright (C) 2015-2019 Free Software Foundation, Inc.
*
* This file is part of GNU lightning.
*
* GNU lightning is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* GNU lightning is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* Authors:
* Paulo Cesar Pereira de Andrade
*/
#include <lightning.h>
#include <lightning/jit_private.h>
#if PROTO
# define free_synth_list(node) _free_synth_list(_jit,node)
static jit_node_t *_free_synth_list(jit_state_t*,jit_node_t*);
#define rewind_prolog() _rewind_prolog(_jit)
static void _rewind_prolog(jit_state_t*);
#define rewind_prepare() _rewind_prepare(_jit)
static void _rewind_prepare(jit_state_t*);
#endif
#if CODE
/*
* Implementation
*/
static jit_node_t *
_free_synth_list(jit_state_t *_jit, jit_node_t *node)
{
jit_node_t *next;
next = node->next;
free_node(node);
for (node = next; node && (node->flag & jit_flag_synth); node = next) {
next = node->next;
free_node(node);
}
return (next);
}
static void
_rewind_prolog(jit_state_t *_jit)
{
jit_node_t *node;
jit_node_t *next;
_jitc->function->self.size = stack_framesize;
#if __arm__
assert(jit_cpu.abi);
_jitc->function->self.size += 64;
#endif
#if __mips__ && NEW_ABI
/* Only add extra stack space if there are varargs
* arguments in registers. */
assert(jit_arg_reg_p(_jitc->function->self.argi));
_jitc->function->self.size += 64;
#endif
_jitc->function->self.argi =
_jitc->function->self.argf = _jitc->function->self.argn = 0;
_jitc->tail = _jitc->function->prolog;
node = _jitc->tail->next;
_jitc->tail->next = (jit_node_t *)0;
_jitc->tail->link = (jit_node_t *)0;
for (; node; node = next) {
next = node->next;
switch (node->code) {
case jit_code_arg:
node->next = (jit_node_t *)0;
jit_make_arg(node);
break;
case jit_code_arg_f:
node->next = (jit_node_t *)0;
jit_make_arg_f(node);
break;
case jit_code_arg_d:
node->next = (jit_node_t *)0;
jit_make_arg_d(node);
break;
case jit_code_getarg_c:
jit_getarg_c(node->u.w, node->v.n);
next = free_synth_list(node);
break;
case jit_code_getarg_uc:
jit_getarg_uc(node->u.w, node->v.n);
next = free_synth_list(node);
break;
case jit_code_getarg_s:
jit_getarg_s(node->u.w, node->v.n);
next = free_synth_list(node);
break;
case jit_code_getarg_us:
jit_getarg_us(node->u.w, node->v.n);
next = free_synth_list(node);
break;
case jit_code_getarg_i:
jit_getarg_i(node->u.w, node->v.n);
next = free_synth_list(node);
break;
case jit_code_getarg_f:
jit_getarg_f(node->u.w, node->v.n);
next = free_synth_list(node);
break;
case jit_code_getarg_d:
jit_getarg_d(node->u.w, node->v.n);
next = free_synth_list(node);
break;
case jit_code_putargr:
jit_putargr(node->u.w, node->v.n);
next = free_synth_list(node);
break;
case jit_code_putargi:
jit_putargi(node->u.w, node->v.n);
next = free_synth_list(node);
break;
case jit_code_putargr_f:
jit_putargr_f(node->u.w, node->v.n);
next = free_synth_list(node);
break;
case jit_code_putargi_f:
jit_putargi_f(node->u.f, node->v.n);
next = free_synth_list(node);
break;
case jit_code_putargr_d:
jit_putargr_d(node->u.w, node->v.n);
next = free_synth_list(node);
break;
case jit_code_putargi_d:
jit_putargi_d(node->u.d, node->v.n);
next = free_synth_list(node);
break;
default:
node->next = (jit_node_t *)0;
link_node(node);
break;
}
}
}
static void
_rewind_prepare(jit_state_t *_jit)
{
jit_node_t *node;
jit_node_t *next;
_jitc->function->call.argi =
_jitc->function->call.argf =
_jitc->function->call.size = 0;
_jitc->tail = _jitc->prepare;
node = _jitc->tail->next;
_jitc->tail->next = (jit_node_t *)0;
_jitc->tail->link = (jit_node_t *)0;
for (; node; node = next) {
next = node->next;
switch (node->code) {
case jit_code_pushargr:
jit_pushargr(node->u.w);
next = free_synth_list(node);
break;
case jit_code_pushargi:
jit_pushargi(node->u.w);
next = free_synth_list(node);
break;
case jit_code_pushargr_f:
jit_pushargr_f(node->u.w);
next = free_synth_list(node);
break;
case jit_code_pushargi_f:
jit_pushargi_f(node->u.f);
next = free_synth_list(node);
break;
case jit_code_pushargr_d:
jit_pushargr_d(node->u.w);
next = free_synth_list(node);
break;
case jit_code_pushargi_d:
jit_pushargi_d(node->u.d);
next = free_synth_list(node);
break;
default:
node->next = (jit_node_t *)0;
link_node(node);
break;
}
}
}
#endif
|