mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 14:32:24 +00:00
[vm] Reset closure functions cache when sorting class ids
Hashes of functions depend on the class ids, so cache of the closure functions should be cleared when class ids are sorted. This is safe to do because at that point all compiled code is cleared. TEST=ci Change-Id: Iaf3a66d1026611fc0a3df3903cb4e09e6d6c4c17 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311723 Reviewed-by: Ryan Macnak <rmacnak@google.com> Auto-Submit: Alexander Markov <alexmarkov@google.com> Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
274db26c57
commit
12c7455436
3 changed files with 16 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "vm/class_finalizer.h"
|
||||
|
||||
#include "vm/canonical_tables.h"
|
||||
#include "vm/closure_functions_cache.h"
|
||||
#include "vm/compiler/jit/compiler.h"
|
||||
#include "vm/flags.h"
|
||||
#include "vm/hash_table.h"
|
||||
|
@ -995,6 +996,7 @@ void ClassFinalizer::SortClasses() {
|
|||
RemapClassIds(old_to_new_cid.get());
|
||||
RehashTypes(); // Types use cid's as part of their hashes.
|
||||
IG->RehashConstants(); // Const objects use cid's as part of their hashes.
|
||||
ClosureFunctionsCache::ResetLocked(); // Function hashes depend on cids.
|
||||
}
|
||||
|
||||
class CidRewriteVisitor : public ObjectVisitor {
|
||||
|
|
|
@ -189,5 +189,16 @@ void ClosureFunctionsCache::ForAllClosureFunctions(
|
|||
}
|
||||
}
|
||||
}
|
||||
void ClosureFunctionsCache::ResetLocked() {
|
||||
auto thread = Thread::Current();
|
||||
auto zone = thread->zone();
|
||||
auto object_store = thread->isolate_group()->object_store();
|
||||
DEBUG_ASSERT(
|
||||
thread->isolate_group()->program_lock()->IsCurrentThreadWriter());
|
||||
|
||||
object_store->set_closure_functions_table(Object::null_array());
|
||||
object_store->set_closure_functions(
|
||||
GrowableObjectArray::Handle(zone, GrowableObjectArray::New()));
|
||||
}
|
||||
|
||||
} // namespace dart
|
||||
|
|
|
@ -59,6 +59,9 @@ class ClosureFunctionsCache : public AllStatic {
|
|||
// closure functions have been visited.
|
||||
static void ForAllClosureFunctions(
|
||||
std::function<bool(const Function&)> callback);
|
||||
|
||||
// Clear the cache of closure functions.
|
||||
static void ResetLocked();
|
||||
};
|
||||
|
||||
} // namespace dart
|
||||
|
|
Loading…
Reference in a new issue