Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/flow_graph_allocator.h" | 9 #include "vm/flow_graph_allocator.h" |
| 10 #include "vm/flow_graph_builder.h" | 10 #include "vm/flow_graph_builder.h" |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 Value* prev = previous_use(); | 490 Value* prev = previous_use(); |
| 491 prev->set_next_use(next); | 491 prev->set_next_use(next); |
| 492 if (next != NULL) next->set_previous_use(prev); | 492 if (next != NULL) next->set_previous_use(prev); |
| 493 } | 493 } |
| 494 | 494 |
| 495 set_previous_use(NULL); | 495 set_previous_use(NULL); |
| 496 set_next_use(NULL); | 496 set_next_use(NULL); |
| 497 } | 497 } |
| 498 | 498 |
| 499 | 499 |
| 500 bool Definition::HasOnlyUse(Value* use) const { | |
| 501 if (((input_use_list() == use) && (env_use_list() == NULL)) || | |
| 502 ((input_use_list() == NULL) && (env_use_list() == use))) { | |
| 503 return (use->next_use() == NULL); | |
| 504 } | |
| 505 return false; | |
| 506 } | |
| 507 | |
| 508 | |
| 500 void Definition::ReplaceUsesWith(Definition* other) { | 509 void Definition::ReplaceUsesWith(Definition* other) { |
| 501 ASSERT(other != NULL); | 510 ASSERT(other != NULL); |
| 502 ASSERT(this != other); | 511 ASSERT(this != other); |
| 503 | 512 |
| 504 Value* current = NULL; | 513 Value* current = NULL; |
| 505 Value* next = input_use_list(); | 514 Value* next = input_use_list(); |
| 506 if (next != NULL) { | 515 if (next != NULL) { |
| 507 // Change all the definitions. | 516 // Change all the definitions. |
| 508 while (next != NULL) { | 517 while (next != NULL) { |
| 509 current = next; | 518 current = next; |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1156 case kUint64ArrayCid: | 1165 case kUint64ArrayCid: |
| 1157 case kFloat32ArrayCid: | 1166 case kFloat32ArrayCid: |
| 1158 case kFloat64ArrayCid: | 1167 case kFloat64ArrayCid: |
| 1159 return true; | 1168 return true; |
| 1160 default: | 1169 default: |
| 1161 return false; | 1170 return false; |
| 1162 } | 1171 } |
| 1163 } | 1172 } |
| 1164 | 1173 |
| 1165 | 1174 |
| 1175 Definition* ConstantInstr::Canonicalize(FlowGraphOptimizer* optimizer) { | |
| 1176 return HasUses() ? this : NULL; | |
|
Vyacheslav Egorov (Google)
2013/03/06 16:44:22
I'd really like to see a more generic dead code el
Kevin Millikin (Google)
2013/03/08 10:38:10
Me too, but this doesn't really seem like an abuse
| |
| 1177 } | |
| 1178 | |
| 1179 | |
| 1166 Definition* LoadFieldInstr::Canonicalize(FlowGraphOptimizer* optimizer) { | 1180 Definition* LoadFieldInstr::Canonicalize(FlowGraphOptimizer* optimizer) { |
| 1167 if (!IsImmutableLengthLoad()) return this; | 1181 if (!IsImmutableLengthLoad()) return this; |
| 1168 | 1182 |
| 1169 // For fixed length arrays if the array is the result of a known constructor | 1183 // For fixed length arrays if the array is the result of a known constructor |
| 1170 // call we can replace the length load with the length argument passed to | 1184 // call we can replace the length load with the length argument passed to |
| 1171 // the constructor. | 1185 // the constructor. |
| 1172 StaticCallInstr* call = value()->definition()->AsStaticCall(); | 1186 StaticCallInstr* call = value()->definition()->AsStaticCall(); |
| 1173 if ((call != NULL) && | 1187 if ((call != NULL) && |
| 1174 call->is_known_list_constructor() && | 1188 call->is_known_list_constructor() && |
| 1175 IsFixedLengthArrayCid(call->Type()->ToCid())) { | 1189 IsFixedLengthArrayCid(call->Type()->ToCid())) { |
| (...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2272 default: | 2286 default: |
| 2273 UNREACHABLE(); | 2287 UNREACHABLE(); |
| 2274 } | 2288 } |
| 2275 return kPowRuntimeEntry; | 2289 return kPowRuntimeEntry; |
| 2276 } | 2290 } |
| 2277 | 2291 |
| 2278 | 2292 |
| 2279 #undef __ | 2293 #undef __ |
| 2280 | 2294 |
| 2281 } // namespace dart | 2295 } // namespace dart |
| OLD | NEW |