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

Side by Side Diff: src/objects.cc

Issue 2095893002: Use source position table for unoptimized code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix gc mole Created 4 years, 5 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-body-descriptors-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 <sstream> 9 #include <sstream>
10 10
(...skipping 20 matching lines...) Expand all
31 #include "src/execution.h" 31 #include "src/execution.h"
32 #include "src/field-index-inl.h" 32 #include "src/field-index-inl.h"
33 #include "src/field-index.h" 33 #include "src/field-index.h"
34 #include "src/field-type.h" 34 #include "src/field-type.h"
35 #include "src/frames-inl.h" 35 #include "src/frames-inl.h"
36 #include "src/full-codegen/full-codegen.h" 36 #include "src/full-codegen/full-codegen.h"
37 #include "src/ic/ic.h" 37 #include "src/ic/ic.h"
38 #include "src/identity-map.h" 38 #include "src/identity-map.h"
39 #include "src/interpreter/bytecode-array-iterator.h" 39 #include "src/interpreter/bytecode-array-iterator.h"
40 #include "src/interpreter/interpreter.h" 40 #include "src/interpreter/interpreter.h"
41 #include "src/interpreter/source-position-table.h"
42 #include "src/isolate-inl.h" 41 #include "src/isolate-inl.h"
43 #include "src/keys.h" 42 #include "src/keys.h"
44 #include "src/list.h" 43 #include "src/list.h"
45 #include "src/log.h" 44 #include "src/log.h"
46 #include "src/lookup.h" 45 #include "src/lookup.h"
47 #include "src/macro-assembler.h" 46 #include "src/macro-assembler.h"
48 #include "src/messages.h" 47 #include "src/messages.h"
49 #include "src/objects-body-descriptors-inl.h" 48 #include "src/objects-body-descriptors-inl.h"
50 #include "src/property-descriptor.h" 49 #include "src/property-descriptor.h"
51 #include "src/prototype.h" 50 #include "src/prototype.h"
52 #include "src/regexp/jsregexp.h" 51 #include "src/regexp/jsregexp.h"
53 #include "src/safepoint-table.h" 52 #include "src/safepoint-table.h"
53 #include "src/source-position-table.h"
54 #include "src/string-builder.h" 54 #include "src/string-builder.h"
55 #include "src/string-search.h" 55 #include "src/string-search.h"
56 #include "src/string-stream.h" 56 #include "src/string-stream.h"
57 #include "src/utils.h" 57 #include "src/utils.h"
58 #include "src/zone.h" 58 #include "src/zone.h"
59 59
60 #ifdef ENABLE_DISASSEMBLER 60 #ifdef ENABLE_DISASSEMBLER
61 #include "src/disasm.h" 61 #include "src/disasm.h"
62 #include "src/disassembler.h" 62 #include "src/disassembler.h"
63 #endif 63 #endif
(...skipping 13421 matching lines...) Expand 10 before | Expand all | Expand 10 after
13485 } 13485 }
13486 } 13486 }
13487 Assembler::FlushICache(GetIsolate(), instruction_start(), instruction_size()); 13487 Assembler::FlushICache(GetIsolate(), instruction_start(), instruction_size());
13488 } 13488 }
13489 13489
13490 // Locate the source position which is closest to the code offset. This is 13490 // Locate the source position which is closest to the code offset. This is
13491 // using the source position information embedded in the relocation info. 13491 // using the source position information embedded in the relocation info.
13492 // The position returned is relative to the beginning of the script where the 13492 // The position returned is relative to the beginning of the script where the
13493 // source for this function is found. 13493 // source for this function is found.
13494 int Code::SourcePosition(int code_offset) { 13494 int Code::SourcePosition(int code_offset) {
13495 int position = RelocInfo::kNoPosition; // Initially no position found.
13495 // Subtract one because the current PC is one instruction after the call site. 13496 // Subtract one because the current PC is one instruction after the call site.
13496 Address pc = instruction_start() + code_offset - 1; 13497 code_offset--;
13497 int position = RelocInfo::kNoPosition; // Initially no position found.
13498 // Find the closest position attached to a pc lower or equal to the current. 13498 // Find the closest position attached to a pc lower or equal to the current.
13499 // Note that the pc of reloc infos grow monotonically. 13499 // Note that the pc of reloc infos grow monotonically.
13500 for (RelocIterator it(this, RelocInfo::kPositionMask); 13500 if (kind() == FUNCTION) {
13501 !it.done() && it.rinfo()->pc() <= pc; it.next()) { 13501 for (SourcePositionTableIterator it(source_position_table());
13502 position = static_cast<int>(it.rinfo()->data()); 13502 !it.done() && it.code_offset() <= code_offset; it.Advance()) {
13503 position = it.source_position();
13504 }
13505 } else {
13506 Address pc = instruction_start() + code_offset;
13507 for (RelocIterator it(this, RelocInfo::kPositionMask);
13508 !it.done() && it.rinfo()->pc() <= pc; it.next()) {
13509 position = static_cast<int>(it.rinfo()->data());
13510 }
13503 } 13511 }
13504 DCHECK(kind() == FUNCTION || (is_optimized_code() && is_turbofanned()) || 13512 DCHECK(kind() == FUNCTION || (is_optimized_code() && is_turbofanned()) ||
13505 is_wasm_code() || position == RelocInfo::kNoPosition); 13513 is_wasm_code() || position == RelocInfo::kNoPosition);
13506 return position; 13514 return position;
13507 } 13515 }
13508 13516
13509 13517
13510 // Same as Code::SourcePosition above except it only looks for statement 13518 // Same as Code::SourcePosition above except it only looks for statement
13511 // positions. 13519 // positions.
13512 int Code::SourceStatementPosition(int code_offset) { 13520 int Code::SourceStatementPosition(int code_offset) {
13513 // First find the closest position. 13521 // First find the closest position.
13514 int position = SourcePosition(code_offset); 13522 int position = SourcePosition(code_offset);
13515 // Now find the closest statement position before the position. 13523 // Now find the closest statement position before the position.
13516 int statement_position = 0; 13524 int statement_position = 0;
13517 for (RelocIterator it(this, RelocInfo::kPositionMask); !it.done(); 13525 if (kind() == FUNCTION) {
13518 it.next()) { 13526 for (SourcePositionTableIterator it(source_position_table()); !it.done();
13519 if (RelocInfo::IsStatementPosition(it.rinfo()->rmode())) { 13527 it.Advance()) {
13520 int p = static_cast<int>(it.rinfo()->data()); 13528 if (it.is_statement()) {
13521 if (statement_position < p && p <= position) { 13529 int p = it.source_position();
13522 statement_position = p; 13530 if (statement_position < p && p <= position) {
13531 statement_position = p;
13532 }
13533 }
13534 }
13535 } else {
13536 for (RelocIterator it(this, RelocInfo::kPositionMask); !it.done();
13537 it.next()) {
13538 if (RelocInfo::IsStatementPosition(it.rinfo()->rmode())) {
13539 int p = static_cast<int>(it.rinfo()->data());
13540 if (statement_position < p && p <= position) {
13541 statement_position = p;
13542 }
13523 } 13543 }
13524 } 13544 }
13525 } 13545 }
13526 return statement_position; 13546 return statement_position;
13527 } 13547 }
13528 13548
13529 13549
13530 SafepointEntry Code::GetSafepointEntry(Address pc) { 13550 SafepointEntry Code::GetSafepointEntry(Address pc) {
13531 SafepointTable table(this); 13551 SafepointTable table(this);
13532 return table.FindEntry(pc); 13552 return table.FindEntry(pc);
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
14313 os << "RelocInfo (size = " << relocation_size() << ")\n"; 14333 os << "RelocInfo (size = " << relocation_size() << ")\n";
14314 for (RelocIterator it(this); !it.done(); it.next()) { 14334 for (RelocIterator it(this); !it.done(); it.next()) {
14315 it.rinfo()->Print(GetIsolate(), os); 14335 it.rinfo()->Print(GetIsolate(), os);
14316 } 14336 }
14317 os << "\n"; 14337 os << "\n";
14318 } 14338 }
14319 #endif // ENABLE_DISASSEMBLER 14339 #endif // ENABLE_DISASSEMBLER
14320 14340
14321 int BytecodeArray::SourcePosition(int offset) { 14341 int BytecodeArray::SourcePosition(int offset) {
14322 int last_position = 0; 14342 int last_position = 0;
14323 for (interpreter::SourcePositionTableIterator iterator( 14343 for (SourcePositionTableIterator iterator(source_position_table());
14324 source_position_table()); 14344 !iterator.done() && iterator.code_offset() <= offset;
14325 !iterator.done() && iterator.bytecode_offset() <= offset;
14326 iterator.Advance()) { 14345 iterator.Advance()) {
14327 last_position = iterator.source_position(); 14346 last_position = iterator.source_position();
14328 } 14347 }
14329 return last_position; 14348 return last_position;
14330 } 14349 }
14331 14350
14332 int BytecodeArray::SourceStatementPosition(int offset) { 14351 int BytecodeArray::SourceStatementPosition(int offset) {
14333 // First find the closest position. 14352 // First find the closest position.
14334 int position = SourcePosition(offset); 14353 int position = SourcePosition(offset);
14335 // Now find the closest statement position before the position. 14354 // Now find the closest statement position before the position.
14336 int statement_position = 0; 14355 int statement_position = 0;
14337 for (interpreter::SourcePositionTableIterator it(source_position_table()); 14356 for (SourcePositionTableIterator it(source_position_table()); !it.done();
14338 !it.done(); it.Advance()) { 14357 it.Advance()) {
14339 if (it.is_statement()) { 14358 if (it.is_statement()) {
14340 int p = it.source_position(); 14359 int p = it.source_position();
14341 if (statement_position < p && p <= position) { 14360 if (statement_position < p && p <= position) {
14342 statement_position = p; 14361 statement_position = p;
14343 } 14362 }
14344 } 14363 }
14345 } 14364 }
14346 return statement_position; 14365 return statement_position;
14347 } 14366 }
14348 14367
14349 void BytecodeArray::Disassemble(std::ostream& os) { 14368 void BytecodeArray::Disassemble(std::ostream& os) {
14350 os << "Parameter count " << parameter_count() << "\n"; 14369 os << "Parameter count " << parameter_count() << "\n";
14351 os << "Frame size " << frame_size() << "\n"; 14370 os << "Frame size " << frame_size() << "\n";
14352 14371
14353 const uint8_t* base_address = GetFirstBytecodeAddress(); 14372 const uint8_t* base_address = GetFirstBytecodeAddress();
14354 interpreter::SourcePositionTableIterator source_positions( 14373 SourcePositionTableIterator source_positions(source_position_table());
14355 source_position_table());
14356 14374
14357 interpreter::BytecodeArrayIterator iterator(handle(this)); 14375 interpreter::BytecodeArrayIterator iterator(handle(this));
14358 while (!iterator.done()) { 14376 while (!iterator.done()) {
14359 if (!source_positions.done() && 14377 if (!source_positions.done() &&
14360 iterator.current_offset() == source_positions.bytecode_offset()) { 14378 iterator.current_offset() == source_positions.code_offset()) {
14361 os << std::setw(5) << source_positions.source_position(); 14379 os << std::setw(5) << source_positions.source_position();
14362 os << (source_positions.is_statement() ? " S> " : " E> "); 14380 os << (source_positions.is_statement() ? " S> " : " E> ");
14363 source_positions.Advance(); 14381 source_positions.Advance();
14364 } else { 14382 } else {
14365 os << " "; 14383 os << " ";
14366 } 14384 }
14367 const uint8_t* current_address = base_address + iterator.current_offset(); 14385 const uint8_t* current_address = base_address + iterator.current_offset();
14368 os << reinterpret_cast<const void*>(current_address) << " @ " 14386 os << reinterpret_cast<const void*>(current_address) << " @ "
14369 << std::setw(4) << iterator.current_offset() << " : "; 14387 << std::setw(4) << iterator.current_offset() << " : ";
14370 interpreter::Bytecodes::Decode(os, current_address, parameter_count()); 14388 interpreter::Bytecodes::Decode(os, current_address, parameter_count());
(...skipping 4490 matching lines...) Expand 10 before | Expand all | Expand 10 after
18861 } else { 18879 } else {
18862 // Old-style generators. 18880 // Old-style generators.
18863 int offset = continuation(); 18881 int offset = continuation();
18864 CHECK(0 <= offset && offset < function()->code()->instruction_size()); 18882 CHECK(0 <= offset && offset < function()->code()->instruction_size());
18865 return function()->code()->SourcePosition(offset); 18883 return function()->code()->SourcePosition(offset);
18866 } 18884 }
18867 } 18885 }
18868 18886
18869 } // namespace internal 18887 } // namespace internal
18870 } // namespace v8 18888 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-body-descriptors-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698