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