Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: runtime/vm/object.h

Issue 2992733003: Revert "[vm] Revise Dart_IntegerToHexCString to avoid dependency on Bigint" (Closed)
Patch Set: Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
6473 // Return the most compact presentation of an integer. 6468 // Return the most compact presentation of an integer.
6474 RawInteger* AsValidInteger() const; 6469 RawInteger* AsValidInteger() const;
6475 6470
6476 // Returns null to indicate that a bigint operation is required. 6471 // Returns null to indicate that a bigint operation is required.
6477 RawInteger* ArithmeticOp(Token::Kind operation, 6472 RawInteger* ArithmeticOp(Token::Kind operation,
6478 const Integer& other, 6473 const Integer& other,
6479 Heap::Space space = Heap::kNew) const; 6474 Heap::Space space = Heap::kNew) const;
6480 RawInteger* BitOp(Token::Kind operation, 6475 RawInteger* BitOp(Token::Kind operation,
6481 const Integer& other, 6476 const Integer& other,
6482 Heap::Space space = Heap::kNew) const; 6477 Heap::Space space = Heap::kNew) const;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
6620 virtual bool IsNegative() const { return Neg(); } 6615 virtual bool IsNegative() const { return Neg(); }
6621 virtual bool Equals(const Instance& other) const; 6616 virtual bool Equals(const Instance& other) const;
6622 6617
6623 virtual double AsDoubleValue() const; 6618 virtual double AsDoubleValue() const;
6624 virtual int64_t AsInt64Value() const; 6619 virtual int64_t AsInt64Value() const;
6625 virtual int64_t AsTruncatedInt64Value() const; 6620 virtual int64_t AsTruncatedInt64Value() const;
6626 virtual uint32_t AsTruncatedUint32Value() const; 6621 virtual uint32_t AsTruncatedUint32Value() const;
6627 6622
6628 virtual int CompareWith(const Integer& other) const; 6623 virtual int CompareWith(const Integer& other) const;
6629 6624
6630 virtual const char* ToHexCString(Zone* zone) const;
6631
6632 virtual bool CheckAndCanonicalizeFields(Thread* thread, 6625 virtual bool CheckAndCanonicalizeFields(Thread* thread,
6633 const char** error_str) const; 6626 const char** error_str) const;
6634 6627
6635 virtual bool FitsIntoSmi() const; 6628 virtual bool FitsIntoSmi() const;
6636 bool FitsIntoInt64() const; 6629 bool FitsIntoInt64() const;
6637 bool FitsIntoUint64() const; 6630 bool FitsIntoUint64() const;
6638 uint64_t AsUint64Value() const; 6631 uint64_t AsUint64Value() const;
6639 6632
6640 static intptr_t InstanceSize() { 6633 static intptr_t InstanceSize() {
6641 return RoundedAllocationSize(sizeof(RawBigint)); 6634 return RoundedAllocationSize(sizeof(RawBigint));
6642 } 6635 }
6643 6636
6644 // Offsets of fields accessed directly by optimized code. 6637 // Offsets of fields accessed directly by optimized code.
6645 static intptr_t neg_offset() { return OFFSET_OF(RawBigint, neg_); } 6638 static intptr_t neg_offset() { return OFFSET_OF(RawBigint, neg_); }
6646 static intptr_t used_offset() { return OFFSET_OF(RawBigint, used_); } 6639 static intptr_t used_offset() { return OFFSET_OF(RawBigint, used_); }
6647 static intptr_t digits_offset() { return OFFSET_OF(RawBigint, digits_); } 6640 static intptr_t digits_offset() { return OFFSET_OF(RawBigint, digits_); }
6648 6641
6649 // Accessors used by native calls from Dart. 6642 // Accessors used by native calls from Dart.
6650 RawBool* neg() const { return raw_ptr()->neg_; } 6643 RawBool* neg() const { return raw_ptr()->neg_; }
6651 RawSmi* used() const { return raw_ptr()->used_; } 6644 RawSmi* used() const { return raw_ptr()->used_; }
6652 RawTypedData* digits() const { return raw_ptr()->digits_; } 6645 RawTypedData* digits() const { return raw_ptr()->digits_; }
6653 6646
6654 // Accessors used by runtime calls from C++. 6647 // Accessors used by runtime calls from C++.
6655 bool Neg() const; 6648 bool Neg() const;
6656 intptr_t Used() const; 6649 intptr_t Used() const;
6657 uint32_t DigitAt(intptr_t index) const; 6650 uint32_t DigitAt(intptr_t index) const;
6658 6651
6659 const char* ToDecCString(Zone* zone) const; 6652 const char* ToDecCString(Zone* zone) const;
6653 const char* ToHexCString(Zone* zone) const;
6660 6654
6661 static const intptr_t kBitsPerDigit = 32; // Same as _Bigint._DIGIT_BITS 6655 static const intptr_t kBitsPerDigit = 32; // Same as _Bigint._DIGIT_BITS
6662 static const intptr_t kBytesPerDigit = 4; 6656 static const intptr_t kBytesPerDigit = 4;
6663 static const int64_t kDigitBase = 1LL << kBitsPerDigit; 6657 static const int64_t kDigitBase = 1LL << kBitsPerDigit;
6664 static const int64_t kDigitMask = kDigitBase - 1; 6658 static const int64_t kDigitMask = kDigitBase - 1;
6665 6659
6666 static RawBigint* New(Heap::Space space = Heap::kNew); // For snapshots. 6660 static RawBigint* New(Heap::Space space = Heap::kNew); // For snapshots.
6667 6661
6668 static RawBigint* New(bool neg, 6662 static RawBigint* New(bool neg,
6669 intptr_t used, 6663 intptr_t used,
(...skipping 2328 matching lines...) Expand 10 before | Expand all | Expand 10 after
8998 8992
8999 inline void TypeArguments::SetHash(intptr_t value) const { 8993 inline void TypeArguments::SetHash(intptr_t value) const {
9000 // This is only safe because we create a new Smi, which does not cause 8994 // This is only safe because we create a new Smi, which does not cause
9001 // heap allocation. 8995 // heap allocation.
9002 StoreSmi(&raw_ptr()->hash_, Smi::New(value)); 8996 StoreSmi(&raw_ptr()->hash_, Smi::New(value));
9003 } 8997 }
9004 8998
9005 } // namespace dart 8999 } // namespace dart
9006 9000
9007 #endif // RUNTIME_VM_OBJECT_H_ 9001 #endif // RUNTIME_VM_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698