Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: src/objects-inl.h

Issue 2788413004: [inspector] cache stack frame for call sites (Closed)
Patch Set: rebased Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
5824 ACCESSORS(StackTraceInfo, frames, FixedArray, kFramesIndex) 5845 ACCESSORS(StackTraceInfo, frames, FixedArray, kFramesIndex)
5825 SMI_ACCESSORS(StackTraceInfo, options, kOptionsIndex) 5846 SMI_ACCESSORS(StackTraceInfo, options, kOptionsIndex)
5826 5847
5848 ACCESSORS(SourcePositionTableWithFrameCache, source_position_table, ByteArray,
5849 kSourcePositionTableIndex)
5850 ACCESSORS(SourcePositionTableWithFrameCache, stack_frame_cache,
5851 UnseededNumberDictionary, kStackFrameCacheIndex)
5852
5827 ACCESSORS(SharedFunctionInfo, name, Object, kNameOffset) 5853 ACCESSORS(SharedFunctionInfo, name, Object, kNameOffset)
5828 ACCESSORS(SharedFunctionInfo, optimized_code_map, FixedArray, 5854 ACCESSORS(SharedFunctionInfo, optimized_code_map, FixedArray,
5829 kOptimizedCodeMapOffset) 5855 kOptimizedCodeMapOffset)
5830 ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset) 5856 ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset)
5831 ACCESSORS(SharedFunctionInfo, feedback_metadata, FeedbackMetadata, 5857 ACCESSORS(SharedFunctionInfo, feedback_metadata, FeedbackMetadata,
5832 kFeedbackMetadataOffset) 5858 kFeedbackMetadataOffset)
5833 SMI_ACCESSORS(SharedFunctionInfo, function_literal_id, kFunctionLiteralIdOffset) 5859 SMI_ACCESSORS(SharedFunctionInfo, function_literal_id, kFunctionLiteralIdOffset)
5834 #if TRACE_MAPS 5860 #if TRACE_MAPS
5835 SMI_ACCESSORS(SharedFunctionInfo, unique_id, kUniqueIdOffset) 5861 SMI_ACCESSORS(SharedFunctionInfo, unique_id, kUniqueIdOffset)
5836 #endif 5862 #endif
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after
6643 6669
6644 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset) 6670 INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset)
6645 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset) 6671 INT_ACCESSORS(Code, prologue_offset, kPrologueOffset)
6646 INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset) 6672 INT_ACCESSORS(Code, constant_pool_offset, kConstantPoolOffset)
6647 #define CODE_ACCESSORS(name, type, offset) \ 6673 #define CODE_ACCESSORS(name, type, offset) \
6648 ACCESSORS_CHECKED2(Code, name, type, offset, true, \ 6674 ACCESSORS_CHECKED2(Code, name, type, offset, true, \
6649 !GetHeap()->InNewSpace(value)) 6675 !GetHeap()->InNewSpace(value))
6650 CODE_ACCESSORS(relocation_info, ByteArray, kRelocationInfoOffset) 6676 CODE_ACCESSORS(relocation_info, ByteArray, kRelocationInfoOffset)
6651 CODE_ACCESSORS(handler_table, FixedArray, kHandlerTableOffset) 6677 CODE_ACCESSORS(handler_table, FixedArray, kHandlerTableOffset)
6652 CODE_ACCESSORS(deoptimization_data, FixedArray, kDeoptimizationDataOffset) 6678 CODE_ACCESSORS(deoptimization_data, FixedArray, kDeoptimizationDataOffset)
6653 CODE_ACCESSORS(source_position_table, ByteArray, kSourcePositionTableOffset) 6679 CODE_ACCESSORS(source_position_table, Object, kSourcePositionTableOffset)
6654 CODE_ACCESSORS(trap_handler_index, Smi, kTrapHandlerIndex) 6680 CODE_ACCESSORS(trap_handler_index, Smi, kTrapHandlerIndex)
6655 CODE_ACCESSORS(raw_type_feedback_info, Object, kTypeFeedbackInfoOffset) 6681 CODE_ACCESSORS(raw_type_feedback_info, Object, kTypeFeedbackInfoOffset)
6656 CODE_ACCESSORS(next_code_link, Object, kNextCodeLinkOffset) 6682 CODE_ACCESSORS(next_code_link, Object, kNextCodeLinkOffset)
6657 #undef CODE_ACCESSORS 6683 #undef CODE_ACCESSORS
6658 6684
6659 void Code::WipeOutHeader() { 6685 void Code::WipeOutHeader() {
6660 WRITE_FIELD(this, kRelocationInfoOffset, NULL); 6686 WRITE_FIELD(this, kRelocationInfoOffset, NULL);
6661 WRITE_FIELD(this, kHandlerTableOffset, NULL); 6687 WRITE_FIELD(this, kHandlerTableOffset, NULL);
6662 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL); 6688 WRITE_FIELD(this, kDeoptimizationDataOffset, NULL);
6663 WRITE_FIELD(this, kSourcePositionTableOffset, NULL); 6689 WRITE_FIELD(this, kSourcePositionTableOffset, NULL);
(...skipping 12 matching lines...) Expand all
6676 } 6702 }
6677 6703
6678 6704
6679 void Code::set_type_feedback_info(Object* value, WriteBarrierMode mode) { 6705 void Code::set_type_feedback_info(Object* value, WriteBarrierMode mode) {
6680 DCHECK(kind() == FUNCTION); 6706 DCHECK(kind() == FUNCTION);
6681 set_raw_type_feedback_info(value, mode); 6707 set_raw_type_feedback_info(value, mode);
6682 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kTypeFeedbackInfoOffset, 6708 CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kTypeFeedbackInfoOffset,
6683 value, mode); 6709 value, mode);
6684 } 6710 }
6685 6711
6712 ByteArray* Code::SourcePositionTable() {
6713 Object* maybe_table = source_position_table();
6714 if (maybe_table->IsByteArray()) return ByteArray::cast(maybe_table);
6715 DCHECK(maybe_table->IsSourcePositionTableWithFrameCache());
6716 return SourcePositionTableWithFrameCache::cast(maybe_table)
6717 ->source_position_table();
6718 }
6686 6719
6687 uint32_t Code::stub_key() { 6720 uint32_t Code::stub_key() {
6688 DCHECK(IsCodeStubOrIC()); 6721 DCHECK(IsCodeStubOrIC());
6689 Smi* smi_key = Smi::cast(raw_type_feedback_info()); 6722 Smi* smi_key = Smi::cast(raw_type_feedback_info());
6690 return static_cast<uint32_t>(smi_key->value()); 6723 return static_cast<uint32_t>(smi_key->value());
6691 } 6724 }
6692 6725
6693 6726
6694 void Code::set_stub_key(uint32_t key) { 6727 void Code::set_stub_key(uint32_t key) {
6695 DCHECK(IsCodeStubOrIC()); 6728 DCHECK(IsCodeStubOrIC());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
6742 ? static_cast<int>(unwinding_info_end() - instruction_start()) 6775 ? static_cast<int>(unwinding_info_end() - instruction_start())
6743 : instruction_size(); 6776 : instruction_size();
6744 return RoundUp(unpadded_body_size, kObjectAlignment); 6777 return RoundUp(unpadded_body_size, kObjectAlignment);
6745 } 6778 }
6746 6779
6747 int Code::SizeIncludingMetadata() { 6780 int Code::SizeIncludingMetadata() {
6748 int size = CodeSize(); 6781 int size = CodeSize();
6749 size += relocation_info()->Size(); 6782 size += relocation_info()->Size();
6750 size += deoptimization_data()->Size(); 6783 size += deoptimization_data()->Size();
6751 size += handler_table()->Size(); 6784 size += handler_table()->Size();
6752 if (kind() == FUNCTION) size += source_position_table()->Size(); 6785 if (kind() == FUNCTION) {
6786 size += SourcePositionTable()->Size();
6787 }
6753 return size; 6788 return size;
6754 } 6789 }
6755 6790
6756 ByteArray* Code::unchecked_relocation_info() { 6791 ByteArray* Code::unchecked_relocation_info() {
6757 return reinterpret_cast<ByteArray*>(READ_FIELD(this, kRelocationInfoOffset)); 6792 return reinterpret_cast<ByteArray*>(READ_FIELD(this, kRelocationInfoOffset));
6758 } 6793 }
6759 6794
6760 6795
6761 byte* Code::relocation_start() { 6796 byte* Code::relocation_start() {
6762 return unchecked_relocation_info()->GetDataStartAddress(); 6797 return unchecked_relocation_info()->GetDataStartAddress();
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after
8273 #undef WRITE_BYTE_FIELD 8308 #undef WRITE_BYTE_FIELD
8274 #undef NOBARRIER_READ_BYTE_FIELD 8309 #undef NOBARRIER_READ_BYTE_FIELD
8275 #undef NOBARRIER_WRITE_BYTE_FIELD 8310 #undef NOBARRIER_WRITE_BYTE_FIELD
8276 8311
8277 } // namespace internal 8312 } // namespace internal
8278 } // namespace v8 8313 } // namespace v8
8279 8314
8280 #include "src/objects/object-macros-undef.h" 8315 #include "src/objects/object-macros-undef.h"
8281 8316
8282 #endif // V8_OBJECTS_INL_H_ 8317 #endif // V8_OBJECTS_INL_H_
OLDNEW
« src/api.cc ('K') | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698