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

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: 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
« runtime/vm/object.cc ('K') | « runtime/vm/precompiler.h ('k') | no next file » | 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 error_(Error::Handle(Z)) { 65 error_(Error::Handle(Z)) {
65 } 66 }
66 67
67 68
68 void Precompiler::DoCompileAll( 69 void Precompiler::DoCompileAll(
69 Dart_QualifiedFunctionName embedder_entry_points[]) { 70 Dart_QualifiedFunctionName embedder_entry_points[]) {
70 // Drop all existing code so we can use the presence of code as an indicator 71 // Drop all existing code so we can use the presence of code as an indicator
71 // that we have already looked for the function's callees. 72 // that we have already looked for the function's callees.
72 ClearAllCode(); 73 ClearAllCode();
73 74
75 // Make sure class hierarchy is stable before compilation so that CHA
76 // can be used.
77 FinalizeAllClasses();
78
74 // Start with the allocations and invocations that happen from C++. 79 // Start with the allocations and invocations that happen from C++.
75 AddRoots(embedder_entry_points); 80 AddRoots(embedder_entry_points);
76 81
77 // TODO(rmacnak): Eagerly add field-invocation functions to all signature 82 // TODO(rmacnak): Eagerly add field-invocation functions to all signature
78 // classes so closure calls don't go through the runtime. 83 // classes so closure calls don't go through the runtime.
79 84
80 // Compile newly found targets and add their callees until we reach a fixed 85 // Compile newly found targets and add their callees until we reach a fixed
81 // point. 86 // point.
82 Iterate(); 87 Iterate();
83 88
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 if (!closures.IsNull()) { 810 if (!closures.IsNull()) {
806 for (intptr_t j = 0; j < closures.Length(); j++) { 811 for (intptr_t j = 0; j < closures.Length(); j++) {
807 function ^= closures.At(j); 812 function ^= closures.At(j);
808 visitor->VisitFunction(function); 813 visitor->VisitFunction(function);
809 } 814 }
810 } 815 }
811 } 816 }
812 } 817 }
813 } 818 }
814 819
820
821 void Precompiler::FinalizeAllClasses() {
822 Library& lib = Library::Handle(Z);
823 Class& cls = Class::Handle(Z);
824
825 for (intptr_t i = 0; i < libraries_.Length(); i++) {
826 lib ^= libraries_.At(i);
827 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate);
828 while (it.HasNext()) {
829 cls = it.GetNextClass();
830 if (cls.IsDynamicClass()) {
831 continue; // class 'dynamic' is in the read-only VM isolate.
832 }
833 cls.EnsureIsFinalized(thread());
rmacnak 2015/10/14 16:38:48 T, since you added it.
srdjan 2015/10/14 16:51:58 Done.
834 }
835 }
836 I->set_all_classes_finalized(true);
837 }
838
839
815 } // namespace dart 840 } // namespace dart
OLDNEW
« runtime/vm/object.cc ('K') | « runtime/vm/precompiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698