Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Side by Side Diff: runtime/vm/intermediate_language.cc

Issue 27727002: Optimize identical-comparisons based on propagated type information. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/bit_vector.h" 8 #include "vm/bit_vector.h"
9 #include "vm/dart_entry.h" 9 #include "vm/dart_entry.h"
10 #include "vm/flow_graph_allocator.h" 10 #include "vm/flow_graph_allocator.h"
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after
1521 if (defn->IsComparison() && 1521 if (defn->IsComparison() &&
1522 (value()->Type()->ToCid() == kBoolCid) && 1522 (value()->Type()->ToCid() == kBoolCid) &&
1523 defn->HasOnlyUse(value())) { 1523 defn->HasOnlyUse(value())) {
1524 defn->AsComparison()->NegateComparison(); 1524 defn->AsComparison()->NegateComparison();
1525 return defn; 1525 return defn;
1526 } 1526 }
1527 return this; 1527 return this;
1528 } 1528 }
1529 1529
1530 1530
1531 static bool MayBeBoxableNumber(intptr_t cid) {
1532 return (cid == kDynamicCid) ||
1533 (cid == kMintCid) ||
1534 (cid == kBigintCid) ||
1535 (cid == kDoubleCid);
1536 }
1537
1538
1539 static bool MaybeNumber(CompileType* type) {
1540 ASSERT(Type::Handle(Type::Number()).IsMoreSpecificThan(
1541 Type::Handle(Type::Number()), NULL));
1542 return type->ToAbstractType()->IsDynamicType()
1543 || type->IsMoreSpecificThan(Type::Handle(Type::Number()));
1544 }
1545
1546
1531 // Returns a replacement for a strict comparison and signals if the result has 1547 // Returns a replacement for a strict comparison and signals if the result has
1532 // to be negated. 1548 // to be negated.
1533 static Definition* CanonicalizeStrictCompare(StrictCompareInstr* compare, 1549 static Definition* CanonicalizeStrictCompare(StrictCompareInstr* compare,
1534 bool* negated) { 1550 bool* negated) {
1551 // Use propagated cid and type information to eliminate number checks.
1552 // If one of the inputs is not a boxable number (Mint, Double, Bigint), or
1553 // is not a subtype of num, no need for number checks.
1554 if (compare->needs_number_check()) {
1555 if (!MayBeBoxableNumber(compare->left()->Type()->ToCid()) ||
1556 !MayBeBoxableNumber(compare->right()->Type()->ToCid())) {
1557 compare->set_needs_number_check(false);
1558 } else if (!MaybeNumber(compare->left()->Type()) ||
1559 !MaybeNumber(compare->right()->Type())) {
1560 compare->set_needs_number_check(false);
1561 }
1562 }
1563
1535 *negated = false; 1564 *negated = false;
1536 Object& constant = Object::Handle(); 1565 Object& constant = Object::Handle();
1537 Value* other = NULL; 1566 Value* other = NULL;
1538 if (compare->right()->BindsToConstant()) { 1567 if (compare->right()->BindsToConstant()) {
1539 constant = compare->right()->BoundConstant().raw(); 1568 constant = compare->right()->BoundConstant().raw();
1540 other = compare->left(); 1569 other = compare->left();
1541 } else if (compare->left()->BindsToConstant()) { 1570 } else if (compare->left()->BindsToConstant()) {
1542 constant = compare->left()->BoundConstant().raw(); 1571 constant = compare->left()->BoundConstant().raw();
1543 other = compare->right(); 1572 other = compare->right();
1544 } else { 1573 } else {
(...skipping 1226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2771 return kCosRuntimeEntry; 2800 return kCosRuntimeEntry;
2772 default: 2801 default:
2773 UNREACHABLE(); 2802 UNREACHABLE();
2774 } 2803 }
2775 return kSinRuntimeEntry; 2804 return kSinRuntimeEntry;
2776 } 2805 }
2777 2806
2778 #undef __ 2807 #undef __
2779 2808
2780 } // namespace dart 2809 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698