| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // Review notes: | 5 // Review notes: |
| 6 // | 6 // |
| 7 // - The use of macros in these inline functions may seem superfluous | 7 // - The use of macros in these inline functions may seem superfluous |
| 8 // but it is absolutely needed to make sure gcc generates optimal | 8 // but it is absolutely needed to make sure gcc generates optimal |
| 9 // code. gcc is not happy when attempting to inline too deep. | 9 // code. gcc is not happy when attempting to inline too deep. |
| 10 // | 10 // |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 int chars_; // Caches the number of characters when computing the hash code. | 628 int chars_; // Caches the number of characters when computing the hash code. |
| 629 uint32_t seed_; | 629 uint32_t seed_; |
| 630 }; | 630 }; |
| 631 | 631 |
| 632 | 632 |
| 633 bool Object::IsNumber() const { | 633 bool Object::IsNumber() const { |
| 634 return IsSmi() || IsHeapNumber(); | 634 return IsSmi() || IsHeapNumber(); |
| 635 } | 635 } |
| 636 | 636 |
| 637 | 637 |
| 638 bool Object::IsInt32() const { |
| 639 if (IsSmi()) return true; |
| 640 if (IsNumber()) { |
| 641 return IsInt32Double(Number()); |
| 642 } |
| 643 return false; |
| 644 } |
| 645 |
| 646 |
| 647 bool Object::IsUint32() const { |
| 648 if (IsSmi()) return Smi::cast(this)->value() >= 0; |
| 649 if (IsNumber()) { |
| 650 double value = Number(); |
| 651 return !i::IsMinusZero(value) && value >= 0 && value <= kMaxUInt32 && |
| 652 value == FastUI2D(i::FastD2UI(value)); |
| 653 } |
| 654 return false; |
| 655 } |
| 656 |
| 657 |
| 638 TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE) | 658 TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE) |
| 639 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) | 659 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) |
| 640 | 660 |
| 641 | 661 |
| 642 bool Object::IsFiller() const { | 662 bool Object::IsFiller() const { |
| 643 if (!Object::IsHeapObject()) return false; | 663 if (!Object::IsHeapObject()) return false; |
| 644 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); | 664 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); |
| 645 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; | 665 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; |
| 646 } | 666 } |
| 647 | 667 |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 bool Object::IsFalse() const { | 1104 bool Object::IsFalse() const { |
| 1085 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kFalse; | 1105 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kFalse; |
| 1086 } | 1106 } |
| 1087 | 1107 |
| 1088 | 1108 |
| 1089 bool Object::IsArgumentsMarker() const { | 1109 bool Object::IsArgumentsMarker() const { |
| 1090 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kArgumentMarker; | 1110 return IsOddball() && Oddball::cast(this)->kind() == Oddball::kArgumentMarker; |
| 1091 } | 1111 } |
| 1092 | 1112 |
| 1093 | 1113 |
| 1094 double Object::Number() { | 1114 double Object::Number() const { |
| 1095 DCHECK(IsNumber()); | 1115 DCHECK(IsNumber()); |
| 1096 return IsSmi() | 1116 return IsSmi() |
| 1097 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value()) | 1117 ? static_cast<double>(reinterpret_cast<const Smi*>(this)->value()) |
| 1098 : reinterpret_cast<HeapNumber*>(this)->value(); | 1118 : reinterpret_cast<const HeapNumber*>(this)->value(); |
| 1099 } | 1119 } |
| 1100 | 1120 |
| 1101 | 1121 |
| 1102 bool Object::IsNaN() const { | 1122 bool Object::IsNaN() const { |
| 1103 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value()); | 1123 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value()); |
| 1104 } | 1124 } |
| 1105 | 1125 |
| 1106 | 1126 |
| 1107 bool Object::IsMinusZero() const { | 1127 bool Object::IsMinusZero() const { |
| 1108 return this->IsHeapNumber() && | 1128 return this->IsHeapNumber() && |
| (...skipping 6408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7517 #undef READ_SHORT_FIELD | 7537 #undef READ_SHORT_FIELD |
| 7518 #undef WRITE_SHORT_FIELD | 7538 #undef WRITE_SHORT_FIELD |
| 7519 #undef READ_BYTE_FIELD | 7539 #undef READ_BYTE_FIELD |
| 7520 #undef WRITE_BYTE_FIELD | 7540 #undef WRITE_BYTE_FIELD |
| 7521 #undef NOBARRIER_READ_BYTE_FIELD | 7541 #undef NOBARRIER_READ_BYTE_FIELD |
| 7522 #undef NOBARRIER_WRITE_BYTE_FIELD | 7542 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7523 | 7543 |
| 7524 } } // namespace v8::internal | 7544 } } // namespace v8::internal |
| 7525 | 7545 |
| 7526 #endif // V8_OBJECTS_INL_H_ | 7546 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |