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 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1100 | 1100 |
1101 bool Object::ToUint32(uint32_t* value) { | 1101 bool Object::ToUint32(uint32_t* value) { |
1102 if (IsSmi()) { | 1102 if (IsSmi()) { |
1103 int num = Smi::cast(this)->value(); | 1103 int num = Smi::cast(this)->value(); |
1104 if (num < 0) return false; | 1104 if (num < 0) return false; |
1105 *value = static_cast<uint32_t>(num); | 1105 *value = static_cast<uint32_t>(num); |
1106 return true; | 1106 return true; |
1107 } | 1107 } |
1108 if (IsHeapNumber()) { | 1108 if (IsHeapNumber()) { |
1109 double num = HeapNumber::cast(this)->value(); | 1109 double num = HeapNumber::cast(this)->value(); |
1110 if (num < 0) return false; | 1110 return DoubleToUint32IfEqualToSelf(num, value); |
1111 uint32_t uint_value = FastD2UI(num); | |
1112 if (FastUI2D(uint_value) == num) { | |
1113 *value = uint_value; | |
1114 return true; | |
1115 } | |
1116 } | 1111 } |
1117 return false; | 1112 return false; |
1118 } | 1113 } |
1119 | 1114 |
1120 // static | 1115 // static |
1121 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, | 1116 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, |
1122 Handle<Object> object) { | 1117 Handle<Object> object) { |
1123 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object); | 1118 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object); |
1124 return ToObject(isolate, object, isolate->native_context()); | 1119 return ToObject(isolate, object, isolate->native_context()); |
1125 } | 1120 } |
(...skipping 7327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8453 #undef WRITE_INT64_FIELD | 8448 #undef WRITE_INT64_FIELD |
8454 #undef READ_BYTE_FIELD | 8449 #undef READ_BYTE_FIELD |
8455 #undef WRITE_BYTE_FIELD | 8450 #undef WRITE_BYTE_FIELD |
8456 #undef NOBARRIER_READ_BYTE_FIELD | 8451 #undef NOBARRIER_READ_BYTE_FIELD |
8457 #undef NOBARRIER_WRITE_BYTE_FIELD | 8452 #undef NOBARRIER_WRITE_BYTE_FIELD |
8458 | 8453 |
8459 } // namespace internal | 8454 } // namespace internal |
8460 } // namespace v8 | 8455 } // namespace v8 |
8461 | 8456 |
8462 #endif // V8_OBJECTS_INL_H_ | 8457 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |