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 4003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4014 } | 4014 } |
4015 | 4015 |
4016 int BytecodeArray::parameter_count() const { | 4016 int BytecodeArray::parameter_count() const { |
4017 // Parameter count is stored as the size on stack of the parameters to allow | 4017 // Parameter count is stored as the size on stack of the parameters to allow |
4018 // it to be used directly by generated code. | 4018 // it to be used directly by generated code. |
4019 return READ_INT_FIELD(this, kParameterSizeOffset) >> kPointerSizeLog2; | 4019 return READ_INT_FIELD(this, kParameterSizeOffset) >> kPointerSizeLog2; |
4020 } | 4020 } |
4021 | 4021 |
4022 ACCESSORS(BytecodeArray, constant_pool, FixedArray, kConstantPoolOffset) | 4022 ACCESSORS(BytecodeArray, constant_pool, FixedArray, kConstantPoolOffset) |
4023 ACCESSORS(BytecodeArray, handler_table, FixedArray, kHandlerTableOffset) | 4023 ACCESSORS(BytecodeArray, handler_table, FixedArray, kHandlerTableOffset) |
4024 ACCESSORS(BytecodeArray, source_position_table, ByteArray, | 4024 ACCESSORS(BytecodeArray, source_position_table, Object, |
4025 kSourcePositionTableOffset) | 4025 kSourcePositionTableOffset) |
4026 | 4026 |
4027 Address BytecodeArray::GetFirstBytecodeAddress() { | 4027 Address BytecodeArray::GetFirstBytecodeAddress() { |
4028 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; | 4028 return reinterpret_cast<Address>(this) - kHeapObjectTag + kHeaderSize; |
4029 } | 4029 } |
4030 | 4030 |
| 4031 ByteArray* BytecodeArray::SourcePositionTable() { |
| 4032 Object* maybe_table = source_position_table(); |
| 4033 if (maybe_table->IsByteArray()) return ByteArray::cast(maybe_table); |
| 4034 DCHECK(maybe_table->IsSourcePositionTableWithFrameCache()); |
| 4035 return SourcePositionTableWithFrameCache::cast(maybe_table) |
| 4036 ->source_position_table(); |
| 4037 } |
4031 | 4038 |
4032 int BytecodeArray::BytecodeArraySize() { return SizeFor(this->length()); } | 4039 int BytecodeArray::BytecodeArraySize() { return SizeFor(this->length()); } |
4033 | 4040 |
4034 int BytecodeArray::SizeIncludingMetadata() { | 4041 int BytecodeArray::SizeIncludingMetadata() { |
4035 int size = BytecodeArraySize(); | 4042 int size = BytecodeArraySize(); |
4036 size += constant_pool()->Size(); | 4043 size += constant_pool()->Size(); |
4037 size += handler_table()->Size(); | 4044 size += handler_table()->Size(); |
4038 size += source_position_table()->Size(); | 4045 size += SourcePositionTable()->Size(); |
4039 return size; | 4046 return size; |
4040 } | 4047 } |
4041 | 4048 |
4042 ACCESSORS(FixedTypedArrayBase, base_pointer, Object, kBasePointerOffset) | 4049 ACCESSORS(FixedTypedArrayBase, base_pointer, Object, kBasePointerOffset) |
4043 | 4050 |
4044 | 4051 |
4045 void* FixedTypedArrayBase::external_pointer() const { | 4052 void* FixedTypedArrayBase::external_pointer() const { |
4046 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset); | 4053 intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset); |
4047 return reinterpret_cast<void*>(ptr); | 4054 return reinterpret_cast<void*>(ptr); |
4048 } | 4055 } |
(...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5228 int AbstractCode::instruction_size() { | 5235 int AbstractCode::instruction_size() { |
5229 if (IsCode()) { | 5236 if (IsCode()) { |
5230 return GetCode()->instruction_size(); | 5237 return GetCode()->instruction_size(); |
5231 } else { | 5238 } else { |
5232 return GetBytecodeArray()->length(); | 5239 return GetBytecodeArray()->length(); |
5233 } | 5240 } |
5234 } | 5241 } |
5235 | 5242 |
5236 ByteArray* AbstractCode::source_position_table() { | 5243 ByteArray* AbstractCode::source_position_table() { |
5237 if (IsCode()) { | 5244 if (IsCode()) { |
5238 return GetCode()->source_position_table(); | 5245 return GetCode()->SourcePositionTable(); |
5239 } else { | 5246 } else { |
5240 return GetBytecodeArray()->source_position_table(); | 5247 return GetBytecodeArray()->SourcePositionTable(); |
5241 } | 5248 } |
5242 } | 5249 } |
5243 | 5250 |
5244 void AbstractCode::set_source_position_table(ByteArray* source_position_table) { | 5251 void AbstractCode::set_source_position_table(ByteArray* source_position_table) { |
5245 if (IsCode()) { | 5252 if (IsCode()) { |
5246 GetCode()->set_source_position_table(source_position_table); | 5253 GetCode()->set_source_position_table(source_position_table); |
5247 } else { | 5254 } else { |
5248 GetBytecodeArray()->set_source_position_table(source_position_table); | 5255 GetBytecodeArray()->set_source_position_table(source_position_table); |
5249 } | 5256 } |
5250 } | 5257 } |
5251 | 5258 |
| 5259 Object* AbstractCode::stack_frame_cache() { |
| 5260 Object* maybe_table; |
| 5261 if (IsCode()) { |
| 5262 maybe_table = GetCode()->source_position_table(); |
| 5263 } else { |
| 5264 maybe_table = GetBytecodeArray()->source_position_table(); |
| 5265 } |
| 5266 if (maybe_table->IsSourcePositionTableWithFrameCache()) { |
| 5267 return SourcePositionTableWithFrameCache::cast(maybe_table) |
| 5268 ->stack_frame_cache(); |
| 5269 } |
| 5270 return Smi::kZero; |
| 5271 } |
| 5272 |
5252 int AbstractCode::SizeIncludingMetadata() { | 5273 int AbstractCode::SizeIncludingMetadata() { |
5253 if (IsCode()) { | 5274 if (IsCode()) { |
5254 return GetCode()->SizeIncludingMetadata(); | 5275 return GetCode()->SizeIncludingMetadata(); |
5255 } else { | 5276 } else { |
5256 return GetBytecodeArray()->SizeIncludingMetadata(); | 5277 return GetBytecodeArray()->SizeIncludingMetadata(); |
5257 } | 5278 } |
5258 } | 5279 } |
5259 int AbstractCode::ExecutableSize() { | 5280 int AbstractCode::ExecutableSize() { |
5260 if (IsCode()) { | 5281 if (IsCode()) { |
5261 return GetCode()->ExecutableSize(); | 5282 return GetCode()->ExecutableSize(); |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5814 SMI_ACCESSORS(StackFrameInfo, script_id, kScriptIdIndex) | 5835 SMI_ACCESSORS(StackFrameInfo, script_id, kScriptIdIndex) |
5815 ACCESSORS(StackFrameInfo, script_name, Object, kScriptNameIndex) | 5836 ACCESSORS(StackFrameInfo, script_name, Object, kScriptNameIndex) |
5816 ACCESSORS(StackFrameInfo, script_name_or_source_url, Object, | 5837 ACCESSORS(StackFrameInfo, script_name_or_source_url, Object, |
5817 kScriptNameOrSourceUrlIndex) | 5838 kScriptNameOrSourceUrlIndex) |
5818 ACCESSORS(StackFrameInfo, function_name, Object, kFunctionNameIndex) | 5839 ACCESSORS(StackFrameInfo, function_name, Object, kFunctionNameIndex) |
5819 SMI_ACCESSORS(StackFrameInfo, flag, kFlagIndex) | 5840 SMI_ACCESSORS(StackFrameInfo, flag, kFlagIndex) |
5820 BOOL_ACCESSORS(StackFrameInfo, flag, is_eval, kIsEvalBit) | 5841 BOOL_ACCESSORS(StackFrameInfo, flag, is_eval, kIsEvalBit) |
5821 BOOL_ACCESSORS(StackFrameInfo, flag, is_constructor, kIsConstructorBit) | 5842 BOOL_ACCESSORS(StackFrameInfo, flag, is_constructor, kIsConstructorBit) |
5822 BOOL_ACCESSORS(StackFrameInfo, flag, is_wasm, kIsWasmBit) | 5843 BOOL_ACCESSORS(StackFrameInfo, flag, is_wasm, kIsWasmBit) |
5823 | 5844 |
| 5845 ACCESSORS(SourcePositionTableWithFrameCache, source_position_table, ByteArray, |
| 5846 kSourcePositionTableIndex) |
| 5847 ACCESSORS(SourcePositionTableWithFrameCache, stack_frame_cache, |
| 5848 UnseededNumberDictionary, kStackFrameCacheIndex) |
| 5849 |
5824 ACCESSORS(SharedFunctionInfo, name, Object, kNameOffset) | 5850 ACCESSORS(SharedFunctionInfo, name, Object, kNameOffset) |
5825 ACCESSORS(SharedFunctionInfo, optimized_code_map, FixedArray, | 5851 ACCESSORS(SharedFunctionInfo, optimized_code_map, FixedArray, |
5826 kOptimizedCodeMapOffset) | 5852 kOptimizedCodeMapOffset) |
5827 ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset) | 5853 ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset) |
5828 ACCESSORS(SharedFunctionInfo, feedback_metadata, FeedbackMetadata, | 5854 ACCESSORS(SharedFunctionInfo, feedback_metadata, FeedbackMetadata, |
5829 kFeedbackMetadataOffset) | 5855 kFeedbackMetadataOffset) |
5830 SMI_ACCESSORS(SharedFunctionInfo, function_literal_id, kFunctionLiteralIdOffset) | 5856 SMI_ACCESSORS(SharedFunctionInfo, function_literal_id, kFunctionLiteralIdOffset) |
5831 #if TRACE_MAPS | 5857 #if TRACE_MAPS |
5832 SMI_ACCESSORS(SharedFunctionInfo, unique_id, kUniqueIdOffset) | 5858 SMI_ACCESSORS(SharedFunctionInfo, unique_id, kUniqueIdOffset) |
5833 #endif | 5859 #endif |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6640 | 6666 |
6641 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) | 6667 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) |
6642 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset) | 6668 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset) |
6643 INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset) | 6669 INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset) |
6644 #define CODE_ACCESSORS(name, type, offset) \ | 6670 #define CODE_ACCESSORS(name, type, offset) \ |
6645 ACCESSORS_CHECKED2(Code, name, type, offset, true, \ | 6671 ACCESSORS_CHECKED2(Code, name, type, offset, true, \ |
6646 !GetHeap()->InNewSpace(value)) | 6672 !GetHeap()->InNewSpace(value)) |
6647 CODE_ACCESSORS(relocation_info, ByteArray, kRelocationInfoOffset) | 6673 CODE_ACCESSORS(relocation_info, ByteArray, kRelocationInfoOffset) |
6648 CODE_ACCESSORS(handler_table, FixedArray, kHandlerTableOffset) | 6674 CODE_ACCESSORS(handler_table, FixedArray, kHandlerTableOffset) |
6649 CODE_ACCESSORS(deoptimization_data, FixedArray, kDeoptimizationDataOffset) | 6675 CODE_ACCESSORS(deoptimization_data, FixedArray, kDeoptimizationDataOffset) |
6650 CODE_ACCESSORS(source_position_table, ByteArray, kSourcePositionTableOffset) | 6676 CODE_ACCESSORS(source_position_table, Object, kSourcePositionTableOffset) |
6651 CODE_ACCESSORS(trap_handler_index, Smi, kTrapHandlerIndex) | 6677 CODE_ACCESSORS(trap_handler_index, Smi, kTrapHandlerIndex) |
6652 CODE_ACCESSORS(raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) | 6678 CODE_ACCESSORS(raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) |
6653 CODE_ACCESSORS(next_code_link, Object, kNextCodeLinkOffset) | 6679 CODE_ACCESSORS(next_code_link, Object, kNextCodeLinkOffset) |
6654 #undef CODE_ACCESSORS | 6680 #undef CODE_ACCESSORS |
6655 | 6681 |
6656 void Code::WipeOutHeader() { | 6682 void Code::WipeOutHeader() { |
6657 WRITE_FIELD(this, kRelocationInfoOffset, NULL); | 6683 WRITE_FIELD(this, kRelocationInfoOffset, NULL); |
6658 WRITE_FIELD(this, kHandlerTableOffset, NULL); | 6684 WRITE_FIELD(this, kHandlerTableOffset, NULL); |
6659 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); | 6685 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); |
6660 WRITE_FIELD(this, kSourcePositionTableOffset, NULL); | 6686 WRITE_FIELD(this, kSourcePositionTableOffset, NULL); |
(...skipping 12 matching lines...) Expand all Loading... |
6673 } | 6699 } |
6674 | 6700 |
6675 | 6701 |
6676 void Code::set_type_feedback_info(Object* value, WriteBarrierMode mode) { | 6702 void Code::set_type_feedback_info(Object* value, WriteBarrierMode mode) { |
6677 DCHECK(kind() == FUNCTION); | 6703 DCHECK(kind() == FUNCTION); |
6678 set_raw_type_feedback_info(value, mode); | 6704 set_raw_type_feedback_info(value, mode); |
6679 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kTypeFeedbackInfoOffset, | 6705 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kTypeFeedbackInfoOffset, |
6680 value, mode); | 6706 value, mode); |
6681 } | 6707 } |
6682 | 6708 |
| 6709 ByteArray* Code::SourcePositionTable() { |
| 6710 Object* maybe_table = source_position_table(); |
| 6711 if (maybe_table->IsByteArray()) return ByteArray::cast(maybe_table); |
| 6712 DCHECK(maybe_table->IsSourcePositionTableWithFrameCache()); |
| 6713 return SourcePositionTableWithFrameCache::cast(maybe_table) |
| 6714 ->source_position_table(); |
| 6715 } |
6683 | 6716 |
6684 uint32_t Code::stub_key() { | 6717 uint32_t Code::stub_key() { |
6685 DCHECK(IsCodeStubOrIC()); | 6718 DCHECK(IsCodeStubOrIC()); |
6686 Smi* smi_key = Smi::cast(raw_type_feedback_info()); | 6719 Smi* smi_key = Smi::cast(raw_type_feedback_info()); |
6687 return static_cast<uint32_t>(smi_key->value()); | 6720 return static_cast<uint32_t>(smi_key->value()); |
6688 } | 6721 } |
6689 | 6722 |
6690 | 6723 |
6691 void Code::set_stub_key(uint32_t key) { | 6724 void Code::set_stub_key(uint32_t key) { |
6692 DCHECK(IsCodeStubOrIC()); | 6725 DCHECK(IsCodeStubOrIC()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6739 ? static_cast<int>(unwinding_info_end() - instruction_start()) | 6772 ? static_cast<int>(unwinding_info_end() - instruction_start()) |
6740 : instruction_size(); | 6773 : instruction_size(); |
6741 return RoundUp(unpadded_body_size, kObjectAlignment); | 6774 return RoundUp(unpadded_body_size, kObjectAlignment); |
6742 } | 6775 } |
6743 | 6776 |
6744 int Code::SizeIncludingMetadata() { | 6777 int Code::SizeIncludingMetadata() { |
6745 int size = CodeSize(); | 6778 int size = CodeSize(); |
6746 size += relocation_info()->Size(); | 6779 size += relocation_info()->Size(); |
6747 size += deoptimization_data()->Size(); | 6780 size += deoptimization_data()->Size(); |
6748 size += handler_table()->Size(); | 6781 size += handler_table()->Size(); |
6749 if (kind() == FUNCTION) size += source_position_table()->Size(); | 6782 if (kind() == FUNCTION) { |
| 6783 size += SourcePositionTable()->Size(); |
| 6784 } |
6750 return size; | 6785 return size; |
6751 } | 6786 } |
6752 | 6787 |
6753 ByteArray* Code::unchecked_relocation_info() { | 6788 ByteArray* Code::unchecked_relocation_info() { |
6754 return reinterpret_cast<ByteArray*>(READ_FIELD(this, kRelocationInfoOffset)); | 6789 return reinterpret_cast<ByteArray*>(READ_FIELD(this, kRelocationInfoOffset)); |
6755 } | 6790 } |
6756 | 6791 |
6757 | 6792 |
6758 byte* Code::relocation_start() { | 6793 byte* Code::relocation_start() { |
6759 return unchecked_relocation_info()->GetDataStartAddress(); | 6794 return unchecked_relocation_info()->GetDataStartAddress(); |
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8270 #undef WRITE_BYTE_FIELD | 8305 #undef WRITE_BYTE_FIELD |
8271 #undef NOBARRIER_READ_BYTE_FIELD | 8306 #undef NOBARRIER_READ_BYTE_FIELD |
8272 #undef NOBARRIER_WRITE_BYTE_FIELD | 8307 #undef NOBARRIER_WRITE_BYTE_FIELD |
8273 | 8308 |
8274 } // namespace internal | 8309 } // namespace internal |
8275 } // namespace v8 | 8310 } // namespace v8 |
8276 | 8311 |
8277 #include "src/objects/object-macros-undef.h" | 8312 #include "src/objects/object-macros-undef.h" |
8278 | 8313 |
8279 #endif // V8_OBJECTS_INL_H_ | 8314 #endif // V8_OBJECTS_INL_H_ |
OLD | NEW |