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

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

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
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | src/interpreter/source-position-table.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef V8_INTERPRETER_SOURCE_POSITION_TABLE_H_
6 #define V8_INTERPRETER_SOURCE_POSITION_TABLE_H_
7
8 #include "src/assert-scope.h"
9 #include "src/handles.h"
10 #include "src/zone.h"
11 #include "src/zone-containers.h"
12
13 namespace v8 {
14 namespace internal {
15
16 class BytecodeArray;
17 class FixedArray;
18 class Isolate;
19
20 namespace interpreter {
21
22 class SourcePositionTableBase {
vogelheim 2016/02/03 11:42:09 I find this an odd use of inheritance. Why not hav
rmcilroy 2016/02/03 12:05:23 +1
Yang 2016/02/03 14:16:20 Done.
23 protected:
24 class IsStatementField : public BitField<bool, 0, 1> {};
25 class SourcePositionField : public BitField<unsigned, 1, 30> {};
26
27 uint32_t EncodeSourcePositionAndType(int source_position, bool is_statement) {
28 return IsStatementField::encode(is_statement) |
29 SourcePositionField::encode(source_position);
30 }
31 };
32
33 class SourcePositionTableBuilder : public SourcePositionTableBase {
34 public:
35 explicit SourcePositionTableBuilder(Isolate* isolate, Zone* zone)
36 : isolate_(isolate), entries_(zone) {}
37
38 void AddStatementPosition(int bytecode_offset, int source_position) {
39 AssertMonotonic(bytecode_offset);
40 entries_.push_back({static_cast<uint32_t>(bytecode_offset),
41 EncodeSourcePositionAndType(source_position, true)});
rmcilroy 2016/02/03 12:05:23 I think these should really be in the cc file (I t
Yang 2016/02/03 14:16:20 Done.
42 }
43
44 void AddExpressionPosition(int bytecode_offset, int source_position) {
45 AssertMonotonic(bytecode_offset);
46 entries_.push_back({static_cast<uint32_t>(bytecode_offset),
47 EncodeSourcePositionAndType(source_position, false)});
48 }
49
50 Handle<FixedArray> ToFixedArray();
51
52 private:
53 struct Entry {
54 uint32_t bytecode_offset;
55 uint32_t source_position_and_type;
56 };
57
58 void AssertMonotonic(int bytecode_offset) {
59 DCHECK_IMPLIES(entries_.size() > 0,
rmcilroy 2016/02/03 12:05:23 DHECK_IMPLIES got ripped out of chromium's base li
Yang 2016/02/03 14:16:20 Done.
60 entries_.back().bytecode_offset < bytecode_offset);
61 }
62
63 Isolate* isolate_;
64 ZoneVector<Entry> entries_;
65
66 friend class SourcePositionTableReader;
67 };
68
69 class SourcePositionTableIterator : public SourcePositionTableBase {
70 public:
71 explicit SourcePositionTableIterator(BytecodeArray* bytecode_array);
72
73 static int PositionFromBytecodeOffset(BytecodeArray* bytecode_array,
74 int bytecode_offset);
75 bool Next();
rmcilroy 2016/02/03 12:05:24 nit - most other v8 iterators seem to use Advance(
Yang 2016/02/03 14:16:20 Done.
76 int bytecode_offset() const { return bytecode_offset_; }
77 int source_position() const { return source_position_; }
78 int is_statement() const { return is_statement_; }
vogelheim 2016/02/03 11:42:09 bool? is_statement_ is bool, so this is an implic
Yang 2016/02/03 14:16:20 Done. Nice catch. Thanks.
79
80 private:
81 FixedArray* table_;
82 int index_;
83 bool is_statement_;
84 int bytecode_offset_;
85 int source_position_;
86 DisallowHeapAllocation no_gc;
87 };
88
89 } // namespace interpreter
90 } // namespace internal
91 } // namespace v8
92
93 #endif // V8_INTERPRETER_SOURCE_POSITION_TABLE_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-generator.cc ('k') | src/interpreter/source-position-table.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698