| 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 3909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3920 | 3920 |
| 3921 class Integer : public Number { | 3921 class Integer : public Number { |
| 3922 public: | 3922 public: |
| 3923 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew); | 3923 static RawInteger* New(const String& str, Heap::Space space = Heap::kNew); |
| 3924 | 3924 |
| 3925 // Returns a canonical Integer object allocated in the old gen space. | 3925 // Returns a canonical Integer object allocated in the old gen space. |
| 3926 static RawInteger* NewCanonical(const String& str); | 3926 static RawInteger* NewCanonical(const String& str); |
| 3927 | 3927 |
| 3928 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew); | 3928 static RawInteger* New(int64_t value, Heap::Space space = Heap::kNew); |
| 3929 | 3929 |
| 3930 // Check if an Integer exceeds 53 bits, and if so throw an exception. |
| 3931 static void CheckForFiftyThreeBitOverflow(const Integer& i, const char* msg); |
| 3932 |
| 3930 virtual double AsDoubleValue() const; | 3933 virtual double AsDoubleValue() const; |
| 3931 virtual int64_t AsInt64Value() const; | 3934 virtual int64_t AsInt64Value() const; |
| 3932 | 3935 |
| 3936 virtual bool FitsIn53Bits() const; |
| 3937 |
| 3933 // Returns 0, -1 or 1. | 3938 // Returns 0, -1 or 1. |
| 3934 virtual int CompareWith(const Integer& other) const; | 3939 virtual int CompareWith(const Integer& other) const; |
| 3935 | 3940 |
| 3936 // Return the most compact presentation of an integer. | 3941 // Return the most compact presentation of an integer. |
| 3937 RawInteger* AsValidInteger() const; | 3942 RawInteger* AsValidInteger() const; |
| 3938 | 3943 |
| 3939 RawInteger* ArithmeticOp(Token::Kind operation, const Integer& other) const; | 3944 RawInteger* ArithmeticOp(Token::Kind operation, const Integer& other) const; |
| 3940 RawInteger* BitOp(Token::Kind operation, const Integer& other) const; | 3945 RawInteger* BitOp(Token::Kind operation, const Integer& other) const; |
| 3941 | 3946 |
| 3942 private: | 3947 private: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3962 virtual bool IsZero() const { return Value() == 0; } | 3967 virtual bool IsZero() const { return Value() == 0; } |
| 3963 virtual bool IsNegative() const { return Value() < 0; } | 3968 virtual bool IsNegative() const { return Value() < 0; } |
| 3964 // Smi values are implicitly canonicalized. | 3969 // Smi values are implicitly canonicalized. |
| 3965 virtual RawInstance* Canonicalize() const { | 3970 virtual RawInstance* Canonicalize() const { |
| 3966 return reinterpret_cast<RawSmi*>(raw_value()); | 3971 return reinterpret_cast<RawSmi*>(raw_value()); |
| 3967 } | 3972 } |
| 3968 | 3973 |
| 3969 virtual double AsDoubleValue() const; | 3974 virtual double AsDoubleValue() const; |
| 3970 virtual int64_t AsInt64Value() const; | 3975 virtual int64_t AsInt64Value() const; |
| 3971 | 3976 |
| 3977 virtual bool FitsIn53Bits() const { return true; } |
| 3978 |
| 3972 virtual int CompareWith(const Integer& other) const; | 3979 virtual int CompareWith(const Integer& other) const; |
| 3973 | 3980 |
| 3974 static intptr_t InstanceSize() { return 0; } | 3981 static intptr_t InstanceSize() { return 0; } |
| 3975 | 3982 |
| 3976 static RawSmi* New(intptr_t value) { | 3983 static RawSmi* New(intptr_t value) { |
| 3977 word raw_smi = (value << kSmiTagShift) | kSmiTag; | 3984 word raw_smi = (value << kSmiTagShift) | kSmiTag; |
| 3978 ASSERT(ValueFromRaw(raw_smi) == value); | 3985 ASSERT(ValueFromRaw(raw_smi) == value); |
| 3979 return reinterpret_cast<RawSmi*>(raw_smi); | 3986 return reinterpret_cast<RawSmi*>(raw_smi); |
| 3980 } | 3987 } |
| 3981 | 3988 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4043 } | 4050 } |
| 4044 virtual bool IsNegative() const { | 4051 virtual bool IsNegative() const { |
| 4045 return value() < 0; | 4052 return value() < 0; |
| 4046 } | 4053 } |
| 4047 | 4054 |
| 4048 virtual bool Equals(const Instance& other) const; | 4055 virtual bool Equals(const Instance& other) const; |
| 4049 | 4056 |
| 4050 virtual double AsDoubleValue() const; | 4057 virtual double AsDoubleValue() const; |
| 4051 virtual int64_t AsInt64Value() const; | 4058 virtual int64_t AsInt64Value() const; |
| 4052 | 4059 |
| 4060 virtual bool FitsIn53Bits() const; |
| 4061 |
| 4053 virtual int CompareWith(const Integer& other) const; | 4062 virtual int CompareWith(const Integer& other) const; |
| 4054 | 4063 |
| 4055 static intptr_t InstanceSize() { | 4064 static intptr_t InstanceSize() { |
| 4056 return RoundedAllocationSize(sizeof(RawMint)); | 4065 return RoundedAllocationSize(sizeof(RawMint)); |
| 4057 } | 4066 } |
| 4058 | 4067 |
| 4059 protected: | 4068 protected: |
| 4060 // Only Integer::NewXXX is allowed to call Mint::NewXXX directly. | 4069 // Only Integer::NewXXX is allowed to call Mint::NewXXX directly. |
| 4061 friend class Integer; | 4070 friend class Integer; |
| 4062 | 4071 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 4080 | 4089 |
| 4081 public: | 4090 public: |
| 4082 virtual bool IsZero() const { return raw_ptr()->signed_length_ == 0; } | 4091 virtual bool IsZero() const { return raw_ptr()->signed_length_ == 0; } |
| 4083 virtual bool IsNegative() const { return raw_ptr()->signed_length_ < 0; } | 4092 virtual bool IsNegative() const { return raw_ptr()->signed_length_ < 0; } |
| 4084 | 4093 |
| 4085 virtual bool Equals(const Instance& other) const; | 4094 virtual bool Equals(const Instance& other) const; |
| 4086 | 4095 |
| 4087 virtual double AsDoubleValue() const; | 4096 virtual double AsDoubleValue() const; |
| 4088 virtual int64_t AsInt64Value() const; | 4097 virtual int64_t AsInt64Value() const; |
| 4089 | 4098 |
| 4099 virtual bool FitsIn53Bits() const { return false; } |
| 4100 |
| 4090 virtual int CompareWith(const Integer& other) const; | 4101 virtual int CompareWith(const Integer& other) const; |
| 4091 | 4102 |
| 4092 static const intptr_t kBytesPerElement = kChunkSize; | 4103 static const intptr_t kBytesPerElement = kChunkSize; |
| 4093 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 4104 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 4094 | 4105 |
| 4095 static intptr_t InstanceSize() { return 0; } | 4106 static intptr_t InstanceSize() { return 0; } |
| 4096 | 4107 |
| 4097 static intptr_t InstanceSize(intptr_t len) { | 4108 static intptr_t InstanceSize(intptr_t len) { |
| 4098 ASSERT(0 <= len && len <= kMaxElements); | 4109 ASSERT(0 <= len && len <= kMaxElements); |
| 4099 return RoundedAllocationSize(sizeof(RawBigint) + (len * kBytesPerElement)); | 4110 return RoundedAllocationSize(sizeof(RawBigint) + (len * kBytesPerElement)); |
| (...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5768 | 5779 |
| 5769 | 5780 |
| 5770 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 5781 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 5771 intptr_t index) { | 5782 intptr_t index) { |
| 5772 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 5783 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 5773 } | 5784 } |
| 5774 | 5785 |
| 5775 } // namespace dart | 5786 } // namespace dart |
| 5776 | 5787 |
| 5777 #endif // VM_OBJECT_H_ | 5788 #endif // VM_OBJECT_H_ |
| OLD | NEW |