Skip to content

Commit 078be2c

Browse files
aamcommit-bot@chromium.org
authored andcommitted
[vm] Add library private key to the Class hash function for reload.
This reduces isolate reload time on a given sample from ~2 seconds to ~200 milliseconds. Remove ASSERT - you can have replacement finalized when original was non-finalized Bug: #34461 Change-Id: I39dc5d67e97bd7c0d654cd751b6829b00337e967 Reviewed-on: https://dart-review.googlesource.com/74961 Commit-Queue: Alexander Aprelev <aam@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
1 parent 4fab565 commit 078be2c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

runtime/vm/isolate_reload.cc

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#include "vm/bit_vector.h"
88
#include "vm/compiler/jit/compiler.h"
99
#include "vm/dart_api_impl.h"
10+
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
11+
#include "vm/hash.h"
12+
#endif
1013
#include "vm/hash_table.h"
1114
#include "vm/heap/become.h"
1215
#include "vm/heap/safepoint.h"
@@ -328,7 +331,15 @@ class ClassMapTraits {
328331
}
329332

330333
static uword Hash(const Object& obj) {
331-
return String::HashRawSymbol(Class::Cast(obj).Name());
334+
uword class_name_hash = String::HashRawSymbol(Class::Cast(obj).Name());
335+
RawLibrary* raw_library = Class::Cast(obj).library();
336+
if (raw_library == Library::null()) {
337+
return class_name_hash;
338+
}
339+
return FinalizeHash(
340+
CombineHashes(class_name_hash,
341+
String::Hash(Library::Handle(raw_library).private_key())),
342+
/* hashbits= */ 30);
332343
}
333344
};
334345

runtime/vm/object_reload.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,6 @@ void Class::CheckReload(const Class& replacement,
591591
if (is_prefinalized()) {
592592
if (!CanReloadPreFinalized(replacement, context)) return;
593593
}
594-
ASSERT(is_finalized() == replacement.is_finalized());
595594
TIR_Print("Class `%s` can be reloaded (%" Pd " and %" Pd ")\n", ToCString(),
596595
id(), replacement.id());
597596
}

0 commit comments

Comments
 (0)