From 001837e6bb0448d439ce6208069265a1a7aefaf5 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 29 Aug 2018 19:55:55 +0100 Subject: Temporary allocator for `context` --- src/ir.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/ir.cpp') 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 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; } -- cgit v1.2.3