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

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

Issue 1682853004: [interpreter, debugger] implement bytecode break location iterator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: small fix 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
1 // Copyright 2016 the V8 project authors. All rights reserved. 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 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/interpreter/source-position-table.h" 5 #include "src/interpreter/source-position-table.h"
6 6
7 #include "src/assembler.h" 7 #include "src/assembler.h"
8 #include "src/objects-inl.h" 8 #include "src/objects-inl.h"
9 #include "src/objects.h" 9 #include "src/objects.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 namespace interpreter { 13 namespace interpreter {
14 14
15 class IsStatementField : public BitField<bool, 0, 1> {}; 15 class IsStatementField : public BitField<bool, 0, 1> {};
16 class SourcePositionField : public BitField<int, 1, 30> {}; 16 class SourcePositionField : public BitField<int, 1, 30> {};
17 17
18 void SourcePositionTableBuilder::AddStatementPosition(size_t bytecode_offset, 18 void SourcePositionTableBuilder::AddStatementPosition(size_t bytecode_offset,
19 int source_position) { 19 int source_position) {
20 int offset = static_cast<int>(bytecode_offset); 20 int offset = static_cast<int>(bytecode_offset);
21 AssertMonotonic(offset); 21 if (AlreadyHasPosition(offset)) return;
22 uint32_t encoded = IsStatementField::encode(true) | 22 uint32_t encoded = IsStatementField::encode(true) |
23 SourcePositionField::encode(source_position); 23 SourcePositionField::encode(source_position);
24 entries_.push_back({offset, encoded}); 24 entries_.push_back({offset, encoded});
25 } 25 }
26 26
27 void SourcePositionTableBuilder::AddExpressionPosition(size_t bytecode_offset, 27 void SourcePositionTableBuilder::AddExpressionPosition(size_t bytecode_offset,
28 int source_position) { 28 int source_position) {
29 int offset = static_cast<int>(bytecode_offset); 29 int offset = static_cast<int>(bytecode_offset);
30 AssertMonotonic(offset); 30 if (AlreadyHasPosition(offset)) return;
31 uint32_t encoded = IsStatementField::encode(false) | 31 uint32_t encoded = IsStatementField::encode(false) |
32 SourcePositionField::encode(source_position); 32 SourcePositionField::encode(source_position);
33 entries_.push_back({offset, encoded}); 33 entries_.push_back({offset, encoded});
34 } 34 }
35 35
36 void SourcePositionTableBuilder::RevertPosition(size_t bytecode_offset) { 36 void SourcePositionTableBuilder::RevertPosition(size_t bytecode_offset) {
37 int offset = static_cast<int>(bytecode_offset); 37 int offset = static_cast<int>(bytecode_offset);
38 // If we already added a source position table entry, but the bytecode array 38 // If we already added a source position table entry, but the bytecode array
39 // builder ended up not outputting a bytecode for the corresponding bytecode 39 // builder ended up not outputting a bytecode for the corresponding bytecode
40 // offset, we have to remove that entry. 40 // offset, we have to remove that entry.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 static_cast<uint32_t>(Smi::cast(table_->get(index_ + 1))->value()); 73 static_cast<uint32_t>(Smi::cast(table_->get(index_ + 1))->value());
74 is_statement_ = IsStatementField::decode(source_position_and_type); 74 is_statement_ = IsStatementField::decode(source_position_and_type);
75 source_position_ = SourcePositionField::decode(source_position_and_type); 75 source_position_ = SourcePositionField::decode(source_position_and_type);
76 } 76 }
77 index_ += 2; 77 index_ += 2;
78 } 78 }
79 79
80 } // namespace interpreter 80 } // namespace interpreter
81 } // namespace internal 81 } // namespace internal
82 } // namespace v8 82 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698