Chromium Code Reviews| Index: runtime/vm/precompiler.cc |
| diff --git a/runtime/vm/precompiler.cc b/runtime/vm/precompiler.cc |
| index d2d0ef01bc064c4cf65eec399456ea59e3173d33..6360c30df8cc108bc582ac530eaf2b8a99bbe3dc 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()) |
| @@ -71,6 +72,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); |
| @@ -812,4 +817,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(thread()); |
|
rmacnak
2015/10/14 16:38:48
T, since you added it.
srdjan
2015/10/14 16:51:58
Done.
|
| + } |
| + } |
| + I->set_all_classes_finalized(true); |
| +} |
| + |
| + |
| } // namespace dart |