[vm] Remove ValidateConstants.

This is already skipped for AOT and is unfixable after the DropTransitiveUserDefinedConstants optimizations.
This is already skipped for reload and is unfixable for issues related to 40442.
The non-reload JIT case isn't very interesting since each kernel constant will be loaded only once anyway.

TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/27003
Bug: https://github.com/dart-lang/sdk/issues/44862
Change-Id: I0676a96426142600f4ed9ec638b344a858aab7dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/314480
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2023-07-19 17:26:50 +00:00 committed by Commit Queue
parent 5016361ccd
commit e50470568b
8 changed files with 0 additions and 202 deletions

View file

@ -8830,7 +8830,6 @@ FullSnapshotWriter::FullSnapshotWriter(
#if defined(DEBUG)
isolate_group()->ValidateClassTable();
isolate_group()->ValidateConstants();
#endif // DEBUG
#if defined(DART_PRECOMPILER)

View file

@ -1491,11 +1491,6 @@ DART_EXPORT void Dart_ShutdownIsolate() {
{
StackZone zone(T);
HandleScope handle_scope(T);
#if defined(DEBUG)
if (T->isolate()->origin_id() == 0) {
T->isolate_group()->ValidateConstants();
}
#endif
Dart::RunShutdownCallback();
}
Dart::ShutdownIsolate(T);

View file

@ -104,24 +104,4 @@ void VerifyPointersVisitor::VerifyPointers(const char* msg,
isolate_group->VisitWeakPersistentHandles(&weak_visitor);
}
#if defined(DEBUG)
VerifyCanonicalVisitor::VerifyCanonicalVisitor(Thread* thread)
: thread_(thread), instanceHandle_(Instance::Handle(thread->zone())) {}
void VerifyCanonicalVisitor::VisitObject(ObjectPtr obj) {
if (!IsInternalOnlyClassId(obj->GetClassId()) &&
(obj->GetClassId() != kTypeArgumentsCid)) {
if (obj->untag()->IsCanonical()) {
instanceHandle_ ^= obj;
const bool is_canonical = instanceHandle_.CheckIsCanonical(thread_);
if (!is_canonical) {
OS::PrintErr("Instance `%s` is not canonical!\n",
instanceHandle_.ToCString());
}
ASSERT(is_canonical);
}
}
}
#endif // defined(DEBUG)
} // namespace dart

View file

@ -906,31 +906,6 @@ void IsolateGroup::RehashConstants() {
heap()->ResetCanonicalHashTable();
}
#if defined(DEBUG)
void IsolateGroup::ValidateConstants() {
if (FLAG_precompiled_mode) {
// TODO(27003)
return;
}
// Issue(https://dartbug.com/44862): Figure out why hot-reload causes
// existence of non-canonical constants.
if (HasAttemptedReload()) {
return;
}
// Verify that all canonical instances are correctly setup in the
// corresponding canonical tables.
NoBackgroundCompilerScope no_bg_compiler(Thread::Current());
heap()->CollectAllGarbage(GCReason::kDebugging);
Thread* thread = Thread::Current();
SafepointMutexLocker ml(
thread->isolate_group()->constant_canonicalization_mutex());
HeapIterationScope iteration(thread);
VerifyCanonicalVisitor check_canonical(thread);
iteration.IterateObjects(&check_canonical);
}
#endif // DEBUG
void Isolate::SendInternalLibMessage(LibMsgId msg_id, uint64_t capability) {
const bool ok = SendInternalLibMessage(main_port(), msg_id, capability);
if (!ok) UNREACHABLE();

View file

@ -287,7 +287,6 @@ class IsolateGroup : public IntrusiveDListEntry<IsolateGroup> {
void RehashConstants();
#if defined(DEBUG)
void ValidateConstants();
void ValidateClassTable();
#endif

View file

@ -1849,10 +1849,6 @@ void ProgramReloadContext::CommitAfterInstanceMorphing() {
IG->RehashConstants();
}
#ifdef DEBUG
IG->ValidateConstants();
#endif
if (FLAG_identity_reload) {
const auto& saved_libs = GrowableObjectArray::Handle(saved_libraries_);
const GrowableObjectArray& libs =

View file

@ -20624,19 +20624,6 @@ InstancePtr Instance::CanonicalizeLocked(Thread* thread) const {
return cls.InsertCanonicalConstant(zone, result);
}
#if defined(DEBUG)
bool Instance::CheckIsCanonical(Thread* thread) const {
Zone* zone = thread->zone();
Instance& result = Instance::Handle(zone);
const Class& cls = Class::Handle(zone, this->clazz());
ASSERT(thread->isolate_group()
->constant_canonicalization_mutex()
->IsOwnedByCurrentThread());
result ^= cls.LookupCanonicalInstance(zone, *this);
return (result.ptr() == this->ptr());
}
#endif // DEBUG
ObjectPtr Instance::GetField(const Field& field) const {
if (field.is_unboxed()) {
switch (field.guarded_cid()) {
@ -22526,40 +22513,6 @@ AbstractTypePtr Type::Canonicalize(Thread* thread) const {
return type.ptr();
}
#if defined(DEBUG)
bool Type::CheckIsCanonical(Thread* thread) const {
const classid_t cid = type_class_id();
if (cid == kDynamicCid) {
return (ptr() == Object::dynamic_type().ptr());
}
if (cid == kVoidCid) {
return (ptr() == Object::void_type().ptr());
}
Zone* zone = thread->zone();
auto isolate_group = thread->isolate_group();
Type& type = Type::Handle(zone);
const Class& cls = Class::Handle(zone, type_class());
// Fast canonical lookup/registry for simple types.
if (IsDeclarationTypeOf(cls)) {
type = cls.declaration_type();
ASSERT(type.IsCanonical());
return (ptr() == type.ptr());
}
ObjectStore* object_store = isolate_group->object_store();
{
ASSERT(thread->isolate_group()
->constant_canonicalization_mutex()
->IsOwnedByCurrentThread());
CanonicalTypeSet table(zone, object_store->canonical_types());
type ^= table.GetOrNull(CanonicalTypeKey(*this));
object_store->set_canonical_types(table.Release());
}
return (ptr() == type.ptr());
}
#endif // DEBUG
void Type::EnumerateURIs(URIs* uris) const {
if (IsDynamicType() || IsVoidType() || IsNeverType()) {
return;
@ -22886,25 +22839,6 @@ AbstractTypePtr FunctionType::Canonicalize(Thread* thread) const {
return sig.ptr();
}
#if defined(DEBUG)
bool FunctionType::CheckIsCanonical(Thread* thread) const {
Zone* zone = thread->zone();
auto isolate_group = thread->isolate_group();
FunctionType& type = FunctionType::Handle(zone);
ObjectStore* object_store = isolate_group->object_store();
{
ASSERT(thread->isolate_group()
->constant_canonicalization_mutex()
->IsOwnedByCurrentThread());
CanonicalFunctionTypeSet table(zone,
object_store->canonical_function_types());
type ^= table.GetOrNull(CanonicalFunctionTypeKey(*this));
object_store->set_canonical_function_types(table.Release());
}
return ptr() == type.ptr();
}
#endif // DEBUG
void FunctionType::EnumerateURIs(URIs* uris) const {
Thread* thread = Thread::Current();
Zone* zone = thread->zone();
@ -23226,26 +23160,6 @@ AbstractTypePtr TypeParameter::Canonicalize(Thread* thread) const {
return type_parameter.ptr();
}
#if defined(DEBUG)
bool TypeParameter::CheckIsCanonical(Thread* thread) const {
Zone* zone = thread->zone();
auto isolate_group = thread->isolate_group();
TypeParameter& type_parameter = TypeParameter::Handle(zone);
ObjectStore* object_store = isolate_group->object_store();
{
ASSERT(thread->isolate_group()
->constant_canonicalization_mutex()
->IsOwnedByCurrentThread());
CanonicalTypeParameterSet table(zone,
object_store->canonical_type_parameters());
type_parameter ^= table.GetOrNull(CanonicalTypeParameterKey(*this));
object_store->set_canonical_type_parameters(table.Release());
}
return (ptr() == type_parameter.ptr());
}
#endif // DEBUG
void TypeParameter::PrintName(NameVisibility name_visibility,
BaseTextBuffer* printer) const {
const TypeParameter& type_param = TypeParameter::Cast(*this);
@ -24085,14 +23999,6 @@ InstancePtr String::CanonicalizeLocked(Thread* thread) const {
return Symbols::New(Thread::Current(), *this);
}
#if defined(DEBUG)
bool String::CheckIsCanonical(Thread* thread) const {
Zone* zone = thread->zone();
const String& str = String::Handle(zone, Symbols::Lookup(thread, *this));
return (str.ptr() == this->ptr());
}
#endif // DEBUG
StringPtr String::New(const char* cstr, Heap::Space space) {
ASSERT(cstr != nullptr);
intptr_t array_len = strlen(cstr);
@ -28014,24 +27920,6 @@ AbstractTypePtr RecordType::Canonicalize(Thread* thread) const {
return rec.ptr();
}
#if defined(DEBUG)
bool RecordType::CheckIsCanonical(Thread* thread) const {
Zone* zone = thread->zone();
auto isolate_group = thread->isolate_group();
RecordType& type = RecordType::Handle(zone);
ObjectStore* object_store = isolate_group->object_store();
{
ASSERT(thread->isolate_group()
->constant_canonicalization_mutex()
->IsOwnedByCurrentThread());
CanonicalRecordTypeSet table(zone, object_store->canonical_record_types());
type ^= table.GetOrNull(CanonicalRecordTypeKey(*this));
object_store->set_canonical_record_types(table.Release());
}
return ptr() == type.ptr();
}
#endif // DEBUG
void RecordType::EnumerateURIs(URIs* uris) const {
AbstractType& type = AbstractType::Handle();
const intptr_t num_fields = NumFields();

View file

@ -8128,11 +8128,6 @@ class Instance : public Object {
InstancePtr CopyShallowToOldSpace(Thread* thread) const;
#if defined(DEBUG)
// Check if instance is canonical.
virtual bool CheckIsCanonical(Thread* thread) const;
#endif // DEBUG
ObjectPtr GetField(const Field& field) const;
void SetField(const Field& field, const Object& value) const;
@ -9027,14 +9022,6 @@ class AbstractType : public Instance {
// Return the canonical version of this type.
virtual AbstractTypePtr Canonicalize(Thread* thread) const;
#if defined(DEBUG)
// Check if abstract type is canonical.
virtual bool CheckIsCanonical(Thread* thread) const {
UNREACHABLE();
return false;
}
#endif // DEBUG
// Add the pair <name, uri> to the list, if not already present.
static void AddURI(URIs* uris, const String& name, const String& uri);
@ -9308,10 +9295,6 @@ class Type : public AbstractType {
FunctionTypeMapping* function_type_mapping) const;
virtual AbstractTypePtr Canonicalize(Thread* thread) const;
#if defined(DEBUG)
// Check if type is canonical.
virtual bool CheckIsCanonical(Thread* thread) const;
#endif // DEBUG
virtual void EnumerateURIs(URIs* uris) const;
virtual void PrintName(NameVisibility visibility,
BaseTextBuffer* printer) const;
@ -9448,10 +9431,6 @@ class FunctionType : public AbstractType {
FunctionTypeMapping* function_type_mapping) const;
virtual AbstractTypePtr Canonicalize(Thread* thread) const;
#if defined(DEBUG)
// Check if type is canonical.
virtual bool CheckIsCanonical(Thread* thread) const;
#endif // DEBUG
virtual void EnumerateURIs(URIs* uris) const;
virtual void PrintName(NameVisibility visibility,
BaseTextBuffer* printer) const;
@ -9754,10 +9733,6 @@ class TypeParameter : public AbstractType {
FunctionTypeMapping* function_type_mapping) const;
virtual AbstractTypePtr Canonicalize(Thread* thread) const;
#if defined(DEBUG)
// Check if type parameter is canonical.
virtual bool CheckIsCanonical(Thread* thread) const;
#endif // DEBUG
virtual void EnumerateURIs(URIs* uris) const { return; }
virtual void PrintName(NameVisibility visibility,
BaseTextBuffer* printer) const;
@ -10211,11 +10186,6 @@ class String : public Instance {
// Caller must hold IsolateGroup::constant_canonicalization_mutex_.
virtual InstancePtr CanonicalizeLocked(Thread* thread) const;
#if defined(DEBUG)
// Check if string is canonical.
virtual bool CheckIsCanonical(Thread* thread) const;
#endif // DEBUG
bool IsSymbol() const { return ptr()->untag()->IsCanonical(); }
bool IsOneByteString() const {
@ -11467,10 +11437,6 @@ class RecordType : public AbstractType {
FunctionTypeMapping* function_type_mapping) const;
virtual AbstractTypePtr Canonicalize(Thread* thread) const;
#if defined(DEBUG)
// Check if type is canonical.
virtual bool CheckIsCanonical(Thread* thread) const;
#endif // DEBUG
virtual void EnumerateURIs(URIs* uris) const;
virtual void PrintName(NameVisibility visibility,
BaseTextBuffer* printer) const;