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

Side by Side Diff: runtime/vm/flow_graph_optimizer.cc

Issue 10869063: Add attributions so printf like functions can have their arguments checked. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebased Created 8 years, 3 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 | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/freelist.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/cha.h" 7 #include "vm/cha.h"
8 #include "vm/flow_graph_builder.h" 8 #include "vm/flow_graph_builder.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 20 matching lines...) Expand all
31 BlockEntryInstr* entry = block_order_[i]; 31 BlockEntryInstr* entry = block_order_[i];
32 entry->Accept(this); 32 entry->Accept(this);
33 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) { 33 for (ForwardInstructionIterator it(entry); !it.Done(); it.Advance()) {
34 Definition* defn = it.Current()->AsDefinition(); 34 Definition* defn = it.Current()->AsDefinition();
35 if (defn != NULL) { 35 if (defn != NULL) {
36 Definition* result = defn->Canonicalize(); 36 Definition* result = defn->Canonicalize();
37 if (result != defn) { 37 if (result != defn) {
38 if (result != NULL) { 38 if (result != NULL) {
39 defn->ReplaceUsesWith(result); 39 defn->ReplaceUsesWith(result);
40 if (FLAG_trace_optimization) { 40 if (FLAG_trace_optimization) {
41 OS::Print("Replacing v%d with v%d\n", 41 OS::Print("Replacing v%"Pd" with v%"Pd"\n",
42 defn->ssa_temp_index(), 42 defn->ssa_temp_index(),
43 result->ssa_temp_index()); 43 result->ssa_temp_index());
44 } 44 }
45 } else if (FLAG_trace_optimization) { 45 } else if (FLAG_trace_optimization) {
46 OS::Print("Removing v%d.\n", defn->ssa_temp_index()); 46 OS::Print("Removing v%"Pd".\n", defn->ssa_temp_index());
47 } 47 }
48 it.RemoveCurrentFromGraph(); 48 it.RemoveCurrentFromGraph();
49 } 49 }
50 } 50 }
51 } 51 }
52 } 52 }
53 } 53 }
54 54
55 55
56 static Definition* CreateConversion(Representation from, 56 static Definition* CreateConversion(Representation from,
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 910
911 Value* use = instr->value(); 911 Value* use = instr->value();
912 ASSERT(use != NULL); 912 ASSERT(use != NULL);
913 Definition* result = use->definition(); 913 Definition* result = use->definition();
914 ASSERT(result != NULL); 914 ASSERT(result != NULL);
915 // Replace uses and remove the current instruction via the iterator. 915 // Replace uses and remove the current instruction via the iterator.
916 instr->ReplaceUsesWith(result); 916 instr->ReplaceUsesWith(result);
917 ASSERT(current_iterator()->Current() == instr); 917 ASSERT(current_iterator()->Current() == instr);
918 current_iterator()->RemoveCurrentFromGraph(); 918 current_iterator()->RemoveCurrentFromGraph();
919 if (FLAG_trace_optimization) { 919 if (FLAG_trace_optimization) {
920 OS::Print("Replacing v%d with v%d\n", 920 OS::Print("Replacing v%"Pd" with v%"Pd"\n",
921 instr->ssa_temp_index(), 921 instr->ssa_temp_index(),
922 result->ssa_temp_index()); 922 result->ssa_temp_index());
923 } 923 }
924 924
925 if (FLAG_trace_type_check_elimination) { 925 if (FLAG_trace_type_check_elimination) {
926 FlowGraphPrinter::PrintTypeCheck(parsed_function(), 926 FlowGraphPrinter::PrintTypeCheck(parsed_function(),
927 instr->token_pos(), 927 instr->token_pos(),
928 instr->value(), 928 instr->value(),
929 instr->dst_type(), 929 instr->dst_type(),
930 instr->dst_name(), 930 instr->dst_name(),
(...skipping 20 matching lines...) Expand all
951 instr->eliminate(); 951 instr->eliminate();
952 952
953 Value* use = instr->value(); 953 Value* use = instr->value();
954 Definition* result = use->definition(); 954 Definition* result = use->definition();
955 ASSERT(result != NULL); 955 ASSERT(result != NULL);
956 // Replace uses and remove the current instruction via the iterator. 956 // Replace uses and remove the current instruction via the iterator.
957 instr->ReplaceUsesWith(result); 957 instr->ReplaceUsesWith(result);
958 ASSERT(current_iterator()->Current() == instr); 958 ASSERT(current_iterator()->Current() == instr);
959 current_iterator()->RemoveCurrentFromGraph(); 959 current_iterator()->RemoveCurrentFromGraph();
960 if (FLAG_trace_optimization) { 960 if (FLAG_trace_optimization) {
961 OS::Print("Replacing v%d with v%d\n", 961 OS::Print("Replacing v%"Pd" with v%"Pd"\n",
962 instr->ssa_temp_index(), 962 instr->ssa_temp_index(),
963 result->ssa_temp_index()); 963 result->ssa_temp_index());
964 } 964 }
965 965
966 if (FLAG_trace_type_check_elimination) { 966 if (FLAG_trace_type_check_elimination) {
967 const String& name = String::Handle(Symbols::New("boolean expression")); 967 const String& name = String::Handle(Symbols::New("boolean expression"));
968 FlowGraphPrinter::PrintTypeCheck(parsed_function(), 968 FlowGraphPrinter::PrintTypeCheck(parsed_function(),
969 instr->token_pos(), 969 instr->token_pos(),
970 instr->value(), 970 instr->value(),
971 Type::Handle(Type::BoolType()), 971 Type::Handle(Type::BoolType()),
(...skipping 18 matching lines...) Expand all
990 !instr->value()->BindsToConstantNull() && 990 !instr->value()->BindsToConstantNull() &&
991 instr->value()->CompileTypeIsMoreSpecificThan(instr->type())) { 991 instr->value()->CompileTypeIsMoreSpecificThan(instr->type())) {
992 Value* use = instr->value(); 992 Value* use = instr->value();
993 Definition* result = use->definition(); 993 Definition* result = use->definition();
994 ASSERT(result != NULL); 994 ASSERT(result != NULL);
995 // Replace uses and remove the current instruction via the iterator. 995 // Replace uses and remove the current instruction via the iterator.
996 instr->ReplaceUsesWith(result); 996 instr->ReplaceUsesWith(result);
997 ASSERT(current_iterator()->Current() == instr); 997 ASSERT(current_iterator()->Current() == instr);
998 current_iterator()->RemoveCurrentFromGraph(); 998 current_iterator()->RemoveCurrentFromGraph();
999 if (FLAG_trace_optimization) { 999 if (FLAG_trace_optimization) {
1000 OS::Print("Replacing v%d with v%d\n", 1000 OS::Print("Replacing v%"Pd" with v%"Pd"\n",
1001 instr->ssa_temp_index(), 1001 instr->ssa_temp_index(),
1002 result->ssa_temp_index()); 1002 result->ssa_temp_index());
1003 } 1003 }
1004 1004
1005 if (FLAG_trace_type_check_elimination) { 1005 if (FLAG_trace_type_check_elimination) {
1006 const String& name = String::Handle(Symbols::New("InstanceOf")); 1006 const String& name = String::Handle(Symbols::New("InstanceOf"));
1007 FlowGraphPrinter::PrintTypeCheck(parsed_function(), 1007 FlowGraphPrinter::PrintTypeCheck(parsed_function(),
1008 instr->token_pos(), 1008 instr->token_pos(),
1009 instr->value(), 1009 instr->value(),
1010 instr->type(), 1010 instr->type(),
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 if ((defn == NULL) || defn->HasSideEffect()) continue; 1160 if ((defn == NULL) || defn->HasSideEffect()) continue;
1161 Definition* result = map->Lookup(defn); 1161 Definition* result = map->Lookup(defn);
1162 if (result == NULL) { 1162 if (result == NULL) {
1163 map->Insert(defn); 1163 map->Insert(defn);
1164 continue; 1164 continue;
1165 } 1165 }
1166 // Replace current with lookup result. 1166 // Replace current with lookup result.
1167 defn->ReplaceUsesWith(result); 1167 defn->ReplaceUsesWith(result);
1168 it.RemoveCurrentFromGraph(); 1168 it.RemoveCurrentFromGraph();
1169 if (FLAG_trace_optimization) { 1169 if (FLAG_trace_optimization) {
1170 OS::Print("Replacing v%d with v%d\n", 1170 OS::Print("Replacing v%"Pd" with v%"Pd"\n",
1171 defn->ssa_temp_index(), 1171 defn->ssa_temp_index(),
1172 result->ssa_temp_index()); 1172 result->ssa_temp_index());
1173 } 1173 }
1174 } 1174 }
1175 1175
1176 // Process children in the dominator tree recursively. 1176 // Process children in the dominator tree recursively.
1177 intptr_t num_children = block->dominated_blocks().length(); 1177 intptr_t num_children = block->dominated_blocks().length();
1178 for (intptr_t i = 0; i < num_children; ++i) { 1178 for (intptr_t i = 0; i < num_children; ++i) {
1179 BlockEntryInstr* child = block->dominated_blocks()[i]; 1179 BlockEntryInstr* child = block->dominated_blocks()[i];
1180 if (i < num_children - 1) { 1180 if (i < num_children - 1) {
1181 DirectChainedHashMap<Definition*> child_map(*map); // Copy map. 1181 DirectChainedHashMap<Definition*> child_map(*map); // Copy map.
1182 OptimizeRecursive(child, &child_map); 1182 OptimizeRecursive(child, &child_map);
1183 } else { 1183 } else {
1184 OptimizeRecursive(child, map); // Reuse map for the last child. 1184 OptimizeRecursive(child, map); // Reuse map for the last child.
1185 } 1185 }
1186 } 1186 }
1187 } 1187 }
1188 1188
1189 1189
1190 } // namespace dart 1190 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_compiler_x64.cc ('k') | runtime/vm/freelist.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698