| 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 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1125 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value()); | 1125 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value()); |
| 1126 } | 1126 } |
| 1127 | 1127 |
| 1128 | 1128 |
| 1129 bool Object::IsMinusZero() const { | 1129 bool Object::IsMinusZero() const { |
| 1130 return this->IsHeapNumber() && | 1130 return this->IsHeapNumber() && |
| 1131 i::IsMinusZero(HeapNumber::cast(this)->value()); | 1131 i::IsMinusZero(HeapNumber::cast(this)->value()); |
| 1132 } | 1132 } |
| 1133 | 1133 |
| 1134 | 1134 |
| 1135 MaybeHandle<Smi> Object::ToSmi(Isolate* isolate, Handle<Object> object) { | |
| 1136 if (object->IsSmi()) return Handle<Smi>::cast(object); | |
| 1137 if (object->IsHeapNumber()) { | |
| 1138 double value = Handle<HeapNumber>::cast(object)->value(); | |
| 1139 int int_value = FastD2I(value); | |
| 1140 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | |
| 1141 return handle(Smi::FromInt(int_value), isolate); | |
| 1142 } | |
| 1143 } | |
| 1144 return Handle<Smi>(); | |
| 1145 } | |
| 1146 | |
| 1147 | |
| 1148 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, | 1135 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, |
| 1149 Handle<Object> object) { | 1136 Handle<Object> object) { |
| 1150 return ToObject( | 1137 return ToObject( |
| 1151 isolate, object, handle(isolate->context()->native_context(), isolate)); | 1138 isolate, object, handle(isolate->context()->native_context(), isolate)); |
| 1152 } | 1139 } |
| 1153 | 1140 |
| 1154 | 1141 |
| 1155 bool Object::HasSpecificClassOf(String* name) { | 1142 bool Object::HasSpecificClassOf(String* name) { |
| 1156 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name); | 1143 return this->IsJSObject() && (JSObject::cast(this)->class_name() == name); |
| 1157 } | 1144 } |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 if (double_array->is_the_hole(i)) { | 1818 if (double_array->is_the_hole(i)) { |
| 1832 TransitionElementsKind(object, FAST_HOLEY_DOUBLE_ELEMENTS); | 1819 TransitionElementsKind(object, FAST_HOLEY_DOUBLE_ELEMENTS); |
| 1833 return; | 1820 return; |
| 1834 } | 1821 } |
| 1835 } | 1822 } |
| 1836 TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS); | 1823 TransitionElementsKind(object, FAST_DOUBLE_ELEMENTS); |
| 1837 } | 1824 } |
| 1838 } | 1825 } |
| 1839 | 1826 |
| 1840 | 1827 |
| 1841 bool JSObject::WouldConvertToSlowElements(Handle<Object> key) { | |
| 1842 uint32_t index = 0; | |
| 1843 return key->ToArrayIndex(&index) && WouldConvertToSlowElements(index); | |
| 1844 } | |
| 1845 | |
| 1846 | |
| 1847 void JSObject::SetMapAndElements(Handle<JSObject> object, | 1828 void JSObject::SetMapAndElements(Handle<JSObject> object, |
| 1848 Handle<Map> new_map, | 1829 Handle<Map> new_map, |
| 1849 Handle<FixedArrayBase> value) { | 1830 Handle<FixedArrayBase> value) { |
| 1850 JSObject::MigrateToMap(object, new_map); | 1831 JSObject::MigrateToMap(object, new_map); |
| 1851 DCHECK((object->map()->has_fast_smi_or_object_elements() || | 1832 DCHECK((object->map()->has_fast_smi_or_object_elements() || |
| 1852 (*value == object->GetHeap()->empty_fixed_array())) == | 1833 (*value == object->GetHeap()->empty_fixed_array())) == |
| 1853 (value->map() == object->GetHeap()->fixed_array_map() || | 1834 (value->map() == object->GetHeap()->fixed_array_map() || |
| 1854 value->map() == object->GetHeap()->fixed_cow_array_map())); | 1835 value->map() == object->GetHeap()->fixed_cow_array_map())); |
| 1855 DCHECK((*value == object->GetHeap()->empty_fixed_array()) || | 1836 DCHECK((*value == object->GetHeap()->empty_fixed_array()) || |
| 1856 (object->map()->has_fast_double_elements() == | 1837 (object->map()->has_fast_double_elements() == |
| (...skipping 5457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7314 #undef READ_SHORT_FIELD | 7295 #undef READ_SHORT_FIELD |
| 7315 #undef WRITE_SHORT_FIELD | 7296 #undef WRITE_SHORT_FIELD |
| 7316 #undef READ_BYTE_FIELD | 7297 #undef READ_BYTE_FIELD |
| 7317 #undef WRITE_BYTE_FIELD | 7298 #undef WRITE_BYTE_FIELD |
| 7318 #undef NOBARRIER_READ_BYTE_FIELD | 7299 #undef NOBARRIER_READ_BYTE_FIELD |
| 7319 #undef NOBARRIER_WRITE_BYTE_FIELD | 7300 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7320 | 7301 |
| 7321 } } // namespace v8::internal | 7302 } } // namespace v8::internal |
| 7322 | 7303 |
| 7323 #endif // V8_OBJECTS_INL_H_ | 7304 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |