Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Side by Side Diff: runtime/vm/precompiler.cc

Issue 1392893003: In precompilation, finalize all classes eagerly. Use the stable class hierarchy for doing CHA based… (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Sync Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/precompiler.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/precompiler.h" 5 #include "vm/precompiler.h"
6 6
7 #include "vm/code_patcher.h" 7 #include "vm/code_patcher.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/isolate.h" 9 #include "vm/isolate.h"
10 #include "vm/log.h" 10 #include "vm/log.h"
11 #include "vm/longjump.h" 11 #include "vm/longjump.h"
12 #include "vm/object.h" 12 #include "vm/object.h"
13 #include "vm/object_store.h" 13 #include "vm/object_store.h"
14 #include "vm/resolver.h" 14 #include "vm/resolver.h"
15 #include "vm/symbols.h" 15 #include "vm/symbols.h"
16 16
17 namespace dart { 17 namespace dart {
18 18
19 19
20 #define T (thread())
20 #define I (isolate()) 21 #define I (isolate())
21 #define Z (zone()) 22 #define Z (zone())
22 23
23 24
24 DEFINE_FLAG(bool, trace_precompiler, false, "Trace precompiler."); 25 DEFINE_FLAG(bool, trace_precompiler, false, "Trace precompiler.");
25 26
26 27
27 static void Jump(const Error& error) { 28 static void Jump(const Error& error) {
28 Thread::Current()->long_jump_base()->Jump(1, error); 29 Thread::Current()->long_jump_base()->Jump(1, error);
29 } 30 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 I->set_collected_closures(collected_closures_); 67 I->set_collected_closures(collected_closures_);
67 } 68 }
68 69
69 70
70 void Precompiler::DoCompileAll( 71 void Precompiler::DoCompileAll(
71 Dart_QualifiedFunctionName embedder_entry_points[]) { 72 Dart_QualifiedFunctionName embedder_entry_points[]) {
72 // Drop all existing code so we can use the presence of code as an indicator 73 // Drop all existing code so we can use the presence of code as an indicator
73 // that we have already looked for the function's callees. 74 // that we have already looked for the function's callees.
74 ClearAllCode(); 75 ClearAllCode();
75 76
77 // Make sure class hierarchy is stable before compilation so that CHA
78 // can be used.
79 FinalizeAllClasses();
80
76 // Start with the allocations and invocations that happen from C++. 81 // Start with the allocations and invocations that happen from C++.
77 AddRoots(embedder_entry_points); 82 AddRoots(embedder_entry_points);
78 83
79 // TODO(rmacnak): Eagerly add field-invocation functions to all signature 84 // TODO(rmacnak): Eagerly add field-invocation functions to all signature
80 // classes so closure calls don't go through the runtime. 85 // classes so closure calls don't go through the runtime.
81 86
82 // Compile newly found targets and add their callees until we reach a fixed 87 // Compile newly found targets and add their callees until we reach a fixed
83 // point. 88 // point.
84 Iterate(); 89 Iterate();
85 90
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 if (!closures.IsNull()) { 822 if (!closures.IsNull()) {
818 for (intptr_t j = 0; j < closures.Length(); j++) { 823 for (intptr_t j = 0; j < closures.Length(); j++) {
819 function ^= closures.At(j); 824 function ^= closures.At(j);
820 visitor->VisitFunction(function); 825 visitor->VisitFunction(function);
821 } 826 }
822 } 827 }
823 } 828 }
824 } 829 }
825 } 830 }
826 831
832
833 void Precompiler::FinalizeAllClasses() {
834 Library& lib = Library::Handle(Z);
835 Class& cls = Class::Handle(Z);
836
837 for (intptr_t i = 0; i < libraries_.Length(); i++) {
838 lib ^= libraries_.At(i);
839 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
840 while (it.HasNext()) {
841 cls = it.GetNextClass();
842 if (cls.IsDynamicClass()) {
843 continue; // class 'dynamic' is in the read-only VM isolate.
844 }
845 cls.EnsureIsFinalized(T);
846 }
847 }
848 I->set_all_classes_finalized(true);
849 }
850
851
827 } // namespace dart 852 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/precompiler.h ('k') | runtime/vm/raw_object_snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698