OLD | NEW |
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" |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 class_count_, | 117 class_count_, |
118 selector_count_, | 118 selector_count_, |
119 dropped_function_count_); | 119 dropped_function_count_); |
120 } | 120 } |
121 | 121 |
122 I->set_compilation_allowed(false); | 122 I->set_compilation_allowed(false); |
123 } | 123 } |
124 | 124 |
125 | 125 |
126 void Precompiler::ClearAllCode() { | 126 void Precompiler::ClearAllCode() { |
127 class CodeCodeFunctionVisitor : public FunctionVisitor { | 127 class ClearCodeFunctionVisitor : public FunctionVisitor { |
128 void VisitFunction(const Function& function) { | 128 void VisitFunction(const Function& function) { |
129 function.ClearCode(); | 129 function.ClearCode(); |
130 } | 130 } |
131 }; | 131 }; |
132 CodeCodeFunctionVisitor visitor; | 132 ClearCodeFunctionVisitor visitor; |
133 VisitFunctions(&visitor); | 133 VisitFunctions(&visitor); |
134 } | 134 } |
135 | 135 |
136 | 136 |
137 void Precompiler::AddRoots(Dart_QualifiedFunctionName embedder_entry_points[]) { | 137 void Precompiler::AddRoots(Dart_QualifiedFunctionName embedder_entry_points[]) { |
138 // Note that <rootlibrary>.main is not a root. The appropriate main will be | 138 // Note that <rootlibrary>.main is not a root. The appropriate main will be |
139 // discovered through _getMainClosure. | 139 // discovered through _getMainClosure. |
140 | 140 |
141 AddSelector(Symbols::NoSuchMethod()); | 141 AddSelector(Symbols::NoSuchMethod()); |
142 | 142 |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 } | 581 } |
582 } | 582 } |
583 } | 583 } |
584 | 584 |
585 | 585 |
586 void Precompiler::AddInstantiatedClass(const Class& cls) { | 586 void Precompiler::AddInstantiatedClass(const Class& cls) { |
587 if (cls.is_allocated()) return; | 587 if (cls.is_allocated()) return; |
588 | 588 |
589 class_count_++; | 589 class_count_++; |
590 cls.set_is_allocated(true); | 590 cls.set_is_allocated(true); |
591 cls.EnsureIsFinalized(T); | 591 error_ = cls.EnsureIsFinalized(T); |
| 592 if (!error_.IsNull()) { |
| 593 Jump(error_); |
| 594 } |
| 595 |
592 changed_ = true; | 596 changed_ = true; |
593 | 597 |
594 if (FLAG_trace_precompiler) { | 598 if (FLAG_trace_precompiler) { |
595 THR_Print("Allocation %" Pd " %s\n", class_count_, cls.ToCString()); | 599 THR_Print("Allocation %" Pd " %s\n", class_count_, cls.ToCString()); |
596 } | 600 } |
597 | 601 |
598 const Class& superclass = Class::Handle(cls.SuperClass()); | 602 const Class& superclass = Class::Handle(cls.SuperClass()); |
599 if (!superclass.IsNull()) { | 603 if (!superclass.IsNull()) { |
600 AddInstantiatedClass(superclass); | 604 AddInstantiatedClass(superclass); |
601 } | 605 } |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
916 "Did you forget to call Dart_FinalizeLoading?", uri.ToCString())); | 920 "Did you forget to call Dart_FinalizeLoading?", uri.ToCString())); |
917 Jump(Error::Handle(Z, ApiError::New(msg))); | 921 Jump(Error::Handle(Z, ApiError::New(msg))); |
918 } | 922 } |
919 | 923 |
920 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); | 924 ClassDictionaryIterator it(lib, ClassDictionaryIterator::kIteratePrivate); |
921 while (it.HasNext()) { | 925 while (it.HasNext()) { |
922 cls = it.GetNextClass(); | 926 cls = it.GetNextClass(); |
923 if (cls.IsDynamicClass()) { | 927 if (cls.IsDynamicClass()) { |
924 continue; // class 'dynamic' is in the read-only VM isolate. | 928 continue; // class 'dynamic' is in the read-only VM isolate. |
925 } | 929 } |
926 cls.EnsureIsFinalized(T); | 930 error_ = cls.EnsureIsFinalized(T); |
| 931 if (!error_.IsNull()) { |
| 932 Jump(error_); |
| 933 } |
927 } | 934 } |
928 } | 935 } |
929 I->set_all_classes_finalized(true); | 936 I->set_all_classes_finalized(true); |
930 } | 937 } |
931 | 938 |
932 | 939 |
933 void Precompiler::ResetPrecompilerState() { | 940 void Precompiler::ResetPrecompilerState() { |
934 changed_ = false; | 941 changed_ = false; |
935 function_count_ = 0; | 942 function_count_ = 0; |
936 class_count_ = 0; | 943 class_count_ = 0; |
(...skipping 13 matching lines...) Expand all Loading... |
950 cls = it.GetNextClass(); | 957 cls = it.GetNextClass(); |
951 if (cls.IsDynamicClass()) { | 958 if (cls.IsDynamicClass()) { |
952 continue; // class 'dynamic' is in the read-only VM isolate. | 959 continue; // class 'dynamic' is in the read-only VM isolate. |
953 } | 960 } |
954 cls.set_is_allocated(false); | 961 cls.set_is_allocated(false); |
955 } | 962 } |
956 } | 963 } |
957 } | 964 } |
958 | 965 |
959 } // namespace dart | 966 } // namespace dart |
OLD | NEW |