OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <memory> | 9 #include <memory> |
10 #include <sstream> | 10 #include <sstream> |
(...skipping 14102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14113 for (RelocIterator it(this, mask); !it.done(); it.next()) { | 14113 for (RelocIterator it(this, mask); !it.done(); it.next()) { |
14114 RelocInfo* info = it.rinfo(); | 14114 RelocInfo* info = it.rinfo(); |
14115 Code* target(Code::GetCodeFromTargetAddress(info->target_address())); | 14115 Code* target(Code::GetCodeFromTargetAddress(info->target_address())); |
14116 if (target->is_inline_cache_stub()) { | 14116 if (target->is_inline_cache_stub()) { |
14117 ICUtility::Clear(this->GetIsolate(), info->pc(), | 14117 ICUtility::Clear(this->GetIsolate(), info->pc(), |
14118 info->host()->constant_pool()); | 14118 info->host()->constant_pool()); |
14119 } | 14119 } |
14120 } | 14120 } |
14121 } | 14121 } |
14122 | 14122 |
| 14123 namespace { |
| 14124 template <typename Code> |
| 14125 void SetStackFrameCacheCommon(Handle<Code> code, |
| 14126 Handle<UnseededNumberDictionary> cache) { |
| 14127 Handle<Object> maybe_table(code->source_position_table(), code->GetIsolate()); |
| 14128 if (maybe_table->IsSourcePositionTableWithFrameCache()) { |
| 14129 Handle<SourcePositionTableWithFrameCache>::cast(maybe_table) |
| 14130 ->set_stack_frame_cache(*cache); |
| 14131 return; |
| 14132 } |
| 14133 DCHECK(maybe_table->IsByteArray()); |
| 14134 Handle<ByteArray> table(Handle<ByteArray>::cast(maybe_table)); |
| 14135 Handle<SourcePositionTableWithFrameCache> table_with_cache = |
| 14136 code->GetIsolate()->factory()->NewSourcePositionTableWithFrameCache( |
| 14137 table, cache); |
| 14138 code->set_source_position_table(*table_with_cache); |
| 14139 } |
| 14140 } // namespace |
| 14141 |
| 14142 // static |
| 14143 void AbstractCode::SetStackFrameCache(Handle<AbstractCode> abstract_code, |
| 14144 Handle<UnseededNumberDictionary> cache) { |
| 14145 if (abstract_code->IsCode()) { |
| 14146 SetStackFrameCacheCommon(handle(abstract_code->GetCode()), cache); |
| 14147 } else { |
| 14148 SetStackFrameCacheCommon(handle(abstract_code->GetBytecodeArray()), cache); |
| 14149 } |
| 14150 } |
| 14151 |
| 14152 namespace { |
| 14153 template <typename Code> |
| 14154 void DropStackFrameCacheCommon(Code* code) { |
| 14155 i::Object* maybe_table = code->source_position_table(); |
| 14156 if (maybe_table->IsByteArray()) return; |
| 14157 DCHECK(maybe_table->IsSourcePositionTableWithFrameCache()); |
| 14158 code->set_source_position_table( |
| 14159 i::SourcePositionTableWithFrameCache::cast(maybe_table) |
| 14160 ->source_position_table()); |
| 14161 } |
| 14162 } // namespace |
| 14163 |
| 14164 void AbstractCode::DropStackFrameCache() { |
| 14165 if (IsCode()) { |
| 14166 DropStackFrameCacheCommon(GetCode()); |
| 14167 } else { |
| 14168 DropStackFrameCacheCommon(GetBytecodeArray()); |
| 14169 } |
| 14170 } |
| 14171 |
14123 int AbstractCode::SourcePosition(int offset) { | 14172 int AbstractCode::SourcePosition(int offset) { |
14124 int position = 0; | 14173 int position = 0; |
14125 // Subtract one because the current PC is one instruction after the call site. | 14174 // Subtract one because the current PC is one instruction after the call site. |
14126 if (IsCode()) offset--; | 14175 if (IsCode()) offset--; |
14127 for (SourcePositionTableIterator iterator(source_position_table()); | 14176 for (SourcePositionTableIterator iterator(source_position_table()); |
14128 !iterator.done() && iterator.code_offset() <= offset; | 14177 !iterator.done() && iterator.code_offset() <= offset; |
14129 iterator.Advance()) { | 14178 iterator.Advance()) { |
14130 position = iterator.source_position().ScriptOffset(); | 14179 position = iterator.source_position().ScriptOffset(); |
14131 } | 14180 } |
14132 return position; | 14181 return position; |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14769 Vector<char> buf = Vector<char>::New(50); | 14818 Vector<char> buf = Vector<char>::New(50); |
14770 intptr_t* ptr = reinterpret_cast<intptr_t*>(begin + constant_pool_offset); | 14819 intptr_t* ptr = reinterpret_cast<intptr_t*>(begin + constant_pool_offset); |
14771 for (int i = 0; i < constant_pool_size; i += kPointerSize, ptr++) { | 14820 for (int i = 0; i < constant_pool_size; i += kPointerSize, ptr++) { |
14772 SNPrintF(buf, "%4d %08" V8PRIxPTR, i, *ptr); | 14821 SNPrintF(buf, "%4d %08" V8PRIxPTR, i, *ptr); |
14773 os << static_cast<const void*>(ptr) << " " << buf.start() << "\n"; | 14822 os << static_cast<const void*>(ptr) << " " << buf.start() << "\n"; |
14774 } | 14823 } |
14775 } | 14824 } |
14776 } | 14825 } |
14777 os << "\n"; | 14826 os << "\n"; |
14778 | 14827 |
14779 SourcePositionTableIterator it(source_position_table()); | 14828 SourcePositionTableIterator it(SourcePositionTable()); |
14780 if (!it.done()) { | 14829 if (!it.done()) { |
14781 os << "Source positions:\n pc offset position\n"; | 14830 os << "Source positions:\n pc offset position\n"; |
14782 for (; !it.done(); it.Advance()) { | 14831 for (; !it.done(); it.Advance()) { |
14783 os << std::setw(10) << std::hex << it.code_offset() << std::dec | 14832 os << std::setw(10) << std::hex << it.code_offset() << std::dec |
14784 << std::setw(10) << it.source_position().ScriptOffset() | 14833 << std::setw(10) << it.source_position().ScriptOffset() |
14785 << (it.is_statement() ? " statement" : "") << "\n"; | 14834 << (it.is_statement() ? " statement" : "") << "\n"; |
14786 } | 14835 } |
14787 os << "\n"; | 14836 os << "\n"; |
14788 } | 14837 } |
14789 | 14838 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14871 } | 14920 } |
14872 } | 14921 } |
14873 #endif // ENABLE_DISASSEMBLER | 14922 #endif // ENABLE_DISASSEMBLER |
14874 | 14923 |
14875 | 14924 |
14876 void BytecodeArray::Disassemble(std::ostream& os) { | 14925 void BytecodeArray::Disassemble(std::ostream& os) { |
14877 os << "Parameter count " << parameter_count() << "\n"; | 14926 os << "Parameter count " << parameter_count() << "\n"; |
14878 os << "Frame size " << frame_size() << "\n"; | 14927 os << "Frame size " << frame_size() << "\n"; |
14879 | 14928 |
14880 const uint8_t* base_address = GetFirstBytecodeAddress(); | 14929 const uint8_t* base_address = GetFirstBytecodeAddress(); |
14881 SourcePositionTableIterator source_positions(source_position_table()); | 14930 SourcePositionTableIterator source_positions(SourcePositionTable()); |
14882 | 14931 |
14883 interpreter::BytecodeArrayIterator iterator(handle(this)); | 14932 interpreter::BytecodeArrayIterator iterator(handle(this)); |
14884 while (!iterator.done()) { | 14933 while (!iterator.done()) { |
14885 if (!source_positions.done() && | 14934 if (!source_positions.done() && |
14886 iterator.current_offset() == source_positions.code_offset()) { | 14935 iterator.current_offset() == source_positions.code_offset()) { |
14887 os << std::setw(5) << source_positions.source_position().ScriptOffset(); | 14936 os << std::setw(5) << source_positions.source_position().ScriptOffset(); |
14888 os << (source_positions.is_statement() ? " S> " : " E> "); | 14937 os << (source_positions.is_statement() ? " S> " : " E> "); |
14889 source_positions.Advance(); | 14938 source_positions.Advance(); |
14890 } else { | 14939 } else { |
14891 os << " "; | 14940 os << " "; |
(...skipping 5559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20451 // depend on this. | 20500 // depend on this. |
20452 return DICTIONARY_ELEMENTS; | 20501 return DICTIONARY_ELEMENTS; |
20453 } | 20502 } |
20454 DCHECK_LE(kind, LAST_ELEMENTS_KIND); | 20503 DCHECK_LE(kind, LAST_ELEMENTS_KIND); |
20455 return kind; | 20504 return kind; |
20456 } | 20505 } |
20457 } | 20506 } |
20458 | 20507 |
20459 } // namespace internal | 20508 } // namespace internal |
20460 } // namespace v8 | 20509 } // namespace v8 |
OLD | NEW |