| 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 2347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2358 | 2358 |
| 2359 | 2359 |
| 2360 void Struct::InitializeBody(int object_size) { | 2360 void Struct::InitializeBody(int object_size) { |
| 2361 Object* value = GetHeap()->undefined_value(); | 2361 Object* value = GetHeap()->undefined_value(); |
| 2362 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { | 2362 for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) { |
| 2363 WRITE_FIELD(this, offset, value); | 2363 WRITE_FIELD(this, offset, value); |
| 2364 } | 2364 } |
| 2365 } | 2365 } |
| 2366 | 2366 |
| 2367 | 2367 |
| 2368 bool Object::ToArrayLength(uint32_t* index) { | 2368 bool Object::ToArrayLength(uint32_t* index) { return Object::ToUint32(index); } |
| 2369 if (IsSmi()) { | 2369 |
| 2370 int value = Smi::cast(this)->value(); | 2370 |
| 2371 if (value < 0) return false; | 2371 bool Object::ToArrayIndex(uint32_t* index) { |
| 2372 *index = value; | 2372 return Object::ToUint32(index) && *index != kMaxUInt32; |
| 2373 return true; | |
| 2374 } | |
| 2375 if (IsHeapNumber()) { | |
| 2376 double value = HeapNumber::cast(this)->value(); | |
| 2377 uint32_t uint_value = static_cast<uint32_t>(value); | |
| 2378 if (value == static_cast<double>(uint_value)) { | |
| 2379 *index = uint_value; | |
| 2380 return true; | |
| 2381 } | |
| 2382 } | |
| 2383 return false; | |
| 2384 } | 2373 } |
| 2385 | 2374 |
| 2386 | 2375 |
| 2387 bool Object::ToArrayIndex(uint32_t* index) { | |
| 2388 return ToArrayLength(index) && *index != kMaxUInt32; | |
| 2389 } | |
| 2390 | |
| 2391 | |
| 2392 bool Object::IsStringObjectWithCharacterAt(uint32_t index) { | 2376 bool Object::IsStringObjectWithCharacterAt(uint32_t index) { |
| 2393 if (!this->IsJSValue()) return false; | 2377 if (!this->IsJSValue()) return false; |
| 2394 | 2378 |
| 2395 JSValue* js_value = JSValue::cast(this); | 2379 JSValue* js_value = JSValue::cast(this); |
| 2396 if (!js_value->value()->IsString()) return false; | 2380 if (!js_value->value()->IsString()) return false; |
| 2397 | 2381 |
| 2398 String* str = String::cast(js_value->value()); | 2382 String* str = String::cast(js_value->value()); |
| 2399 if (index >= static_cast<uint32_t>(str->length())) return false; | 2383 if (index >= static_cast<uint32_t>(str->length())) return false; |
| 2400 | 2384 |
| 2401 return true; | 2385 return true; |
| (...skipping 5725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8127 #undef WRITE_INT64_FIELD | 8111 #undef WRITE_INT64_FIELD |
| 8128 #undef READ_BYTE_FIELD | 8112 #undef READ_BYTE_FIELD |
| 8129 #undef WRITE_BYTE_FIELD | 8113 #undef WRITE_BYTE_FIELD |
| 8130 #undef NOBARRIER_READ_BYTE_FIELD | 8114 #undef NOBARRIER_READ_BYTE_FIELD |
| 8131 #undef NOBARRIER_WRITE_BYTE_FIELD | 8115 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 8132 | 8116 |
| 8133 } // namespace internal | 8117 } // namespace internal |
| 8134 } // namespace v8 | 8118 } // namespace v8 |
| 8135 | 8119 |
| 8136 #endif // V8_OBJECTS_INL_H_ | 8120 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |