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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
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 #ifndef VM_OBJECT_H_ 5 #ifndef VM_OBJECT_H_
6 #define VM_OBJECT_H_ 6 #define VM_OBJECT_H_
7 7
8 #include "include/dart_api.h" 8 #include "include/dart_api.h"
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "platform/utils.h" 10 #include "platform/utils.h"
(...skipping 5008 matching lines...) Expand 10 before | Expand all | Expand 10 after
5019 static RawClass* Class(); 5019 static RawClass* Class();
5020 5020
5021 static intptr_t Value(const RawSmi* raw_smi) { 5021 static intptr_t Value(const RawSmi* raw_smi) {
5022 return ValueFromRaw(reinterpret_cast<uword>(raw_smi)); 5022 return ValueFromRaw(reinterpret_cast<uword>(raw_smi));
5023 } 5023 }
5024 5024
5025 static intptr_t RawValue(intptr_t value) { 5025 static intptr_t RawValue(intptr_t value) {
5026 return reinterpret_cast<intptr_t>(New(value)); 5026 return reinterpret_cast<intptr_t>(New(value));
5027 } 5027 }
5028 5028
5029 static bool IsValid(intptr_t value) { 5029 template <typename T>
5030 return (value >= kMinValue) && (value <= kMaxValue); 5030 static bool IsValid(T value) {
5031 } 5031 COMPILE_ASSERT(sizeof(kMinValue) == sizeof(kMaxValue));
5032 5032 if (sizeof(value) < sizeof(kMinValue)) {
Vyacheslav Egorov (Google) 2014/06/24 12:18:12 We also need to check that it is integral type bec
Florian Schneider 2014/06/24 12:35:06 Done. Added a COMPILE_ASSERT because we should nev
5033 static bool IsValid64(int64_t value) { 5033 return true;
5034 return (value >= kMinValue) && (value <= kMaxValue); 5034 }
5035 if (static_cast<T>(-1) < 0) {
Vyacheslav Egorov (Google) 2014/06/24 12:18:12 I would really prefer we write C++ here: std::num
Florian Schneider 2014/06/24 12:35:06 Done.
5036 return (value >= static_cast<T>(kMinValue))
5037 && (value <= static_cast<T>(kMaxValue));
5038 } else {
5039 return value <= static_cast<T>(kMaxValue);
5040 }
5035 } 5041 }
5036 5042
5037 RawInteger* ShiftOp(Token::Kind kind, 5043 RawInteger* ShiftOp(Token::Kind kind,
5038 const Smi& other, 5044 const Smi& other,
5039 const bool silent = false) const; 5045 const bool silent = false) const;
5040 5046
5041 void operator=(RawSmi* value) { 5047 void operator=(RawSmi* value) {
5042 raw_ = value; 5048 raw_ = value;
5043 CHECK_HANDLE(); 5049 CHECK_HANDLE();
5044 } 5050 }
(...skipping 2084 matching lines...) Expand 10 before | Expand all | Expand 10 after
7129 7135
7130 7136
7131 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, 7137 RawObject* MegamorphicCache::GetTargetFunction(const Array& array,
7132 intptr_t index) { 7138 intptr_t index) {
7133 return array.At((index * kEntryLength) + kTargetFunctionIndex); 7139 return array.At((index * kEntryLength) + kTargetFunctionIndex);
7134 } 7140 }
7135 7141
7136 } // namespace dart 7142 } // namespace dart
7137 7143
7138 #endif // VM_OBJECT_H_ 7144 #endif // VM_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698