mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-31 02:12:04 +00:00
Make the heap_allocator just be the permanent_allocator
This improves the speed of the compiler with very little memory increase (which surprised me, Ginger Bill)
This commit is contained in:
@@ -1411,7 +1411,6 @@ gb_internal bool init_build_paths(String init_filename) {
|
||||
if ((bc->command_kind & Command__does_build) && (!bc->ignore_microsoft_magic)) {
|
||||
// NOTE(ic): It would be nice to extend this so that we could specify the Visual Studio version that we want instead of defaulting to the latest.
|
||||
Find_Result find_result = find_visual_studio_and_windows_sdk();
|
||||
defer (mc_free_all());
|
||||
|
||||
if (find_result.windows_sdk_version == 0) {
|
||||
gb_printf_err("Windows SDK not found.\n");
|
||||
|
||||
@@ -306,10 +306,11 @@ gb_internal gbAllocator temporary_allocator() {
|
||||
gb_internal GB_ALLOCATOR_PROC(heap_allocator_proc);
|
||||
|
||||
gb_internal gbAllocator heap_allocator(void) {
|
||||
gbAllocator a;
|
||||
a.proc = heap_allocator_proc;
|
||||
a.data = nullptr;
|
||||
return a;
|
||||
return arena_allocator(&permanent_arena);
|
||||
// gbAllocator a;
|
||||
// a.proc = heap_allocator_proc;
|
||||
// a.data = nullptr;
|
||||
// return a;
|
||||
}
|
||||
|
||||
|
||||
|
||||
13
src/main.cpp
13
src/main.cpp
@@ -1716,6 +1716,16 @@ gb_internal void show_timings(Checker *c, Timings *t) {
|
||||
|
||||
timings_print_all(t);
|
||||
|
||||
if (build_context.show_more_timings) {
|
||||
#if defined(GB_SYSTEM_WINDOWS)
|
||||
PROCESS_MEMORY_COUNTERS p = {sizeof(p)};
|
||||
if (GetProcessMemoryInfo(GetCurrentProcess(), &p, sizeof(p))) {
|
||||
gb_printf("\n");
|
||||
gb_printf("Peak Memory Size: %.3f MiB\n", (cast(f64)p.PeakWorkingSetSize) / cast(f64)(1024ull * 1024ull));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!(build_context.export_timings_format == TimingsExportUnspecified)) {
|
||||
timings_export_all(t, c, true);
|
||||
}
|
||||
@@ -2481,14 +2491,13 @@ int main(int arg_count, char const **arg_ptr) {
|
||||
usage(make_string_c(arg_ptr[0]));
|
||||
return 1;
|
||||
}
|
||||
virtual_memory_init();
|
||||
|
||||
timings_init(&global_timings, str_lit("Total Time"), 2048);
|
||||
defer (timings_destroy(&global_timings));
|
||||
|
||||
MAIN_TIME_SECTION("initialization");
|
||||
|
||||
virtual_memory_init();
|
||||
|
||||
init_string_interner();
|
||||
init_global_error_collector();
|
||||
init_keyword_hash_table();
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
//
|
||||
// Here is the API you need to know about:
|
||||
//
|
||||
gb_global gbAllocator mc_allocator = heap_allocator();
|
||||
gb_global gbAllocator mc_allocator = permanent_allocator();
|
||||
|
||||
struct Find_Result {
|
||||
int windows_sdk_version; // Zero if no Windows SDK found.
|
||||
@@ -91,10 +91,6 @@ gb_internal void mc_free(String16 str) {
|
||||
if (str.len) gb_free(mc_allocator, str.text);
|
||||
}
|
||||
|
||||
gb_internal void mc_free_all() {
|
||||
gb_free_all(mc_allocator);
|
||||
}
|
||||
|
||||
typedef struct _MC_Find_Data {
|
||||
DWORD file_attributes;
|
||||
String filename;
|
||||
|
||||
Reference in New Issue
Block a user