| Index: runtime/vm/precompiler.cc
|
| diff --git a/runtime/vm/precompiler.cc b/runtime/vm/precompiler.cc
|
| index f061da02c6905080a973bca7316e9dec985b45da..7000601bc549cc3da0aa236ab80d47122d4d798b 100644
|
| --- a/runtime/vm/precompiler.cc
|
| +++ b/runtime/vm/precompiler.cc
|
| @@ -17,6 +17,7 @@
|
| namespace dart {
|
|
|
|
|
| +#define T (thread())
|
| #define I (isolate())
|
| #define Z (zone())
|
|
|
| @@ -73,6 +74,10 @@ void Precompiler::DoCompileAll(
|
| // that we have already looked for the function's callees.
|
| ClearAllCode();
|
|
|
| + // Make sure class hierarchy is stable before compilation so that CHA
|
| + // can be used.
|
| + FinalizeAllClasses();
|
| +
|
| // Start with the allocations and invocations that happen from C++.
|
| AddRoots(embedder_entry_points);
|
|
|
| @@ -824,4 +829,24 @@ void Precompiler::VisitFunctions(FunctionVisitor* visitor) {
|
| }
|
| }
|
|
|
| +
|
| +void Precompiler::FinalizeAllClasses() {
|
| + Library& lib = Library::Handle(Z);
|
| + Class& cls = Class::Handle(Z);
|
| +
|
| + for (intptr_t i = 0; i < libraries_.Length(); i++) {
|
| + lib ^= libraries_.At(i);
|
| + ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
|
| + while (it.HasNext()) {
|
| + cls = it.GetNextClass();
|
| + if (cls.IsDynamicClass()) {
|
| + continue; // class 'dynamic' is in the read-only VM isolate.
|
| + }
|
| + cls.EnsureIsFinalized(T);
|
| + }
|
| + }
|
| + I->set_all_classes_finalized(true);
|
| +}
|
| +
|
| +
|
| } // namespace dart
|
|
|