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 RUNTIME_VM_OBJECT_H_ | 5 #ifndef RUNTIME_VM_OBJECT_H_ |
6 #define RUNTIME_VM_OBJECT_H_ | 6 #define RUNTIME_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 6440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6451 virtual double AsDoubleValue() const; | 6451 virtual double AsDoubleValue() const; |
6452 virtual int64_t AsInt64Value() const; | 6452 virtual int64_t AsInt64Value() const; |
6453 virtual int64_t AsTruncatedInt64Value() const { return AsInt64Value(); } | 6453 virtual int64_t AsTruncatedInt64Value() const { return AsInt64Value(); } |
6454 virtual uint32_t AsTruncatedUint32Value() const; | 6454 virtual uint32_t AsTruncatedUint32Value() const; |
6455 | 6455 |
6456 virtual bool FitsIntoSmi() const; | 6456 virtual bool FitsIntoSmi() const; |
6457 | 6457 |
6458 // Returns 0, -1 or 1. | 6458 // Returns 0, -1 or 1. |
6459 virtual int CompareWith(const Integer& other) const; | 6459 virtual int CompareWith(const Integer& other) const; |
6460 | 6460 |
| 6461 // Converts integer to hex string. |
| 6462 // TODO(alexmarkov): this method can become non-virtual once Bigint class is |
| 6463 // decoupled from Integer hierarchy. |
| 6464 virtual const char* ToHexCString(Zone* zone) const; |
| 6465 |
6461 // Return the most compact presentation of an integer. | 6466 // Return the most compact presentation of an integer. |
6462 RawInteger* AsValidInteger() const; | 6467 RawInteger* AsValidInteger() const; |
6463 | 6468 |
6464 // Returns null to indicate that a bigint operation is required. | 6469 // Returns null to indicate that a bigint operation is required. |
6465 RawInteger* ArithmeticOp(Token::Kind operation, | 6470 RawInteger* ArithmeticOp(Token::Kind operation, |
6466 const Integer& other, | 6471 const Integer& other, |
6467 Heap::Space space = Heap::kNew) const; | 6472 Heap::Space space = Heap::kNew) const; |
6468 RawInteger* BitOp(Token::Kind operation, | 6473 RawInteger* BitOp(Token::Kind operation, |
6469 const Integer& other, | 6474 const Integer& other, |
6470 Heap::Space space = Heap::kNew) const; | 6475 Heap::Space space = Heap::kNew) const; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6608 virtual bool IsNegative() const { return Neg(); } | 6613 virtual bool IsNegative() const { return Neg(); } |
6609 virtual bool Equals(const Instance& other) const; | 6614 virtual bool Equals(const Instance& other) const; |
6610 | 6615 |
6611 virtual double AsDoubleValue() const; | 6616 virtual double AsDoubleValue() const; |
6612 virtual int64_t AsInt64Value() const; | 6617 virtual int64_t AsInt64Value() const; |
6613 virtual int64_t AsTruncatedInt64Value() const; | 6618 virtual int64_t AsTruncatedInt64Value() const; |
6614 virtual uint32_t AsTruncatedUint32Value() const; | 6619 virtual uint32_t AsTruncatedUint32Value() const; |
6615 | 6620 |
6616 virtual int CompareWith(const Integer& other) const; | 6621 virtual int CompareWith(const Integer& other) const; |
6617 | 6622 |
| 6623 virtual const char* ToHexCString(Zone* zone) const; |
| 6624 |
6618 virtual bool CheckAndCanonicalizeFields(Thread* thread, | 6625 virtual bool CheckAndCanonicalizeFields(Thread* thread, |
6619 const char** error_str) const; | 6626 const char** error_str) const; |
6620 | 6627 |
6621 virtual bool FitsIntoSmi() const; | 6628 virtual bool FitsIntoSmi() const; |
6622 bool FitsIntoInt64() const; | 6629 bool FitsIntoInt64() const; |
6623 bool FitsIntoUint64() const; | 6630 bool FitsIntoUint64() const; |
6624 uint64_t AsUint64Value() const; | 6631 uint64_t AsUint64Value() const; |
6625 | 6632 |
6626 static intptr_t InstanceSize() { | 6633 static intptr_t InstanceSize() { |
6627 return RoundedAllocationSize(sizeof(RawBigint)); | 6634 return RoundedAllocationSize(sizeof(RawBigint)); |
6628 } | 6635 } |
6629 | 6636 |
6630 // Offsets of fields accessed directly by optimized code. | 6637 // Offsets of fields accessed directly by optimized code. |
6631 static intptr_t neg_offset() { return OFFSET_OF(RawBigint, neg_); } | 6638 static intptr_t neg_offset() { return OFFSET_OF(RawBigint, neg_); } |
6632 static intptr_t used_offset() { return OFFSET_OF(RawBigint, used_); } | 6639 static intptr_t used_offset() { return OFFSET_OF(RawBigint, used_); } |
6633 static intptr_t digits_offset() { return OFFSET_OF(RawBigint, digits_); } | 6640 static intptr_t digits_offset() { return OFFSET_OF(RawBigint, digits_); } |
6634 | 6641 |
6635 // Accessors used by native calls from Dart. | 6642 // Accessors used by native calls from Dart. |
6636 RawBool* neg() const { return raw_ptr()->neg_; } | 6643 RawBool* neg() const { return raw_ptr()->neg_; } |
6637 RawSmi* used() const { return raw_ptr()->used_; } | 6644 RawSmi* used() const { return raw_ptr()->used_; } |
6638 RawTypedData* digits() const { return raw_ptr()->digits_; } | 6645 RawTypedData* digits() const { return raw_ptr()->digits_; } |
6639 | 6646 |
6640 // Accessors used by runtime calls from C++. | 6647 // Accessors used by runtime calls from C++. |
6641 bool Neg() const; | 6648 bool Neg() const; |
6642 intptr_t Used() const; | 6649 intptr_t Used() const; |
6643 uint32_t DigitAt(intptr_t index) const; | 6650 uint32_t DigitAt(intptr_t index) const; |
6644 | 6651 |
6645 const char* ToDecCString(Zone* zone) const; | 6652 const char* ToDecCString(Zone* zone) const; |
6646 const char* ToHexCString(Zone* zone) const; | |
6647 | 6653 |
6648 static const intptr_t kBitsPerDigit = 32; // Same as _Bigint._DIGIT_BITS | 6654 static const intptr_t kBitsPerDigit = 32; // Same as _Bigint._DIGIT_BITS |
6649 static const intptr_t kBytesPerDigit = 4; | 6655 static const intptr_t kBytesPerDigit = 4; |
6650 static const int64_t kDigitBase = 1LL << kBitsPerDigit; | 6656 static const int64_t kDigitBase = 1LL << kBitsPerDigit; |
6651 static const int64_t kDigitMask = kDigitBase - 1; | 6657 static const int64_t kDigitMask = kDigitBase - 1; |
6652 | 6658 |
6653 static RawBigint* New(Heap::Space space = Heap::kNew); // For snapshots. | 6659 static RawBigint* New(Heap::Space space = Heap::kNew); // For snapshots. |
6654 | 6660 |
6655 static RawBigint* New(bool neg, | 6661 static RawBigint* New(bool neg, |
6656 intptr_t used, | 6662 intptr_t used, |
(...skipping 2328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8985 | 8991 |
8986 inline void TypeArguments::SetHash(intptr_t value) const { | 8992 inline void TypeArguments::SetHash(intptr_t value) const { |
8987 // This is only safe because we create a new Smi, which does not cause | 8993 // This is only safe because we create a new Smi, which does not cause |
8988 // heap allocation. | 8994 // heap allocation. |
8989 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); | 8995 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); |
8990 } | 8996 } |
8991 | 8997 |
8992 } // namespace dart | 8998 } // namespace dart |
8993 | 8999 |
8994 #endif // RUNTIME_VM_OBJECT_H_ | 9000 #endif // RUNTIME_VM_OBJECT_H_ |
OLD | NEW |