GitLab will be upgraded on 30 Jan 2023 from 2.00 pm (AEDT) to 3.00 pm (AEDT). During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

entrypoints.rs 23.8 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
use compiler::backend::RegGroup;

23
use std::sync::{Arc, RwLock};
24
25
26
pub type EntryFuncSig = MuFuncSig;

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

32
impl RuntimeEntrypoint {
33
34
35
36
37
    fn new(
        c_name: &str,
        arg_tys: Vec<P<MuType>>,
        ret_tys: Vec<P<MuType>>
    ) -> RuntimeEntrypoint {
38
39
40
41
        RuntimeEntrypoint {
            sig: P(MuFuncSig {
                hdr: MuEntityHeader::unnamed(ir::new_internal_id()),
                ret_tys: ret_tys,
42
                arg_tys: arg_tys
43
            }),
44
45
46
47
48
            aot: ValueLocation::Relocatable(
                RegGroup::GPR,
                Arc::new(c_name.to_string())
            ),
            jit: RwLock::new(None)
49
50
51
        }
    }
}
52

53
// decl: thread/mod.rs
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
54
//#[cfg(not(feature = "realtime"))]
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
lazy_static! {
    // impl: runtime_ARCH_OS.c
    pub static ref GET_THREAD_LOCAL : RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_get_thread_local",
        vec![],
        vec![ADDRESS_TYPE.clone()]);
    pub static ref SET_RETVAL : RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_set_retval",
        vec![UINT32_TYPE.clone()],
        vec![]);
    pub static ref THREAD_EXIT : RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_thread_exit",
        vec![ADDRESS_TYPE.clone()],
        vec![]);

70
    // impl: thread/mod.rs
71
72
73
74
75
76
77
78
79
80
81
82
    pub static ref NEW_STACK: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_new_stack",
        vec![ADDRESS_TYPE.clone(), ADDRESS_TYPE.clone()],
        vec![STACKREF_TYPE.clone()]);
    pub static ref KILL_STACK: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_kill_stack",
        vec![STACKREF_TYPE.clone()],
        vec![]);
    pub static ref SAFECALL_KILL_STACK: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_safecall_kill_stack",
        vec![STACKREF_TYPE.clone()],
        vec![]);
83
84
85
86
87
88
89
90
91
92
93
94
//    pub static ref NEW_THREAD_NORMAL: RuntimeEntrypoint = RuntimeEntrypoint::new(
//        "muentry_new_thread_normal",
//        vec![STACKREF_TYPE.clone(), REF_VOID_TYPE.clone()],
//        vec![THREADREF_TYPE.clone()]);
//    pub static ref NEW_THREAD_EXCEPTIONAL: RuntimeEntrypoint = RuntimeEntrypoint::new(
//        "muentry_new_thread_exceptional",
//        vec![STACKREF_TYPE.clone(), REF_VOID_TYPE.clone(), REF_VOID_TYPE.clone()],
//        vec![THREADREF_TYPE.clone()]);
}

#[cfg(not(feature = "realtime"))]
lazy_static! {
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
    pub static ref NEW_THREAD_NORMAL: RuntimeEntrypoint =
        RuntimeEntrypoint::new(
            "muentry_new_thread_normal",
            vec![STACKREF_TYPE.clone(), REF_VOID_TYPE.clone()],
            vec![THREADREF_TYPE.clone()]
        );
    pub static ref NEW_THREAD_EXCEPTIONAL: RuntimeEntrypoint =
        RuntimeEntrypoint::new(
            "muentry_new_thread_exceptional",
            vec![
                STACKREF_TYPE.clone(),
                REF_VOID_TYPE.clone(),
                REF_VOID_TYPE.clone()
            ],
            vec![THREADREF_TYPE.clone()]
        );
111
}
qinsoon's avatar
qinsoon committed
112

113
114
115
// decl: thread/mod.rs
#[cfg(feature = "realtime")]
lazy_static! {
116
    pub static ref NEW_RT_THREAD_NORMAL: RuntimeEntrypoint = RuntimeEntrypoint::new(
117
        "muentry_new_rt_thread_normal",
118
        vec![ATTRREF_TYPE.clone(), STACKREF_TYPE.clone(), REF_VOID_TYPE.clone()],
119
120
121
        vec![THREADREF_TYPE.clone()]);
    pub static ref NEW_RT_THREAD_EXCEPTIONAL: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_new_rt_thread_exceptional",
122
        vec![ATTRREF_TYPE.clone(), STACKREF_TYPE.clone(), REF_VOID_TYPE.clone(), REF_VOID_TYPE.clone()],
123
        vec![THREADREF_TYPE.clone()]);
124
125
126
127
128
129
130
131
132
133
134
135
    pub static ref THREAD_SET_ATTR: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_thread_set_attr",
        vec![THREADREF_TYPE.clone(), ADDRESS_TYPE.clone()],
        vec![]
    );
    pub static ref THREAD_GET_ATTR: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_thread_get_attr",
        vec![THREADREF_TYPE.clone()],
        vec![ADDRESS_TYPE.clone()]
    );
    pub static ref THREAD_SET_PRIORITY: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_thread_set_priority",
136
137
138
        vec![THREADREF_TYPE.clone(), UINT64_TYPE.clone()],
        vec![]
    );
139
140
    pub static ref THREAD_GET_PRIORITY: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_thread_get_priority",
141
        vec![THREADREF_TYPE.clone()],
142
143
        vec![UINT64_TYPE.clone()]
    );
144
145
    pub static ref THREAD_CLEAR_CPU: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_thread_clear_cpu",
146
147
148
        vec![THREADREF_TYPE.clone(), UINT64_TYPE.clone()],
        vec![]
    );
149
150
    pub static ref THREAD_SET_CPU: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_thread_set_cpu",
151
        vec![THREADREF_TYPE.clone(), UINT64_TYPE.clone()],
152
153
        vec![]
    );
154
155
    pub static ref THREAD_ISSET_CPU: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_thread_isset_cpu",
156
157
158
        vec![THREADREF_TYPE.clone(), UINT64_TYPE.clone()],
        vec![UINT1_TYPE.clone()]
    );
159
160
161
162
163
164
165
166
167
168
169
170
    /// Allocate an EMM region
    pub static ref NEW_REG: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_new_reg",
        vec![UINT64_TYPE.clone()],      // (region_size)
        vec![ADDRESS_TYPE.clone()]      // returns region_ref
    );
    /// Deallocate an EMM region
    pub static ref DELETE_REG: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_delete_reg",
        vec![ADDRESS_TYPE.clone()],     // (region_ref)
        vec![]                          // returns nothing
    );
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
    /// Resets an EMM region
    pub static ref COLLECT_REG: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_collect_reg",
        vec![ADDRESS_TYPE.clone()],     // (region_ref)
        vec![]                          // returns nothing
    );
    /// Returns the regionref for an object, or null if the object is not in any region
    pub static ref FIND_REG: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_find_reg",
        vec![ADDRESS_TYPE.clone()],     // (ref<T>)
        vec![ADDRESS_TYPE.clone()]      // returns regionref
    );
    /// Returns the number of free bytes in an EMM region
    pub static ref GET_FREE_REG: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_get_free_reg",
        vec![ADDRESS_TYPE.clone()],     // (region_ref)
        vec![UINT64_TYPE.clone()]       // returns usize
    );
    /// Returns the number of allocated bytes in an EMM region
    pub static ref GET_ALLOCATED_REG: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_get_allocated_reg",
        vec![ADDRESS_TYPE.clone()],     // (region_ref)
        vec![UINT64_TYPE.clone()]       // returns usize
    );
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
    /// Untraced rAlloc for non-hybrid types
    pub static ref RALLOC: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_ralloc",
        vec![
            ADDRESS_TYPE.clone(),       // (region_ref,
            UINT64_TYPE.clone()         // block_size)
        ],
        vec![ADDRESS_TYPE.clone()]      // returns uptr<T>
    );
    /// Traced rAlloc for non-hybrid types
    pub static ref RALLOC_TRACED: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_ralloc_traced",
        vec![
            ADDRESS_TYPE.clone(),       // (region_ref,
            UINT64_TYPE.clone()         // type_id)
        ],
        vec![ADDRESS_TYPE.clone()]      // returns uptr<T>
    );
    /// Traced rAlloc for hybrid types
    pub static ref RALLOC_HYBRID: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_ralloc_hybrid",
        vec![
            ADDRESS_TYPE.clone(),       // (region_ref,
            UINT64_TYPE.clone(),        // fixed_part_length,
            UINT64_TYPE.clone(),        // var_part_unit_size,
            UINT64_TYPE.clone()         // var_part_length)
        ],
        vec![ADDRESS_TYPE.clone()]      // returns uptr<T>
    );
    /// Traced rAlloc for hybrid types
    pub static ref RALLOC_HYBRID_TRACED: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_ralloc_hybrid_traced",
        vec![
            ADDRESS_TYPE.clone(),       // (region_ref,
            UINT64_TYPE.clone(),        // hybrid_type_id,
            UINT64_TYPE.clone()         // var_part_length)
        ],
        vec![ADDRESS_TYPE.clone()]      // returns uptr<T>
    );
    /// Untraced eAlloc for both non-hybrid types
    pub static ref EALLOC: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_ealloc",
        vec![
            UINT64_TYPE.clone()         // (block_size)
        ],
        vec![ADDRESS_TYPE.clone()]      // returns uptr<T>
    );
    /// Traced eAlloc for non-hybrid types
    pub static ref EALLOC_TRACED: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_ealloc_traced",
        vec![
            UINT64_TYPE.clone()         // (type_id)
        ],
        vec![ADDRESS_TYPE.clone()]      // returns uptr<T>
    );
    /// Traced eAlloc for hybrid types
    pub static ref EALLOC_HYBRID: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_ealloc_hybrid",
        vec![
            UINT64_TYPE.clone(),        // (fixed_part_len,
            UINT64_TYPE.clone(),        // var_part_unit_size,
            UINT64_TYPE.clone()         // var_part_length)
        ],
        vec![ADDRESS_TYPE.clone()]      // returns uptr<T>
    );
    /// Traced eAlloc for hybrid types
    pub static ref EALLOC_HYBRID_TRACED: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_ealloc_hybrid_traced",
        vec![
            UINT64_TYPE.clone(),        // (hybrid_type_id,
            UINT64_TYPE.clone()         // var_part_length)
        ],
        vec![ADDRESS_TYPE.clone()]      // returns uptr<T>
    );
    /// Delete for all objects allocated by the eAlloc family
    pub static ref EDELETE: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_edelete",
        vec![
            ADDRESS_TYPE.clone()        // (block_uptr)
        ],
        vec![]                          // returns nothing
    );
277
278
279
280
281
282
283
284
285
286
287
288
    /// Get the current time value, since the UNIX_EPOCH, in nano-seconds
    pub static ref GETTIME: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_gettime",
        vec![],
        vec![UINT64_TYPE.clone()]      // returns u128 (#ns)
    );
    /// Set the current time value, in nano-seconds
    pub static ref SETTIME: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_settime",
        vec![UINT64_TYPE.clone()],     // (u128)
        vec![]                          // returns nothing
    );
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
289
290
291
292
293
294
295
296

    pub static ref NEWTIMER: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_new_timer",
        vec![],                         // ()
        vec![ADDRESS_TYPE.clone()]      // returns timerref
    );
    pub static ref SETTIMER: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_set_timer",
297
        vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone(), UINT64_TYPE.clone(), ADDRESS_TYPE.clone(), ADDRESS_TYPE.clone()],
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
298
                                        // (timerref, timeval, ufuncptr, uptr<void>)
299
        vec![]      // returns nothing
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
    );
    pub static ref CANCELTIMER: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_cancel_timer",
        vec![ADDRESS_TYPE.clone()],     // (timerref)
        vec![]                          // returns nothing
    );
    pub static ref DELETETIMER: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_delete_timer",
        vec![ADDRESS_TYPE.clone()],     // (timerref)
        vec![]                          // returns nothing
    );
    pub static ref SLEEP: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_sleep_ns",
        vec![UINT64_TYPE.clone()],     // (u64)
        vec![]                          // returns nothing
    );
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
    pub static ref NEWATTR: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_attr_new",
        vec![],     // ()
        vec![ADDRESS_TYPE.clone()]  // returns attrref
    );
    pub static ref DELETEATTR: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_attr_delete",
        vec![ADDRESS_TYPE.clone()],     // (attrref)
        vec![]  // returns nothing
    );
    pub static ref ATTR_SET_PRIORITY: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_attr_set_priority",
        vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone()],     // (attrref, u64)
        vec![]  // returns nothing
    );
    pub static ref ATTR_GET_PRIORITY: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_attr_get_priority",
        vec![ADDRESS_TYPE.clone()],     // (attrref)
        vec![UINT64_TYPE.clone()]  // returns u64
    );
    pub static ref ATTR_SET_CPU: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_attr_set_cpu",
        vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone()],     // (attrref, u64)
        vec![]  // returns nothing
    );
    pub static ref ATTR_CLEAR_CPU: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_attr_clear_cpu",
        vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone()],     // (attrref, u64)
        vec![]  // returns nothing
    );
    pub static ref ATTR_ISSET_CPU: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_attr_isset_cpu",
        vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone()],     // (attrref, u64)
        vec![UINT1_TYPE.clone()]  // returns bool
    );
    pub static ref ATTR_ZERO_CPU: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_attr_zero_cpu",
        vec![ADDRESS_TYPE.clone()],     // (attrref)
        vec![]  // returns nothing
    );
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
    pub static ref CONDVAR_NEW: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_condvar_new",
        vec![],     // ()
        vec![ADDRESS_TYPE.clone()]  // returns convar address
    );
    pub static ref CONDVAR_DELETE: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_condvar_delete",
        vec![ADDRESS_TYPE.clone()],     // (cv's address)
        vec![]  // returns nothing
    );
    pub static ref CONDVAR_ACQ_LOCK: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_condvar_acq_lock",
        vec![ADDRESS_TYPE.clone()],     // (cv's address)
        vec![]  // returns nothing
    );
    pub static ref CONDVAR_REL_LOCK: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_condvar_rel_lock",
        vec![ADDRESS_TYPE.clone()],     // (cv's address)
        vec![]  // returns nothing
    );
    pub static ref CONDVAR_WAIT: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_condvar_wait",
        vec![ADDRESS_TYPE.clone()],     // (cv's address)
        vec![]  // returns nothing
    );
    pub static ref CONDVAR_SIGNAL: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_condvar_signal",
        vec![ADDRESS_TYPE.clone()],     // (cv's address)
        vec![]  // returns nothing
    );
    pub static ref CONDVAR_BROADCAST: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_condvar_broadcast",
        vec![ADDRESS_TYPE.clone()],     // (cv's address)
        vec![]  // returns nothing
    );
391
392
}

393
394
// impl/decl: gc/lib.rs
lazy_static! {
395
396
    pub static ref ALLOC_TINY: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_alloc_tiny",
397
398
399
400
401
        vec![
            ADDRESS_TYPE.clone(),
            UINT64_TYPE.clone(),
            UINT64_TYPE.clone()
        ],
402
403
        vec![ADDRESS_TYPE.clone()]
    );
qinsoon's avatar
qinsoon committed
404
405
    pub static ref ALLOC_TINY_SLOW: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_alloc_tiny_slow",
406
407
408
409
410
        vec![
            ADDRESS_TYPE.clone(),
            UINT64_TYPE.clone(),
            UINT64_TYPE.clone()
        ],
qinsoon's avatar
qinsoon committed
411
412
        vec![ADDRESS_TYPE.clone()]
    );
413
414
    pub static ref ALLOC_NORMAL: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_alloc_normal",
415
416
417
418
419
        vec![
            ADDRESS_TYPE.clone(),
            UINT64_TYPE.clone(),
            UINT64_TYPE.clone()
        ],
420
421
        vec![ADDRESS_TYPE.clone()]
    );
422
423
424
425
426
427
428
429
430
431
    pub static ref ALLOC_NORMAL_SLOW: RuntimeEntrypoint =
        RuntimeEntrypoint::new(
            "muentry_alloc_normal_slow",
            vec![
                ADDRESS_TYPE.clone(),
                UINT64_TYPE.clone(),
                UINT64_TYPE.clone()
            ],
            vec![ADDRESS_TYPE.clone()]
        );
432
    pub static ref ALLOC_LARGE: RuntimeEntrypoint = RuntimeEntrypoint::new(
433
        "muentry_alloc_large",
434
435
436
437
438
        vec![
            ADDRESS_TYPE.clone(),
            UINT64_TYPE.clone(),
            UINT64_TYPE.clone()
        ],
439
440
441
442
        vec![ADDRESS_TYPE.clone()]
    );
    pub static ref ALLOC_VAR_SIZE: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_alloc_var_size",
443
444
445
446
447
448
449
450
        vec![
            UINT64_TYPE.clone(),
            UINT64_TYPE.clone(),
            UINT64_TYPE.clone(),
            UINT64_TYPE.clone(),
            UINT64_TYPE.clone(),
            UINT64_TYPE.clone()
        ],
451
452
        vec![ADDRESS_TYPE.clone()]
    );
453
    pub static ref INIT_TINY: RuntimeEntrypoint = RuntimeEntrypoint::new(
454
        "muentry_init_tiny_object",
455
456
457
458
459
        vec![
            ADDRESS_TYPE.clone(),
            ADDRESS_TYPE.clone(),
            UINT8_TYPE.clone()
        ],
460
461
462
463
        vec![]
    );
    pub static ref INIT_SMALL: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_init_small_object",
464
465
466
467
468
        vec![
            ADDRESS_TYPE.clone(),
            ADDRESS_TYPE.clone(),
            UINT16_TYPE.clone()
        ],
469
470
471
472
        vec![]
    );
    pub static ref INIT_MEDIUM: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_init_medium_object",
473
474
475
476
477
        vec![
            ADDRESS_TYPE.clone(),
            ADDRESS_TYPE.clone(),
            UINT32_TYPE.clone()
        ],
478
479
480
481
        vec![]
    );
    pub static ref INIT_LARGE: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_init_large_object",
482
483
484
485
486
487
        vec![
            ADDRESS_TYPE.clone(),
            ADDRESS_TYPE.clone(),
            UINT64_TYPE.clone(),
            UINT64_TYPE.clone()
        ],
488
489
        vec![]
    );
490
    pub static ref PIN_OBJECT: RuntimeEntrypoint = RuntimeEntrypoint::new(
491
492
        "muentry_pin_object",
        vec![ADDRESS_TYPE.clone()],
493
494
        vec![ADDRESS_TYPE.clone()]
    );
495
496
497
498
499
    pub static ref UNPIN_OBJECT: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_unpin_object",
        vec![ADDRESS_TYPE.clone()],
        vec![]
    );
500
}
qinsoon's avatar
qinsoon committed
501

Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
502
503
// decl: futex
lazy_static! {
504
    pub static ref NEW_FUTEX: RuntimeEntrypoint = RuntimeEntrypoint::new(
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
505
        "muentry_futex_new",
506
        vec![UINT64_TYPE.clone()],
507
508
509
        vec![ADDRESS_TYPE.clone()]
    );
    pub static ref DELETE_FUTEX: RuntimeEntrypoint = RuntimeEntrypoint::new(
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
510
511
        "muentry_futex_delete",
        vec![ADDRESS_TYPE.clone()],
512
513
514
        vec![]
    );
    pub static ref LOCK_FUTEX: RuntimeEntrypoint = RuntimeEntrypoint::new(
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
515
        "muentry_futex_lock",
516
517
518
519
        vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone()],
        vec![]
    );
    pub static ref UNLOCK_FUTEX: RuntimeEntrypoint = RuntimeEntrypoint::new(
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
520
        "muentry_futex_unlock",
521
        vec![ADDRESS_TYPE.clone(), UINT64_TYPE.clone()],
522
523
        vec![]
    );
Javad Ebrahimian Amiri's avatar
Javad Ebrahimian Amiri committed
524
525
}

526
527
528
529
530
531
532
533
534
535
536
537
// decl: exception.rs
lazy_static! {
    // impl: exception.rs
    pub static ref THROW_EXCEPTION : RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_throw_exception",
        vec![ADDRESS_TYPE.clone()],
        vec![]);
    // impl: runtime_ARCH_OS.S
    pub static ref THROW_EXCEPTION_INTERNAL: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "throw_exception_internal",
        vec![ADDRESS_TYPE.clone(), ADDRESS_TYPE.clone()],
        vec![]);
538
539
}

540
// impl/decl: math.rs
541
542
lazy_static! {
    pub static ref FREM32: RuntimeEntrypoint = RuntimeEntrypoint::new(
543
544
        "muentry_frem32",
        vec![FLOAT_TYPE.clone(), FLOAT_TYPE.clone()],
545
546
547
        vec![FLOAT_TYPE.clone()]
    );
    pub static ref FREM64: RuntimeEntrypoint = RuntimeEntrypoint::new(
548
549
        "muentry_frem64",
        vec![DOUBLE_TYPE.clone(), DOUBLE_TYPE.clone()],
550
551
552
        vec![DOUBLE_TYPE.clone()]
    );
    pub static ref UDIV_U128: RuntimeEntrypoint = RuntimeEntrypoint::new(
553
554
        "muentry_udiv_u128",
        vec![UINT128_TYPE.clone(), UINT128_TYPE.clone()],
555
556
557
        vec![UINT128_TYPE.clone()]
    );
    pub static ref SDIV_I128: RuntimeEntrypoint = RuntimeEntrypoint::new(
558
559
        "muentry_sdiv_i128",
        vec![UINT128_TYPE.clone(), UINT128_TYPE.clone()],
560
561
562
        vec![UINT128_TYPE.clone()]
    );
    pub static ref UREM_U128: RuntimeEntrypoint = RuntimeEntrypoint::new(
563
564
        "muentry_urem_u128",
        vec![UINT128_TYPE.clone(), UINT128_TYPE.clone()],
565
566
567
        vec![UINT128_TYPE.clone()]
    );
    pub static ref SREM_I128: RuntimeEntrypoint = RuntimeEntrypoint::new(
568
569
        "muentry_srem_i128",
        vec![UINT128_TYPE.clone(), UINT128_TYPE.clone()],
570
571
        vec![UINT128_TYPE.clone()]
    );
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
    pub static ref FPTOUI_DOUBLE_U128: RuntimeEntrypoint =
        RuntimeEntrypoint::new(
            "muentry_fptoui_double_u128",
            vec![DOUBLE_TYPE.clone()],
            vec![UINT128_TYPE.clone()]
        );
    pub static ref FPTOSI_DOUBLE_I128: RuntimeEntrypoint =
        RuntimeEntrypoint::new(
            "muentry_fptosi_double_i128",
            vec![DOUBLE_TYPE.clone()],
            vec![UINT128_TYPE.clone()]
        );
    pub static ref UITOFP_U128_DOUBLE: RuntimeEntrypoint =
        RuntimeEntrypoint::new(
            "muentry_uitofp_u128_double",
            vec![UINT128_TYPE.clone()],
            vec![DOUBLE_TYPE.clone()]
        );
    pub static ref SITOFP_I128_DOUBLE: RuntimeEntrypoint =
        RuntimeEntrypoint::new(
            "muentry_sitofp_i128_double",
            vec![UINT128_TYPE.clone()],
            vec![DOUBLE_TYPE.clone()]
        );
    pub static ref FPTOUI_FLOAT_U128: RuntimeEntrypoint =
        RuntimeEntrypoint::new(
            "muentry_fptoui_float_u128",
            vec![FLOAT_TYPE.clone()],
            vec![UINT128_TYPE.clone()]
        );
    pub static ref FPTOSI_FLOAT_I128: RuntimeEntrypoint =
        RuntimeEntrypoint::new(
            "muentry_fptosi_float_i128",
            vec![FLOAT_TYPE.clone()],
            vec![UINT128_TYPE.clone()]
        );
    pub static ref UITOFP_U128_FLOAT: RuntimeEntrypoint =
        RuntimeEntrypoint::new(
            "muentry_uitofp_u128_float",
            vec![UINT128_TYPE.clone()],
            vec![FLOAT_TYPE.clone()]
        );
    pub static ref SITOFP_I128_FLOAT: RuntimeEntrypoint =
        RuntimeEntrypoint::new(
            "muentry_sitofp_i128_float",
            vec![UINT128_TYPE.clone()],
            vec![FLOAT_TYPE.clone()]
        );
620
}
621

622
// impl/decl: mod.rs
623
lazy_static! {
624
625
626
627
628
629
630
631
632
633
    pub static ref PRINT_HEX: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_print_hex",
        vec![UINT64_TYPE.clone()],
        vec![]
    );
    pub static ref PRINT_BOOL: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_print_bool",
        vec![UINT1_TYPE.clone()],
        vec![]
    );
634
635
636
637
638
    pub static ref PRINT_TIME: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_print_time",
        vec![UINT64_TYPE.clone()],
        vec![]
    );
639
    pub static ref MEM_ZERO: RuntimeEntrypoint = RuntimeEntrypoint::new(
640
641
        "muentry_mem_zero",
        vec![IREF_VOID_TYPE.clone(), UINT64_TYPE.clone()],
642
643
        vec![]
    );
644
645
646
647
648
649
650
651
652
653
    pub static ref RAND_INT64: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_rand_int64",
        vec![UINT64_TYPE.clone(), UINT64_TYPE.clone()],
        vec![UINT64_TYPE.clone()]
    );
    pub static ref RAND_F64: RuntimeEntrypoint = RuntimeEntrypoint::new(
        "muentry_rand_f64",
        vec![DOUBLE_TYPE.clone(), DOUBLE_TYPE.clone()],
        vec![DOUBLE_TYPE.clone()]
    );
654
}