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

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

Issue 11275098: Improve RangeBoundary::LowerBound/UpperBound. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | « no previous file | 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) 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/intermediate_language.h" 5 #include "vm/intermediate_language.h"
6 6
7 #include "vm/bit_vector.h" 7 #include "vm/bit_vector.h"
8 #include "vm/dart_entry.h" 8 #include "vm/dart_entry.h"
9 #include "vm/flow_graph_allocator.h" 9 #include "vm/flow_graph_allocator.h"
10 #include "vm/flow_graph_builder.h" 10 #include "vm/flow_graph_builder.h"
(...skipping 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 RangeBoundary RangeBoundary::FromDefinition(Definition* defn, intptr_t offs) { 2111 RangeBoundary RangeBoundary::FromDefinition(Definition* defn, intptr_t offs) {
2112 if (defn->IsConstant() && defn->AsConstant()->value().IsSmi()) { 2112 if (defn->IsConstant() && defn->AsConstant()->value().IsSmi()) {
2113 return FromConstant(Smi::Cast(defn->AsConstant()->value()).Value() + offs); 2113 return FromConstant(Smi::Cast(defn->AsConstant()->value()).Value() + offs);
2114 } 2114 }
2115 return RangeBoundary(kSymbol, reinterpret_cast<intptr_t>(defn), offs); 2115 return RangeBoundary(kSymbol, reinterpret_cast<intptr_t>(defn), offs);
2116 } 2116 }
2117 2117
2118 2118
2119 RangeBoundary RangeBoundary::LowerBound() const { 2119 RangeBoundary RangeBoundary::LowerBound() const {
2120 if (IsConstant()) return *this; 2120 if (IsConstant()) return *this;
2121 if (symbol()->range() == NULL) return MinSmi(); 2121 return Add(Range::ConstantMin(symbol()->range()),
2122 return Add(symbol()->range()->min().LowerBound(),
2123 RangeBoundary::FromConstant(offset_), 2122 RangeBoundary::FromConstant(offset_),
2124 MinSmi()); 2123 MinSmi());
2125 } 2124 }
2126 2125
2127 2126
2128 RangeBoundary RangeBoundary::UpperBound() const { 2127 RangeBoundary RangeBoundary::UpperBound() const {
2129 if (IsConstant()) return *this; 2128 if (IsConstant()) return *this;
2130 if (symbol()->range() == NULL) return MaxSmi(); 2129 return Add(Range::ConstantMax(symbol()->range()),
2131 return Add(symbol()->range()->max().UpperBound(),
2132 RangeBoundary::FromConstant(offset_), 2130 RangeBoundary::FromConstant(offset_),
2133 MaxSmi()); 2131 MaxSmi());
2134 } 2132 }
2135 2133
2136 2134
2135 static Definition* UnwrapConstraint(Definition* defn) {
2136 while (defn->IsConstraint()) {
2137 defn = defn->AsConstraint()->value()->definition();
2138 }
2139 return defn;
2140 }
2141
2142
2137 static bool AreEqualDefinitions(Definition* a, Definition* b) { 2143 static bool AreEqualDefinitions(Definition* a, Definition* b) {
2144 a = UnwrapConstraint(a);
2145 b = UnwrapConstraint(b);
2138 return (a == b) || (!a->AffectedBySideEffect() && a->Equals(b)); 2146 return (a == b) || (!a->AffectedBySideEffect() && a->Equals(b));
2139 } 2147 }
2140 2148
2141 2149
2142 // Returns true if two range boundaries refer to the same symbol. 2150 // Returns true if two range boundaries refer to the same symbol.
2143 static bool DependOnSameSymbol(const RangeBoundary& a, const RangeBoundary& b) { 2151 static bool DependOnSameSymbol(const RangeBoundary& a, const RangeBoundary& b) {
2144 return a.IsSymbol() && b.IsSymbol() && 2152 return a.IsSymbol() && b.IsSymbol() &&
2145 AreEqualDefinitions(a.symbol(), b.symbol()); 2153 AreEqualDefinitions(a.symbol(), b.symbol());
2146 } 2154 }
2147 2155
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
2601 } while (CanonicalizeMaxBoundary(&max) || CanonicalizeMinBoundary(&length)); 2609 } while (CanonicalizeMaxBoundary(&max) || CanonicalizeMinBoundary(&length));
2602 2610
2603 // Failed to prove that maximum is bounded with array length. 2611 // Failed to prove that maximum is bounded with array length.
2604 return false; 2612 return false;
2605 } 2613 }
2606 2614
2607 2615
2608 #undef __ 2616 #undef __
2609 2617
2610 } // namespace dart 2618 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698