mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Reduce allocated Vmem for the compiler on 32 bit machines.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
- With avx512, passing a 512 bit vector in a union would be lowered incorrectly, causing an assert. #2362
|
||||
- Codegen error in `if (try x = (true ? io::EOF? : 1))`, i.e. using if-try with a known Empty.
|
||||
- Codegen error in `if (try x = (false ? io::EOF? : 1))`, i.e. using if-try with a CT known value.
|
||||
- Reduce allocated Vmem for the compiler on 32 bit machines.
|
||||
|
||||
### Stdlib changes
|
||||
- Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`.
|
||||
|
||||
@@ -40,6 +40,8 @@ static const char *out_name(void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define START_VMEM_SIZE (sizeof(size_t) == 4 ? 1024 : 4096)
|
||||
|
||||
void compiler_init(BuildOptions *build_options)
|
||||
{
|
||||
// Process --path
|
||||
@@ -76,13 +78,14 @@ void compiler_init(BuildOptions *build_options)
|
||||
compiler.context.module_list = NULL;
|
||||
compiler.context.generic_module_list = NULL;
|
||||
compiler.context.method_extensions = NULL;
|
||||
vmem_init(&ast_arena, 4096);
|
||||
|
||||
vmem_init(&ast_arena, START_VMEM_SIZE);
|
||||
ast_calloc();
|
||||
vmem_init(&expr_arena, 4096);
|
||||
vmem_init(&expr_arena, START_VMEM_SIZE);
|
||||
expr_calloc();
|
||||
vmem_init(&decl_arena, 4096);
|
||||
vmem_init(&decl_arena, START_VMEM_SIZE);
|
||||
decl_calloc();
|
||||
vmem_init(&type_info_arena, 4096);
|
||||
vmem_init(&type_info_arena, START_VMEM_SIZE);
|
||||
type_info_calloc();
|
||||
// Create zero index value.
|
||||
if (build_options->std_lib_dir)
|
||||
|
||||
@@ -14,11 +14,14 @@ static Vmem arena;
|
||||
uintptr_t arena_zero;
|
||||
static Vmem char_arena;
|
||||
|
||||
#define START_VMEM_SIZE (sizeof(size_t) == 4 ? 1024 : 4096)
|
||||
|
||||
void memory_init(size_t max_mem)
|
||||
{
|
||||
if (max_mem) vmem_set_max_limit(max_mem);
|
||||
vmem_init(&arena, 4096);
|
||||
vmem_init(&char_arena, 2048);
|
||||
|
||||
vmem_init(&arena, START_VMEM_SIZE);
|
||||
vmem_init(&char_arena, START_VMEM_SIZE / 2);
|
||||
allocations_done = 0;
|
||||
arena_zero = (uintptr_t)arena.ptr;
|
||||
vmem_alloc(&arena, 16);
|
||||
@@ -73,7 +76,7 @@ void run_arena_allocator_tests(void)
|
||||
ASSERT(calloc_arena(10) != calloc_arena(10) && "Expected different values...");
|
||||
printf("-- Tested basic allocation - OK.\n");
|
||||
ASSERT(arena.allocated == 48 && "Expected allocations rounded to next 16 bytes");
|
||||
calloc_arena(1);
|
||||
(void)calloc_arena(1);
|
||||
ASSERT(arena.allocated == 64 && "Expected allocations rounded to next 16 bytes");
|
||||
printf("-- Tested allocation alignment - OK.\n");
|
||||
ASSERT(calloc_arena(1024 * 1024) != NULL && "Expected allocation to work");
|
||||
|
||||
Reference in New Issue
Block a user