aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-08-29 19:55:55 +0100
committergingerBill <bill@gingerbill.org>2018-08-29 19:55:55 +0100
commit001837e6bb0448d439ce6208069265a1a7aefaf5 (patch)
tree7252984ec2c8d5844d8236006f9959b3dbee15da /src
parent28523f17e2c702379dff89b024edcb1614256476 (diff)
Temporary allocator for `context`
Diffstat (limited to 'src')
-rw-r--r--src/checker.cpp1
-rw-r--r--src/ir.cpp17
2 files changed, 15 insertions, 3 deletions
diff --git a/src/checker.cpp b/src/checker.cpp
index b0d6d72aa..2035ded75 100644
--- a/src/checker.cpp
+++ b/src/checker.cpp
@@ -1309,6 +1309,7 @@ void generate_minimum_dependency_set(Checker *c, Entity *start) {
str_lit("args__"),
str_lit("type_table"),
+ str_lit("global_scratch_allocator"),
str_lit("Type_Info"),
str_lit("Source_Code_Location"),
diff --git a/src/ir.cpp b/src/ir.cpp
index daa0770d2..53391c236 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -1658,11 +1658,22 @@ irValue *ir_find_or_generate_context_ptr(irProcedure *proc) {
ir_push_context_onto_stack(proc, c);
ir_emit_store(proc, c, ir_emit_load(proc, proc->module->global_default_context));
- irValue *ep = ir_emit_struct_ep(proc, c, 0);
+
+#if 1
Array<irValue *> args = {};
- irValue *v = ir_emit_package_call(proc, "os", "heap_allocator", args);
- ir_emit_store(proc, ep, v);
+ ir_emit_store(proc, ir_emit_struct_ep(proc, c, 0), ir_emit_package_call(proc, "os", "heap_allocator", args));
+ ir_emit_store(proc, ir_emit_struct_ep(proc, c, 2), ir_emit_package_call(proc, "os", "current_thread_id", args));
+ array_init(&args, heap_allocator(), 1);
+ AstPackage *rt_pkg = get_core_package(proc->module->info, str_lit("runtime"));
+ Entity *e = scope_lookup_current(rt_pkg->scope, str_lit("global_scratch_allocator_data"));
+ irValue **found = map_get(&proc->module->values, hash_entity(e));
+ GB_ASSERT_MSG(found != nullptr, "%.*s", LIT(e->token.string));
+ args[0] = *found;
+ ir_emit_store(proc, ir_emit_struct_ep(proc, c, 1), ir_emit_package_call(proc, "mem", "scratch_allocator", args));
+#else
+ ir_emit_init_context(proc, c);
+#endif
return c;
}