[Bug #20566] Mention out-of-range argument cases in `String#<<`
[ruby.git] / wasm / machine.c
blob2ca84625029a05bcdf4955d039b81ef82d1e3647
1 #include <stdlib.h>
2 #include "wasm/machine.h"
3 #include "wasm/asyncify.h"
5 #ifndef WASM_SCAN_STACK_BUFFER_SIZE
6 # define WASM_SCAN_STACK_BUFFER_SIZE 6144
7 #endif
9 struct asyncify_buf {
10 void *top;
11 void *end;
12 uint8_t buffer[WASM_SCAN_STACK_BUFFER_SIZE];
15 static void
16 init_asyncify_buf(struct asyncify_buf* buf)
18 buf->top = &buf->buffer[0];
19 buf->end = &buf->buffer[WASM_SCAN_STACK_BUFFER_SIZE];
22 static void *_rb_wasm_active_scan_buf = NULL;
24 void
25 rb_wasm_scan_locals(rb_wasm_scan_func scan)
27 static struct asyncify_buf buf;
28 static int spilling = 0;
29 if (!spilling) {
30 spilling = 1;
31 init_asyncify_buf(&buf);
32 _rb_wasm_active_scan_buf = &buf;
33 asyncify_start_unwind(&buf);
34 } else {
35 asyncify_stop_rewind();
36 spilling = 0;
37 _rb_wasm_active_scan_buf = NULL;
38 scan(buf.top, buf.end);
42 static void *rb_wasm_stack_base = NULL;
44 __attribute__((constructor))
45 int
46 rb_wasm_record_stack_base(void)
48 rb_wasm_stack_base = rb_wasm_get_stack_pointer();
49 return 0;
52 void *
53 rb_wasm_stack_get_base(void)
55 return rb_wasm_stack_base;
58 void *
59 rb_wasm_handle_scan_unwind(void)
61 return _rb_wasm_active_scan_buf;