#if #defined((package core.set).Set) {
Set :: (package core.set).Set;
-}
\ No newline at end of file
+}
+
+
+// This procedure is a special compiler generated procedure that initializes all the data segments
+// in the program. It should only be called once, by the main thread, at the start of execution. It
+// is undefined behaviour if it is called more than once.
+__initialize_data_segments :: () -> i32 ---
+
[X] Write basic threading primatives like mutex and semaphore
[X] Make heap and printf take a mutex
- [ ] LATER: add thread-local variables
+ [X] LATER: add thread-local variables
- Have a new global that is the TLS base pointer
- Any global variable (memres) tagged with #threadlocal will be placed in a block with the
base pointer being the new global
- The global is initialized to a heap allocated block at the start of each thread
+Optimize the generation of multi-threaded modules when post-mvp features are enabled:
+ [X] memory.init intrinsic
+ [ ] atomatic generation of initializers for all data segments
+ [ ] emit datacount section
\ No newline at end of file
WI_F32X4_CONVERT_I32X4_U = SIMD_INSTR_MASK | 251,
+ WI_MEMORY_INIT = EXT_INSTR_MASK | 0x08,
WI_MEMORY_COPY = EXT_INSTR_MASK | 0x0a,
WI_MEMORY_FILL = EXT_INSTR_MASK | 0x0b,
AstType *builtin_any_type;
AstType *builtin_code_type;
-AstTyped *type_table_node = NULL;
+AstFunction *builtin_initialize_data_segments = NULL;
+AstTyped *type_table_node = NULL;
const BuiltinSymbol builtin_symbols[] = {
{ NULL, "void", (AstNode *) &basic_type_void },
return;
}
+ builtin_initialize_data_segments = (AstType *) symbol_raw_resolve(p->scope, "__initialize_data_segments");
+ if (builtin_code_type == NULL) {
+ onyx_report_error((OnyxFilePos) { 0 }, "'__initialize_data_segments' procedure not found in builtin package.");
+ return;
+ }
+
p = package_lookup("builtin.type_info");
if (p != NULL) {
type_table_node = (AstTyped *) symbol_raw_resolve(p->scope, "type_table");
bh_buffer_append(buff, leb, leb_len);
break;
+ case WI_MEMORY_INIT:
case WI_MEMORY_COPY:
leb = uint_to_uleb128((u64) instr->data.i1, &leb_len);
bh_buffer_append(buff, leb, leb_len);