| 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/cha.h" | 7 #include "vm/cha.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/hash_table.h" | 10 #include "vm/hash_table.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 } | 112 } |
| 113 | 113 |
| 114 DropUncompiledFunctions(); | 114 DropUncompiledFunctions(); |
| 115 DropFields(); | 115 DropFields(); |
| 116 | 116 |
| 117 // TODO(rmacnak): DropEmptyClasses(); | 117 // TODO(rmacnak): DropEmptyClasses(); |
| 118 | 118 |
| 119 BindStaticCalls(); | 119 BindStaticCalls(); |
| 120 | 120 |
| 121 DedupStackmaps(); | 121 DedupStackmaps(); |
| 122 DedupStackmapLists(); |
| 122 | 123 |
| 123 if (FLAG_trace_precompiler) { | 124 if (FLAG_trace_precompiler) { |
| 124 THR_Print("Precompiled %" Pd " functions, %" Pd " dynamic types," | 125 THR_Print("Precompiled %" Pd " functions, %" Pd " dynamic types," |
| 125 " %" Pd " dynamic selectors.\n Dropped %" Pd " functions, %" Pd | 126 " %" Pd " dynamic selectors.\n Dropped %" Pd " functions, %" Pd |
| 126 " fields.\n", | 127 " fields.\n", |
| 127 function_count_, | 128 function_count_, |
| 128 class_count_, | 129 class_count_, |
| 129 selector_count_, | 130 selector_count_, |
| 130 dropped_function_count_, | 131 dropped_function_count_, |
| 131 dropped_field_count_); | 132 dropped_field_count_); |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 Code& code_; | 1102 Code& code_; |
| 1102 Array& stackmaps_; | 1103 Array& stackmaps_; |
| 1103 Stackmap& stackmap_; | 1104 Stackmap& stackmap_; |
| 1104 }; | 1105 }; |
| 1105 | 1106 |
| 1106 DedupStackmapsVisitor visitor(Z); | 1107 DedupStackmapsVisitor visitor(Z); |
| 1107 VisitFunctions(&visitor); | 1108 VisitFunctions(&visitor); |
| 1108 } | 1109 } |
| 1109 | 1110 |
| 1110 | 1111 |
| 1112 void Precompiler::DedupStackmapLists() { |
| 1113 class DedupStackmapListsVisitor : public FunctionVisitor { |
| 1114 public: |
| 1115 explicit DedupStackmapListsVisitor(Zone* zone) : |
| 1116 zone_(zone), |
| 1117 canonical_stackmap_lists_(), |
| 1118 code_(Code::Handle(zone)), |
| 1119 stackmaps_(Array::Handle(zone)), |
| 1120 stackmap_(Stackmap::Handle(zone)) { |
| 1121 } |
| 1122 |
| 1123 void VisitFunction(const Function& function) { |
| 1124 if (!function.HasCode()) { |
| 1125 ASSERT(function.HasImplicitClosureFunction()); |
| 1126 return; |
| 1127 } |
| 1128 code_ = function.CurrentCode(); |
| 1129 stackmaps_ = code_.stackmaps(); |
| 1130 if (stackmaps_.IsNull()) return; |
| 1131 |
| 1132 stackmaps_ = DedupStackmapList(stackmaps_); |
| 1133 code_.set_stackmaps(stackmaps_); |
| 1134 } |
| 1135 |
| 1136 RawArray* DedupStackmapList(const Array& stackmaps) { |
| 1137 const Array* canonical_stackmap_list = |
| 1138 canonical_stackmap_lists_.Lookup(&stackmaps); |
| 1139 if (canonical_stackmap_list == NULL) { |
| 1140 canonical_stackmap_lists_.Insert( |
| 1141 &Array::ZoneHandle(zone_, stackmaps.raw())); |
| 1142 return stackmaps.raw(); |
| 1143 } else { |
| 1144 return canonical_stackmap_list->raw(); |
| 1145 } |
| 1146 } |
| 1147 |
| 1148 private: |
| 1149 Zone* zone_; |
| 1150 ArraySet canonical_stackmap_lists_; |
| 1151 Code& code_; |
| 1152 Array& stackmaps_; |
| 1153 Stackmap& stackmap_; |
| 1154 }; |
| 1155 |
| 1156 DedupStackmapListsVisitor visitor(Z); |
| 1157 VisitFunctions(&visitor); |
| 1158 } |
| 1159 |
| 1160 |
| 1111 void Precompiler::VisitFunctions(FunctionVisitor* visitor) { | 1161 void Precompiler::VisitFunctions(FunctionVisitor* visitor) { |
| 1112 Library& lib = Library::Handle(Z); | 1162 Library& lib = Library::Handle(Z); |
| 1113 Class& cls = Class::Handle(Z); | 1163 Class& cls = Class::Handle(Z); |
| 1114 Array& functions = Array::Handle(Z); | 1164 Array& functions = Array::Handle(Z); |
| 1115 Object& object = Object::Handle(Z); | 1165 Object& object = Object::Handle(Z); |
| 1116 Function& function = Function::Handle(Z); | 1166 Function& function = Function::Handle(Z); |
| 1117 GrowableObjectArray& closures = GrowableObjectArray::Handle(Z); | 1167 GrowableObjectArray& closures = GrowableObjectArray::Handle(Z); |
| 1118 | 1168 |
| 1119 for (intptr_t i = 0; i < libraries_.Length(); i++) { | 1169 for (intptr_t i = 0; i < libraries_.Length(); i++) { |
| 1120 lib ^= libraries_.At(i); | 1170 lib ^= libraries_.At(i); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 cls = it.GetNextClass(); | 1254 cls = it.GetNextClass(); |
| 1205 if (cls.IsDynamicClass()) { | 1255 if (cls.IsDynamicClass()) { |
| 1206 continue; // class 'dynamic' is in the read-only VM isolate. | 1256 continue; // class 'dynamic' is in the read-only VM isolate. |
| 1207 } | 1257 } |
| 1208 cls.set_is_allocated(false); | 1258 cls.set_is_allocated(false); |
| 1209 } | 1259 } |
| 1210 } | 1260 } |
| 1211 } | 1261 } |
| 1212 | 1262 |
| 1213 } // namespace dart | 1263 } // namespace dart |
| OLD | NEW |