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

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

Issue 11779017: Ensure that LowerBound and UpperBound return overflow marker when overflow occurs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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') | tests/language/range_analysis_test.dart » ('j') | 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 2140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2151 return FromConstant(Smi::Cast(defn->AsConstant()->value()).Value() + offs); 2151 return FromConstant(Smi::Cast(defn->AsConstant()->value()).Value() + offs);
2152 } 2152 }
2153 return RangeBoundary(kSymbol, reinterpret_cast<intptr_t>(defn), offs); 2153 return RangeBoundary(kSymbol, reinterpret_cast<intptr_t>(defn), offs);
2154 } 2154 }
2155 2155
2156 2156
2157 RangeBoundary RangeBoundary::LowerBound() const { 2157 RangeBoundary RangeBoundary::LowerBound() const {
2158 if (IsConstant()) return *this; 2158 if (IsConstant()) return *this;
2159 return Add(Range::ConstantMin(symbol()->range()), 2159 return Add(Range::ConstantMin(symbol()->range()),
2160 RangeBoundary::FromConstant(offset_), 2160 RangeBoundary::FromConstant(offset_),
2161 MinSmi()); 2161 OverflowedMinSmi());
2162 } 2162 }
2163 2163
2164 2164
2165 RangeBoundary RangeBoundary::UpperBound() const { 2165 RangeBoundary RangeBoundary::UpperBound() const {
2166 if (IsConstant()) return *this; 2166 if (IsConstant()) return *this;
2167 return Add(Range::ConstantMax(symbol()->range()), 2167 return Add(Range::ConstantMax(symbol()->range()),
2168 RangeBoundary::FromConstant(offset_), 2168 RangeBoundary::FromConstant(offset_),
2169 MaxSmi()); 2169 OverflowedMaxSmi());
2170 } 2170 }
2171 2171
2172 2172
2173 static Definition* UnwrapConstraint(Definition* defn) { 2173 static Definition* UnwrapConstraint(Definition* defn) {
2174 while (defn->IsConstraint()) { 2174 while (defn->IsConstraint()) {
2175 defn = defn->AsConstraint()->value()->definition(); 2175 defn = defn->AsConstraint()->value()->definition();
2176 } 2176 }
2177 return defn; 2177 return defn;
2178 } 2178 }
2179 2179
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2309 2309
2310 return true; 2310 return true;
2311 } 2311 }
2312 2312
2313 2313
2314 RangeBoundary RangeBoundary::Min(RangeBoundary a, RangeBoundary b) { 2314 RangeBoundary RangeBoundary::Min(RangeBoundary a, RangeBoundary b) {
2315 if (DependOnSameSymbol(a, b)) { 2315 if (DependOnSameSymbol(a, b)) {
2316 return (a.offset() <= b.offset()) ? a : b; 2316 return (a.offset() <= b.offset()) ? a : b;
2317 } 2317 }
2318 2318
2319 const intptr_t min_a = a.LowerBound().value(); 2319 const intptr_t min_a = a.LowerBound().Clamp().value();
2320 const intptr_t min_b = b.LowerBound().value(); 2320 const intptr_t min_b = b.LowerBound().Clamp().value();
2321 2321
2322 return RangeBoundary::FromConstant(Utils::Minimum(min_a, min_b)); 2322 return RangeBoundary::FromConstant(Utils::Minimum(min_a, min_b));
2323 } 2323 }
2324 2324
2325 2325
2326 RangeBoundary RangeBoundary::Max(RangeBoundary a, RangeBoundary b) { 2326 RangeBoundary RangeBoundary::Max(RangeBoundary a, RangeBoundary b) {
2327 if (DependOnSameSymbol(a, b)) { 2327 if (DependOnSameSymbol(a, b)) {
2328 return (a.offset() >= b.offset()) ? a : b; 2328 return (a.offset() >= b.offset()) ? a : b;
2329 } 2329 }
2330 2330
2331 const intptr_t max_a = a.UpperBound().value(); 2331 const intptr_t max_a = a.UpperBound().Clamp().value();
2332 const intptr_t max_b = b.UpperBound().value(); 2332 const intptr_t max_b = b.UpperBound().Clamp().value();
2333 2333
2334 return RangeBoundary::FromConstant(Utils::Maximum(max_a, max_b)); 2334 return RangeBoundary::FromConstant(Utils::Maximum(max_a, max_b));
2335 } 2335 }
2336 2336
2337 2337
2338 void Definition::InferRange() { 2338 void Definition::InferRange() {
2339 ASSERT(GetPropagatedCid() == kSmiCid); // Has meaning only for smis. 2339 ASSERT(GetPropagatedCid() == kSmiCid); // Has meaning only for smis.
2340 if (range_ == NULL) { 2340 if (range_ == NULL) {
2341 range_ = Range::Unknown(); 2341 range_ = Range::Unknown();
2342 } 2342 }
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
2710 default: 2710 default:
2711 UNREACHABLE(); 2711 UNREACHABLE();
2712 return -1; 2712 return -1;
2713 } 2713 }
2714 } 2714 }
2715 2715
2716 2716
2717 #undef __ 2717 #undef __
2718 2718
2719 } // namespace dart 2719 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | tests/language/range_analysis_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698