diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 861d72fcb..ea3ca8d3a 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -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(); 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(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(); 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(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(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); } diff --git a/src/check_expr.cpp b/src/check_expr.cpp index e66498b6d..3b29d5f94 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -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(); 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(); 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(); 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(); split_args->positional = positional_args; split_args->named = named_args; ce->split_args = split_args; diff --git a/src/check_type.cpp b/src/check_type.cpp index d8fd8d079..f780f82b0 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -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(); gen_types->types = array_make(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(); wd->ctx = *ctx; wd->type = soa_struct; wd->wait_to_finish = true; diff --git a/src/checker.cpp b/src/checker.cpp index 720556a4f..5677b39b9 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -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(); 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(); 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(); 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(); 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(); 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 const &n } gb_internal CheckerContext *create_checker_context(Checker *c) { - CheckerContext *ctx = gb_alloc_item(permanent_allocator(), CheckerContext); + CheckerContext *ctx = permanent_alloc_item(); 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(); pi->file = e->file; pi->token = e->token; pi->decl = e->decl_info; diff --git a/src/entity.cpp b/src/entity.cpp index 070b05462..1a01e0945 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -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(); + md->mutex = permanent_alloc_item(); 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 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->kind = kind; entity->state = EntityState_Unresolved; entity->scope = scope; diff --git a/src/exact_value.cpp b/src/exact_value.cpp index fa99ed3fe..525b8cb91 100644 --- a/src/exact_value.cpp +++ b/src/exact_value.cpp @@ -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(); 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(); 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(); 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(); return r; } diff --git a/src/llvm_abi.cpp b/src/llvm_abi.cpp index ec7c63b1a..6aabe456f 100644 --- a/src/llvm_abi.cpp +++ b/src/llvm_abi.cpp @@ -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(); 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(); 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(); 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(); 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(); 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(); 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(); 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(); ft->ctx = c; ft->args = array_make(lb_function_type_args_allocator(), arg_count); for (unsigned i = 0; i < arg_count; i++) { diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index 929b056a3..fac3e3354 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -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(); 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(); 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(); wd->target_machine = m->target_machine; wd->code_gen_file_type = code_gen_file_type; wd->filepath_obj = filepath_obj; diff --git a/src/llvm_backend_general.cpp b/src/llvm_backend_general.cpp index 6694f1a75..35a0f5f65 100644 --- a/src/llvm_backend_general.cpp +++ b/src/llvm_backend_general.cpp @@ -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(); 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(); 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(); 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(); 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(); 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(); b->block = LLVMCreateBasicBlockInContext(p->module->ctx, name); b->appended = false; if (append) { diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp index 88165f4d2..121b8c550 100644 --- a/src/llvm_backend_proc.cpp +++ b/src/llvm_backend_proc.cpp @@ -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(); 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(); p->module = m; p->name = link_name; diff --git a/src/llvm_backend_stmt.cpp b/src/llvm_backend_stmt.cpp index a93d3305e..fe09b26c8 100644 --- a/src/llvm_backend_stmt.cpp +++ b/src/llvm_backend_stmt.cpp @@ -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(); tl->prev = p->target_list; tl->break_ = break_; tl->continue_ = continue_; diff --git a/src/main.cpp b/src/main.cpp index d7288e5f4..ee3f42660 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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(); + Checker *checker = permanent_alloc_item(); 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(); if (!lb_init_generator(gen, checker)) { return 1; } diff --git a/src/parser.cpp b/src/parser.cpp index b302c935d..f79287ceb 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -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(); 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(); 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(); 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(); 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(); 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(); file->pkg = pkg; file->id = cast(i32)(imported_file.index+1); TokenPos err_pos = {0}; diff --git a/src/queue.cpp b/src/queue.cpp index 82f82f3e1..563fbe69e 100644 --- a/src/queue.cpp +++ b/src/queue.cpp @@ -37,7 +37,7 @@ gb_internal void mpsc_destroy(MPSCQueue *q) { template gb_internal MPSCNode *mpsc_alloc_node(MPSCQueue *q, T const &value) { // auto new_node = gb_alloc_item(heap_allocator(), MPSCNode); - auto new_node = gb_alloc_item(permanent_allocator(), MPSCNode); + auto new_node = permanent_alloc_item >(); new_node->value = value; return new_node; } diff --git a/src/types.cpp b/src/types.cpp index 0f7aa2199..1ab759c9a 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -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(); 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(); + t->EnumeratedArray.max_value = permanent_alloc_item(); 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;