File: stack_ops.S

package info (click to toggle)
emscripten 3.1.69%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 121,860 kB
  • sloc: ansic: 636,110; cpp: 425,974; javascript: 78,401; python: 58,404; sh: 49,154; pascal: 5,237; makefile: 3,366; asm: 2,415; lisp: 1,869
file content (40 lines) | stat: -rw-r--r-- 902 bytes parent folder | download
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
.globl _emscripten_stack_restore
.globl _emscripten_stack_alloc
.globl emscripten_stack_get_current

#ifdef __wasm64__
#define PTR i64
#define MASK 0xfffffffffffffff0
#else
#define PTR i32
#define MASK 0xfffffff0
#endif

.globaltype __stack_pointer, PTR

_emscripten_stack_restore:
  .functype _emscripten_stack_restore(PTR) -> ()
  local.get 0
  global.set __stack_pointer
  end_function

_emscripten_stack_alloc:
  .functype _emscripten_stack_alloc(PTR) -> (PTR)
  .local PTR, PTR
  global.get __stack_pointer
  # Get arg 0 -> number of bytes to allocate
  local.get 0
  # Stack grows down.  Subtract arg0 from __stack_pointer
  PTR.sub
  # Align result by anding with ~15
  PTR.const MASK
  PTR.and
  local.tee 1
  global.set __stack_pointer
  local.get 1
  end_function

emscripten_stack_get_current:
  .functype emscripten_stack_get_current () -> (PTR)
  global.get __stack_pointer
  end_function