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

Unified Diff: runtime/vm/object.h

Issue 353513002: Use range information for optimizing integer boxing and fix bug in range analysis. (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 | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 37654)
+++ runtime/vm/object.h (working copy)
@@ -5,6 +5,7 @@
#ifndef VM_OBJECT_H_
#define VM_OBJECT_H_
+#include <limits>
#include "include/dart_api.h"
#include "platform/assert.h"
#include "platform/utils.h"
@@ -5026,12 +5027,18 @@
return reinterpret_cast<intptr_t>(New(value));
}
- static bool IsValid(intptr_t value) {
- return (value >= kMinValue) && (value <= kMaxValue);
- }
+ template <typename T>
+ static bool IsValid(T value) {
+ COMPILE_ASSERT(sizeof(kMinValue) == sizeof(kMaxValue));
+ COMPILE_ASSERT(std::numeric_limits<T>::is_integer);
+ if (sizeof(value) < sizeof(kMinValue)) {
+ return true;
+ }
- static bool IsValid64(int64_t value) {
- return (value >= kMinValue) && (value <= kMaxValue);
+ T min_value = std::numeric_limits<T>::is_signed
+ ? static_cast<T>(kMinValue) : 0;
+ return (value >= min_value)
+ && (value <= static_cast<T>(kMaxValue));
}
RawInteger* ShiftOp(Token::Kind kind,
« no previous file with comments | « runtime/vm/intermediate_language_ia32.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698