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/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 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 708 | 708 |
| 709 cid = kSmiCid; | 709 cid = kSmiCid; |
| 710 } else { | 710 } else { |
| 711 // Shortcut for equality with null. | 711 // Shortcut for equality with null. |
| 712 // TODO(vegorov): this optimization is not speculative and should | 712 // TODO(vegorov): this optimization is not speculative and should |
| 713 // be hoisted out of this function. | 713 // be hoisted out of this function. |
| 714 ConstantInstr* right_const = right->AsConstant(); | 714 ConstantInstr* right_const = right->AsConstant(); |
| 715 ConstantInstr* left_const = left->AsConstant(); | 715 ConstantInstr* left_const = left->AsConstant(); |
| 716 if ((right_const != NULL && right_const->value().IsNull()) || | 716 if ((right_const != NULL && right_const->value().IsNull()) || |
| 717 (left_const != NULL && left_const->value().IsNull())) { | 717 (left_const != NULL && left_const->value().IsNull())) { |
| 718 StrictCompareInstr* comp = new (Z) | 718 StrictCompareInstr* comp = new (Z) StrictCompareInstr( |
| 719 StrictCompareInstr(call->token_pos(), Token::kEQ_STRICT, | 719 call->token_pos(), Token::kEQ_STRICT, new (Z) Value(left), |
| 720 new (Z) Value(left), new (Z) Value(right), | 720 new (Z) Value(right), false, // No number check. |
|
Vyacheslav Egorov (Google)
2017/05/23 12:00:00
better maybe write this comment /* number_check =
| |
| 721 false); // No number check. | 721 Thread::Current()->GetNextDeoptId()); |
|
Vyacheslav Egorov (Google)
2017/05/23 12:00:00
I think this can be kNoDeoptId
We should probably
| |
| 722 ReplaceCall(call, comp); | 722 ReplaceCall(call, comp); |
| 723 return true; | 723 return true; |
| 724 } | 724 } |
| 725 return false; | 725 return false; |
| 726 } | 726 } |
| 727 } | 727 } |
| 728 ASSERT(cid != kIllegalCid); | 728 ASSERT(cid != kIllegalCid); |
| 729 EqualityCompareInstr* comp = new (Z) | 729 EqualityCompareInstr* comp = new (Z) |
| 730 EqualityCompareInstr(call->token_pos(), op_kind, new (Z) Value(left), | 730 EqualityCompareInstr(call->token_pos(), op_kind, new (Z) Value(left), |
| 731 new (Z) Value(right), cid, call->deopt_id()); | 731 new (Z) Value(right), cid, call->deopt_id()); |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1442 type = AbstractType::Cast(call->ArgumentAt(3)->AsConstant()->value()).raw(); | 1442 type = AbstractType::Cast(call->ArgumentAt(3)->AsConstant()->value()).raw(); |
| 1443 } | 1443 } |
| 1444 | 1444 |
| 1445 if (TypeCheckAsClassEquality(type)) { | 1445 if (TypeCheckAsClassEquality(type)) { |
| 1446 LoadClassIdInstr* left_cid = new (Z) LoadClassIdInstr(new (Z) Value(left)); | 1446 LoadClassIdInstr* left_cid = new (Z) LoadClassIdInstr(new (Z) Value(left)); |
| 1447 InsertBefore(call, left_cid, NULL, FlowGraph::kValue); | 1447 InsertBefore(call, left_cid, NULL, FlowGraph::kValue); |
| 1448 const intptr_t type_cid = Class::Handle(Z, type.type_class()).id(); | 1448 const intptr_t type_cid = Class::Handle(Z, type.type_class()).id(); |
| 1449 ConstantInstr* cid = | 1449 ConstantInstr* cid = |
| 1450 flow_graph()->GetConstant(Smi::Handle(Z, Smi::New(type_cid))); | 1450 flow_graph()->GetConstant(Smi::Handle(Z, Smi::New(type_cid))); |
| 1451 | 1451 |
| 1452 StrictCompareInstr* check_cid = | 1452 StrictCompareInstr* check_cid = new (Z) StrictCompareInstr( |
| 1453 new (Z) StrictCompareInstr(call->token_pos(), Token::kEQ_STRICT, | 1453 call->token_pos(), Token::kEQ_STRICT, new (Z) Value(left_cid), |
| 1454 new (Z) Value(left_cid), new (Z) Value(cid), | 1454 new (Z) Value(cid), false, // No number check. |
| 1455 false); // No number check. | 1455 Thread::Current()->GetNextDeoptId()); |
|
Vyacheslav Egorov (Google)
2017/05/23 12:00:00
Ditto.
| |
| 1456 ReplaceCall(call, check_cid); | 1456 ReplaceCall(call, check_cid); |
| 1457 return; | 1457 return; |
| 1458 } | 1458 } |
| 1459 | 1459 |
| 1460 if (precompiler_ != NULL) { | 1460 if (precompiler_ != NULL) { |
| 1461 TypeRangeCache* cache = precompiler_->type_range_cache(); | 1461 TypeRangeCache* cache = precompiler_->type_range_cache(); |
| 1462 intptr_t lower_limit, upper_limit; | 1462 intptr_t lower_limit, upper_limit; |
| 1463 if (cache != NULL && | 1463 if (cache != NULL && |
| 1464 cache->InstanceOfHasClassRange(type, &lower_limit, &upper_limit)) { | 1464 cache->InstanceOfHasClassRange(type, &lower_limit, &upper_limit)) { |
| 1465 // left.instanceof(type) => | 1465 // left.instanceof(type) => |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2222 FlowGraph::kEffect); | 2222 FlowGraph::kEffect); |
| 2223 current_iterator()->RemoveCurrentFromGraph(); | 2223 current_iterator()->RemoveCurrentFromGraph(); |
| 2224 } | 2224 } |
| 2225 } | 2225 } |
| 2226 } | 2226 } |
| 2227 } | 2227 } |
| 2228 | 2228 |
| 2229 #endif // DART_PRECOMPILER | 2229 #endif // DART_PRECOMPILER |
| 2230 | 2230 |
| 2231 } // namespace dart | 2231 } // namespace dart |
| OLD | NEW |