Replace static initializer with @init / @finalizer

This commit is contained in:
Christoffer Lerno
2023-10-03 12:28:42 +02:00
committed by Christoffer Lerno
parent 757a5b58e8
commit 4cc30c0d33
28 changed files with 120 additions and 264 deletions

View File

@@ -76,8 +76,6 @@ enum CallLocation : int(String name)
MACRO("macro"),
LAMBDA("lambda"),
TEST("test"),
INITIALIZER("initializer"),
FINALIZER("finalizer")
}
struct CallstackElement
@@ -427,7 +425,7 @@ fn void install_signal_handler(CInt signal, SignalFunction func) @local
}
// Clean this up
static initialize @priority(101)
fn void install_signal_handlers() @init(101) @local
{
install_signal_handler(libc::SIGBUS, &sig_bus_error);
install_signal_handler(libc::SIGSEGV, &sig_segmentation_fault);

View File

@@ -656,7 +656,7 @@ module std::core::mem @if(WASM_NOLIBC);
SimpleHeapAllocator wasm_allocator @private;
extern int __heap_base;
static initialize @priority(1)
fn void initialize_wasm_mem() @init(1) @private
{
allocator::wasm_memory.allocate_block(mem::DEFAULT_MEM_ALIGNMENT)!!; // Give us a valid null.
// Check if we need to move the heap.