To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

entrypoints.rs 14.7 KB
Newer Older
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
1
// Copyright 2017 The Australian National University
qinsoon's avatar
qinsoon committed
2
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
3
4
5
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
qinsoon's avatar
qinsoon committed
6
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
7
//     http://www.apache.org/licenses/LICENSE-2.0
qinsoon's avatar
qinsoon committed
8
//
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
9
10
11
12
13
14
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

15
16
17
18
19
use runtime::ValueLocation;

use ast::ir;
use ast::ir::*;
use ast::ptr::*;
qinsoon's avatar
qinsoon committed
20
use ast::types::*;
21
22
23
24
25
26
27
use compiler::backend::RegGroup;

use std::sync::RwLock;

pub type EntryFuncSig = MuFuncSig;

pub struct RuntimeEntrypoint {
28
29
    pub sig: P<MuFuncSig>,
    pub aot: ValueLocation,
30
    pub jit: RwLock<Option<ValueLocation>>
31
32
33
}

lazy_static! {
qinsoon's avatar
qinsoon committed
34
35
    // impl: runtime_x64_macos.c
    // decl: thread.rs
36
37
38
    pub static ref GET_THREAD_LOCAL : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
qinsoon's avatar
qinsoon committed
39
            ret_tys: vec![ADDRESS_TYPE.clone()],
40
41
            arg_tys: vec![]
        }),
qinsoon's avatar
qinsoon committed
42
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_get_thread_local")),
43
44
        jit: RwLock::new(None),
    };
45
46
47
48
49
50
51
52
53
54
55
56

    // impl: runtime_x64_sysv.c
    // decl: thread.rs
    pub static ref SET_RETVAL : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
            arg_tys: vec![UINT32_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_set_retval")),
        jit: RwLock::new(None)
    };
qinsoon's avatar
qinsoon committed
57

qinsoon's avatar
qinsoon committed
58
    // impl: runtime_asm_ARCH_OS.s
qinsoon's avatar
qinsoon committed
59
    // decl: thread.rs
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
60
    pub static ref THREAD_EXIT : RuntimeEntrypoint = RuntimeEntrypoint {
61
62
63
        sig: P(MuFuncSig{
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
qinsoon's avatar
qinsoon committed
64
            arg_tys: vec![ADDRESS_TYPE.clone()]
65
        }),
qinsoon's avatar
qinsoon committed
66
        aot: ValueLocation::Relocatable(RegGroup::GPR,
67
68
69
                                        String::from("muentry_thread_exit")),
        jit: RwLock::new(None),
    };
70

71
    // impl/decl: thread.rs
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
72
    pub static ref NEW_STACK: RuntimeEntrypoint = RuntimeEntrypoint {
73
74
75
76
77
78
        sig: P(MuFuncSig{
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![STACKREF_TYPE.clone()],
            arg_tys: vec![ADDRESS_TYPE.clone(), ADDRESS_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_new_stack")),
79
80
        jit: RwLock::new(None),
    };
81

Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
82
83
84
85
86
87
88
89
90
91
92
    // impl/decl: thread.rs
    pub static ref KILL_STACK: RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig{
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
            arg_tys: vec![STACKREF_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_kill_stack")),
        jit: RwLock::new(None),
    };

93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
    // impl/decl: thread.rs
    pub static ref NEW_THREAD_NORMAL: RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig{
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            arg_tys: vec![STACKREF_TYPE.clone(), REF_VOID_TYPE.clone()],
            ret_tys: vec![THREADREF_TYPE.clone()],
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_new_thread_normal")),
        jit: RwLock::new(None),
    };


    // impl/decl: thread.rs
    pub static ref NEW_THREAD_EXCEPTIONAL: RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig{
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            arg_tys: vec![STACKREF_TYPE.clone(), REF_VOID_TYPE.clone(), REF_VOID_TYPE.clone()],
            ret_tys: vec![THREADREF_TYPE.clone()],
        }),
Isaac Oscar Gariano's avatar
Isaac Oscar Gariano committed
112
113
        aot: ValueLocation::Relocatable(RegGroup::GPR,
            String::from("muentry_new_thread_exceptional")),
114
115
116
117
        jit: RwLock::new(None),
    };


118
119
120
121
122
123
124
125
126
127
    // impl/decl: gc/lib.rs
    pub static ref ALLOC_FAST : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![ADDRESS_TYPE.clone()],
            arg_tys: vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_alloc_fast")),
        jit: RwLock::new(None)
    };
qinsoon's avatar
qinsoon committed
128

qinsoon's avatar
qinsoon committed
129
    // impl/decl: gc/lib.rs
130
131
132
    pub static ref ALLOC_SLOW : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
qinsoon's avatar
qinsoon committed
133
            ret_tys: vec![ADDRESS_TYPE.clone()],
qinsoon's avatar
qinsoon committed
134
            arg_tys: vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone()]
135
        }),
qinsoon's avatar
qinsoon committed
136
137
138
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_alloc_slow")),
        jit: RwLock::new(None),
    };
qinsoon's avatar
qinsoon committed
139
140
141
142
143
144
145
146
147
148
149

    // impl/decl: gc/lib.rs
    pub static ref ALLOC_LARGE : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![ADDRESS_TYPE.clone()],
            arg_tys: vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_alloc_large")),
        jit: RwLock::new(None)
    };
150
151
152
153
154
155
156
157
158
159
160

    // impl/decl: gc/lib.rs
    pub static ref INIT_OBJ : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
            arg_tys: vec![ADDRESS_TYPE.clone(), ADDRESS_TYPE.clone(), UINT64_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_init_object")),
        jit: RwLock::new(None)
    };
qinsoon's avatar
qinsoon committed
161
162
163
164
165
166

    // impl/decl: gc/lib.rs
    pub static ref INIT_HYBRID : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
qinsoon's avatar
qinsoon committed
167
168
            arg_tys: vec![ADDRESS_TYPE.clone(), ADDRESS_TYPE.clone(),
                          UINT64_TYPE.clone(), UINT64_TYPE.clone()]
qinsoon's avatar
qinsoon committed
169
170
171
172
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_init_hybrid")),
        jit: RwLock::new(None)
    };
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194

    // impl/decl: gc/lib.rs
    pub static ref PIN_OBJECT : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![ADDRESS_TYPE.clone()],
            arg_tys: vec![ADDRESS_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_pin_object")),
        jit: RwLock::new(None)
    };

    // impl/decl: gc/lib.rs
    pub static ref UNPIN_OBJECT : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
            arg_tys: vec![ADDRESS_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_unpin_object")),
        jit: RwLock::new(None)
    };
qinsoon's avatar
qinsoon committed
195

qinsoon's avatar
qinsoon committed
196
197
198
199
200
    // impl/decl: exception.rs
    pub static ref THROW_EXCEPTION : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
qinsoon's avatar
qinsoon committed
201
            arg_tys: vec![ADDRESS_TYPE.clone()]
qinsoon's avatar
qinsoon committed
202
203
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_throw_exception")),
204
205
        jit: RwLock::new(None),
    };
qinsoon's avatar
qinsoon committed
206

207
208
209
210
211
212
213
214
215
216
217
218
    pub static ref THROW_EXCEPTION_INTERNAL: RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
            arg_tys: vec![ADDRESS_TYPE.clone(), ADDRESS_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("throw_exception_internal")),
        jit: RwLock::new(None)
    };
}

lazy_static!{
qinsoon's avatar
qinsoon committed
219
    // impl/decl: math.rs
220
    pub static ref FREM32 : RuntimeEntrypoint = RuntimeEntrypoint {
qinsoon's avatar
qinsoon committed
221
222
        sig: P(MuFuncSig{
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
223
224
            ret_tys: vec![FLOAT_TYPE.clone()],
            arg_tys: vec![FLOAT_TYPE.clone(), FLOAT_TYPE.clone()]
qinsoon's avatar
qinsoon committed
225
        }),
226
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_frem32")),
227
228
229
        jit: RwLock::new(None)
    };

230
231
    // impl/decl: math.rs
    pub static ref FREM64 : RuntimeEntrypoint = RuntimeEntrypoint {
232
233
        sig: P(MuFuncSig{
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
qinsoon's avatar
qinsoon committed
234
235
            ret_tys: vec![DOUBLE_TYPE.clone()],
            arg_tys: vec![DOUBLE_TYPE.clone(), DOUBLE_TYPE.clone()]
236
        }),
237
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_frem64")),
qinsoon's avatar
qinsoon committed
238
239
        jit: RwLock::new(None)
    };
240

241
242
243
    pub static ref UDIV_U128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
244
245
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 2]
246
247
248
249
250
251
252
253
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_udiv_u128")),
        jit: RwLock::new(None)
    };

    pub static ref SDIV_I128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
254
255
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 2]
256
257
258
259
260
261
262
263
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_sdiv_i128")),
        jit: RwLock::new(None)
    };

    pub static ref UREM_U128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
264
265
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 2]
266
267
268
269
270
271
272
273
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_urem_u128")),
        jit: RwLock::new(None)
    };

    pub static ref SREM_I128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
274
275
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 2]
276
277
278
279
280
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_srem_i128")),
        jit: RwLock::new(None)
    };

281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
    pub static ref FPTOUI_DOUBLE_U128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![DOUBLE_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_fptoui_double_u128")),
        jit: RwLock::new(None)
    };

    pub static ref FPTOSI_DOUBLE_I128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![DOUBLE_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_fptosi_double_i128")),
        jit: RwLock::new(None)
    };
    pub static ref UITOFP_U128_DOUBLE : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![DOUBLE_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_uitofp_u128_double")),
        jit: RwLock::new(None)
    };

    pub static ref SITOFP_I128_DOUBLE : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![DOUBLE_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_sitofp_i128_double")),
        jit: RwLock::new(None)
    };

    // Conversion to/from int<128> from/to float
        pub static ref FPTOUI_FLOAT_U128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![FLOAT_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_fptoui_float_u128")),
        jit: RwLock::new(None)
    };

    pub static ref FPTOSI_FLOAT_I128 : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![UINT128_TYPE.clone(); 1],
            arg_tys: vec![FLOAT_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_fptosi_float_i128")),
        jit: RwLock::new(None)
    };
    pub static ref UITOFP_U128_FLOAT : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![FLOAT_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_uitofp_u128_float")),
        jit: RwLock::new(None)
    };

    pub static ref SITOFP_I128_FLOAT : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![FLOAT_TYPE.clone(); 1],
            arg_tys: vec![UINT128_TYPE.clone(); 1]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_sitofp_i128_float")),
        jit: RwLock::new(None)
    };

360
361
362
363
364
365
366
367
368
369
    // impl/decl: mod.rs
    pub static ref PRINT_HEX : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
            arg_tys: vec![UINT64_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_print_hex")),
        jit: RwLock::new(None)
    };
370
371
372
373
374
375
376
377
378
379
380

    // impl/decl: mod.rs
    pub static ref MEM_ZERO : RuntimeEntrypoint = RuntimeEntrypoint {
        sig: P(MuFuncSig {
            hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
            ret_tys: vec![],
            arg_tys: vec![IREF_VOID_TYPE.clone(), UINT64_TYPE.clone()]
        }),
        aot: ValueLocation::Relocatable(RegGroup::GPR, String::from("muentry_mem_zero")),
        jit: RwLock::new(None)
    };
381
}