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