From b5df18c8fd725a2993c520ddc8777ecad71e3d11 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 1 Dec 2019 00:29:16 -0500 Subject: inline ConstGlobalRefs into ZigValue Having ConstGlobalRefs be a pointer in ZigValue was a hack that caused plenty of bugs. It was used to work around difficulties in type coercing array values into slices. However, after #3787 is merged, array values no longer type coerce into slices, and so this provided an opportunity to clean up the code. This has the nice effect of reducing stage1 peak RAM usage during the std lib tests from 3.443 GiB to 3.405 GiB (saving 39 MiB). There is one behavior test failing in this branch, which I plan to debug after merging #3787. --- src/analyze.cpp | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index c0d2d636ef..abef74052e 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -5908,12 +5908,7 @@ ZigValue *create_const_arg_tuple(CodeGen *g, size_t arg_index_start, size_t arg_ ZigValue *create_const_vals(size_t count) { - ConstGlobalRefs *global_refs = allocate(count, "ConstGlobalRefs"); - ZigValue *vals = allocate(count, "ZigValue"); - for (size_t i = 0; i < count; i += 1) { - vals[i].global_refs = &global_refs[i]; - } - return vals; + return allocate(count, "ZigValue"); } ZigValue **alloc_const_vals_ptrs(size_t count) { @@ -6480,20 +6475,14 @@ bool const_values_equal_ptr(ZigValue *a, ZigValue *b) { return false; return true; case ConstPtrSpecialBaseArray: - if (a->data.x_ptr.data.base_array.array_val != b->data.x_ptr.data.base_array.array_val && - a->data.x_ptr.data.base_array.array_val->global_refs != - b->data.x_ptr.data.base_array.array_val->global_refs) - { + if (a->data.x_ptr.data.base_array.array_val != b->data.x_ptr.data.base_array.array_val) { return false; } if (a->data.x_ptr.data.base_array.elem_index != b->data.x_ptr.data.base_array.elem_index) return false; return true; case ConstPtrSpecialBaseStruct: - if (a->data.x_ptr.data.base_struct.struct_val != b->data.x_ptr.data.base_struct.struct_val && - a->data.x_ptr.data.base_struct.struct_val->global_refs != - b->data.x_ptr.data.base_struct.struct_val->global_refs) - { + if (a->data.x_ptr.data.base_struct.struct_val != b->data.x_ptr.data.base_struct.struct_val) { return false; } if (a->data.x_ptr.data.base_struct.field_index != b->data.x_ptr.data.base_struct.field_index) @@ -6501,27 +6490,21 @@ bool const_values_equal_ptr(ZigValue *a, ZigValue *b) { return true; case ConstPtrSpecialBaseErrorUnionCode: if (a->data.x_ptr.data.base_err_union_code.err_union_val != - b->data.x_ptr.data.base_err_union_code.err_union_val && - a->data.x_ptr.data.base_err_union_code.err_union_val->global_refs != - b->data.x_ptr.data.base_err_union_code.err_union_val->global_refs) + b->data.x_ptr.data.base_err_union_code.err_union_val) { return false; } return true; case ConstPtrSpecialBaseErrorUnionPayload: if (a->data.x_ptr.data.base_err_union_payload.err_union_val != - b->data.x_ptr.data.base_err_union_payload.err_union_val && - a->data.x_ptr.data.base_err_union_payload.err_union_val->global_refs != - b->data.x_ptr.data.base_err_union_payload.err_union_val->global_refs) + b->data.x_ptr.data.base_err_union_payload.err_union_val) { return false; } return true; case ConstPtrSpecialBaseOptionalPayload: if (a->data.x_ptr.data.base_optional_payload.optional_val != - b->data.x_ptr.data.base_optional_payload.optional_val && - a->data.x_ptr.data.base_optional_payload.optional_val->global_refs != - b->data.x_ptr.data.base_optional_payload.optional_val->global_refs) + b->data.x_ptr.data.base_optional_payload.optional_val) { return false; } -- cgit v1.2.3