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 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value()) | 1030 ? static_cast<double>(reinterpret_cast<Smi*>(this)->value()) |
1031 : reinterpret_cast<HeapNumber*>(this)->value(); | 1031 : reinterpret_cast<HeapNumber*>(this)->value(); |
1032 } | 1032 } |
1033 | 1033 |
1034 | 1034 |
1035 bool Object::IsNaN() { | 1035 bool Object::IsNaN() { |
1036 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value()); | 1036 return this->IsHeapNumber() && std::isnan(HeapNumber::cast(this)->value()); |
1037 } | 1037 } |
1038 | 1038 |
1039 | 1039 |
1040 Handle<Object> Object::ToSmi(Isolate* isolate, Handle<Object> object) { | 1040 MaybeHandle<Smi> Object::ToSmi(Isolate* isolate, Handle<Object> object) { |
1041 if (object->IsSmi()) return object; | 1041 if (object->IsSmi()) return Handle<Smi>::cast(object); |
1042 if (object->IsHeapNumber()) { | 1042 if (object->IsHeapNumber()) { |
1043 double value = Handle<HeapNumber>::cast(object)->value(); | 1043 double value = Handle<HeapNumber>::cast(object)->value(); |
1044 int int_value = FastD2I(value); | 1044 int int_value = FastD2I(value); |
1045 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | 1045 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { |
1046 return handle(Smi::FromInt(int_value), isolate); | 1046 return handle(Smi::FromInt(int_value), isolate); |
1047 } | 1047 } |
1048 } | 1048 } |
1049 return Handle<Object>(); | 1049 return Handle<Smi>(); |
1050 } | 1050 } |
1051 | 1051 |
1052 | 1052 |
1053 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, | 1053 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, |
1054 Handle<Object> object) { | 1054 Handle<Object> object) { |
1055 return ToObject( | 1055 return ToObject( |
1056 isolate, object, handle(isolate->context()->native_context(), isolate)); | 1056 isolate, object, handle(isolate->context()->native_context(), isolate)); |
1057 } | 1057 } |
1058 | 1058 |
1059 | 1059 |
(...skipping 5922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6982 #undef READ_SHORT_FIELD | 6982 #undef READ_SHORT_FIELD |
6983 #undef WRITE_SHORT_FIELD | 6983 #undef WRITE_SHORT_FIELD |
6984 #undef READ_BYTE_FIELD | 6984 #undef READ_BYTE_FIELD |
6985 #undef WRITE_BYTE_FIELD | 6985 #undef WRITE_BYTE_FIELD |
6986 #undef NOBARRIER_READ_BYTE_FIELD | 6986 #undef NOBARRIER_READ_BYTE_FIELD |
6987 #undef NOBARRIER_WRITE_BYTE_FIELD | 6987 #undef NOBARRIER_WRITE_BYTE_FIELD |
6988 | 6988 |
6989 } } // namespace v8::internal | 6989 } } // namespace v8::internal |
6990 | 6990 |
6991 #endif // V8_OBJECTS_INL_H_ | 6991 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |