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 2617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2628 // Initialize small layout fields first. | 2628 // Initialize small layout fields first. |
2629 Init(small); | 2629 Init(small); |
2630 | 2630 |
2631 // Set is_extended_layout field. | 2631 // Set is_extended_layout field. |
2632 uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); | 2632 uint32_t small_layout_1 = READ_UINT32_FIELD(this, kSmallLayout1Offset); |
2633 small_layout_1 = IsExtendedField::update(small_layout_1, true); | 2633 small_layout_1 = IsExtendedField::update(small_layout_1, true); |
2634 WRITE_INT32_FIELD(this, kSmallLayout1Offset, small_layout_1); | 2634 WRITE_INT32_FIELD(this, kSmallLayout1Offset, small_layout_1); |
2635 | 2635 |
2636 // Initialize the extended layout fields. | 2636 // Initialize the extended layout fields. |
2637 int extended_header_offset = get_extended_section_header_offset(); | 2637 int extended_header_offset = get_extended_section_header_offset(); |
2638 WRITE_INT_FIELD(this, extended_header_offset + kExtendedInt64CountOffset, | 2638 WRITE_INT32_FIELD(this, extended_header_offset + kExtendedInt64CountOffset, |
2639 extended.count_of(INT64)); | 2639 extended.count_of(INT64)); |
2640 WRITE_INT_FIELD(this, extended_header_offset + kExtendedCodePtrCountOffset, | 2640 WRITE_INT32_FIELD(this, extended_header_offset + kExtendedCodePtrCountOffset, |
2641 extended.count_of(CODE_PTR)); | 2641 extended.count_of(CODE_PTR)); |
2642 WRITE_INT_FIELD(this, extended_header_offset + kExtendedHeapPtrCountOffset, | 2642 WRITE_INT32_FIELD(this, extended_header_offset + kExtendedHeapPtrCountOffset, |
2643 extended.count_of(HEAP_PTR)); | 2643 extended.count_of(HEAP_PTR)); |
2644 WRITE_INT_FIELD(this, extended_header_offset + kExtendedInt32CountOffset, | 2644 WRITE_INT32_FIELD(this, extended_header_offset + kExtendedInt32CountOffset, |
2645 extended.count_of(INT32)); | 2645 extended.count_of(INT32)); |
2646 } | 2646 } |
2647 | 2647 |
2648 | 2648 |
2649 int ConstantPoolArray::size() { | 2649 int ConstantPoolArray::size() { |
2650 NumberOfEntries small(this, SMALL_SECTION); | 2650 NumberOfEntries small(this, SMALL_SECTION); |
2651 if (!is_extended_layout()) { | 2651 if (!is_extended_layout()) { |
2652 return SizeFor(small); | 2652 return SizeFor(small); |
2653 } else { | 2653 } else { |
2654 NumberOfEntries extended(this, EXTENDED_SECTION); | 2654 NumberOfEntries extended(this, EXTENDED_SECTION); |
2655 return SizeForExtended(small, extended); | 2655 return SizeForExtended(small, extended); |
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3307 | 3307 |
3308 | 3308 |
3309 uint32_t Name::hash_field() { | 3309 uint32_t Name::hash_field() { |
3310 return READ_UINT32_FIELD(this, kHashFieldOffset); | 3310 return READ_UINT32_FIELD(this, kHashFieldOffset); |
3311 } | 3311 } |
3312 | 3312 |
3313 | 3313 |
3314 void Name::set_hash_field(uint32_t value) { | 3314 void Name::set_hash_field(uint32_t value) { |
3315 WRITE_UINT32_FIELD(this, kHashFieldOffset, value); | 3315 WRITE_UINT32_FIELD(this, kHashFieldOffset, value); |
3316 #if V8_HOST_ARCH_64_BIT | 3316 #if V8_HOST_ARCH_64_BIT |
3317 WRITE_UINT32_FIELD(this, kHashFieldOffset + kIntSize, 0); | 3317 #if V8_TARGET_LITTLE_ENDIAN |
| 3318 WRITE_UINT32_FIELD(this, kHashFieldSlot + kIntSize, 0); |
| 3319 #else |
| 3320 WRITE_UINT32_FIELD(this, kHashFieldSlot, 0); |
| 3321 #endif |
3318 #endif | 3322 #endif |
3319 } | 3323 } |
3320 | 3324 |
3321 | 3325 |
3322 bool Name::Equals(Name* other) { | 3326 bool Name::Equals(Name* other) { |
3323 if (other == this) return true; | 3327 if (other == this) return true; |
3324 if ((this->IsInternalizedString() && other->IsInternalizedString()) || | 3328 if ((this->IsInternalizedString() && other->IsInternalizedString()) || |
3325 this->IsSymbol() || other->IsSymbol()) { | 3329 this->IsSymbol() || other->IsSymbol()) { |
3326 return false; | 3330 return false; |
3327 } | 3331 } |
(...skipping 2150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5478 SMI_ACCESSORS(SharedFunctionInfo, compiler_hints, | 5482 SMI_ACCESSORS(SharedFunctionInfo, compiler_hints, |
5479 kCompilerHintsOffset) | 5483 kCompilerHintsOffset) |
5480 SMI_ACCESSORS(SharedFunctionInfo, opt_count_and_bailout_reason, | 5484 SMI_ACCESSORS(SharedFunctionInfo, opt_count_and_bailout_reason, |
5481 kOptCountAndBailoutReasonOffset) | 5485 kOptCountAndBailoutReasonOffset) |
5482 SMI_ACCESSORS(SharedFunctionInfo, counters, kCountersOffset) | 5486 SMI_ACCESSORS(SharedFunctionInfo, counters, kCountersOffset) |
5483 SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) | 5487 SMI_ACCESSORS(SharedFunctionInfo, ast_node_count, kAstNodeCountOffset) |
5484 SMI_ACCESSORS(SharedFunctionInfo, profiler_ticks, kProfilerTicksOffset) | 5488 SMI_ACCESSORS(SharedFunctionInfo, profiler_ticks, kProfilerTicksOffset) |
5485 | 5489 |
5486 #else | 5490 #else |
5487 | 5491 |
5488 #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ | 5492 #if V8_TARGET_LITTLE_ENDIAN |
5489 STATIC_ASSERT(holder::offset % kPointerSize == 0); \ | 5493 #define PSEUDO_SMI_LO_ALIGN 0 |
5490 int holder::name() const { \ | 5494 #define PSEUDO_SMI_HI_ALIGN kIntSize |
5491 int value = READ_INT_FIELD(this, offset); \ | 5495 #else |
5492 DCHECK(kHeapObjectTag == 1); \ | 5496 #define PSEUDO_SMI_LO_ALIGN kIntSize |
5493 DCHECK((value & kHeapObjectTag) == 0); \ | 5497 #define PSEUDO_SMI_HI_ALIGN 0 |
5494 return value >> 1; \ | 5498 #endif |
5495 } \ | 5499 |
5496 void holder::set_##name(int value) { \ | 5500 #define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \ |
5497 DCHECK(kHeapObjectTag == 1); \ | 5501 STATIC_ASSERT(holder::offset % kPointerSize == PSEUDO_SMI_LO_ALIGN); \ |
5498 DCHECK((value & 0xC0000000) == 0xC0000000 || \ | 5502 int holder::name() const { \ |
5499 (value & 0xC0000000) == 0x0); \ | 5503 int value = READ_INT_FIELD(this, offset); \ |
5500 WRITE_INT_FIELD(this, \ | 5504 DCHECK(kHeapObjectTag == 1); \ |
5501 offset, \ | 5505 DCHECK((value & kHeapObjectTag) == 0); \ |
5502 (value << 1) & ~kHeapObjectTag); \ | 5506 return value >> 1; \ |
| 5507 } \ |
| 5508 void holder::set_##name(int value) { \ |
| 5509 DCHECK(kHeapObjectTag == 1); \ |
| 5510 DCHECK((value & 0xC0000000) == 0xC0000000 || (value & 0xC0000000) == 0x0); \ |
| 5511 WRITE_INT_FIELD(this, offset, (value << 1) & ~kHeapObjectTag); \ |
5503 } | 5512 } |
5504 | 5513 |
5505 #define PSEUDO_SMI_ACCESSORS_HI(holder, name, offset) \ | 5514 #define PSEUDO_SMI_ACCESSORS_HI(holder, name, offset) \ |
5506 STATIC_ASSERT(holder::offset % kPointerSize == kIntSize); \ | 5515 STATIC_ASSERT(holder::offset % kPointerSize == PSEUDO_SMI_HI_ALIGN); \ |
5507 INT_ACCESSORS(holder, name, offset) | 5516 INT_ACCESSORS(holder, name, offset) |
5508 | 5517 |
5509 | 5518 |
5510 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, length, kLengthOffset) | 5519 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, length, kLengthOffset) |
5511 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, | 5520 PSEUDO_SMI_ACCESSORS_HI(SharedFunctionInfo, |
5512 formal_parameter_count, | 5521 formal_parameter_count, |
5513 kFormalParameterCountOffset) | 5522 kFormalParameterCountOffset) |
5514 | 5523 |
5515 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, | 5524 PSEUDO_SMI_ACCESSORS_LO(SharedFunctionInfo, |
5516 expected_nof_properties, | 5525 expected_nof_properties, |
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6625 } | 6634 } |
6626 | 6635 |
6627 | 6636 |
6628 void String::SetForwardedInternalizedString(String* canonical) { | 6637 void String::SetForwardedInternalizedString(String* canonical) { |
6629 DCHECK(IsInternalizedString()); | 6638 DCHECK(IsInternalizedString()); |
6630 DCHECK(HasHashCode()); | 6639 DCHECK(HasHashCode()); |
6631 if (canonical == this) return; // No need to forward. | 6640 if (canonical == this) return; // No need to forward. |
6632 DCHECK(SlowEquals(canonical)); | 6641 DCHECK(SlowEquals(canonical)); |
6633 DCHECK(canonical->IsInternalizedString()); | 6642 DCHECK(canonical->IsInternalizedString()); |
6634 DCHECK(canonical->HasHashCode()); | 6643 DCHECK(canonical->HasHashCode()); |
6635 WRITE_FIELD(this, kHashFieldOffset, canonical); | 6644 WRITE_FIELD(this, kHashFieldSlot, canonical); |
6636 // Setting the hash field to a tagged value sets the LSB, causing the hash | 6645 // Setting the hash field to a tagged value sets the LSB, causing the hash |
6637 // code to be interpreted as uninitialized. We use this fact to recognize | 6646 // code to be interpreted as uninitialized. We use this fact to recognize |
6638 // that we have a forwarded string. | 6647 // that we have a forwarded string. |
6639 DCHECK(!HasHashCode()); | 6648 DCHECK(!HasHashCode()); |
6640 } | 6649 } |
6641 | 6650 |
6642 | 6651 |
6643 String* String::GetForwardedInternalizedString() { | 6652 String* String::GetForwardedInternalizedString() { |
6644 DCHECK(IsInternalizedString()); | 6653 DCHECK(IsInternalizedString()); |
6645 if (HasHashCode()) return this; | 6654 if (HasHashCode()) return this; |
6646 String* canonical = String::cast(READ_FIELD(this, kHashFieldOffset)); | 6655 String* canonical = String::cast(READ_FIELD(this, kHashFieldSlot)); |
6647 DCHECK(canonical->IsInternalizedString()); | 6656 DCHECK(canonical->IsInternalizedString()); |
6648 DCHECK(SlowEquals(canonical)); | 6657 DCHECK(SlowEquals(canonical)); |
6649 DCHECK(canonical->HasHashCode()); | 6658 DCHECK(canonical->HasHashCode()); |
6650 return canonical; | 6659 return canonical; |
6651 } | 6660 } |
6652 | 6661 |
6653 | 6662 |
6654 Object* JSReceiver::GetConstructor() { | 6663 Object* JSReceiver::GetConstructor() { |
6655 return map()->constructor(); | 6664 return map()->constructor(); |
6656 } | 6665 } |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7248 #undef READ_SHORT_FIELD | 7257 #undef READ_SHORT_FIELD |
7249 #undef WRITE_SHORT_FIELD | 7258 #undef WRITE_SHORT_FIELD |
7250 #undef READ_BYTE_FIELD | 7259 #undef READ_BYTE_FIELD |
7251 #undef WRITE_BYTE_FIELD | 7260 #undef WRITE_BYTE_FIELD |
7252 #undef NOBARRIER_READ_BYTE_FIELD | 7261 #undef NOBARRIER_READ_BYTE_FIELD |
7253 #undef NOBARRIER_WRITE_BYTE_FIELD | 7262 #undef NOBARRIER_WRITE_BYTE_FIELD |
7254 | 7263 |
7255 } } // namespace v8::internal | 7264 } } // namespace v8::internal |
7256 | 7265 |
7257 #endif // V8_OBJECTS_INL_H_ | 7266 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |