Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: vm/flow_graph_optimizer.cc

Issue 10830275: Optimize expressions of the form (expr === true) when expr has boolean type. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: addressed comments Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/flow_graph_optimizer.h ('k') | vm/il_printer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/flow_graph_optimizer.h" 5 #include "vm/flow_graph_optimizer.h"
6 6
7 #include "vm/flow_graph_builder.h" 7 #include "vm/flow_graph_builder.h"
8 #include "vm/il_printer.h" 8 #include "vm/il_printer.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 10
11 namespace dart { 11 namespace dart {
12 12
13 DECLARE_FLAG(bool, eliminate_type_checks); 13 DECLARE_FLAG(bool, eliminate_type_checks);
14 DECLARE_FLAG(bool, enable_type_checks); 14 DECLARE_FLAG(bool, enable_type_checks);
15 DECLARE_FLAG(bool, trace_optimization); 15 DEFINE_FLAG(bool, trace_optimization, false, "Print optimization details.");
16 DECLARE_FLAG(bool, trace_type_check_elimination); 16 DECLARE_FLAG(bool, trace_type_check_elimination);
17 17
18 void FlowGraphOptimizer::ApplyICData() { 18 void FlowGraphOptimizer::ApplyICData() {
19 VisitBlocks(); 19 VisitBlocks();
20 } 20 }
21 21
22 22
23 void FlowGraphOptimizer::OptimizeComputations() {
24 for (intptr_t i = 0; i < block_order_.length(); ++i) {
25 BlockEntryInstr* entry = block_order_[i];
26 entry->Accept(this);
27 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
28 BindInstr* instr = it.Current()->AsBind();
29 if (instr != NULL) {
30 Definition* result = instr->computation()->TryReplace(instr);
31 if (result != NULL) {
32 // Replace uses and remove the current instructions via the iterator.
33 instr->ReplaceUsesWith(result);
34 it.RemoveCurrentFromGraph();
35 if (FLAG_trace_optimization) {
36 OS::Print("Replacing v%d with v%d\n",
37 instr->ssa_temp_index(),
38 result->ssa_temp_index());
39 }
40 }
41 }
42 }
43 }
44 }
45
46
23 static bool ICDataHasReceiverClassId(const ICData& ic_data, intptr_t class_id) { 47 static bool ICDataHasReceiverClassId(const ICData& ic_data, intptr_t class_id) {
24 ASSERT(ic_data.num_args_tested() > 0); 48 ASSERT(ic_data.num_args_tested() > 0);
25 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) { 49 for (intptr_t i = 0; i < ic_data.NumberOfChecks(); i++) {
26 const intptr_t test_class_id = ic_data.GetReceiverClassIdAt(i); 50 const intptr_t test_class_id = ic_data.GetReceiverClassIdAt(i);
27 if (test_class_id == class_id) { 51 if (test_class_id == class_id) {
28 return true; 52 return true;
29 } 53 }
30 } 54 }
31 return false; 55 return false;
32 } 56 }
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 LocationSummary* locs = it.Current()->locs(); 676 LocationSummary* locs = it.Current()->locs();
653 if ((locs != NULL) && locs->is_call()) { 677 if ((locs != NULL) && locs->is_call()) {
654 is_leaf_ = false; 678 is_leaf_ = false;
655 return; 679 return;
656 } 680 }
657 } 681 }
658 } 682 }
659 } 683 }
660 684
661 } // namespace dart 685 } // namespace dart
OLDNEW
« no previous file with comments | « vm/flow_graph_optimizer.h ('k') | vm/il_printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698