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/aot_optimizer.h" | 7 #include "vm/aot_optimizer.h" |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
10 #include "vm/branch_optimizer.h" | 10 #include "vm/branch_optimizer.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 ClassTable* table = thread_->isolate()->class_table(); | 269 ClassTable* table = thread_->isolate()->class_table(); |
270 Class& cls = Class::Handle(zone); | 270 Class& cls = Class::Handle(zone); |
271 AbstractType& cls_type = AbstractType::Handle(zone); | 271 AbstractType& cls_type = AbstractType::Handle(zone); |
272 for (intptr_t cid = kInstanceCid; cid < table->NumCids(); cid++) { | 272 for (intptr_t cid = kInstanceCid; cid < table->NumCids(); cid++) { |
273 // Create local zone because deep hierarchies may allocate lots of handles | 273 // Create local zone because deep hierarchies may allocate lots of handles |
274 // within one iteration of this loop. | 274 // within one iteration of this loop. |
275 StackZone stack_zone(thread_); | 275 StackZone stack_zone(thread_); |
276 HANDLESCOPE(thread_); | 276 HANDLESCOPE(thread_); |
277 | 277 |
278 if (!table->HasValidClassAt(cid)) continue; | 278 if (!table->HasValidClassAt(cid)) continue; |
| 279 if (cid == kTypeArgumentsCid) continue; |
279 if (cid == kVoidCid) continue; | 280 if (cid == kVoidCid) continue; |
280 if (cid == kDynamicCid) continue; | 281 if (cid == kDynamicCid) continue; |
281 if (cid == kNullCid) continue; // Instance is not at Bottom like Null type. | 282 if (cid == kNullCid) continue; // Instance is not at Bottom like Null type. |
282 cls = table->At(cid); | 283 cls = table->At(cid); |
283 if (cls.is_abstract()) continue; | 284 if (cls.is_abstract()) continue; |
284 if (cls.is_patch()) continue; | 285 if (cls.is_patch()) continue; |
285 if (cls.IsTopLevel()) continue; | 286 if (cls.IsTopLevel()) continue; |
286 | 287 |
287 cls_type = cls.RareType(); | 288 cls_type = cls.RareType(); |
288 if (cls_type.IsSubtypeOf(type, NULL, NULL, Heap::kNew)) { | 289 if (cls_type.IsSubtypeOf(type, NULL, NULL, Heap::kNew)) { |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 | 667 |
667 AddSelector(Symbols::Call()); // For speed, not correctness. | 668 AddSelector(Symbols::Call()); // For speed, not correctness. |
668 | 669 |
669 // Allocated from C++. | 670 // Allocated from C++. |
670 Class& cls = Class::Handle(Z); | 671 Class& cls = Class::Handle(Z); |
671 for (intptr_t cid = kInstanceCid; cid < kNumPredefinedCids; cid++) { | 672 for (intptr_t cid = kInstanceCid; cid < kNumPredefinedCids; cid++) { |
672 ASSERT(isolate()->class_table()->IsValidIndex(cid)); | 673 ASSERT(isolate()->class_table()->IsValidIndex(cid)); |
673 if (!isolate()->class_table()->HasValidClassAt(cid)) { | 674 if (!isolate()->class_table()->HasValidClassAt(cid)) { |
674 continue; | 675 continue; |
675 } | 676 } |
676 if ((cid == kDynamicCid) || (cid == kVoidCid) || | 677 if ((cid == kTypeArgumentsCid) || (cid == kDynamicCid) || |
677 (cid == kFreeListElement) || (cid == kForwardingCorpse)) { | 678 (cid == kVoidCid) || (cid == kFreeListElement) || |
| 679 (cid == kForwardingCorpse)) { |
678 continue; | 680 continue; |
679 } | 681 } |
680 cls = isolate()->class_table()->At(cid); | 682 cls = isolate()->class_table()->At(cid); |
681 AddInstantiatedClass(cls); | 683 AddInstantiatedClass(cls); |
682 } | 684 } |
683 | 685 |
684 AddEntryPoints(vm_entry_points); | 686 AddEntryPoints(vm_entry_points); |
685 AddEntryPoints(embedder_entry_points); | 687 AddEntryPoints(embedder_entry_points); |
686 const Library& lib = Library::Handle(I->object_store()->root_library()); | 688 const Library& lib = Library::Handle(I->object_store()->root_library()); |
687 const String& name = String::Handle(String::New("main")); | 689 const String& name = String::Handle(String::New("main")); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 } | 959 } |
958 } else if (entry.IsField()) { | 960 } else if (entry.IsField()) { |
959 // Potential need for field initializer. | 961 // Potential need for field initializer. |
960 field ^= entry.raw(); | 962 field ^= entry.raw(); |
961 AddField(field); | 963 AddField(field); |
962 } else if (entry.IsInstance()) { | 964 } else if (entry.IsInstance()) { |
963 // Const object, literal or args descriptor. | 965 // Const object, literal or args descriptor. |
964 instance ^= entry.raw(); | 966 instance ^= entry.raw(); |
965 if (entry.IsAbstractType()) { | 967 if (entry.IsAbstractType()) { |
966 AddType(AbstractType::Cast(entry)); | 968 AddType(AbstractType::Cast(entry)); |
| 969 } else if (entry.IsTypeArguments()) { |
| 970 AddTypeArguments(TypeArguments::Cast(entry)); |
967 } else { | 971 } else { |
968 AddConstObject(instance); | 972 AddConstObject(instance); |
969 } | 973 } |
970 } else if (entry.IsFunction()) { | 974 } else if (entry.IsFunction()) { |
971 // Local closure function. | 975 // Local closure function. |
972 target ^= entry.raw(); | 976 target ^= entry.raw(); |
973 AddFunction(target); | 977 AddFunction(target); |
974 } else if (entry.IsCode()) { | 978 } else if (entry.IsCode()) { |
975 target_code ^= entry.raw(); | 979 target_code ^= entry.raw(); |
976 if (target_code.IsAllocationStubCode()) { | 980 if (target_code.IsAllocationStubCode()) { |
977 cls ^= target_code.owner(); | 981 cls ^= target_code.owner(); |
978 AddInstantiatedClass(cls); | 982 AddInstantiatedClass(cls); |
979 } | 983 } |
980 } else if (entry.IsTypeArguments()) { | |
981 AddTypeArguments(TypeArguments::Cast(entry)); | |
982 } | 984 } |
983 } | 985 } |
984 } | 986 } |
985 | 987 |
986 const Array& inlined_functions = | 988 const Array& inlined_functions = |
987 Array::Handle(Z, code.inlined_id_to_function()); | 989 Array::Handle(Z, code.inlined_id_to_function()); |
988 for (intptr_t i = 0; i < inlined_functions.Length(); i++) { | 990 for (intptr_t i = 0; i < inlined_functions.Length(); i++) { |
989 target ^= inlined_functions.At(i); | 991 target ^= inlined_functions.At(i); |
990 AddTypesOf(target); | 992 AddTypesOf(target); |
991 } | 993 } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 class ConstObjectVisitor : public ObjectPointerVisitor { | 1152 class ConstObjectVisitor : public ObjectPointerVisitor { |
1151 public: | 1153 public: |
1152 ConstObjectVisitor(Precompiler* precompiler, Isolate* isolate) | 1154 ConstObjectVisitor(Precompiler* precompiler, Isolate* isolate) |
1153 : ObjectPointerVisitor(isolate), | 1155 : ObjectPointerVisitor(isolate), |
1154 precompiler_(precompiler), | 1156 precompiler_(precompiler), |
1155 subinstance_(Object::Handle()) {} | 1157 subinstance_(Object::Handle()) {} |
1156 | 1158 |
1157 virtual void VisitPointers(RawObject** first, RawObject** last) { | 1159 virtual void VisitPointers(RawObject** first, RawObject** last) { |
1158 for (RawObject** current = first; current <= last; current++) { | 1160 for (RawObject** current = first; current <= last; current++) { |
1159 subinstance_ = *current; | 1161 subinstance_ = *current; |
1160 if (subinstance_.IsInstance()) { | 1162 if (subinstance_.IsTypeArguments()) { |
| 1163 precompiler_->AddTypeArguments(TypeArguments::Cast(subinstance_)); |
| 1164 } else if (subinstance_.IsInstance()) { |
1161 precompiler_->AddConstObject(Instance::Cast(subinstance_)); | 1165 precompiler_->AddConstObject(Instance::Cast(subinstance_)); |
1162 } | 1166 } |
1163 } | 1167 } |
1164 subinstance_ = Object::null(); | 1168 subinstance_ = Object::null(); |
1165 } | 1169 } |
1166 | 1170 |
1167 private: | 1171 private: |
1168 Precompiler* precompiler_; | 1172 Precompiler* precompiler_; |
1169 Object& subinstance_; | 1173 Object& subinstance_; |
1170 }; | 1174 }; |
(...skipping 2701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3872 } | 3876 } |
3873 result[idx++] = NULL; | 3877 result[idx++] = NULL; |
3874 renames_map.Release(); | 3878 renames_map.Release(); |
3875 | 3879 |
3876 return result; | 3880 return result; |
3877 } | 3881 } |
3878 | 3882 |
3879 #endif // DART_PRECOMPILER | 3883 #endif // DART_PRECOMPILER |
3880 | 3884 |
3881 } // namespace dart | 3885 } // namespace dart |
OLD | NEW |