| 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/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/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 | 1390 |
| 1391 | 1391 |
| 1392 void FlowGraphOptimizer::InlineStringIsEmptyGetter(InstanceCallInstr* call) { | 1392 void FlowGraphOptimizer::InlineStringIsEmptyGetter(InstanceCallInstr* call) { |
| 1393 AddReceiverCheck(call); | 1393 AddReceiverCheck(call); |
| 1394 | 1394 |
| 1395 LoadFieldInstr* load = BuildLoadStringLength(call->ArgumentAt(0)); | 1395 LoadFieldInstr* load = BuildLoadStringLength(call->ArgumentAt(0)); |
| 1396 InsertBefore(call, load, NULL, Definition::kValue); | 1396 InsertBefore(call, load, NULL, Definition::kValue); |
| 1397 | 1397 |
| 1398 ConstantInstr* zero = flow_graph()->GetConstant(Smi::Handle(Smi::New(0))); | 1398 ConstantInstr* zero = flow_graph()->GetConstant(Smi::Handle(Smi::New(0))); |
| 1399 StrictCompareInstr* compare = | 1399 StrictCompareInstr* compare = |
| 1400 new StrictCompareInstr(Token::kEQ_STRICT, | 1400 new StrictCompareInstr(call->token_pos(), |
| 1401 Token::kEQ_STRICT, |
| 1401 new Value(load), | 1402 new Value(load), |
| 1402 new Value(zero)); | 1403 new Value(zero)); |
| 1403 ReplaceCall(call, compare); | 1404 ReplaceCall(call, compare); |
| 1404 } | 1405 } |
| 1405 | 1406 |
| 1406 | 1407 |
| 1407 void FlowGraphOptimizer::InlineObjectCid(InstanceCallInstr* call) { | 1408 void FlowGraphOptimizer::InlineObjectCid(InstanceCallInstr* call) { |
| 1408 LoadClassIdInstr* load = new LoadClassIdInstr(new Value(call->ArgumentAt(0))); | 1409 LoadClassIdInstr* load = new LoadClassIdInstr(new Value(call->ArgumentAt(0))); |
| 1409 ReplaceCall(call, load); | 1410 ReplaceCall(call, load); |
| 1410 } | 1411 } |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2600 | 2601 |
| 2601 | 2602 |
| 2602 template <typename T> | 2603 template <typename T> |
| 2603 bool FlowGraphOptimizer::StrictifyEqualityCompare( | 2604 bool FlowGraphOptimizer::StrictifyEqualityCompare( |
| 2604 EqualityCompareInstr* compare, | 2605 EqualityCompareInstr* compare, |
| 2605 T current_instruction) const { | 2606 T current_instruction) const { |
| 2606 if (CanStrictifyEqualityCompare(compare)) { | 2607 if (CanStrictifyEqualityCompare(compare)) { |
| 2607 Token::Kind strict_kind = (compare->kind() == Token::kEQ) ? | 2608 Token::Kind strict_kind = (compare->kind() == Token::kEQ) ? |
| 2608 Token::kEQ_STRICT : Token::kNE_STRICT; | 2609 Token::kEQ_STRICT : Token::kNE_STRICT; |
| 2609 StrictCompareInstr* strict_comp = | 2610 StrictCompareInstr* strict_comp = |
| 2610 new StrictCompareInstr(strict_kind, | 2611 new StrictCompareInstr(compare->token_pos(), |
| 2612 strict_kind, |
| 2611 compare->left()->CopyWithType(), | 2613 compare->left()->CopyWithType(), |
| 2612 compare->right()->CopyWithType()); | 2614 compare->right()->CopyWithType()); |
| 2613 current_instruction->ReplaceWith(strict_comp, current_iterator()); | 2615 current_instruction->ReplaceWith(strict_comp, current_iterator()); |
| 2614 return true; | 2616 return true; |
| 2615 } | 2617 } |
| 2616 return false; | 2618 return false; |
| 2617 } | 2619 } |
| 2618 | 2620 |
| 2619 | 2621 |
| 2620 template <typename T> | 2622 template <typename T> |
| (...skipping 3383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6004 return join; | 6006 return join; |
| 6005 } | 6007 } |
| 6006 | 6008 |
| 6007 | 6009 |
| 6008 BranchInstr* BranchSimplifier::CloneBranch(BranchInstr* branch, | 6010 BranchInstr* BranchSimplifier::CloneBranch(BranchInstr* branch, |
| 6009 Value* left, | 6011 Value* left, |
| 6010 Value* right) { | 6012 Value* right) { |
| 6011 ComparisonInstr* comparison = branch->comparison(); | 6013 ComparisonInstr* comparison = branch->comparison(); |
| 6012 ComparisonInstr* new_comparison = NULL; | 6014 ComparisonInstr* new_comparison = NULL; |
| 6013 if (comparison->IsStrictCompare()) { | 6015 if (comparison->IsStrictCompare()) { |
| 6014 new_comparison = new StrictCompareInstr(comparison->kind(), left, right); | 6016 new_comparison = new StrictCompareInstr(comparison->token_pos(), |
| 6017 comparison->kind(), |
| 6018 left, |
| 6019 right); |
| 6015 } else if (comparison->IsEqualityCompare()) { | 6020 } else if (comparison->IsEqualityCompare()) { |
| 6016 EqualityCompareInstr* equality_compare = comparison->AsEqualityCompare(); | 6021 EqualityCompareInstr* equality_compare = comparison->AsEqualityCompare(); |
| 6017 EqualityCompareInstr* new_equality_compare = | 6022 EqualityCompareInstr* new_equality_compare = |
| 6018 new EqualityCompareInstr(equality_compare->token_pos(), | 6023 new EqualityCompareInstr(equality_compare->token_pos(), |
| 6019 comparison->kind(), | 6024 comparison->kind(), |
| 6020 left, | 6025 left, |
| 6021 right, | 6026 right, |
| 6022 Array::Handle()); | 6027 Array::Handle()); |
| 6023 new_equality_compare->set_ic_data(equality_compare->ic_data()); | 6028 new_equality_compare->set_ic_data(equality_compare->ic_data()); |
| 6024 new_comparison = new_equality_compare; | 6029 new_comparison = new_equality_compare; |
| (...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6530 | 6535 |
| 6531 // Insert materializations at environment uses. | 6536 // Insert materializations at environment uses. |
| 6532 const Class& cls = Class::Handle(alloc->constructor().Owner()); | 6537 const Class& cls = Class::Handle(alloc->constructor().Owner()); |
| 6533 for (intptr_t i = 0; i < exits.length(); i++) { | 6538 for (intptr_t i = 0; i < exits.length(); i++) { |
| 6534 CreateMaterializationAt(exits[i], alloc, cls, *fields); | 6539 CreateMaterializationAt(exits[i], alloc, cls, *fields); |
| 6535 } | 6540 } |
| 6536 } | 6541 } |
| 6537 | 6542 |
| 6538 | 6543 |
| 6539 } // namespace dart | 6544 } // namespace dart |
| OLD | NEW |