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

Side by Side Diff: src/objects.cc

Issue 2788413004: [inspector] cache stack frame for call sites (Closed)
Patch Set: reverted v8-debugger change 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
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 14110 matching lines...) Expand 10 before | Expand all | Expand 10 after
14121 for (RelocIterator it(this, mask); !it.done(); it.next()) { 14121 for (RelocIterator it(this, mask); !it.done(); it.next()) {
14122 RelocInfo* info = it.rinfo(); 14122 RelocInfo* info = it.rinfo();
14123 Code* target(Code::GetCodeFromTargetAddress(info->target_address())); 14123 Code* target(Code::GetCodeFromTargetAddress(info->target_address()));
14124 if (target->is_inline_cache_stub()) { 14124 if (target->is_inline_cache_stub()) {
14125 ICUtility::Clear(this->GetIsolate(), info->pc(), 14125 ICUtility::Clear(this->GetIsolate(), info->pc(),
14126 info->host()->constant_pool()); 14126 info->host()->constant_pool());
14127 } 14127 }
14128 } 14128 }
14129 } 14129 }
14130 14130
14131 namespace {
14132 template <typename Code>
14133 void SetStackFrameCacheCommon(Handle<Code> code,
14134 Handle<UnseededNumberDictionary> cache) {
14135 Handle<Object> maybe_table(code->source_position_table(), code->GetIsolate());
14136 if (maybe_table->IsSourcePositionTableWithFrameCache()) {
14137 Handle<SourcePositionTableWithFrameCache>::cast(maybe_table)
14138 ->set_stack_frame_cache(*cache);
14139 return;
14140 }
14141 DCHECK(maybe_table->IsByteArray());
14142 Handle<ByteArray> table(Handle<ByteArray>::cast(maybe_table));
14143 Handle<SourcePositionTableWithFrameCache> table_with_cache =
14144 code->GetIsolate()->factory()->NewSourcePositionTableWithFrameCache(
14145 table, cache);
14146 code->set_source_position_table(*table_with_cache);
14147 }
14148 } // namespace
14149
14150 // static
14151 void AbstractCode::SetStackFrameCache(Handle<AbstractCode> abstract_code,
14152 Handle<UnseededNumberDictionary> cache) {
14153 if (abstract_code->IsCode()) {
14154 SetStackFrameCacheCommon(handle(abstract_code->GetCode()), cache);
14155 } else {
14156 SetStackFrameCacheCommon(handle(abstract_code->GetBytecodeArray()), cache);
14157 }
14158 }
14159
14160 namespace {
14161 template <typename Code>
14162 void DropStackFrameCacheCommon(Code* code) {
14163 i::Object* maybe_table = code->source_position_table();
14164 if (maybe_table->IsByteArray()) return;
14165 DCHECK(maybe_table->IsSourcePositionTableWithFrameCache());
14166 code->set_source_position_table(
14167 i::SourcePositionTableWithFrameCache::cast(maybe_table)
14168 ->source_position_table());
14169 }
14170 } // namespace
14171
14172 void AbstractCode::DropStackFrameCache() {
14173 if (IsCode()) {
14174 DropStackFrameCacheCommon(GetCode());
14175 } else {
14176 DropStackFrameCacheCommon(GetBytecodeArray());
14177 }
14178 }
14179
14131 int AbstractCode::SourcePosition(int offset) { 14180 int AbstractCode::SourcePosition(int offset) {
14132 int position = 0; 14181 int position = 0;
14133 // Subtract one because the current PC is one instruction after the call site. 14182 // Subtract one because the current PC is one instruction after the call site.
14134 if (IsCode()) offset--; 14183 if (IsCode()) offset--;
14135 for (SourcePositionTableIterator iterator(source_position_table()); 14184 for (SourcePositionTableIterator iterator(source_position_table());
14136 !iterator.done() && iterator.code_offset() <= offset; 14185 !iterator.done() && iterator.code_offset() <= offset;
14137 iterator.Advance()) { 14186 iterator.Advance()) {
14138 position = iterator.source_position().ScriptOffset(); 14187 position = iterator.source_position().ScriptOffset();
14139 } 14188 }
14140 return position; 14189 return position;
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
14777 Vector<char> buf = Vector<char>::New(50); 14826 Vector<char> buf = Vector<char>::New(50);
14778 intptr_t* ptr = reinterpret_cast<intptr_t*>(begin + constant_pool_offset); 14827 intptr_t* ptr = reinterpret_cast<intptr_t*>(begin + constant_pool_offset);
14779 for (int i = 0; i < constant_pool_size; i += kPointerSize, ptr++) { 14828 for (int i = 0; i < constant_pool_size; i += kPointerSize, ptr++) {
14780 SNPrintF(buf, "%4d %08" V8PRIxPTR, i, *ptr); 14829 SNPrintF(buf, "%4d %08" V8PRIxPTR, i, *ptr);
14781 os << static_cast<const void*>(ptr) << " " << buf.start() << "\n"; 14830 os << static_cast<const void*>(ptr) << " " << buf.start() << "\n";
14782 } 14831 }
14783 } 14832 }
14784 } 14833 }
14785 os << "\n"; 14834 os << "\n";
14786 14835
14787 SourcePositionTableIterator it(source_position_table()); 14836 SourcePositionTableIterator it(SourcePositionTable());
14788 if (!it.done()) { 14837 if (!it.done()) {
14789 os << "Source positions:\n pc offset position\n"; 14838 os << "Source positions:\n pc offset position\n";
14790 for (; !it.done(); it.Advance()) { 14839 for (; !it.done(); it.Advance()) {
14791 os << std::setw(10) << std::hex << it.code_offset() << std::dec 14840 os << std::setw(10) << std::hex << it.code_offset() << std::dec
14792 << std::setw(10) << it.source_position().ScriptOffset() 14841 << std::setw(10) << it.source_position().ScriptOffset()
14793 << (it.is_statement() ? " statement" : "") << "\n"; 14842 << (it.is_statement() ? " statement" : "") << "\n";
14794 } 14843 }
14795 os << "\n"; 14844 os << "\n";
14796 } 14845 }
14797 14846
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
14879 } 14928 }
14880 } 14929 }
14881 #endif // ENABLE_DISASSEMBLER 14930 #endif // ENABLE_DISASSEMBLER
14882 14931
14883 14932
14884 void BytecodeArray::Disassemble(std::ostream& os) { 14933 void BytecodeArray::Disassemble(std::ostream& os) {
14885 os << "Parameter count " << parameter_count() << "\n"; 14934 os << "Parameter count " << parameter_count() << "\n";
14886 os << "Frame size " << frame_size() << "\n"; 14935 os << "Frame size " << frame_size() << "\n";
14887 14936
14888 const uint8_t* base_address = GetFirstBytecodeAddress(); 14937 const uint8_t* base_address = GetFirstBytecodeAddress();
14889 SourcePositionTableIterator source_positions(source_position_table()); 14938 SourcePositionTableIterator source_positions(SourcePositionTable());
14890 14939
14891 interpreter::BytecodeArrayIterator iterator(handle(this)); 14940 interpreter::BytecodeArrayIterator iterator(handle(this));
14892 while (!iterator.done()) { 14941 while (!iterator.done()) {
14893 if (!source_positions.done() && 14942 if (!source_positions.done() &&
14894 iterator.current_offset() == source_positions.code_offset()) { 14943 iterator.current_offset() == source_positions.code_offset()) {
14895 os << std::setw(5) << source_positions.source_position().ScriptOffset(); 14944 os << std::setw(5) << source_positions.source_position().ScriptOffset();
14896 os << (source_positions.is_statement() ? " S> " : " E> "); 14945 os << (source_positions.is_statement() ? " S> " : " E> ");
14897 source_positions.Advance(); 14946 source_positions.Advance();
14898 } else { 14947 } else {
14899 os << " "; 14948 os << " ";
(...skipping 5559 matching lines...) Expand 10 before | Expand all | Expand 10 after
20459 // depend on this. 20508 // depend on this.
20460 return DICTIONARY_ELEMENTS; 20509 return DICTIONARY_ELEMENTS;
20461 } 20510 }
20462 DCHECK_LE(kind, LAST_ELEMENTS_KIND); 20511 DCHECK_LE(kind, LAST_ELEMENTS_KIND);
20463 return kind; 20512 return kind;
20464 } 20513 }
20465 } 20514 }
20466 20515
20467 } // namespace internal 20516 } // namespace internal
20468 } // namespace v8 20517 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698