-
Notifications
You must be signed in to change notification settings - Fork 233
Expand file tree
/
Copy pathwasi_thread_start.S
More file actions
64 lines (47 loc) · 1.34 KB
/
wasi_thread_start.S
File metadata and controls
64 lines (47 loc) · 1.34 KB
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
#define PTR i32
#define PTRSIZE 4
# Preprocessor's define directive doesn't resolve math expressions,
# so we hardcode the result of PTRSIZE * 2 operation
#define DOUBLE_PTRSIZE 8
.text
.export_name wasi_thread_start, wasi_thread_start
.globaltype __stack_pointer, PTR
.globaltype __tls_base, PTR
#ifndef NDEBUG
.globaltype __stack_base, PTR
.globaltype __stack_limit, PTR
#endif
.functype __wasi_thread_start_C (i32, PTR) -> ()
.hidden wasi_thread_start
.globl wasi_thread_start
.type wasi_thread_start,@function
wasi_thread_start:
.functype wasi_thread_start (i32, PTR) -> ()
# Set up the minimum C environment.
# Note: offsetof(start_arg, stack) == 0
local.get 1 # start_arg
PTR.load 0 # stack
global.set __stack_pointer
local.get 1 # start_arg
PTR.load PTRSIZE # tls_base
global.set __tls_base
#ifndef NDEBUG
# configure __stack_base and __stack_limit in debug mode
# to allow for stack overflow detection
local.get 1 # start_arg
PTR.load 0 # stack
global.set __stack_base
local.get 1 # start_arg
PTR.load DOUBLE_PTRSIZE # stack_limit
global.set __stack_limit
#endif
# Make the C function do the rest of work.
local.get 0 # tid
local.get 1 # start_arg
call __wasi_thread_start_C
end_function
#ifndef NDEBUG
.section .data,"",@
__stack_base:
__stack_limit:
#endif