Chromium Code Reviews| 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 4458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4469 // Returns a canonical Integer object allocated in the old gen space. | 4469 // Returns a canonical Integer object allocated in the old gen space. |
| 4470 static RawInteger* NewCanonical(const String& str); | 4470 static RawInteger* NewCanonical(const String& str); |
| 4471 | 4471 |
| 4472 // Do not throw JavascriptIntegerOverflow if 'silent' is true. | 4472 // Do not throw JavascriptIntegerOverflow if 'silent' is true. |
| 4473 static RawInteger* New(int64_t value, | 4473 static RawInteger* New(int64_t value, |
| 4474 Heap::Space space = Heap::kNew, | 4474 Heap::Space space = Heap::kNew, |
| 4475 const bool silent = false); | 4475 const bool silent = false); |
| 4476 | 4476 |
| 4477 virtual double AsDoubleValue() const; | 4477 virtual double AsDoubleValue() const; |
| 4478 virtual int64_t AsInt64Value() const; | 4478 virtual int64_t AsInt64Value() const; |
| 4479 virtual int32_t AsTruncatedUint32Value() const; | |
|
srdjan
2013/11/26 23:39:16
s/int32_t/uint32_t/
Here and below.
Cutch
2013/11/26 23:44:48
Done.
| |
| 4479 | 4480 |
| 4480 // Returns 0, -1 or 1. | 4481 // Returns 0, -1 or 1. |
| 4481 virtual int CompareWith(const Integer& other) const; | 4482 virtual int CompareWith(const Integer& other) const; |
| 4482 | 4483 |
| 4483 // Return the most compact presentation of an integer. | 4484 // Return the most compact presentation of an integer. |
| 4484 RawInteger* AsValidInteger() const; | 4485 RawInteger* AsValidInteger() const; |
| 4485 | 4486 |
| 4486 RawInteger* ArithmeticOp(Token::Kind operation, const Integer& other) const; | 4487 RawInteger* ArithmeticOp(Token::Kind operation, const Integer& other) const; |
| 4487 RawInteger* BitOp(Token::Kind operation, const Integer& other) const; | 4488 RawInteger* BitOp(Token::Kind operation, const Integer& other) const; |
| 4488 | 4489 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 4511 virtual bool Equals(const Instance& other) const; | 4512 virtual bool Equals(const Instance& other) const; |
| 4512 virtual bool IsZero() const { return Value() == 0; } | 4513 virtual bool IsZero() const { return Value() == 0; } |
| 4513 virtual bool IsNegative() const { return Value() < 0; } | 4514 virtual bool IsNegative() const { return Value() < 0; } |
| 4514 // Smi values are implicitly canonicalized. | 4515 // Smi values are implicitly canonicalized. |
| 4515 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { | 4516 virtual RawInstance* CheckAndCanonicalize(const char** error_str) const { |
| 4516 return reinterpret_cast<RawSmi*>(raw_value()); | 4517 return reinterpret_cast<RawSmi*>(raw_value()); |
| 4517 } | 4518 } |
| 4518 | 4519 |
| 4519 virtual double AsDoubleValue() const; | 4520 virtual double AsDoubleValue() const; |
| 4520 virtual int64_t AsInt64Value() const; | 4521 virtual int64_t AsInt64Value() const; |
| 4522 virtual int32_t AsTruncatedUint32Value() const; | |
| 4521 | 4523 |
| 4522 virtual int CompareWith(const Integer& other) const; | 4524 virtual int CompareWith(const Integer& other) const; |
| 4523 | 4525 |
| 4524 static intptr_t InstanceSize() { return 0; } | 4526 static intptr_t InstanceSize() { return 0; } |
| 4525 | 4527 |
| 4526 static RawSmi* New(intptr_t value) { | 4528 static RawSmi* New(intptr_t value) { |
| 4527 word raw_smi = (value << kSmiTagShift) | kSmiTag; | 4529 word raw_smi = (value << kSmiTagShift) | kSmiTag; |
| 4528 ASSERT(ValueFromRaw(raw_smi) == value); | 4530 ASSERT(ValueFromRaw(raw_smi) == value); |
| 4529 return reinterpret_cast<RawSmi*>(raw_smi); | 4531 return reinterpret_cast<RawSmi*>(raw_smi); |
| 4530 } | 4532 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4600 return value() == 0; | 4602 return value() == 0; |
| 4601 } | 4603 } |
| 4602 virtual bool IsNegative() const { | 4604 virtual bool IsNegative() const { |
| 4603 return value() < 0; | 4605 return value() < 0; |
| 4604 } | 4606 } |
| 4605 | 4607 |
| 4606 virtual bool Equals(const Instance& other) const; | 4608 virtual bool Equals(const Instance& other) const; |
| 4607 | 4609 |
| 4608 virtual double AsDoubleValue() const; | 4610 virtual double AsDoubleValue() const; |
| 4609 virtual int64_t AsInt64Value() const; | 4611 virtual int64_t AsInt64Value() const; |
| 4612 virtual int32_t AsTruncatedUint32Value() const; | |
| 4610 | 4613 |
| 4611 virtual int CompareWith(const Integer& other) const; | 4614 virtual int CompareWith(const Integer& other) const; |
| 4612 | 4615 |
| 4613 static intptr_t InstanceSize() { | 4616 static intptr_t InstanceSize() { |
| 4614 return RoundedAllocationSize(sizeof(RawMint)); | 4617 return RoundedAllocationSize(sizeof(RawMint)); |
| 4615 } | 4618 } |
| 4616 | 4619 |
| 4617 protected: | 4620 protected: |
| 4618 // Only Integer::NewXXX is allowed to call Mint::NewXXX directly. | 4621 // Only Integer::NewXXX is allowed to call Mint::NewXXX directly. |
| 4619 friend class Integer; | 4622 friend class Integer; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 4637 static const int kChunkSize = sizeof(Chunk); | 4640 static const int kChunkSize = sizeof(Chunk); |
| 4638 | 4641 |
| 4639 public: | 4642 public: |
| 4640 virtual bool IsZero() const { return raw_ptr()->signed_length_ == 0; } | 4643 virtual bool IsZero() const { return raw_ptr()->signed_length_ == 0; } |
| 4641 virtual bool IsNegative() const { return raw_ptr()->signed_length_ < 0; } | 4644 virtual bool IsNegative() const { return raw_ptr()->signed_length_ < 0; } |
| 4642 | 4645 |
| 4643 virtual bool Equals(const Instance& other) const; | 4646 virtual bool Equals(const Instance& other) const; |
| 4644 | 4647 |
| 4645 virtual double AsDoubleValue() const; | 4648 virtual double AsDoubleValue() const; |
| 4646 virtual int64_t AsInt64Value() const; | 4649 virtual int64_t AsInt64Value() const; |
| 4650 virtual int32_t AsTruncatedUint32Value() const; | |
| 4647 | 4651 |
| 4648 virtual int CompareWith(const Integer& other) const; | 4652 virtual int CompareWith(const Integer& other) const; |
| 4649 | 4653 |
| 4650 static const intptr_t kBytesPerElement = kChunkSize; | 4654 static const intptr_t kBytesPerElement = kChunkSize; |
| 4651 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; | 4655 static const intptr_t kMaxElements = kSmiMax / kBytesPerElement; |
| 4652 | 4656 |
| 4653 static intptr_t InstanceSize() { return 0; } | 4657 static intptr_t InstanceSize() { return 0; } |
| 4654 | 4658 |
| 4655 static intptr_t InstanceSize(intptr_t len) { | 4659 static intptr_t InstanceSize(intptr_t len) { |
| 4656 ASSERT(0 <= len && len <= kMaxElements); | 4660 ASSERT(0 <= len && len <= kMaxElements); |
| (...skipping 1774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6431 | 6435 |
| 6432 | 6436 |
| 6433 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 6437 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 6434 intptr_t index) { | 6438 intptr_t index) { |
| 6435 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 6439 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 6436 } | 6440 } |
| 6437 | 6441 |
| 6438 } // namespace dart | 6442 } // namespace dart |
| 6439 | 6443 |
| 6440 #endif // VM_OBJECT_H_ | 6444 #endif // VM_OBJECT_H_ |
| OLD | NEW |