Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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_ |
| OLD | NEW |