aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-12-01 00:29:16 -0500
committerAndrew Kelley <andrew@ziglang.org>2019-12-01 00:29:16 -0500
commitb5df18c8fd725a2993c520ddc8777ecad71e3d11 (patch)
tree7036027c6652261cfeafce4819c809f1808e58dc /src/analyze.cpp
parent951dc451d6d49fca499e9a722a3f543d6e8bf7c1 (diff)
downloadzig-b5df18c8fd725a2993c520ddc8777ecad71e3d11.tar.gz
zig-b5df18c8fd725a2993c520ddc8777ecad71e3d11.zip
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.
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp29
1 files changed, 6 insertions, 23 deletions
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<ConstGlobalRefs>(count, "ConstGlobalRefs");
- ZigValue *vals = allocate<ZigValue>(count, "ZigValue");
- for (size_t i = 0; i < count; i += 1) {
- vals[i].global_refs = &global_refs[i];
- }
- return vals;
+ return allocate<ZigValue>(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;
}