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

Side by Side Diff: src/objects.cc

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

Powered by Google App Engine
This is Rietveld 408576698