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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 | 1090 |
1091 bool Object::ToUint32(uint32_t* value) { | 1091 bool Object::ToUint32(uint32_t* value) { |
1092 if (IsSmi()) { | 1092 if (IsSmi()) { |
1093 int num = Smi::cast(this)->value(); | 1093 int num = Smi::cast(this)->value(); |
1094 if (num < 0) return false; | 1094 if (num < 0) return false; |
1095 *value = static_cast<uint32_t>(num); | 1095 *value = static_cast<uint32_t>(num); |
1096 return true; | 1096 return true; |
1097 } | 1097 } |
1098 if (IsHeapNumber()) { | 1098 if (IsHeapNumber()) { |
1099 double num = HeapNumber::cast(this)->value(); | 1099 double num = HeapNumber::cast(this)->value(); |
1100 if (num < 0) return false; | 1100 return DoubleToUint32IfEqualToSelf(num, value); |
1101 uint32_t uint_value = FastD2UI(num); | |
1102 if (FastUI2D(uint_value) == num) { | |
1103 *value = uint_value; | |
1104 return true; | |
1105 } | |
1106 } | 1101 } |
1107 return false; | 1102 return false; |
1108 } | 1103 } |
1109 | 1104 |
1110 // static | 1105 // static |
1111 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, | 1106 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, |
1112 Handle<Object> object) { | 1107 Handle<Object> object) { |
1113 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object); | 1108 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object); |
1114 return ToObject(isolate, object, isolate->native_context()); | 1109 return ToObject(isolate, object, isolate->native_context()); |
1115 } | 1110 } |
(...skipping 7304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8420 #undef WRITE_INT64_FIELD | 8415 #undef WRITE_INT64_FIELD |
8421 #undef READ_BYTE_FIELD | 8416 #undef READ_BYTE_FIELD |
8422 #undef WRITE_BYTE_FIELD | 8417 #undef WRITE_BYTE_FIELD |
8423 #undef NOBARRIER_READ_BYTE_FIELD | 8418 #undef NOBARRIER_READ_BYTE_FIELD |
8424 #undef NOBARRIER_WRITE_BYTE_FIELD | 8419 #undef NOBARRIER_WRITE_BYTE_FIELD |
8425 | 8420 |
8426 } // namespace internal | 8421 } // namespace internal |
8427 } // namespace v8 | 8422 } // namespace v8 |
8428 | 8423 |
8429 #endif // V8_OBJECTS_INL_H_ | 8424 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |