diff options
| author | Michael Dusan <michael.dusan@gmail.com> | 2019-11-25 19:19:32 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-11-25 19:19:32 -0500 |
| commit | 6b7e1085e38878419547ea74f0ce7259636b80b8 (patch) | |
| tree | 453be0063701daa889aa4b29d54cb93a89f4c336 /src/codegen.cpp | |
| parent | fe254ea309f7e95f492d8c8e706c73267082b5a3 (diff) | |
| parent | 6c89f96df1484fc5017eb484f0f8270ab4be341f (diff) | |
| download | zig-6b7e1085e38878419547ea74f0ce7259636b80b8.tar.gz zig-6b7e1085e38878419547ea74f0ce7259636b80b8.zip | |
Merge pull request #3774 from mikdusan/stage1-intern-housekeeping
stage1: consolodate interning
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 59 |
1 files changed, 46 insertions, 13 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index 30ac5af4a1..327ab76425 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -8010,29 +8010,36 @@ static void define_builtin_types(CodeGen *g) { static void define_intern_values(CodeGen *g) { { - auto& value = g->intern_values.x_undefined; + auto& value = g->intern.x_undefined; value.type = g->builtin_types.entry_undef; value.global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs.undefined"); value.special = ConstValSpecialStatic; } { - auto& value = g->intern_values.x_void; + auto& value = g->intern.x_void; value.type = g->builtin_types.entry_void; value.global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs.void"); value.special = ConstValSpecialStatic; } { - auto& value = g->intern_values.x_null; + auto& value = g->intern.x_null; value.type = g->builtin_types.entry_null; value.global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs.null"); value.special = ConstValSpecialStatic; } { - auto& value = g->intern_values.x_unreachable; + auto& value = g->intern.x_unreachable; value.type = g->builtin_types.entry_unreachable; value.global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs.unreachable"); value.special = ConstValSpecialStatic; } + { + auto& value = g->intern.zero_byte; + value.type = g->builtin_types.entry_u8; + value.global_refs = allocate<ConstGlobalRefs>(1, "ConstGlobalRefs.zero_byte"); + value.special = ConstValSpecialStatic; + bigint_init_unsigned(&value.data.x_bigint, 0); + } } static BuiltinFnEntry *create_builtin_fn(CodeGen *g, BuiltinFnId id, const char *name, size_t count) { @@ -8669,15 +8676,6 @@ static void init(CodeGen *g) { g->unreach_instruction->value->type = g->builtin_types.entry_unreachable; g->unreach_instruction->value->global_refs = allocate<ConstGlobalRefs>(1); - g->const_void_val.special = ConstValSpecialStatic; - g->const_void_val.type = g->builtin_types.entry_void; - g->const_void_val.global_refs = allocate<ConstGlobalRefs>(1); - - g->const_zero_byte.special = ConstValSpecialStatic; - g->const_zero_byte.type = g->builtin_types.entry_u8; - g->const_zero_byte.global_refs = allocate<ConstGlobalRefs>(1); - bigint_init_unsigned(&g->const_zero_byte.data.x_bigint, 0); - { ConstGlobalRefs *global_refs = allocate<ConstGlobalRefs>(PanicMsgIdCount); for (size_t i = 0; i < PanicMsgIdCount; i += 1) { @@ -10564,3 +10562,38 @@ void codegen_switch_sub_prog_node(CodeGen *g, Stage2ProgressNode *node) { } g->sub_progress_node = node; } + +ZigValue *CodeGen::Intern::for_undefined() { +#ifdef ZIG_ENABLE_MEM_PROFILE + memprof_intern_count.x_undefined += 1; +#endif + return &this->x_undefined; +} + +ZigValue *CodeGen::Intern::for_void() { +#ifdef ZIG_ENABLE_MEM_PROFILE + memprof_intern_count.x_void += 1; +#endif + return &this->x_void; +} + +ZigValue *CodeGen::Intern::for_null() { +#ifdef ZIG_ENABLE_MEM_PROFILE + memprof_intern_count.x_null += 1; +#endif + return &this->x_null; +} + +ZigValue *CodeGen::Intern::for_unreachable() { +#ifdef ZIG_ENABLE_MEM_PROFILE + memprof_intern_count.x_unreachable += 1; +#endif + return &this->x_unreachable; +} + +ZigValue *CodeGen::Intern::for_zero_byte() { +#ifdef ZIG_ENABLE_MEM_PROFILE + memprof_intern_count.zero_byte += 1; +#endif + return &this->zero_byte; +} |
