Chromium Code Reviews| 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 2349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2360 } | 2360 } |
| 2361 | 2361 |
| 2362 | 2362 |
| 2363 ConstantPoolArray::LayoutSection ConstantPoolArray::final_section() { | 2363 ConstantPoolArray::LayoutSection ConstantPoolArray::final_section() { |
| 2364 return is_extended_layout() ? EXTENDED_SECTION : SMALL_SECTION; | 2364 return is_extended_layout() ? EXTENDED_SECTION : SMALL_SECTION; |
| 2365 } | 2365 } |
| 2366 | 2366 |
| 2367 | 2367 |
| 2368 int ConstantPoolArray::first_extended_section_index() { | 2368 int ConstantPoolArray::first_extended_section_index() { |
| 2369 ASSERT(is_extended_layout()); | 2369 ASSERT(is_extended_layout()); |
| 2370 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | 2370 uint32_t small_layout_3 = READ_UINT32_FIELD(this, kSmallLayout3Offset); |
| 2371 return TotalCountField::decode(small_layout_2); | 2371 return TotalCountField::decode(small_layout_3); |
| 2372 } | 2372 } |
| 2373 | 2373 |
| 2374 | 2374 |
| 2375 int ConstantPoolArray::get_extended_section_header_offset() { | 2375 int ConstantPoolArray::get_extended_section_header_offset() { |
| 2376 return RoundUp(SizeFor(NumberOfEntries(this, SMALL_SECTION)), kInt64Size); | 2376 return RoundUp(SizeFor(NumberOfEntries(this, SMALL_SECTION)), kInt64Size); |
| 2377 } | 2377 } |
| 2378 | 2378 |
| 2379 | 2379 |
| 2380 ConstantPoolArray::WeakObjectState ConstantPoolArray::get_weak_object_state() { | 2380 ConstantPoolArray::WeakObjectState ConstantPoolArray::get_weak_object_state() { |
| 2381 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | 2381 uint32_t small_layout_3 = READ_UINT32_FIELD(this, kSmallLayout3Offset); |
| 2382 return WeakObjectStateField::decode(small_layout_2); | 2382 return WeakObjectStateField::decode(small_layout_3); |
| 2383 } | 2383 } |
| 2384 | 2384 |
| 2385 | 2385 |
| 2386 void ConstantPoolArray::set_weak_object_state( | 2386 void ConstantPoolArray::set_weak_object_state( |
| 2387 ConstantPoolArray::WeakObjectState state) { | 2387 ConstantPoolArray::WeakObjectState state) { |
| 2388 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | 2388 uint32_t small_layout_3 = READ_UINT32_FIELD(this, kSmallLayout3Offset); |
| 2389 small_layout_2 = WeakObjectStateField::update(small_layout_2, state); | 2389 small_layout_3 = WeakObjectStateField::update(small_layout_3, state); |
| 2390 WRITE_INT32_FIELD(this, kSmallLayout2Offset, small_layout_2); | 2390 WRITE_INT32_FIELD(this, kSmallLayout3Offset, small_layout_3); |
| 2391 } | 2391 } |
| 2392 | 2392 |
| 2393 | 2393 |
| 2394 int ConstantPoolArray::first_index(Type type, LayoutSection section) { | 2394 int ConstantPoolArray::first_index(Type type, LayoutSection section) { |
| 2395 int index = 0; | 2395 int index = 0; |
| 2396 if (section == EXTENDED_SECTION) { | 2396 if (section == EXTENDED_SECTION) { |
| 2397 ASSERT(is_extended_layout()); | 2397 ASSERT(is_extended_layout()); |
| 2398 index += first_extended_section_index(); | 2398 index += first_extended_section_index(); |
| 2399 } | 2399 } |
| 2400 | 2400 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 2415 int ConstantPoolArray::number_of_entries(Type type, LayoutSection section) { | 2415 int ConstantPoolArray::number_of_entries(Type type, LayoutSection section) { |
| 2416 if (section == SMALL_SECTION) { | 2416 if (section == SMALL_SECTION) { |
| 2417 uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); | 2417 uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); |
| 2418 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | 2418 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); |
| 2419 switch (type) { | 2419 switch (type) { |
| 2420 case INT64: | 2420 case INT64: |
| 2421 return Int64CountField::decode(small_layout_1); | 2421 return Int64CountField::decode(small_layout_1); |
| 2422 case CODE_PTR: | 2422 case CODE_PTR: |
| 2423 return CodePtrCountField::decode(small_layout_1); | 2423 return CodePtrCountField::decode(small_layout_1); |
| 2424 case HEAP_PTR: | 2424 case HEAP_PTR: |
| 2425 return HeapPtrCountField::decode(small_layout_1); | 2425 return HeapPtrCountField::decode(small_layout_2); |
| 2426 case INT32: | 2426 case INT32: |
| 2427 return Int32CountField::decode(small_layout_2); | 2427 return Int32CountField::decode(small_layout_2); |
| 2428 default: | 2428 default: |
| 2429 UNREACHABLE(); | 2429 UNREACHABLE(); |
| 2430 return 0; | 2430 return 0; |
| 2431 } | 2431 } |
| 2432 } else { | 2432 } else { |
| 2433 ASSERT(section == EXTENDED_SECTION && is_extended_layout()); | 2433 ASSERT(section == EXTENDED_SECTION && is_extended_layout()); |
| 2434 int offset = get_extended_section_header_offset(); | 2434 int offset = get_extended_section_header_offset(); |
| 2435 switch (type) { | 2435 switch (type) { |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2586 ASSERT(offset_is_type(offset, HEAP_PTR)); | 2586 ASSERT(offset_is_type(offset, HEAP_PTR)); |
| 2587 WRITE_FIELD(this, offset, value); | 2587 WRITE_FIELD(this, offset, value); |
| 2588 WRITE_BARRIER(GetHeap(), this, offset, value); | 2588 WRITE_BARRIER(GetHeap(), this, offset, value); |
| 2589 } | 2589 } |
| 2590 | 2590 |
| 2591 | 2591 |
| 2592 void ConstantPoolArray::Init(const NumberOfEntries& small) { | 2592 void ConstantPoolArray::Init(const NumberOfEntries& small) { |
| 2593 uint32_t small_layout_1 = | 2593 uint32_t small_layout_1 = |
| 2594 Int64CountField::encode(small.count_of(INT64)) | | 2594 Int64CountField::encode(small.count_of(INT64)) | |
| 2595 CodePtrCountField::encode(small.count_of(CODE_PTR)) | | 2595 CodePtrCountField::encode(small.count_of(CODE_PTR)) | |
| 2596 HeapPtrCountField::encode(small.count_of(HEAP_PTR)) | | |
| 2597 IsExtendedField::encode(false); | 2596 IsExtendedField::encode(false); |
| 2598 uint32_t small_layout_2 = | 2597 uint32_t small_layout_2 = |
| 2599 Int32CountField::encode(small.count_of(INT32)) | | 2598 HeapPtrCountField::encode(small.count_of(HEAP_PTR)) | |
| 2599 Int32CountField::encode(small.count_of(INT32)); | |
| 2600 uint32_t small_layout_3 = | |
| 2600 TotalCountField::encode(small.total_count()) | | 2601 TotalCountField::encode(small.total_count()) | |
| 2601 WeakObjectStateField::encode(NO_WEAK_OBJECTS); | 2602 WeakObjectStateField::encode(NO_WEAK_OBJECTS); |
| 2602 WRITE_UINT32_FIELD(this, kSmallLayout1Offset, small_layout_1); | 2603 WRITE_UINT32_FIELD(this, kSmallLayout1Offset, small_layout_1); |
| 2603 WRITE_UINT32_FIELD(this, kSmallLayout2Offset, small_layout_2); | 2604 WRITE_UINT32_FIELD(this, kSmallLayout2Offset, small_layout_2); |
| 2605 WRITE_UINT32_FIELD(this, kSmallLayout3Offset, small_layout_3); | |
|
rmcilroy
2014/07/29 17:11:45
Why did you have to add another layout field? I t
| |
| 2604 if (kHeaderSize != kFirstEntryOffset) { | 2606 if (kHeaderSize != kFirstEntryOffset) { |
| 2605 ASSERT(kFirstEntryOffset - kHeaderSize == kInt32Size); | 2607 ASSERT(kFirstEntryOffset - kHeaderSize == kInt32Size); |
| 2606 WRITE_UINT32_FIELD(this, kHeaderSize, 0); // Zero out header padding. | 2608 WRITE_UINT32_FIELD(this, kHeaderSize, 0); // Zero out header padding. |
| 2607 } | 2609 } |
| 2608 } | 2610 } |
| 2609 | 2611 |
| 2610 | 2612 |
| 2611 void ConstantPoolArray::InitExtended(const NumberOfEntries& small, | 2613 void ConstantPoolArray::InitExtended(const NumberOfEntries& small, |
| 2612 const NumberOfEntries& extended) { | 2614 const NumberOfEntries& extended) { |
| 2613 // Initialize small layout fields first. | 2615 // Initialize small layout fields first. |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 2636 if (!is_extended_layout()) { | 2638 if (!is_extended_layout()) { |
| 2637 return SizeFor(small); | 2639 return SizeFor(small); |
| 2638 } else { | 2640 } else { |
| 2639 NumberOfEntries extended(this, EXTENDED_SECTION); | 2641 NumberOfEntries extended(this, EXTENDED_SECTION); |
| 2640 return SizeForExtended(small, extended); | 2642 return SizeForExtended(small, extended); |
| 2641 } | 2643 } |
| 2642 } | 2644 } |
| 2643 | 2645 |
| 2644 | 2646 |
| 2645 int ConstantPoolArray::length() { | 2647 int ConstantPoolArray::length() { |
| 2646 uint32_t small_layout_2 = READ_UINT32_FIELD(this, kSmallLayout2Offset); | 2648 uint32_t small_layout_3 = READ_UINT32_FIELD(this, kSmallLayout3Offset); |
| 2647 int length = TotalCountField::decode(small_layout_2); | 2649 int length = TotalCountField::decode(small_layout_3); |
| 2648 if (is_extended_layout()) { | 2650 if (is_extended_layout()) { |
| 2649 length += number_of_entries(INT64, EXTENDED_SECTION) + | 2651 length += number_of_entries(INT64, EXTENDED_SECTION) + |
| 2650 number_of_entries(CODE_PTR, EXTENDED_SECTION) + | 2652 number_of_entries(CODE_PTR, EXTENDED_SECTION) + |
| 2651 number_of_entries(HEAP_PTR, EXTENDED_SECTION) + | 2653 number_of_entries(HEAP_PTR, EXTENDED_SECTION) + |
| 2652 number_of_entries(INT32, EXTENDED_SECTION); | 2654 number_of_entries(INT32, EXTENDED_SECTION); |
| 2653 } | 2655 } |
| 2654 return length; | 2656 return length; |
| 2655 } | 2657 } |
| 2656 | 2658 |
| 2657 | 2659 |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3309 SMI_ACCESSORS(String, length, kLengthOffset) | 3311 SMI_ACCESSORS(String, length, kLengthOffset) |
| 3310 SYNCHRONIZED_SMI_ACCESSORS(String, length, kLengthOffset) | 3312 SYNCHRONIZED_SMI_ACCESSORS(String, length, kLengthOffset) |
| 3311 | 3313 |
| 3312 | 3314 |
| 3313 uint32_t Name::hash_field() { | 3315 uint32_t Name::hash_field() { |
| 3314 return READ_UINT32_FIELD(this, kHashFieldOffset); | 3316 return READ_UINT32_FIELD(this, kHashFieldOffset); |
| 3315 } | 3317 } |
| 3316 | 3318 |
| 3317 | 3319 |
| 3318 void Name::set_hash_field(uint32_t value) { | 3320 void Name::set_hash_field(uint32_t value) { |
| 3319 WRITE_UINT32_FIELD(this, kHashFieldOffset, value); | 3321 WRITE_INTPTR_FIELD(this, kHashFieldSlot, value); |
| 3320 #if V8_HOST_ARCH_64_BIT | |
| 3321 WRITE_UINT32_FIELD(this, kHashFieldOffset + kIntSize, 0); | |
| 3322 #endif | |
| 3323 } | 3322 } |
| 3324 | 3323 |
| 3325 | 3324 |
| 3326 bool Name::Equals(Name* other) { | 3325 bool Name::Equals(Name* other) { |
| 3327 if (other == this) return true; | 3326 if (other == this) return true; |
| 3328 if ((this->IsInternalizedString() && other->IsInternalizedString()) || | 3327 if ((this->IsInternalizedString() && other->IsInternalizedString()) || |
| 3329 this->IsSymbol() || other->IsSymbol()) { | 3328 this->IsSymbol() || other->IsSymbol()) { |
| 3330 return false; | 3329 return false; |
| 3331 } | 3330 } |
| 3332 return String::cast(this)->SlowEquals(String::cast(other)); | 3331 return String::cast(this)->SlowEquals(String::cast(other)); |
| (...skipping 2131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5464 SMI_ACCESSORS(SharedFunctionInfo, compiler_hints, | 5463 SMI_ACCESSORS(SharedFunctionInfo, compiler_hints, |
| 5465 kCompilerHintsOffset) | 5464 kCompilerHintsOffset) |
| 5466 SMI_ACCESSORS(SharedFunctionInfo, opt_count_and_bailout_reason, | 5465 SMI_ACCESSORS(SharedFunctionInfo, opt_count_and_bailout_reason, |
| 5467 kOptCountAndBailoutReasonOffset) | 5466 kOptCountAndBailoutReasonOffset) |
| 5468 SMI_ACCESSORS(SharedFunctionInfo, counters, kCountersOffset) | 5467 SMI_ACCESSORS(SharedFunctionInfo, counters, kCountersOffset) |
| 5469 SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) | 5468 SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) |
| 5470 SMI_ACCESSORS(SharedFunctionInfo, profiler_ticks, kProfilerTicksOffset) | 5469 SMI_ACCESSORS(SharedFunctionInfo, profiler_ticks, kProfilerTicksOffset) |
| 5471 | 5470 |
| 5472 #else | 5471 #else |
| 5473 | 5472 |
| 5474 #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ | 5473 #if V8_TARGET_LITTLE_ENDIAN |
| 5475 STATIC_ASSERT(holder::offset % kPointerSize == 0); \ | 5474 #define PSEUDO_SMI_LO_ALIGN 0 |
| 5476 int holder::name() const { \ | 5475 #define PSEUDO_SMI_HI_ALIGN kIntSize |
| 5477 int value = READ_INT_FIELD(this, offset); \ | 5476 #else |
| 5478 ASSERT(kHeapObjectTag == 1); \ | 5477 #define PSEUDO_SMI_LO_ALIGN kIntSize |
| 5479 ASSERT((value & kHeapObjectTag) == 0); \ | 5478 #define PSEUDO_SMI_HI_ALIGN 0 |
| 5480 return value >> 1; \ | 5479 #endif |
| 5481 } \ | 5480 |
| 5482 void holder::set_##name(int value) { \ | 5481 #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ |
| 5483 ASSERT(kHeapObjectTag == 1); \ | 5482 STATIC_ASSERT(holder::offset % kPointerSize == PSEUDO_SMI_LO_ALIGN); \ |
| 5484 ASSERT((value & 0xC0000000) == 0xC0000000 || \ | 5483 int holder::name() const { \ |
| 5485 (value & 0xC0000000) == 0x0); \ | 5484 int value = READ_INT_FIELD(this, offset); \ |
| 5486 WRITE_INT_FIELD(this, \ | 5485 ASSERT(kHeapObjectTag == 1); \ |
| 5487 offset, \ | 5486 ASSERT((value & kHeapObjectTag) == 0); \ |
| 5488 (value << 1) & ~kHeapObjectTag); \ | 5487 return value >> 1; \ |
| 5488 } \ | |
| 5489 void holder::set_##name(int value) { \ | |
| 5490 ASSERT(kHeapObjectTag == 1); \ | |
| 5491 ASSERT((value & 0xC0000000) == 0xC0000000 || \ | |
| 5492 (value & 0xC0000000) == 0x0); \ | |
| 5493 WRITE_INT_FIELD(this, \ | |
| 5494 offset, \ | |
| 5495 (value << 1) & ~kHeapObjectTag); \ | |
| 5489 } | 5496 } |
| 5490 | 5497 |
| 5491 #define PSEUDO_SMI_ACCESSORS_HI(holder, name, offset) \ | 5498 #define PSEUDO_SMI_ACCESSORS_HI(holder, name, offset) \ |
| 5492 STATIC_ASSERT(holder::offset % kPointerSize == kIntSize); \ | 5499 STATIC_ASSERT(holder::offset % kPointerSize == PSEUDO_SMI_HI_ALIGN); \ |
| 5493 INT_ACCESSORS(holder, name, offset) | 5500 INT_ACCESSORS(holder, name, offset) |
| 5494 | 5501 |
| 5495 | 5502 |
| 5496 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, length, kLengthOffset) | 5503 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, length, kLengthOffset) |
| 5497 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, | 5504 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, |
| 5498 formal_parameter_count, | 5505 formal_parameter_count, |
| 5499 kFormalParameterCountOffset) | 5506 kFormalParameterCountOffset) |
| 5500 | 5507 |
| 5501 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, | 5508 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, |
| 5502 expected_nof_properties, | 5509 expected_nof_properties, |
| (...skipping 1711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7214 #undef READ_SHORT_FIELD | 7221 #undef READ_SHORT_FIELD |
| 7215 #undef WRITE_SHORT_FIELD | 7222 #undef WRITE_SHORT_FIELD |
| 7216 #undef READ_BYTE_FIELD | 7223 #undef READ_BYTE_FIELD |
| 7217 #undef WRITE_BYTE_FIELD | 7224 #undef WRITE_BYTE_FIELD |
| 7218 #undef NOBARRIER_READ_BYTE_FIELD | 7225 #undef NOBARRIER_READ_BYTE_FIELD |
| 7219 #undef NOBARRIER_WRITE_BYTE_FIELD | 7226 #undef NOBARRIER_WRITE_BYTE_FIELD |
| 7220 | 7227 |
| 7221 } } // namespace v8::internal | 7228 } } // namespace v8::internal |
| 7222 | 7229 |
| 7223 #endif // V8_OBJECTS_INL_H_ | 7230 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |