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

Side by Side Diff: src/interpreter/source-position-table.cc

Issue 1662983002: [interpreter] add source positions for call and call-new. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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
(Empty)
1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/interpreter/source-position-table.h"
6
7 #include "src/assembler.h"
8 #include "src/objects-inl.h"
9 #include "src/objects.h"
10
11 namespace v8 {
12 namespace internal {
13 namespace interpreter {
14
15 Handle<FixedArray> SourcePositionTableBuilder::ToFixedArray() {
16 int length = entries_.size();
17 Handle<FixedArray> table =
18 isolate_->factory()->NewFixedArray(length * 2, TENURED);
19 for (int i = 0; i < length; i++) {
20 table->set(i * 2, Smi::FromInt(entries_[i].bytecode_offset));
21 table->set(i * 2 + 1, Smi::FromInt(entries_[i].source_position_and_type));
22 }
23 return table;
24 }
25
26 SourcePositionTableIterator::SourcePositionTableIterator(
27 BytecodeArray* bytecode_array)
28 : table_(bytecode_array->source_position_table()),
29 index_(0),
30 is_statement_(false),
31 bytecode_offset_(RelocInfo::kNoPosition),
32 source_position_(RelocInfo::kNoPosition) {
33 DCHECK(table_->length() % 2 == 0);
34 }
35
36 bool SourcePositionTableIterator::Next() {
37 if (index_ < table_->length()) {
38 int new_bytecode_offset = Smi::cast(table_->get(index_))->value();
39 // Bytecode offsets are in ascending order.
40 DCHECK_LT(bytecode_offset_, new_bytecode_offset);
41 bytecode_offset_ = new_bytecode_offset;
42 uint32_t source_position_and_type =
43 static_cast<uint32_t>(Smi::cast(table_->get(index_ + 1))->value());
44 is_statement_ = IsStatementField::decode(source_position_and_type);
45 source_position_ = SourcePositionField::decode(source_position_and_type);
46 index_ += 2;
47 return true;
48 }
49 is_statement_ = false;
50 bytecode_offset_ = RelocInfo::kNoPosition;
51 source_position_ = RelocInfo::kNoPosition;
52 return false;
53 }
54
55 int SourcePositionTableIterator::PositionFromBytecodeOffset(
56 BytecodeArray* bytecode_array, int bytecode_offset) {
57 SourcePositionTableIterator iterator(bytecode_array);
58 int last_position = 0;
59 while (iterator.Next() && iterator.bytecode_offset() <= bytecode_offset) {
60 last_position = iterator.source_position();
61 }
62 return last_position;
63 }
64
65 } // namespace interpreter
66 } // namespace internal
67 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698