| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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/redundancy_elimination.h" | 5 #include "vm/redundancy_elimination.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/flow_graph.h" | 8 #include "vm/flow_graph.h" |
| 9 #include "vm/hash_map.h" | 9 #include "vm/hash_map.h" |
| 10 #include "vm/il_printer.h" | 10 #include "vm/il_printer.h" |
| (...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1542 | 1542 |
| 1543 Isolate* isolate() const { return graph_->isolate(); } | 1543 Isolate* isolate() const { return graph_->isolate(); } |
| 1544 Zone* zone() const { return graph_->zone(); } | 1544 Zone* zone() const { return graph_->zone(); } |
| 1545 | 1545 |
| 1546 static bool OptimizeGraph(FlowGraph* graph) { | 1546 static bool OptimizeGraph(FlowGraph* graph) { |
| 1547 ASSERT(FLAG_load_cse); | 1547 ASSERT(FLAG_load_cse); |
| 1548 if (FLAG_trace_load_optimization) { | 1548 if (FLAG_trace_load_optimization) { |
| 1549 FlowGraphPrinter::PrintGraph("Before LoadOptimizer", graph); | 1549 FlowGraphPrinter::PrintGraph("Before LoadOptimizer", graph); |
| 1550 } | 1550 } |
| 1551 | 1551 |
| 1552 // For now, bail out for large functions to avoid OOM situations. |
| 1553 // TODO(fschneider): Fix the memory consumption issue. |
| 1554 intptr_t function_length = |
| 1555 graph->function().end_token_pos().Pos() - |
| 1556 graph->function().token_pos().Pos(); |
| 1557 if (function_length >= FLAG_huge_method_cutoff_in_tokens) { |
| 1558 return false; |
| 1559 } |
| 1560 |
| 1552 DirectChainedHashMap<PointerKeyValueTrait<Place> > map; | 1561 DirectChainedHashMap<PointerKeyValueTrait<Place> > map; |
| 1553 AliasedSet* aliased_set = NumberPlaces(graph, &map, kOptimizeLoads); | 1562 AliasedSet* aliased_set = NumberPlaces(graph, &map, kOptimizeLoads); |
| 1554 if ((aliased_set != NULL) && !aliased_set->IsEmpty()) { | 1563 if ((aliased_set != NULL) && !aliased_set->IsEmpty()) { |
| 1555 // If any loads were forwarded return true from Optimize to run load | 1564 // If any loads were forwarded return true from Optimize to run load |
| 1556 // forwarding again. This will allow to forward chains of loads. | 1565 // forwarding again. This will allow to forward chains of loads. |
| 1557 // This is especially important for context variables as they are built | 1566 // This is especially important for context variables as they are built |
| 1558 // as loads from loaded context. | 1567 // as loads from loaded context. |
| 1559 // TODO(vegorov): renumber newly discovered congruences during the | 1568 // TODO(vegorov): renumber newly discovered congruences during the |
| 1560 // forwarding to forward chains without running whole pass twice. | 1569 // forwarding to forward chains without running whole pass twice. |
| 1561 LoadOptimizer load_optimizer(graph, aliased_set); | 1570 LoadOptimizer load_optimizer(graph, aliased_set); |
| (...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2507 exposed_stores_.Add(NULL); | 2516 exposed_stores_.Add(NULL); |
| 2508 } | 2517 } |
| 2509 } | 2518 } |
| 2510 | 2519 |
| 2511 static void OptimizeGraph(FlowGraph* graph) { | 2520 static void OptimizeGraph(FlowGraph* graph) { |
| 2512 ASSERT(FLAG_load_cse); | 2521 ASSERT(FLAG_load_cse); |
| 2513 if (FLAG_trace_load_optimization) { | 2522 if (FLAG_trace_load_optimization) { |
| 2514 FlowGraphPrinter::PrintGraph("Before StoreOptimizer", graph); | 2523 FlowGraphPrinter::PrintGraph("Before StoreOptimizer", graph); |
| 2515 } | 2524 } |
| 2516 | 2525 |
| 2526 // For now, bail out for large functions to avoid OOM situations. |
| 2527 // TODO(fschneider): Fix the memory consumption issue. |
| 2528 intptr_t function_length = |
| 2529 graph->function().end_token_pos().Pos() - |
| 2530 graph->function().token_pos().Pos(); |
| 2531 if (function_length >= FLAG_huge_method_cutoff_in_tokens) { |
| 2532 return; |
| 2533 } |
| 2534 |
| 2517 DirectChainedHashMap<PointerKeyValueTrait<Place> > map; | 2535 DirectChainedHashMap<PointerKeyValueTrait<Place> > map; |
| 2518 AliasedSet* aliased_set = NumberPlaces(graph, &map, kOptimizeStores); | 2536 AliasedSet* aliased_set = NumberPlaces(graph, &map, kOptimizeStores); |
| 2519 if ((aliased_set != NULL) && !aliased_set->IsEmpty()) { | 2537 if ((aliased_set != NULL) && !aliased_set->IsEmpty()) { |
| 2520 StoreOptimizer store_optimizer(graph, aliased_set, &map); | 2538 StoreOptimizer store_optimizer(graph, aliased_set, &map); |
| 2521 store_optimizer.Optimize(); | 2539 store_optimizer.Optimize(); |
| 2522 } | 2540 } |
| 2523 } | 2541 } |
| 2524 | 2542 |
| 2525 private: | 2543 private: |
| 2526 void Optimize() { | 2544 void Optimize() { |
| (...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3464 join->phis_ = NULL; | 3482 join->phis_ = NULL; |
| 3465 } else { | 3483 } else { |
| 3466 join->phis_->TruncateTo(to_index); | 3484 join->phis_->TruncateTo(to_index); |
| 3467 } | 3485 } |
| 3468 } | 3486 } |
| 3469 } | 3487 } |
| 3470 } | 3488 } |
| 3471 | 3489 |
| 3472 | 3490 |
| 3473 } // namespace dart | 3491 } // namespace dart |
| OLD | NEW |