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

Unified Diff: runtime/vm/intermediate_language.h

Issue 333643004: Add range analysis for left-shift smi operations. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: addressed comments, added tests Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.cc » ('j') | runtime/vm/intermediate_language_test.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language.h
===================================================================
--- runtime/vm/intermediate_language.h (revision 37229)
+++ runtime/vm/intermediate_language.h (working copy)
@@ -2504,6 +2504,9 @@
value_(other.value_),
offset_(other.offset_) { }
+ explicit RangeBoundary(intptr_t val)
+ : kind_(kConstant), value_(val), offset_(0) { }
+
RangeBoundary& operator=(const RangeBoundary& other) {
kind_ = other.kind_;
value_ = other.value_;
@@ -2512,7 +2515,7 @@
}
static RangeBoundary FromConstant(intptr_t val) {
- return RangeBoundary(kConstant, val, 0);
+ return RangeBoundary(val);
}
static RangeBoundary NegativeInfinity() {
@@ -2554,6 +2557,12 @@
return *this;
}
+ bool Equals(const RangeBoundary& other) {
+ return kind_ == other.kind_
+ && value_ == other.value_
+ && offset_ == other.offset_;
+ }
+
bool IsUnknown() const { return kind_ == kUnknown; }
bool IsConstant() const { return kind_ == kConstant; }
bool IsSymbol() const { return kind_ == kSymbol; }
@@ -2607,6 +2616,23 @@
return RangeBoundary::FromConstant(result);
}
+ static RangeBoundary Shl(const RangeBoundary& value_boundary,
+ intptr_t shift_count,
+ const RangeBoundary& overflow) {
+ ASSERT(value_boundary.IsConstant());
+ ASSERT(shift_count >= 0);
+ intptr_t limit = 64 - shift_count;
+ int64_t value = static_cast<int64_t>(value_boundary.value());
+ if ((value == 0) ||
+ (shift_count == 0) ||
+ ((limit > 0) && (Utils::IsInt(limit, value)))) {
+ // Result stays in 64 bit range.
+ int64_t result = value << shift_count;
+ return Smi::IsValid64(result) ? RangeBoundary(result) : overflow;
+ }
+ return overflow;
+ }
+
private:
RangeBoundary(Kind kind, intptr_t value, intptr_t offset)
: kind_(kind), value_(value), offset_(offset) { }
@@ -2662,6 +2688,11 @@
bool IsUnsatisfiable() const;
+ static void Shl(Range* left_range,
+ Range* right_range,
+ RangeBoundary* min,
+ RangeBoundary* max);
+
private:
RangeBoundary min_;
RangeBoundary max_;
« no previous file with comments | « no previous file | runtime/vm/intermediate_language.cc » ('j') | runtime/vm/intermediate_language_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698