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/aot_optimizer.h" | 5 #include "vm/aot_optimizer.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/branch_optimizer.h" | 8 #include "vm/branch_optimizer.h" |
9 #include "vm/cha.h" | 9 #include "vm/cha.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 // Shortcut for equality with null. | 703 // Shortcut for equality with null. |
704 // TODO(vegorov): this optimization is not speculative and should | 704 // TODO(vegorov): this optimization is not speculative and should |
705 // be hoisted out of this function. | 705 // be hoisted out of this function. |
706 ConstantInstr* right_const = right->AsConstant(); | 706 ConstantInstr* right_const = right->AsConstant(); |
707 ConstantInstr* left_const = left->AsConstant(); | 707 ConstantInstr* left_const = left->AsConstant(); |
708 if ((right_const != NULL && right_const->value().IsNull()) || | 708 if ((right_const != NULL && right_const->value().IsNull()) || |
709 (left_const != NULL && left_const->value().IsNull())) { | 709 (left_const != NULL && left_const->value().IsNull())) { |
710 StrictCompareInstr* comp = new (Z) | 710 StrictCompareInstr* comp = new (Z) |
711 StrictCompareInstr(call->token_pos(), Token::kEQ_STRICT, | 711 StrictCompareInstr(call->token_pos(), Token::kEQ_STRICT, |
712 new (Z) Value(left), new (Z) Value(right), | 712 new (Z) Value(left), new (Z) Value(right), |
713 /* number_check = */ false, Thread::kNoDeoptId); | 713 false); // No number check. |
714 ReplaceCall(call, comp); | 714 ReplaceCall(call, comp); |
715 return true; | 715 return true; |
716 } | 716 } |
717 return false; | 717 return false; |
718 } | 718 } |
719 } | 719 } |
720 ASSERT(cid != kIllegalCid); | 720 ASSERT(cid != kIllegalCid); |
721 EqualityCompareInstr* comp = new (Z) | 721 EqualityCompareInstr* comp = new (Z) |
722 EqualityCompareInstr(call->token_pos(), op_kind, new (Z) Value(left), | 722 EqualityCompareInstr(call->token_pos(), op_kind, new (Z) Value(left), |
723 new (Z) Value(right), cid, call->deopt_id()); | 723 new (Z) Value(right), cid, call->deopt_id()); |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1434 type = AbstractType::Cast(call->ArgumentAt(3)->AsConstant()->value()).raw(); | 1434 type = AbstractType::Cast(call->ArgumentAt(3)->AsConstant()->value()).raw(); |
1435 } | 1435 } |
1436 | 1436 |
1437 if (TypeCheckAsClassEquality(type)) { | 1437 if (TypeCheckAsClassEquality(type)) { |
1438 LoadClassIdInstr* left_cid = new (Z) LoadClassIdInstr(new (Z) Value(left)); | 1438 LoadClassIdInstr* left_cid = new (Z) LoadClassIdInstr(new (Z) Value(left)); |
1439 InsertBefore(call, left_cid, NULL, FlowGraph::kValue); | 1439 InsertBefore(call, left_cid, NULL, FlowGraph::kValue); |
1440 const intptr_t type_cid = Class::Handle(Z, type.type_class()).id(); | 1440 const intptr_t type_cid = Class::Handle(Z, type.type_class()).id(); |
1441 ConstantInstr* cid = | 1441 ConstantInstr* cid = |
1442 flow_graph()->GetConstant(Smi::Handle(Z, Smi::New(type_cid))); | 1442 flow_graph()->GetConstant(Smi::Handle(Z, Smi::New(type_cid))); |
1443 | 1443 |
1444 StrictCompareInstr* check_cid = new (Z) StrictCompareInstr( | 1444 StrictCompareInstr* check_cid = |
1445 call->token_pos(), Token::kEQ_STRICT, new (Z) Value(left_cid), | 1445 new (Z) StrictCompareInstr(call->token_pos(), Token::kEQ_STRICT, |
1446 new (Z) Value(cid), /* number_check = */ false, Thread::kNoDeoptId); | 1446 new (Z) Value(left_cid), new (Z) Value(cid), |
| 1447 false); // No number check. |
1447 ReplaceCall(call, check_cid); | 1448 ReplaceCall(call, check_cid); |
1448 return; | 1449 return; |
1449 } | 1450 } |
1450 | 1451 |
1451 if (precompiler_ != NULL) { | 1452 if (precompiler_ != NULL) { |
1452 TypeRangeCache* cache = precompiler_->type_range_cache(); | 1453 TypeRangeCache* cache = precompiler_->type_range_cache(); |
1453 intptr_t lower_limit, upper_limit; | 1454 intptr_t lower_limit, upper_limit; |
1454 if (cache != NULL && | 1455 if (cache != NULL && |
1455 cache->InstanceOfHasClassRange(type, &lower_limit, &upper_limit)) { | 1456 cache->InstanceOfHasClassRange(type, &lower_limit, &upper_limit)) { |
1456 // left.instanceof(type) => | 1457 // left.instanceof(type) => |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2197 FlowGraph::kEffect); | 2198 FlowGraph::kEffect); |
2198 current_iterator()->RemoveCurrentFromGraph(); | 2199 current_iterator()->RemoveCurrentFromGraph(); |
2199 } | 2200 } |
2200 } | 2201 } |
2201 } | 2202 } |
2202 } | 2203 } |
2203 | 2204 |
2204 #endif // DART_PRECOMPILER | 2205 #endif // DART_PRECOMPILER |
2205 | 2206 |
2206 } // namespace dart | 2207 } // namespace dart |
OLD | NEW |