Skip to content

Commit

Permalink
[vm] Add library private key to the Class hash function for reload.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
aam authored and commit-bot@chromium.org committed Sep 14, 2018
1 parent 4fab565 commit 078be2c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 12 additions & 1 deletion runtime/vm/isolate_reload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#include "vm/bit_vector.h"
#include "vm/compiler/jit/compiler.h"
#include "vm/dart_api_impl.h"
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/hash.h"
#endif
#include "vm/hash_table.h"
#include "vm/heap/become.h"
#include "vm/heap/safepoint.h"
Expand Down Expand Up @@ -328,7 +331,15 @@ class ClassMapTraits {
}

static uword Hash(const Object& obj) {
return String::HashRawSymbol(Class::Cast(obj).Name());
uword class_name_hash = String::HashRawSymbol(Class::Cast(obj).Name());
RawLibrary* raw_library = Class::Cast(obj).library();
if (raw_library == Library::null()) {
return class_name_hash;
}
return FinalizeHash(
CombineHashes(class_name_hash,
String::Hash(Library::Handle(raw_library).private_key())),
/* hashbits= */ 30);
}
};

Expand Down
1 change: 0 additions & 1 deletion runtime/vm/object_reload.cc
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,6 @@ void Class::CheckReload(const Class& replacement,
if (is_prefinalized()) {
if (!CanReloadPreFinalized(replacement, context)) return;
}
ASSERT(is_finalized() == replacement.is_finalized());
TIR_Print("Class `%s` can be reloaded (%" Pd " and %" Pd ")\n", ToCString(),
id(), replacement.id());
}
Expand Down

0 comments on commit 078be2c

Please sign in to comment.