Working on simplifying configurable allocation scheme

This commit is contained in:
Krzosa Karol
2023-01-01 12:40:58 +01:00
parent 8c0a8bf72b
commit c5539276ae
18 changed files with 169 additions and 347 deletions

View File

@@ -138,7 +138,8 @@ parse_all_modules() {
CORE_Static Ast_Module *
add_module(Token *pos, Intern_String filename, B32 command_line_module) {
Scratch scratch;
Scratch_Arena *scratch = pctx->scratch;
Scratch_Scope _scope(scratch);
String absolute_file_path = {};
String absolute_base_folder = {};
@@ -292,14 +293,17 @@ const U32 COMPILE_TESTING = 0x8;
CORE_Static void
compile_file(Arena *arena, String filename, U32 compile_flags = COMPILE_NULL) {
String result = compile_file_to_string(arena, filename);
if (is_flag_set(compile_flags, COMPILE_AND_RUN)) {
log_info_no_nl("%Q - ", filename);
}
String result = compile_file_to_string(arena, filename);
assert(os_write_file("program.c"_s, result));
B32 r = os_write_file("program.c"_s, result);
assert(r);
Scratch_Arena *scratch = pctx->scratch;
Scratch_Scope _scope(scratch);
Scratch scratch;
F64 begin = os_time();
String_Builder builder = {scratch};
builder.addf("clang program.c -Wall -Wno-unused-function -Wno-parentheses-equality -g -o a" OS_EXE " ");
@@ -321,12 +325,13 @@ compile_file(Arena *arena, String filename, U32 compile_flags = COMPILE_NULL) {
}
if (is_flag_set(compile_flags, COMPILE_PRINT_ALLOCATOR_STATS_BEFORE_DESTROY)) {
Arena *p = (Arena *)pctx->perm;
Arena *stage = (Arena *)&pctx->stage_arena;
log_info("Pernament arena len: %llu commit: %llu", p->len, p->memory.commit);
log_info("Stage arena len: %llu commit: %llu", stage->len, stage->memory.commit);
log_info("Scratch1 len: %llu commit: %llu", thread_ctx.scratch[0].len, thread_ctx.scratch[0].memory.commit);
log_info("Scratch2 len: %llu commit: %llu", thread_ctx.scratch[1].len, thread_ctx.scratch[1].memory.commit);
// @! allocator stats
//Arena *p = (Arena *)pctx->perm;
//Arena *stage = (Arena *)&pctx->stage_arena;
//log_info("Pernament arena len: %llu commit: %llu", pct, p->memory.commit);
//log_info("Stage arena len: %llu commit: %llu", stage->len, stage->memory.commit);
//log_info("Scratch1 len: %llu commit: %llu", thread_ctx.scratch[0].len, thread_ctx.scratch[0].memory.commit);
//log_info("Scratch2 len: %llu commit: %llu", thread_ctx.scratch[1].len, thread_ctx.scratch[1].memory.commit);
}
if (is_flag_set(compile_flags, COMPILE_AND_RUN)) {