Skip to content

Commit 8999635

Browse files
creliercommit-bot@chromium.org
authored andcommitted
[VM/runtime] Tighten asserts and do not allow duplicate canonical recursive types.
Several improvements in previous CLs should have eliminated duplicate canonical recursive types. TEST=existing ones Change-Id: Ic7ef6ea614baa678a9aa99d3f2cae4ceadc71396 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200884 Reviewed-by: Alexander Markov <[email protected]> Commit-Queue: Régis Crelier <[email protected]>
1 parent 899654d commit 8999635

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

runtime/vm/class_finalizer.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,8 +1653,7 @@ void ClassFinalizer::RehashTypes() {
16531653
for (intptr_t i = 0; i < types.Length(); i++) {
16541654
type ^= types.At(i);
16551655
bool present = types_table.Insert(type);
1656-
// Two recursive types with different topology (and hashes) may be equal.
1657-
ASSERT(!present || type.IsRecursive());
1656+
ASSERT(!present);
16581657
}
16591658
object_store->set_canonical_types(types_table.Release());
16601659

@@ -1674,8 +1673,7 @@ void ClassFinalizer::RehashTypes() {
16741673
for (intptr_t i = 0; i < function_types.Length(); i++) {
16751674
function_type ^= function_types.At(i);
16761675
bool present = function_types_table.Insert(function_type);
1677-
// Two recursive types with different topology (and hashes) may be equal.
1678-
ASSERT(!present || function_type.IsRecursive());
1676+
ASSERT(!present);
16791677
}
16801678
object_store->set_canonical_function_types(function_types_table.Release());
16811679

@@ -1695,8 +1693,7 @@ void ClassFinalizer::RehashTypes() {
16951693
for (intptr_t i = 0; i < typeparams.Length(); i++) {
16961694
typeparam ^= typeparams.At(i);
16971695
bool present = typeparams_table.Insert(typeparam);
1698-
// Two recursive types with different topology (and hashes) may be equal.
1699-
ASSERT(!present || typeparam.IsRecursive());
1696+
ASSERT(!present);
17001697
}
17011698
object_store->set_canonical_type_parameters(typeparams_table.Release());
17021699

@@ -1720,8 +1717,7 @@ void ClassFinalizer::RehashTypes() {
17201717
for (intptr_t i = 0; i < typeargs.Length(); i++) {
17211718
typearg ^= typeargs.At(i);
17221719
bool present = typeargs_table.Insert(typearg);
1723-
// Two recursive types with different topology (and hashes) may be equal.
1724-
ASSERT(!present || typearg.IsRecursive());
1720+
ASSERT(!present);
17251721
}
17261722
object_store->set_canonical_type_arguments(typeargs_table.Release());
17271723
}

runtime/vm/clustered_snapshot.cc

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -533,14 +533,8 @@ class CanonicalSetSerializationCluster : public SerializationCluster {
533533
element ^= ptr;
534534
intptr_t entry = -1;
535535
const bool present = table.FindKeyOrDeletedOrUnused(element, &entry);
536-
if (!present) {
537-
table.InsertKey(entry, element);
538-
} else {
539-
// Two recursive types with different topology (and hashes)
540-
// may be equal.
541-
ASSERT(element.IsRecursive());
542-
objects_[num_occupied++] = ptr;
543-
}
536+
ASSERT(!present);
537+
table.InsertKey(entry, element);
544538
} else {
545539
objects_[num_occupied++] = ptr;
546540
}

0 commit comments

Comments
 (0)