Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/cha.h" | 8 #include "vm/cha.h" |
| 9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/hash_map.h" | 10 #include "vm/hash_map.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 259 return ICDataHasOnlyReceiverArgumentClassIds(ic_data, class_ids, class_ids); | 259 return ICDataHasOnlyReceiverArgumentClassIds(ic_data, class_ids, class_ids); |
| 260 } | 260 } |
| 261 | 261 |
| 262 | 262 |
| 263 static bool HasOneDouble(const ICData& ic_data) { | 263 static bool HasOneDouble(const ICData& ic_data) { |
| 264 return ICDataHasReceiverClassId(ic_data, kDoubleCid); | 264 return ICDataHasReceiverClassId(ic_data, kDoubleCid); |
| 265 } | 265 } |
| 266 | 266 |
| 267 | 267 |
| 268 static bool ShouldSpecializeForDouble(const ICData& ic_data) { | 268 static bool ShouldSpecializeForDouble(const ICData& ic_data) { |
| 269 if (ic_data.NumberOfChecks() != 1) return false; | 269 if (ic_data.NumberOfChecks() < 1) return false; |
| 270 if (ic_data.num_args_tested() != 2) return false; | 270 if (ic_data.num_args_tested() != 2) return false; |
| 271 | 271 |
| 272 Function& target = Function::Handle(); | 272 for (intptr_t check_idx = 0; |
| 273 GrowableArray<intptr_t> class_ids; | 273 check_idx < ic_data.NumberOfChecks(); |
| 274 ic_data.GetCheckAt(0, &class_ids, &target); | 274 check_idx++) { |
| 275 ASSERT(class_ids.length() == 2); | 275 Function& target = Function::Handle(); |
| 276 GrowableArray<intptr_t> class_ids; | |
| 277 ic_data.GetCheckAt(check_idx, &class_ids, &target); | |
| 278 ASSERT(class_ids.length() == 2); | |
| 276 | 279 |
| 277 const bool seen_double = | 280 const bool seen_double = |
|
Florian Schneider
2012/09/21 13:23:07
It would be nice to have a helper that checks for
| |
| 278 (class_ids[0] == kDoubleCid) || (class_ids[1] == kDoubleCid); | 281 (class_ids[0] == kDoubleCid) || (class_ids[1] == kDoubleCid); |
| 279 | 282 |
| 280 const bool seen_only_smi_or_double = | 283 const bool seen_only_smi_or_double = |
| 281 ((class_ids[0] == kDoubleCid) || (class_ids[0] == kSmiCid)) && | 284 ((class_ids[0] == kDoubleCid) || (class_ids[0] == kSmiCid)) && |
| 282 ((class_ids[1] == kDoubleCid) || (class_ids[1] == kSmiCid)); | 285 ((class_ids[1] == kDoubleCid) || (class_ids[1] == kSmiCid)); |
| 283 | 286 |
| 284 return seen_double && seen_only_smi_or_double; | 287 if (!seen_double || !seen_only_smi_or_double) { |
| 288 return false; | |
| 289 } | |
| 290 } | |
| 291 return true; | |
| 285 } | 292 } |
| 286 | 293 |
| 287 | 294 |
| 288 static void RemovePushArguments(InstanceCallInstr* call) { | 295 static void RemovePushArguments(InstanceCallInstr* call) { |
| 289 // Remove original push arguments. | 296 // Remove original push arguments. |
| 290 for (intptr_t i = 0; i < call->ArgumentCount(); ++i) { | 297 for (intptr_t i = 0; i < call->ArgumentCount(); ++i) { |
| 291 PushArgumentInstr* push = call->ArgumentAt(i); | 298 PushArgumentInstr* push = call->ArgumentAt(i); |
| 292 push->ReplaceUsesWith(push->value()->definition()); | 299 push->ReplaceUsesWith(push->value()->definition()); |
| 293 push->RemoveFromGraph(); | 300 push->RemoveFromGraph(); |
| 294 } | 301 } |
| (...skipping 2193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2488 it.Advance()) { | 2495 it.Advance()) { |
| 2489 JoinEntryInstr* join = it.Current()->AsJoinEntry(); | 2496 JoinEntryInstr* join = it.Current()->AsJoinEntry(); |
| 2490 if (join != NULL) join->EliminateUnreachablePhiInputs(); | 2497 if (join != NULL) join->EliminateUnreachablePhiInputs(); |
| 2491 } | 2498 } |
| 2492 | 2499 |
| 2493 graph_->ComputeUseLists(); | 2500 graph_->ComputeUseLists(); |
| 2494 } | 2501 } |
| 2495 | 2502 |
| 2496 | 2503 |
| 2497 } // namespace dart | 2504 } // namespace dart |
| OLD | NEW |