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 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 I->object_store()->set_completer_class(null_class); | 389 I->object_store()->set_completer_class(null_class); |
390 I->object_store()->set_stream_iterator_class(null_class); | 390 I->object_store()->set_stream_iterator_class(null_class); |
391 I->object_store()->set_symbol_class(null_class); | 391 I->object_store()->set_symbol_class(null_class); |
392 } | 392 } |
393 DropClasses(); | 393 DropClasses(); |
394 DropLibraries(); | 394 DropLibraries(); |
395 | 395 |
396 BindStaticCalls(); | 396 BindStaticCalls(); |
397 SwitchICCalls(); | 397 SwitchICCalls(); |
398 | 398 |
| 399 MegamorphicCache::ShareEmptyBuckets(); |
399 DedupStackmaps(); | 400 DedupStackmaps(); |
400 DedupStackmapLists(); | 401 DedupLists(); |
401 | 402 |
402 if (FLAG_dedup_instructions) { | 403 if (FLAG_dedup_instructions) { |
403 // Reduces binary size but obfuscates profiler results. | 404 // Reduces binary size but obfuscates profiler results. |
404 DedupInstructions(); | 405 DedupInstructions(); |
405 } | 406 } |
406 | 407 |
407 zone_ = NULL; | 408 zone_ = NULL; |
408 } | 409 } |
409 | 410 |
410 intptr_t symbols_before = -1; | 411 intptr_t symbols_before = -1; |
(...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2195 Code& code_; | 2196 Code& code_; |
2196 Array& stackmaps_; | 2197 Array& stackmaps_; |
2197 Stackmap& stackmap_; | 2198 Stackmap& stackmap_; |
2198 }; | 2199 }; |
2199 | 2200 |
2200 DedupStackmapsVisitor visitor(Z); | 2201 DedupStackmapsVisitor visitor(Z); |
2201 VisitFunctions(&visitor); | 2202 VisitFunctions(&visitor); |
2202 } | 2203 } |
2203 | 2204 |
2204 | 2205 |
2205 void Precompiler::DedupStackmapLists() { | 2206 void Precompiler::DedupLists() { |
2206 class DedupStackmapListsVisitor : public FunctionVisitor { | 2207 class DedupListsVisitor : public FunctionVisitor { |
2207 public: | 2208 public: |
2208 explicit DedupStackmapListsVisitor(Zone* zone) : | 2209 explicit DedupListsVisitor(Zone* zone) : |
2209 zone_(zone), | 2210 zone_(zone), |
2210 canonical_stackmap_lists_(), | 2211 canonical_lists_(), |
2211 code_(Code::Handle(zone)), | 2212 code_(Code::Handle(zone)), |
2212 stackmaps_(Array::Handle(zone)), | 2213 list_(Array::Handle(zone)) { |
2213 stackmap_(Stackmap::Handle(zone)) { | |
2214 } | 2214 } |
2215 | 2215 |
2216 void Visit(const Function& function) { | 2216 void Visit(const Function& function) { |
2217 if (!function.HasCode()) { | 2217 code_ = function.CurrentCode(); |
2218 return; | 2218 if (!code_.IsNull()) { |
| 2219 list_ = code_.stackmaps(); |
| 2220 if (!list_.IsNull()) { |
| 2221 list_ = DedupList(list_); |
| 2222 code_.set_stackmaps(list_); |
| 2223 } |
2219 } | 2224 } |
2220 code_ = function.CurrentCode(); | |
2221 stackmaps_ = code_.stackmaps(); | |
2222 if (stackmaps_.IsNull()) return; | |
2223 | 2225 |
2224 stackmaps_ = DedupStackmapList(stackmaps_); | 2226 list_ = function.parameter_types(); |
2225 code_.set_stackmaps(stackmaps_); | 2227 if (!list_.IsNull()) { |
| 2228 if (!function.IsSignatureFunction() && |
| 2229 !function.IsClosureFunction() && |
| 2230 (function.name() != Symbols::Call().raw()) && |
| 2231 !list_.InVMHeap()) { |
| 2232 // Parameter types not needed for function type tests. |
| 2233 for (intptr_t i = 0; i < list_.Length(); i++) { |
| 2234 list_.SetAt(i, Object::dynamic_type()); |
| 2235 } |
| 2236 } |
| 2237 list_ = DedupList(list_); |
| 2238 function.set_parameter_types(list_); |
| 2239 } |
| 2240 |
| 2241 list_ = function.parameter_names(); |
| 2242 if (!list_.IsNull()) { |
| 2243 if (!function.HasOptionalNamedParameters() && |
| 2244 !list_.InVMHeap()) { |
| 2245 // Parameter names not needed for resolution. |
| 2246 for (intptr_t i = 0; i < list_.Length(); i++) { |
| 2247 list_.SetAt(i, Symbols::OptimizedOut()); |
| 2248 } |
| 2249 } |
| 2250 list_ = DedupList(list_); |
| 2251 function.set_parameter_names(list_); |
| 2252 } |
2226 } | 2253 } |
2227 | 2254 |
2228 RawArray* DedupStackmapList(const Array& stackmaps) { | 2255 RawArray* DedupList(const Array& list) { |
2229 const Array* canonical_stackmap_list = | 2256 const Array* canonical_list = canonical_lists_.LookupValue(&list); |
2230 canonical_stackmap_lists_.LookupValue(&stackmaps); | 2257 if (canonical_list == NULL) { |
2231 if (canonical_stackmap_list == NULL) { | 2258 canonical_lists_.Insert(&Array::ZoneHandle(zone_, list.raw())); |
2232 canonical_stackmap_lists_.Insert( | 2259 return list.raw(); |
2233 &Array::ZoneHandle(zone_, stackmaps.raw())); | |
2234 return stackmaps.raw(); | |
2235 } else { | 2260 } else { |
2236 return canonical_stackmap_list->raw(); | 2261 return canonical_list->raw(); |
2237 } | 2262 } |
2238 } | 2263 } |
2239 | 2264 |
2240 private: | 2265 private: |
2241 Zone* zone_; | 2266 Zone* zone_; |
2242 ArraySet canonical_stackmap_lists_; | 2267 ArraySet canonical_lists_; |
2243 Code& code_; | 2268 Code& code_; |
2244 Array& stackmaps_; | 2269 Array& list_; |
2245 Stackmap& stackmap_; | |
2246 }; | 2270 }; |
2247 | 2271 |
2248 DedupStackmapListsVisitor visitor(Z); | 2272 DedupListsVisitor visitor(Z); |
2249 VisitFunctions(&visitor); | 2273 VisitFunctions(&visitor); |
2250 } | 2274 } |
2251 | 2275 |
2252 | 2276 |
2253 void Precompiler::DedupInstructions() { | 2277 void Precompiler::DedupInstructions() { |
2254 class DedupInstructionsVisitor : public FunctionVisitor { | 2278 class DedupInstructionsVisitor : public FunctionVisitor { |
2255 public: | 2279 public: |
2256 explicit DedupInstructionsVisitor(Zone* zone) : | 2280 explicit DedupInstructionsVisitor(Zone* zone) : |
2257 zone_(zone), | 2281 zone_(zone), |
2258 canonical_instructions_set_(), | 2282 canonical_instructions_set_(), |
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3266 | 3290 |
3267 ASSERT(FLAG_precompiled_mode); | 3291 ASSERT(FLAG_precompiled_mode); |
3268 const bool optimized = function.IsOptimizable(); // False for natives. | 3292 const bool optimized = function.IsOptimizable(); // False for natives. |
3269 DartPrecompilationPipeline pipeline(zone, field_type_map); | 3293 DartPrecompilationPipeline pipeline(zone, field_type_map); |
3270 return PrecompileFunctionHelper(&pipeline, function, optimized); | 3294 return PrecompileFunctionHelper(&pipeline, function, optimized); |
3271 } | 3295 } |
3272 | 3296 |
3273 #endif // DART_PRECOMPILER | 3297 #endif // DART_PRECOMPILER |
3274 | 3298 |
3275 } // namespace dart | 3299 } // namespace dart |
OLD | NEW |