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 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 bool Object::IsDeoptimizationInputData() const { | 724 bool Object::IsDeoptimizationInputData() const { |
725 // Must be a fixed array. | 725 // Must be a fixed array. |
726 if (!IsFixedArray()) return false; | 726 if (!IsFixedArray()) return false; |
727 | 727 |
728 // There's no sure way to detect the difference between a fixed array and | 728 // There's no sure way to detect the difference between a fixed array and |
729 // a deoptimization data array. Since this is used for asserts we can | 729 // a deoptimization data array. Since this is used for asserts we can |
730 // check that the length is zero or else the fixed size plus a multiple of | 730 // check that the length is zero or else the fixed size plus a multiple of |
731 // the entry size. | 731 // the entry size. |
732 int length = FixedArray::cast(this)->length(); | 732 int length = FixedArray::cast(this)->length(); |
733 if (length == 0) return true; | 733 if (length == 0) return true; |
| 734 if (length < DeoptimizationInputData::kFirstDeoptEntryIndex) return false; |
734 | 735 |
735 length -= DeoptimizationInputData::kFirstDeoptEntryIndex; | 736 FixedArray* self = FixedArray::cast(const_cast<Object*>(this)); |
736 return length >= 0 && | 737 int deopt_count = |
737 length % DeoptimizationInputData::kDeoptEntrySize == 0; | 738 Smi::cast(self->get(DeoptimizationInputData::kDeoptEntryCountIndex)) |
| 739 ->value(); |
| 740 int patch_count = |
| 741 Smi::cast( |
| 742 self->get( |
| 743 DeoptimizationInputData::kReturnAddressPatchEntryCountIndex)) |
| 744 ->value(); |
| 745 |
| 746 return length == DeoptimizationInputData::LengthFor(deopt_count, patch_count); |
738 } | 747 } |
739 | 748 |
740 | 749 |
741 bool Object::IsDeoptimizationOutputData() const { | 750 bool Object::IsDeoptimizationOutputData() const { |
742 if (!IsFixedArray()) return false; | 751 if (!IsFixedArray()) return false; |
743 // There's actually no way to see the difference between a fixed array and | 752 // There's actually no way to see the difference between a fixed array and |
744 // a deoptimization data array. Since this is used for asserts we can check | 753 // a deoptimization data array. Since this is used for asserts we can check |
745 // that the length is plausible though. | 754 // that the length is plausible though. |
746 if (FixedArray::cast(this)->length() % 2 != 0) return false; | 755 if (FixedArray::cast(this)->length() % 2 != 0) return false; |
747 return true; | 756 return true; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value()) | 1084 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value()) |
1076 : reinterpret_cast<HeapNumber*>(this)->value(); | 1085 : reinterpret_cast<HeapNumber*>(this)->value(); |
1077 } | 1086 } |
1078 | 1087 |
1079 | 1088 |
1080 bool Object::IsNaN() const { | 1089 bool Object::IsNaN() const { |
1081 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value()); | 1090 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value()); |
1082 } | 1091 } |
1083 | 1092 |
1084 | 1093 |
| 1094 bool Object::IsMinusZero() const { |
| 1095 return this->IsHeapNumber() && |
| 1096 i::IsMinusZero(HeapNumber::cast(this)->value()); |
| 1097 } |
| 1098 |
| 1099 |
1085 MaybeHandle<Smi> Object::ToSmi(Isolate* isolate, Handle<Object> object) { | 1100 MaybeHandle<Smi> Object::ToSmi(Isolate* isolate, Handle<Object> object) { |
1086 if (object->IsSmi()) return Handle<Smi>::cast(object); | 1101 if (object->IsSmi()) return Handle<Smi>::cast(object); |
1087 if (object->IsHeapNumber()) { | 1102 if (object->IsHeapNumber()) { |
1088 double value = Handle<HeapNumber>::cast(object)->value(); | 1103 double value = Handle<HeapNumber>::cast(object)->value(); |
1089 int int_value = FastD2I(value); | 1104 int int_value = FastD2I(value); |
1090 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | 1105 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { |
1091 return handle(Smi::FromInt(int_value), isolate); | 1106 return handle(Smi::FromInt(int_value), isolate); |
1092 } | 1107 } |
1093 } | 1108 } |
1094 return Handle<Smi>(); | 1109 return Handle<Smi>(); |
(...skipping 3601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4696 } | 4711 } |
4697 | 4712 |
4698 | 4713 |
4699 inline void Code::set_is_crankshafted(bool value) { | 4714 inline void Code::set_is_crankshafted(bool value) { |
4700 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); | 4715 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags2Offset); |
4701 int updated = IsCrankshaftedField::update(previous, value); | 4716 int updated = IsCrankshaftedField::update(previous, value); |
4702 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); | 4717 WRITE_UINT32_FIELD(this, kKindSpecificFlags2Offset, updated); |
4703 } | 4718 } |
4704 | 4719 |
4705 | 4720 |
| 4721 inline bool Code::is_turbofanned() { |
| 4722 ASSERT(kind() == OPTIMIZED_FUNCTION || kind() == STUB); |
| 4723 return IsTurbofannedField::decode( |
| 4724 READ_UINT32_FIELD(this, kKindSpecificFlags1Offset)); |
| 4725 } |
| 4726 |
| 4727 |
| 4728 inline void Code::set_is_turbofanned(bool value) { |
| 4729 ASSERT(kind() == OPTIMIZED_FUNCTION || kind() == STUB); |
| 4730 int previous = READ_UINT32_FIELD(this, kKindSpecificFlags1Offset); |
| 4731 int updated = IsTurbofannedField::update(previous, value); |
| 4732 WRITE_UINT32_FIELD(this, kKindSpecificFlags1Offset, updated); |
| 4733 } |
| 4734 |
| 4735 |
4706 bool Code::optimizable() { | 4736 bool Code::optimizable() { |
4707 ASSERT_EQ(FUNCTION, kind()); | 4737 ASSERT_EQ(FUNCTION, kind()); |
4708 return READ_BYTE_FIELD(this, kOptimizableOffset) == 1; | 4738 return READ_BYTE_FIELD(this, kOptimizableOffset) == 1; |
4709 } | 4739 } |
4710 | 4740 |
4711 | 4741 |
4712 void Code::set_optimizable(bool value) { | 4742 void Code::set_optimizable(bool value) { |
4713 ASSERT_EQ(FUNCTION, kind()); | 4743 ASSERT_EQ(FUNCTION, kind()); |
4714 WRITE_BYTE_FIELD(this, kOptimizableOffset, value ? 1 : 0); | 4744 WRITE_BYTE_FIELD(this, kOptimizableOffset, value ? 1 : 0); |
4715 } | 4745 } |
(...skipping 2512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7228 #undef READ_SHORT_FIELD | 7258 #undef READ_SHORT_FIELD |
7229 #undef WRITE_SHORT_FIELD | 7259 #undef WRITE_SHORT_FIELD |
7230 #undef READ_BYTE_FIELD | 7260 #undef READ_BYTE_FIELD |
7231 #undef WRITE_BYTE_FIELD | 7261 #undef WRITE_BYTE_FIELD |
7232 #undef NOBARRIER_READ_BYTE_FIELD | 7262 #undef NOBARRIER_READ_BYTE_FIELD |
7233 #undef NOBARRIER_WRITE_BYTE_FIELD | 7263 #undef NOBARRIER_WRITE_BYTE_FIELD |
7234 | 7264 |
7235 } } // namespace v8::internal | 7265 } } // namespace v8::internal |
7236 | 7266 |
7237 #endif // V8_OBJECTS_INL_H_ | 7267 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |