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 <limits> | |
9 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
10 #include "platform/assert.h" | 9 #include "platform/assert.h" |
11 #include "platform/utils.h" | 10 #include "platform/utils.h" |
12 #include "vm/json_stream.h" | 11 #include "vm/json_stream.h" |
13 #include "vm/bitmap.h" | 12 #include "vm/bitmap.h" |
14 #include "vm/dart.h" | 13 #include "vm/dart.h" |
15 #include "vm/globals.h" | 14 #include "vm/globals.h" |
16 #include "vm/handles.h" | 15 #include "vm/handles.h" |
17 #include "vm/heap.h" | 16 #include "vm/heap.h" |
18 #include "vm/isolate.h" | 17 #include "vm/isolate.h" |
(...skipping 2977 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2996 void AddDescriptor(intptr_t index, | 2995 void AddDescriptor(intptr_t index, |
2997 uword pc, | 2996 uword pc, |
2998 RawPcDescriptors::Kind kind, | 2997 RawPcDescriptors::Kind kind, |
2999 int64_t deopt_id, | 2998 int64_t deopt_id, |
3000 int64_t token_pos, // Or deopt reason. | 2999 int64_t token_pos, // Or deopt reason. |
3001 intptr_t try_index) const { // Or deopt index. | 3000 intptr_t try_index) const { // Or deopt index. |
3002 RawPcDescriptors::PcDescriptorRec* rec = recAt(index); | 3001 RawPcDescriptors::PcDescriptorRec* rec = recAt(index); |
3003 rec->set_pc(pc); | 3002 rec->set_pc(pc); |
3004 rec->set_kind(kind); | 3003 rec->set_kind(kind); |
3005 ASSERT(Utils::IsInt(32, deopt_id)); | 3004 ASSERT(Utils::IsInt(32, deopt_id)); |
3006 rec->set_deopt_id(deopt_id); | 3005 rec->set_deopt_id(static_cast<int32_t>(deopt_id)); |
3007 ASSERT(Utils::IsInt(32, token_pos)); | 3006 ASSERT(Utils::IsInt(32, token_pos)); |
3008 rec->set_token_pos(token_pos, | 3007 rec->set_token_pos(static_cast<int32_t>(token_pos), |
3009 RecordSizeInBytes() == RawPcDescriptors::kCompressedRecSize); | 3008 RecordSizeInBytes() == RawPcDescriptors::kCompressedRecSize); |
3010 ASSERT(Utils::IsInt(16, try_index)); | 3009 ASSERT(Utils::IsInt(16, try_index)); |
3011 rec->set_try_index(try_index); | 3010 rec->set_try_index(try_index); |
3012 ASSERT(rec->try_index() == try_index); | 3011 ASSERT(rec->try_index() == try_index); |
3013 ASSERT(rec->token_pos() == token_pos); | 3012 ASSERT(rec->token_pos() == token_pos); |
3014 } | 3013 } |
3015 | 3014 |
3016 static const intptr_t kMaxBytesPerElement = | 3015 static const intptr_t kMaxBytesPerElement = |
3017 sizeof(RawPcDescriptors::PcDescriptorRec); | 3016 sizeof(RawPcDescriptors::PcDescriptorRec); |
3018 static const intptr_t kMaxElements = kSmiMax / kMaxBytesPerElement; | 3017 static const intptr_t kMaxElements = kSmiMax / kMaxBytesPerElement; |
(...skipping 2052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5071 | 5070 |
5072 virtual double AsDoubleValue() const; | 5071 virtual double AsDoubleValue() const; |
5073 virtual int64_t AsInt64Value() const; | 5072 virtual int64_t AsInt64Value() const; |
5074 virtual uint32_t AsTruncatedUint32Value() const; | 5073 virtual uint32_t AsTruncatedUint32Value() const; |
5075 | 5074 |
5076 virtual int CompareWith(const Integer& other) const; | 5075 virtual int CompareWith(const Integer& other) const; |
5077 | 5076 |
5078 static intptr_t InstanceSize() { return 0; } | 5077 static intptr_t InstanceSize() { return 0; } |
5079 | 5078 |
5080 static RawSmi* New(intptr_t value) { | 5079 static RawSmi* New(intptr_t value) { |
5081 word raw_smi = (value << kSmiTagShift) | kSmiTag; | 5080 intptr_t raw_smi = (value << kSmiTagShift) | kSmiTag; |
5082 ASSERT(ValueFromRaw(raw_smi) == value); | 5081 ASSERT(ValueFromRaw(raw_smi) == value); |
5083 return reinterpret_cast<RawSmi*>(raw_smi); | 5082 return reinterpret_cast<RawSmi*>(raw_smi); |
5084 } | 5083 } |
5085 | 5084 |
5086 static RawClass* Class(); | 5085 static RawClass* Class(); |
5087 | 5086 |
5088 static intptr_t Value(const RawSmi* raw_smi) { | 5087 static intptr_t Value(const RawSmi* raw_smi) { |
5089 return ValueFromRaw(reinterpret_cast<uword>(raw_smi)); | 5088 return ValueFromRaw(reinterpret_cast<uword>(raw_smi)); |
5090 } | 5089 } |
5091 | 5090 |
5092 static intptr_t RawValue(intptr_t value) { | 5091 static intptr_t RawValue(intptr_t value) { |
5093 return reinterpret_cast<intptr_t>(New(value)); | 5092 return reinterpret_cast<intptr_t>(New(value)); |
5094 } | 5093 } |
5095 | 5094 |
5096 template <typename T> | 5095 static bool IsValid(int64_t value) { |
5097 static bool IsValid(T value) { | 5096 return (value >= kMinValue) && (value <= kMaxValue); |
5098 COMPILE_ASSERT(sizeof(kMinValue) == sizeof(kMaxValue)); | |
5099 COMPILE_ASSERT(std::numeric_limits<T>::is_integer); | |
5100 if (sizeof(value) < sizeof(kMinValue)) { | |
5101 return true; | |
5102 } | |
5103 | |
5104 T min_value = std::numeric_limits<T>::is_signed | |
5105 ? static_cast<T>(kMinValue) : 0; | |
5106 return (value >= min_value) | |
5107 && (value <= static_cast<T>(kMaxValue)); | |
5108 } | 5097 } |
5109 | 5098 |
5110 RawInteger* ShiftOp(Token::Kind kind, | 5099 RawInteger* ShiftOp(Token::Kind kind, |
5111 const Smi& other, | 5100 const Smi& other, |
5112 const bool silent = false) const; | 5101 const bool silent = false) const; |
5113 | 5102 |
5114 void operator=(RawSmi* value) { | 5103 void operator=(RawSmi* value) { |
5115 raw_ = value; | 5104 raw_ = value; |
5116 CHECK_HANDLE(); | 5105 CHECK_HANDLE(); |
5117 } | 5106 } |
(...skipping 2129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7247 | 7236 |
7248 | 7237 |
7249 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 7238 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
7250 intptr_t index) { | 7239 intptr_t index) { |
7251 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 7240 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
7252 } | 7241 } |
7253 | 7242 |
7254 } // namespace dart | 7243 } // namespace dart |
7255 | 7244 |
7256 #endif // VM_OBJECT_H_ | 7245 #endif // VM_OBJECT_H_ |
OLD | NEW |