mirror of
https://github.com/ziglang/zig.git
synced 2025-12-08 07:13:08 +00:00
- split util_base.hpp from util.hpp - new namespaces: `mem` and `heap` - new `mem::Allocator` interface - new `heap::CAllocator` impl with global `heap::c_allocator` - new `heap::ArenaAllocator` impl - new `mem::TypeInfo` extracts names without RTTI - name extraction is enabled w/ ZIG_ENABLE_MEM_PROFILE=1 - new `mem::List` takes explicit `Allocator&` parameter - new `mem::HashMap` takes explicit `Allocator&` parameter - add Codegen.pass1_arena and use for all `ZigValue` allocs - deinit Codegen.pass1_arena early in `zig_llvm_emit_output()`
38 lines
763 B
C++
38 lines
763 B
C++
/*
|
|
* Copyright (c) 2020 Andrew Kelley
|
|
*
|
|
* This file is part of zig, which is MIT licensed.
|
|
* See http://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "config.h"
|
|
#include "mem.hpp"
|
|
#include "mem_profile.hpp"
|
|
#include "heap.hpp"
|
|
|
|
namespace mem {
|
|
|
|
void init() {
|
|
heap::bootstrap_allocator_state.init("heap::bootstrap_allocator");
|
|
heap::c_allocator_state.init("heap::c_allocator");
|
|
}
|
|
|
|
void deinit() {
|
|
heap::c_allocator_state.deinit();
|
|
heap::bootstrap_allocator_state.deinit();
|
|
}
|
|
|
|
#ifdef ZIG_ENABLE_MEM_PROFILE
|
|
void print_report(FILE *file) {
|
|
heap::c_allocator_state.print_report(file);
|
|
intern_counters.print_report(file);
|
|
}
|
|
#endif
|
|
|
|
#ifdef ZIG_ENABLE_MEM_PROFILE
|
|
bool report_print = false;
|
|
FILE *report_file{nullptr};
|
|
#endif
|
|
|
|
} // namespace mem
|