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 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 uint32_t seed_; | 641 uint32_t seed_; |
642 }; | 642 }; |
643 | 643 |
644 | 644 |
645 bool Object::IsNumber() const { | 645 bool Object::IsNumber() const { |
646 return IsSmi() || IsHeapNumber(); | 646 return IsSmi() || IsHeapNumber(); |
647 } | 647 } |
648 | 648 |
649 | 649 |
650 TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE) | 650 TYPE_CHECKER(ByteArray, BYTE_ARRAY_TYPE) |
| 651 TYPE_CHECKER(BytecodeArray, BYTECODE_ARRAY_TYPE) |
651 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) | 652 TYPE_CHECKER(FreeSpace, FREE_SPACE_TYPE) |
652 | 653 |
653 | 654 |
654 bool Object::IsFiller() const { | 655 bool Object::IsFiller() const { |
655 if (!Object::IsHeapObject()) return false; | 656 if (!Object::IsHeapObject()) return false; |
656 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); | 657 InstanceType instance_type = HeapObject::cast(this)->map()->instance_type(); |
657 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; | 658 return instance_type == FREE_SPACE_TYPE || instance_type == FILLER_TYPE; |
658 } | 659 } |
659 | 660 |
660 | 661 |
(...skipping 2256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2917 } | 2918 } |
2918 | 2919 |
2919 | 2920 |
2920 // ------------------------------------ | 2921 // ------------------------------------ |
2921 // Cast operations | 2922 // Cast operations |
2922 | 2923 |
2923 | 2924 |
2924 CAST_ACCESSOR(AccessorInfo) | 2925 CAST_ACCESSOR(AccessorInfo) |
2925 CAST_ACCESSOR(ArrayList) | 2926 CAST_ACCESSOR(ArrayList) |
2926 CAST_ACCESSOR(ByteArray) | 2927 CAST_ACCESSOR(ByteArray) |
| 2928 CAST_ACCESSOR(BytecodeArray) |
2927 CAST_ACCESSOR(Cell) | 2929 CAST_ACCESSOR(Cell) |
2928 CAST_ACCESSOR(Code) | 2930 CAST_ACCESSOR(Code) |
2929 CAST_ACCESSOR(CodeCacheHashTable) | 2931 CAST_ACCESSOR(CodeCacheHashTable) |
2930 CAST_ACCESSOR(CompilationCacheTable) | 2932 CAST_ACCESSOR(CompilationCacheTable) |
2931 CAST_ACCESSOR(ConsString) | 2933 CAST_ACCESSOR(ConsString) |
2932 CAST_ACCESSOR(DeoptimizationInputData) | 2934 CAST_ACCESSOR(DeoptimizationInputData) |
2933 CAST_ACCESSOR(DeoptimizationOutputData) | 2935 CAST_ACCESSOR(DeoptimizationOutputData) |
2934 CAST_ACCESSOR(DependentCode) | 2936 CAST_ACCESSOR(DependentCode) |
2935 CAST_ACCESSOR(DescriptorArray) | 2937 CAST_ACCESSOR(DescriptorArray) |
2936 CAST_ACCESSOR(ExternalArray) | 2938 CAST_ACCESSOR(ExternalArray) |
(...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3618 DCHECK_TAG_ALIGNED(address); | 3620 DCHECK_TAG_ALIGNED(address); |
3619 return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag); | 3621 return reinterpret_cast<ByteArray*>(address - kHeaderSize + kHeapObjectTag); |
3620 } | 3622 } |
3621 | 3623 |
3622 | 3624 |
3623 Address ByteArray::GetDataStartAddress() { | 3625 Address ByteArray::GetDataStartAddress() { |
3624 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; | 3626 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; |
3625 } | 3627 } |
3626 | 3628 |
3627 | 3629 |
| 3630 byte BytecodeArray::get(int index) { |
| 3631 DCHECK(index >= 0 && index < this->length()); |
| 3632 return READ_BYTE_FIELD(this, kHeaderSize + index * kCharSize); |
| 3633 } |
| 3634 |
| 3635 |
| 3636 void BytecodeArray::set(int index, byte value) { |
| 3637 DCHECK(index >= 0 && index < this->length()); |
| 3638 WRITE_BYTE_FIELD(this, kHeaderSize + index * kCharSize, value); |
| 3639 } |
| 3640 |
| 3641 |
| 3642 INT_ACCESSORS(BytecodeArray, frame_size, kFrameSizeOffset) |
| 3643 INT_ACCESSORS(BytecodeArray, number_of_locals, kNumberOfLocalsOffset) |
| 3644 |
| 3645 |
| 3646 Address BytecodeArray::GetFirstBytecodeAddress() { |
| 3647 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; |
| 3648 } |
| 3649 |
| 3650 |
3628 uint8_t* ExternalUint8ClampedArray::external_uint8_clamped_pointer() { | 3651 uint8_t* ExternalUint8ClampedArray::external_uint8_clamped_pointer() { |
3629 return reinterpret_cast<uint8_t*>(external_pointer()); | 3652 return reinterpret_cast<uint8_t*>(external_pointer()); |
3630 } | 3653 } |
3631 | 3654 |
3632 | 3655 |
3633 uint8_t ExternalUint8ClampedArray::get_scalar(int index) { | 3656 uint8_t ExternalUint8ClampedArray::get_scalar(int index) { |
3634 DCHECK((index >= 0) && (index < this->length())); | 3657 DCHECK((index >= 0) && (index < this->length())); |
3635 uint8_t* ptr = external_uint8_clamped_pointer(); | 3658 uint8_t* ptr = external_uint8_clamped_pointer(); |
3636 return ptr[index]; | 3659 return ptr[index]; |
3637 } | 3660 } |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4106 if (instance_type == ONE_BYTE_STRING_TYPE || | 4129 if (instance_type == ONE_BYTE_STRING_TYPE || |
4107 instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) { | 4130 instance_type == ONE_BYTE_INTERNALIZED_STRING_TYPE) { |
4108 // Strings may get concurrently truncated, hence we have to access its | 4131 // Strings may get concurrently truncated, hence we have to access its |
4109 // length synchronized. | 4132 // length synchronized. |
4110 return SeqOneByteString::SizeFor( | 4133 return SeqOneByteString::SizeFor( |
4111 reinterpret_cast<SeqOneByteString*>(this)->synchronized_length()); | 4134 reinterpret_cast<SeqOneByteString*>(this)->synchronized_length()); |
4112 } | 4135 } |
4113 if (instance_type == BYTE_ARRAY_TYPE) { | 4136 if (instance_type == BYTE_ARRAY_TYPE) { |
4114 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); | 4137 return reinterpret_cast<ByteArray*>(this)->ByteArraySize(); |
4115 } | 4138 } |
| 4139 if (instance_type == BYTECODE_ARRAY_TYPE) { |
| 4140 return reinterpret_cast<BytecodeArray*>(this)->BytecodeArraySize(); |
| 4141 } |
4116 if (instance_type == FREE_SPACE_TYPE) { | 4142 if (instance_type == FREE_SPACE_TYPE) { |
4117 return reinterpret_cast<FreeSpace*>(this)->nobarrier_size(); | 4143 return reinterpret_cast<FreeSpace*>(this)->nobarrier_size(); |
4118 } | 4144 } |
4119 if (instance_type == STRING_TYPE || | 4145 if (instance_type == STRING_TYPE || |
4120 instance_type == INTERNALIZED_STRING_TYPE) { | 4146 instance_type == INTERNALIZED_STRING_TYPE) { |
4121 // Strings may get concurrently truncated, hence we have to access its | 4147 // Strings may get concurrently truncated, hence we have to access its |
4122 // length synchronized. | 4148 // length synchronized. |
4123 return SeqTwoByteString::SizeFor( | 4149 return SeqTwoByteString::SizeFor( |
4124 reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length()); | 4150 reinterpret_cast<SeqTwoByteString*>(this)->synchronized_length()); |
4125 } | 4151 } |
(...skipping 1382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5508 return function_data()->IsSmi(); | 5534 return function_data()->IsSmi(); |
5509 } | 5535 } |
5510 | 5536 |
5511 | 5537 |
5512 BuiltinFunctionId SharedFunctionInfo::builtin_function_id() { | 5538 BuiltinFunctionId SharedFunctionInfo::builtin_function_id() { |
5513 DCHECK(HasBuiltinFunctionId()); | 5539 DCHECK(HasBuiltinFunctionId()); |
5514 return static_cast<BuiltinFunctionId>(Smi::cast(function_data())->value()); | 5540 return static_cast<BuiltinFunctionId>(Smi::cast(function_data())->value()); |
5515 } | 5541 } |
5516 | 5542 |
5517 | 5543 |
| 5544 bool SharedFunctionInfo::HasBytecodeArray() { |
| 5545 return function_data()->IsBytecodeArray(); |
| 5546 } |
| 5547 |
| 5548 |
| 5549 BytecodeArray* SharedFunctionInfo::bytecode_array() { |
| 5550 DCHECK(HasBytecodeArray()); |
| 5551 return BytecodeArray::cast(function_data()); |
| 5552 } |
| 5553 |
| 5554 |
5518 int SharedFunctionInfo::ic_age() { | 5555 int SharedFunctionInfo::ic_age() { |
5519 return ICAgeBits::decode(counters()); | 5556 return ICAgeBits::decode(counters()); |
5520 } | 5557 } |
5521 | 5558 |
5522 | 5559 |
5523 void SharedFunctionInfo::set_ic_age(int ic_age) { | 5560 void SharedFunctionInfo::set_ic_age(int ic_age) { |
5524 set_counters(ICAgeBits::update(counters(), ic_age)); | 5561 set_counters(ICAgeBits::update(counters(), ic_age)); |
5525 } | 5562 } |
5526 | 5563 |
5527 | 5564 |
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7313 #undef READ_SHORT_FIELD | 7350 #undef READ_SHORT_FIELD |
7314 #undef WRITE_SHORT_FIELD | 7351 #undef WRITE_SHORT_FIELD |
7315 #undef READ_BYTE_FIELD | 7352 #undef READ_BYTE_FIELD |
7316 #undef WRITE_BYTE_FIELD | 7353 #undef WRITE_BYTE_FIELD |
7317 #undef NOBARRIER_READ_BYTE_FIELD | 7354 #undef NOBARRIER_READ_BYTE_FIELD |
7318 #undef NOBARRIER_WRITE_BYTE_FIELD | 7355 #undef NOBARRIER_WRITE_BYTE_FIELD |
7319 | 7356 |
7320 } } // namespace v8::internal | 7357 } } // namespace v8::internal |
7321 | 7358 |
7322 #endif // V8_OBJECTS_INL_H_ | 7359 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |