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

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: 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.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,24 @@
return RangeBoundary::FromConstant(result);
}
+ static RangeBoundary Shl(const RangeBoundary& a,
Vyacheslav Egorov (Google) 2014/06/12 14:59:00 operand a
Florian Schneider 2014/06/12 15:12:43 Done.
+ intptr_t b,
Vyacheslav Egorov (Google) 2014/06/12 14:59:00 more meaningful name: shift?
Florian Schneider 2014/06/12 15:12:42 Done.
+ const RangeBoundary& overflow) {
+ ASSERT(a.IsConstant());
+ ASSERT(b >= 0);
+ intptr_t limit = 63 - b;
Vyacheslav Egorov (Google) 2014/06/12 14:59:00 I think this should be 64 (think b = 0).
Florian Schneider 2014/06/12 15:12:42 Done.
+ if ((a.value() == 0) ||
+ ((limit > 0) &&
+ (Utils::IsInt(limit, static_cast<int64_t>(a.value()))))) {
+ // Result stays in 64 bit range.
+ int64_t result = a.value() << b;
Vyacheslav Egorov (Google) 2014/06/12 14:59:00 this is intptr_t range shift
Florian Schneider 2014/06/12 15:12:42 Done.
+ return Smi::IsValid(result)
+ ? RangeBoundary::FromConstant(result)
+ : overflow;
+ }
+ return overflow;
+ }
+
private:
RangeBoundary(Kind kind, intptr_t value, intptr_t offset)
: kind_(kind), value_(value), offset_(offset) { }
@@ -2662,6 +2689,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.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698