Use permanent_alloc_item directly rather than through the gb_alloc_item generic interface

This commit is contained in:
gingerBill
2026-03-16 16:03:27 +00:00
parent 3dc68c2e08
commit 1744f57d01
15 changed files with 60 additions and 65 deletions

View File

@@ -1707,7 +1707,7 @@ gb_internal bool cache_load_file_directive(CheckerContext *c, Ast *call, String
}
defer ({
if (cache == nullptr) {
LoadFileCache *new_cache = gb_alloc_item(permanent_allocator(), LoadFileCache);
LoadFileCache *new_cache = permanent_alloc_item<LoadFileCache>();
new_cache->path = path;
new_cache->data = data;
new_cache->file_error = file_error;
@@ -1745,7 +1745,7 @@ gb_internal bool cache_load_file_directive(CheckerContext *c, Ast *call, String
case LoadFileTier_Contents: {
isize file_size = cast(isize)gb_file_size(&f);
if (file_size > 0) {
u8 *ptr = cast(u8 *)gb_alloc(permanent_allocator(), file_size+1);
u8 *ptr = permanent_alloc_array<u8>(file_size+1);
gb_file_read_at(&f, ptr, file_size, 0);
ptr[file_size] = '\0';
data.text = ptr;
@@ -1950,7 +1950,7 @@ gb_internal LoadDirectiveResult check_load_directory_directive(CheckerContext *c
}
defer ({
if (cache == nullptr) {
LoadDirectoryCache *new_cache = gb_alloc_item(permanent_allocator(), LoadDirectoryCache);
LoadDirectoryCache *new_cache = permanent_alloc_item<LoadDirectoryCache>();
new_cache->path = path;
new_cache->files = file_caches;
new_cache->file_error = file_error;
@@ -3605,18 +3605,17 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As
gb_string_free(type_str);
return false;
}
gbAllocator a = permanent_allocator();
Type *tuple = alloc_type_tuple();
if (is_type_struct(type)) {
isize variable_count = type->Struct.fields.count;
slice_init(&tuple->Tuple.variables, a, variable_count);
tuple->Tuple.variables = permanent_slice_make<Entity *>(variable_count);
// NOTE(bill): don't copy the entities, this should be good enough
gb_memmove_array(tuple->Tuple.variables.data, type->Struct.fields.data, variable_count);
} else if (is_type_array(type)) {
isize variable_count = cast(isize)type->Array.count;
slice_init(&tuple->Tuple.variables, a, variable_count);
tuple->Tuple.variables = permanent_slice_make<Entity *>(variable_count);
for (isize i = 0; i < variable_count; i++) {
tuple->Tuple.variables[i] = alloc_entity_array_elem(nullptr, blank_token, type->Array.elem, cast(i32)i);
}

View File

@@ -499,7 +499,7 @@ gb_internal bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, E
rw_mutex_shared_unlock(&gen_procs->mutex); // @local-mutex
} else {
gen_procs = gb_alloc_item(permanent_allocator(), GenProcsData);
gen_procs = permanent_alloc_item<GenProcsData>();
gen_procs->procs.allocator = heap_allocator();
base_entity->Procedure.gen_procs = gen_procs;
mutex_unlock(&base_entity->Procedure.gen_procs_mutex); // @entity-mutex
@@ -536,7 +536,7 @@ gb_internal bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, E
DeclInfo *decl = other->decl_info;
if (decl->proc_checked_state != ProcCheckedState_Checked) {
ProcInfo *proc_info = gb_alloc_item(permanent_allocator(), ProcInfo);
ProcInfo *proc_info = permanent_alloc_item<ProcInfo>();
proc_info->file = other->file;
proc_info->token = other->token;
proc_info->decl = decl;
@@ -630,7 +630,7 @@ gb_internal bool find_or_generate_polymorphic_procedure(CheckerContext *old_c, E
array_add(&gen_procs->procs, entity);
rw_mutex_unlock(&gen_procs->mutex); // @local-mutex
ProcInfo *proc_info = gb_alloc_item(permanent_allocator(), ProcInfo);
ProcInfo *proc_info = permanent_alloc_item<ProcInfo>();
proc_info->file = file;
proc_info->token = token;
proc_info->decl = d;
@@ -7696,7 +7696,7 @@ gb_internal CallArgumentData check_call_arguments(CheckerContext *c, Operand *op
}
named_args = slice(ce->args, positional_args.count, ce->args.count);
auto split_args = gb_alloc_item(permanent_allocator(), AstSplitArgs);
auto split_args = permanent_alloc_item<AstSplitArgs>();
split_args->positional = positional_args;
split_args->named = named_args;
ce->split_args = split_args;

View File

@@ -272,7 +272,7 @@ gb_internal GenTypesData *ensure_polymorphic_record_entity_has_gen_types(Checker
GB_ASSERT(original_type->kind == Type_Named);
mutex_lock(&original_type->Named.gen_types_data_mutex);
if (original_type->Named.gen_types_data == nullptr) {
GenTypesData *gen_types = gb_alloc_item(permanent_allocator(), GenTypesData);
GenTypesData *gen_types = permanent_alloc_item<GenTypesData>();
gen_types->types = array_make<Entity *>(heap_allocator());
original_type->Named.gen_types_data = gen_types;
}
@@ -3303,7 +3303,7 @@ gb_internal Type *make_soa_struct_internal(CheckerContext *ctx, Ast *array_typ_e
add_type_info_type(ctx, soa_struct);
wait_signal_set(&soa_struct->Struct.fields_wait_signal);
} else {
SoaTypeWorkerData *wd = gb_alloc_item(permanent_allocator(), SoaTypeWorkerData);
SoaTypeWorkerData *wd = permanent_alloc_item<SoaTypeWorkerData>();
wd->ctx = *ctx;
wd->type = soa_struct;
wd->wait_to_finish = true;

View File

@@ -123,7 +123,7 @@ gb_internal void import_graph_node_set_add(ImportGraphNodeSet *s, ImportGraphNod
// }
gb_internal ImportGraphNode *import_graph_node_create(gbAllocator a, AstPackage *pkg) {
ImportGraphNode *n = gb_alloc_item(a, ImportGraphNode);
ImportGraphNode *n = permanent_alloc_item<ImportGraphNode>();
n->pkg = pkg;
n->scope = pkg->scope;
return n;
@@ -163,7 +163,6 @@ gb_internal void import_graph_node_swap(ImportGraphNode **data, isize i, isize j
gb_internal void init_decl_info(DeclInfo *d, Scope *scope, DeclInfo *parent) {
gb_zero_item(d);
if (parent) {
mutex_lock(&parent->next_mutex);
d->next_sibling = parent->next_child;
@@ -181,7 +180,7 @@ gb_internal void init_decl_info(DeclInfo *d, Scope *scope, DeclInfo *parent) {
}
gb_internal DeclInfo *make_decl_info(Scope *scope, DeclInfo *parent) {
DeclInfo *d = gb_alloc_item(permanent_allocator(), DeclInfo);
DeclInfo *d = permanent_alloc_item<DeclInfo>();
init_decl_info(d, scope, parent);
return d;
}
@@ -214,7 +213,7 @@ gb_internal DeclInfo *make_decl_info(Scope *scope, DeclInfo *parent) {
gb_internal Scope *create_scope(CheckerInfo *info, Scope *parent) {
Scope *s = gb_alloc_item(permanent_allocator(), Scope);
Scope *s = permanent_alloc_item<Scope>();
s->parent = parent;
if (parent != nullptr && parent != builtin_pkg->scope) {
@@ -1018,7 +1017,7 @@ gb_internal void add_global_type_entity(String name, Type *type) {
gb_internal AstPackage *create_builtin_package(char const *name) {
gbAllocator a = permanent_allocator();
AstPackage *pkg = gb_alloc_item(a, AstPackage);
AstPackage *pkg = permanent_alloc_item<AstPackage>();
pkg->name = make_string_c(name);
pkg->kind = Package_Builtin;
@@ -2412,7 +2411,7 @@ gb_internal void check_procedure_later(Checker *c, ProcInfo *info) {
}
gb_internal void check_procedure_later(Checker *c, AstFile *file, Token token, DeclInfo *decl, Type *type, Ast *body, u64 tags) {
ProcInfo *info = gb_alloc_item(permanent_allocator(), ProcInfo);
ProcInfo *info = permanent_alloc_item<ProcInfo>();
info->file = file;
info->token = token;
info->decl = decl;
@@ -3259,7 +3258,7 @@ gb_internal Type *find_type_in_pkg(CheckerInfo *info, String const &pkg, String
}
gb_internal CheckerTypePath *new_checker_type_path(gbAllocator allocator) {
auto *tp = gb_alloc_item(allocator, CheckerTypePath);
auto *tp = gb_alloc_item(heap_allocator(), CheckerTypePath);
array_init(tp, allocator, 0, 16);
return tp;
}
@@ -5016,7 +5015,7 @@ gb_internal void check_collect_entities(CheckerContext *c, Slice<Ast *> const &n
}
gb_internal CheckerContext *create_checker_context(Checker *c) {
CheckerContext *ctx = gb_alloc_item(permanent_allocator(), CheckerContext);
CheckerContext *ctx = permanent_alloc_item<CheckerContext>();
init_checker_context(ctx, c);
return ctx;
}
@@ -6228,7 +6227,7 @@ gb_internal void check_procedure_later_from_entity(Checker *c, Entity *e, char c
GB_ASSERT(e->decl_info != nullptr);
ProcInfo *pi = gb_alloc_item(permanent_allocator(), ProcInfo);
ProcInfo *pi = permanent_alloc_item<ProcInfo>();
pi->file = e->file;
pi->token = e->token;
pi->decl = e->decl_info;

View File

@@ -151,8 +151,8 @@ struct TypeNameObjCMetadata {
};
gb_internal TypeNameObjCMetadata *create_type_name_obj_c_metadata() {
TypeNameObjCMetadata *md = gb_alloc_item(permanent_allocator(), TypeNameObjCMetadata);
md->mutex = gb_alloc_item(permanent_allocator(), BlockingMutex);
TypeNameObjCMetadata *md = permanent_alloc_item<TypeNameObjCMetadata>();
md->mutex = permanent_alloc_item<BlockingMutex>();
array_init(&md->type_entries, heap_allocator());
array_init(&md->value_entries, heap_allocator());
return md;
@@ -345,8 +345,7 @@ gb_internal bool entity_has_deferred_procedure(Entity *e) {
gb_global std::atomic<u64> global_entity_id;
gb_internal Entity *alloc_entity(EntityKind kind, Scope *scope, Token token, Type *type) {
gbAllocator a = permanent_allocator();
Entity *entity = gb_alloc_item(a, Entity);
Entity *entity = permanent_alloc_item<Entity>();
entity->kind = kind;
entity->state = EntityState_Unresolved;
entity->scope = scope;

View File

@@ -146,7 +146,7 @@ gb_internal ExactValue exact_value_float(f64 f) {
gb_internal ExactValue exact_value_complex(f64 real, f64 imag) {
ExactValue result = {ExactValue_Complex};
result.value_complex = gb_alloc_item(permanent_allocator(), Complex128);
result.value_complex = permanent_alloc_item<Complex128>();
result.value_complex->real = real;
result.value_complex->imag = imag;
return result;
@@ -154,7 +154,7 @@ gb_internal ExactValue exact_value_complex(f64 real, f64 imag) {
gb_internal ExactValue exact_value_quaternion(f64 real, f64 imag, f64 jmag, f64 kmag) {
ExactValue result = {ExactValue_Quaternion};
result.value_quaternion = gb_alloc_item(permanent_allocator(), Quaternion256);
result.value_quaternion = permanent_alloc_item<Quaternion256>();
result.value_quaternion->real = real;
result.value_quaternion->imag = imag;
result.value_quaternion->jmag = jmag;
@@ -438,7 +438,7 @@ gb_internal ExactValue exact_value_to_complex(ExactValue v) {
// return exact_value_complex(v.value_quaternion.real, v.value_quaternion.imag);
}
ExactValue r = {ExactValue_Invalid};
v.value_complex = gb_alloc_item(permanent_allocator(), Complex128);
v.value_complex = permanent_alloc_item<Complex128>();
return r;
}
gb_internal ExactValue exact_value_to_quaternion(ExactValue v) {
@@ -453,7 +453,7 @@ gb_internal ExactValue exact_value_to_quaternion(ExactValue v) {
return v;
}
ExactValue r = {ExactValue_Invalid};
v.value_quaternion = gb_alloc_item(permanent_allocator(), Quaternion256);
v.value_quaternion = permanent_alloc_item<Quaternion256>();
return r;
}

View File

@@ -389,7 +389,7 @@ namespace lbAbi386 {
gb_internal LB_ABI_INFO(abi_info) {
LLVMContextRef c = m->ctx;
lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType);
lbFunctionType *ft = permanent_alloc_item<lbFunctionType>();
ft->ctx = c;
ft->args = compute_arg_types(c, arg_types, arg_count);
ft->ret = compute_return_type(ft, c, return_type, return_is_defined, return_is_tuple);
@@ -471,7 +471,7 @@ namespace lbAbiAmd64Win64 {
gb_internal LB_ABI_INFO(abi_info) {
LLVMContextRef c = m->ctx;
lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType);
lbFunctionType *ft = permanent_alloc_item<lbFunctionType>();
ft->ctx = c;
ft->args = compute_arg_types(c, arg_types, arg_count);
ft->ret = compute_return_type(ft, c, return_type, return_is_defined, return_is_tuple);
@@ -617,7 +617,7 @@ namespace lbAbiAmd64SysV {
gb_internal LB_ABI_INFO(abi_info) {
LLVMContextRef c = m->ctx;
lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType);
lbFunctionType *ft = permanent_alloc_item<lbFunctionType>();
ft->ctx = c;
ft->calling_convention = calling_convention;
@@ -1128,7 +1128,7 @@ namespace lbAbiArm64 {
gb_internal LB_ABI_INFO(abi_info) {
LLVMContextRef c = m->ctx;
lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType);
lbFunctionType *ft = permanent_alloc_item<lbFunctionType>();
ft->ctx = c;
ft->args = compute_arg_types(c, arg_types, arg_count);
ft->ret = compute_return_type(ft, c, return_type, return_is_defined, return_is_tuple);
@@ -1349,7 +1349,7 @@ namespace lbAbiWasm {
gb_internal LB_ABI_INFO(abi_info) {
LLVMContextRef c = m->ctx;
lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType);
lbFunctionType *ft = permanent_alloc_item<lbFunctionType>();
ft->ctx = c;
ft->calling_convention = calling_convention;
ft->args = compute_arg_types(c, arg_types, arg_count, calling_convention, original_type);
@@ -1558,7 +1558,7 @@ namespace lbAbiArm32 {
gb_internal LB_ABI_INFO(abi_info) {
LLVMContextRef c = m->ctx;
lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType);
lbFunctionType *ft = permanent_alloc_item<lbFunctionType>();
ft->ctx = c;
ft->args = compute_arg_types(c, arg_types, arg_count, calling_convention);
ft->ret = compute_return_type(c, return_type, return_is_defined);
@@ -1867,7 +1867,7 @@ namespace lbAbiRiscv64 {
}
gb_internal LB_ABI_INFO(abi_info) {
lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType);
lbFunctionType *ft = permanent_alloc_item<lbFunctionType>();
ft->ctx = m->ctx;
ft->calling_convention = calling_convention;
@@ -1889,7 +1889,7 @@ gb_internal LB_ABI_INFO(lb_get_abi_info_internal) {
case ProcCC_None:
case ProcCC_InlineAsm:
{
lbFunctionType *ft = gb_alloc_item(permanent_allocator(), lbFunctionType);
lbFunctionType *ft = permanent_alloc_item<lbFunctionType>();
ft->ctx = c;
ft->args = array_make<lbArgType>(lb_function_type_args_allocator(), arg_count);
for (unsigned i = 0; i < arg_count; i++) {

View File

@@ -2647,7 +2647,7 @@ gb_internal void lb_llvm_module_passes_and_verification(lbGenerator *gen, bool d
if (do_threading) {
for (auto const &entry : gen->modules) {
lbModule *m = entry.value;
auto wd = gb_alloc_item(permanent_allocator(), lbLLVMModulePassWorkerData);
auto wd = permanent_alloc_item<lbLLVMModulePassWorkerData>();
wd->m = m;
wd->target_machine = m->target_machine;
wd->do_threading = true;
@@ -2658,7 +2658,7 @@ gb_internal void lb_llvm_module_passes_and_verification(lbGenerator *gen, bool d
} else {
for (auto const &entry : gen->modules) {
lbModule *m = entry.value;
auto wd = gb_alloc_item(permanent_allocator(), lbLLVMModulePassWorkerData);
auto wd = permanent_alloc_item<lbLLVMModulePassWorkerData>();
wd->m = m;
wd->target_machine = m->target_machine;
wd->do_threading = false;
@@ -2778,7 +2778,7 @@ gb_internal bool lb_llvm_object_generation(lbGenerator *gen, bool do_threading)
array_add(&gen->output_object_paths, filepath_obj);
array_add(&gen->output_temp_paths, filepath_ll);
auto *wd = gb_alloc_item(permanent_allocator(), lbLLVMEmitWorker);
auto *wd = permanent_alloc_item<lbLLVMEmitWorker>();
wd->target_machine = m->target_machine;
wd->code_gen_file_type = code_gen_file_type;
wd->filepath_obj = filepath_obj;

View File

@@ -166,7 +166,7 @@ gb_internal bool lb_init_generator(lbGenerator *gen, Checker *c) {
bool module_per_file = build_context.module_per_file && (build_context.optimization_level <= 0 || build_context.lto_kind != LTO_None);
for (auto const &entry : gen->info->packages) {
AstPackage *pkg = entry.value;
auto m = gb_alloc_item(permanent_allocator(), lbModule);
auto m = permanent_alloc_item<lbModule>();
m->pkg = pkg;
m->gen = gen;
m->checker = c;
@@ -174,7 +174,7 @@ gb_internal bool lb_init_generator(lbGenerator *gen, Checker *c) {
lb_init_module(m, do_threading);
if (LLVM_WEAK_MONOMORPHIZATION) {
auto pm = gb_alloc_item(permanent_allocator(), lbModule);
auto pm = permanent_alloc_item<lbModule>();
pm->pkg = pkg;
pm->gen = gen;
pm->checker = c;
@@ -216,7 +216,7 @@ gb_internal bool lb_init_generator(lbGenerator *gen, Checker *c) {
}
// NOTE(bill): Probably per file is not a good idea, so leave this for later
for (AstFile *file : pkg->files) {
auto m = gb_alloc_item(permanent_allocator(), lbModule);
auto m = permanent_alloc_item<lbModule>();
m->file = file;
m->pkg = pkg;
m->gen = gen;
@@ -226,7 +226,7 @@ gb_internal bool lb_init_generator(lbGenerator *gen, Checker *c) {
if (LLVM_WEAK_MONOMORPHIZATION) {
auto pm = gb_alloc_item(permanent_allocator(), lbModule);
auto pm = permanent_alloc_item<lbModule>();
pm->file = file;
pm->pkg = pkg;
pm->gen = gen;
@@ -242,7 +242,7 @@ gb_internal bool lb_init_generator(lbGenerator *gen, Checker *c) {
}
if (LLVM_WEAK_MONOMORPHIZATION) {
lbModule *m = gb_alloc_item(permanent_allocator(), lbModule);
lbModule *m = permanent_alloc_item<lbModule>();
gen->equal_module = m;
m->gen = gen;
m->checker = c;
@@ -2728,7 +2728,7 @@ gb_internal void lb_add_edge(lbBlock *from, lbBlock *to) {
gb_internal lbBlock *lb_create_block(lbProcedure *p, char const *name, bool append) {
lbBlock *b = gb_alloc_item(permanent_allocator(), lbBlock);
lbBlock *b = permanent_alloc_item<lbBlock>();
b->block = LLVMCreateBasicBlockInContext(p->module->ctx, name);
b->appended = false;
if (append) {

View File

@@ -99,7 +99,7 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i
}
}
lbProcedure *p = gb_alloc_item(permanent_allocator(), lbProcedure);
lbProcedure *p = permanent_alloc_item<lbProcedure>();
p->module = m;
entity->code_gen_module = m;
@@ -395,7 +395,7 @@ gb_internal lbProcedure *lb_create_dummy_procedure(lbModule *m, String link_name
GB_ASSERT_MSG(found == nullptr, "failed to create dummy procedure for: %.*s", LIT(link_name));
}
lbProcedure *p = gb_alloc_item(permanent_allocator(), lbProcedure);
lbProcedure *p = permanent_alloc_item<lbProcedure>();
p->module = m;
p->name = link_name;

View File

@@ -260,7 +260,7 @@ gb_internal lbBranchBlocks lb_lookup_branch_blocks(lbProcedure *p, Ast *ident) {
}
gb_internal lbTargetList *lb_push_target_list(lbProcedure *p, Ast *label, lbBlock *break_, lbBlock *continue_, lbBlock *fallthrough_) {
lbTargetList *tl = gb_alloc_item(permanent_allocator(), lbTargetList);
lbTargetList *tl = permanent_alloc_item<lbTargetList>();
tl->prev = p->target_list;
tl->break_ = break_;
tl->continue_ = continue_;

View File

@@ -4012,8 +4012,8 @@ int main(int arg_count, char const **arg_ptr) {
init_universal();
// TODO(bill): prevent compiling without a linker
Parser *parser = gb_alloc_item(permanent_allocator(), Parser);
Checker *checker = gb_alloc_item(permanent_allocator(), Checker);
Parser * parser = permanent_alloc_item<Parser>();
Checker *checker = permanent_alloc_item<Checker>();
bool failed_to_cache_parsing = false;
MAIN_TIME_SECTION("parse files");
@@ -4151,7 +4151,7 @@ int main(int arg_count, char const **arg_ptr) {
} else
#endif
{
lbGenerator *gen = gb_alloc_item(permanent_allocator(), lbGenerator);
lbGenerator *gen = permanent_alloc_item<lbGenerator>();
if (!lb_init_generator(gen, checker)) {
return 1;
}

View File

@@ -1476,7 +1476,7 @@ gb_internal CommentGroup *consume_comment_group(AstFile *f, isize n, isize *end_
CommentGroup *comments = nullptr;
if (list.count > 0) {
comments = gb_alloc_item(permanent_allocator(), CommentGroup);
comments = permanent_alloc_item<CommentGroup>();
comments->list = slice_from_array(list);
array_add(&f->comments, comments);
}
@@ -5151,7 +5151,7 @@ gb_internal Ast *parse_import_decl(AstFile *f, ImportDeclKind kind) {
}
if (file_path.string == "\".\"") {
syntax_error(import_name, "Cannot cyclicly import packages");
// syntax_error(import_name, "Cannot cyclicly import packages");
}
expect_semicolon(f);
@@ -5797,7 +5797,7 @@ gb_internal WORKER_TASK_PROC(parser_worker_proc) {
ParserWorkerData *wd = cast(ParserWorkerData *)data;
ParseFileError err = process_imported_file(wd->parser, wd->imported_file);
if (err != ParseFile_None) {
auto *node = gb_alloc_item(permanent_allocator(), ParseFileErrorNode);
auto *node = permanent_alloc_item<ParseFileErrorNode>();
node->err = err;
MUTEX_GUARD_BLOCK(&wd->parser->file_error_mutex) {
@@ -5817,7 +5817,7 @@ gb_internal WORKER_TASK_PROC(parser_worker_proc) {
gb_internal void parser_add_file_to_process(Parser *p, AstPackage *pkg, FileInfo fi, TokenPos pos) {
ImportedFile f = {pkg, fi, pos, p->file_to_process_count++};
f.pos.file_id = cast(i32)(f.index+1);
auto wd = gb_alloc_item(permanent_allocator(), ParserWorkerData);
auto wd = permanent_alloc_item<ParserWorkerData>();
wd->parser = p;
wd->imported_file = f;
thread_pool_add_task(parser_worker_proc, wd);
@@ -5854,7 +5854,7 @@ gb_internal void parser_add_foreign_file_to_process(Parser *p, AstPackage *pkg,
// TODO(bill): Use a better allocator
ImportedFile f = {pkg, fi, pos, p->file_to_process_count++};
f.pos.file_id = cast(i32)(f.index+1);
auto wd = gb_alloc_item(permanent_allocator(), ForeignFileWorkerData);
auto wd = permanent_alloc_item<ForeignFileWorkerData>();
wd->parser = p;
wd->imported_file = f;
wd->foreign_kind = kind;
@@ -5874,7 +5874,7 @@ gb_internal AstPackage *try_add_import_path(Parser *p, String path, String const
path = copy_string(permanent_allocator(), path);
AstPackage *pkg = gb_alloc_item(permanent_allocator(), AstPackage);
AstPackage *pkg = permanent_alloc_item<AstPackage>();
pkg->kind = kind;
pkg->fullpath = path;
array_init(&pkg->files, permanent_allocator());
@@ -6880,7 +6880,7 @@ gb_internal ParseFileError process_imported_file(Parser *p, ImportedFile importe
FileInfo fi = imported_file.fi;
TokenPos pos = imported_file.pos;
AstFile *file = gb_alloc_item(permanent_allocator(), AstFile);
AstFile *file = permanent_alloc_item<AstFile>();
file->pkg = pkg;
file->id = cast(i32)(imported_file.index+1);
TokenPos err_pos = {0};

View File

@@ -37,7 +37,7 @@ gb_internal void mpsc_destroy(MPSCQueue<T> *q) {
template <typename T>
gb_internal MPSCNode<T> *mpsc_alloc_node(MPSCQueue<T> *q, T const &value) {
// auto new_node = gb_alloc_item(heap_allocator(), MPSCNode<T>);
auto new_node = gb_alloc_item(permanent_allocator(), MPSCNode<T>);
auto new_node = permanent_alloc_item<MPSCNode<T> >();
new_node->value = value;
return new_node;
}

View File

@@ -979,9 +979,7 @@ gb_internal void set_base_type(Type *t, Type *base) {
gb_internal Type *alloc_type(TypeKind kind) {
// gbAllocator a = heap_allocator();
gbAllocator a = permanent_allocator();
Type *t = gb_alloc_item(a, Type);
gb_zero_item(t);
Type *t = permanent_alloc_item<Type>();
t->kind = kind;
t->cached_size = -1;
t->cached_align = -1;
@@ -1076,8 +1074,8 @@ gb_internal Type *alloc_type_enumerated_array(Type *elem, Type *index, ExactValu
Type *t = alloc_type(Type_EnumeratedArray);
t->EnumeratedArray.elem = elem;
t->EnumeratedArray.index = index;
t->EnumeratedArray.min_value = gb_alloc_item(permanent_allocator(), ExactValue);
t->EnumeratedArray.max_value = gb_alloc_item(permanent_allocator(), ExactValue);
t->EnumeratedArray.min_value = permanent_alloc_item<ExactValue>();
t->EnumeratedArray.max_value = permanent_alloc_item<ExactValue>();
gb_memmove(t->EnumeratedArray.min_value, min_value, gb_size_of(ExactValue));
gb_memmove(t->EnumeratedArray.max_value, max_value, gb_size_of(ExactValue));
t->EnumeratedArray.op = op;