OLD | NEW |
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 #ifndef V8_INTERPRETER_SOURCE_POSITION_TABLE_H_ | 5 #ifndef V8_INTERPRETER_SOURCE_POSITION_TABLE_H_ |
6 #define V8_INTERPRETER_SOURCE_POSITION_TABLE_H_ | 6 #define V8_INTERPRETER_SOURCE_POSITION_TABLE_H_ |
7 | 7 |
8 #include "src/assert-scope.h" | 8 #include "src/assert-scope.h" |
9 #include "src/checks.h" | 9 #include "src/checks.h" |
10 #include "src/handles.h" | 10 #include "src/handles.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 }; | 35 }; |
36 | 36 |
37 class SourcePositionTableBuilder : public PositionsRecorder { | 37 class SourcePositionTableBuilder : public PositionsRecorder { |
38 public: | 38 public: |
39 SourcePositionTableBuilder(Isolate* isolate, Zone* zone) | 39 SourcePositionTableBuilder(Isolate* isolate, Zone* zone) |
40 : isolate_(isolate), | 40 : isolate_(isolate), |
41 bytes_(zone), | 41 bytes_(zone), |
42 #ifdef ENABLE_SLOW_DCHECKS | 42 #ifdef ENABLE_SLOW_DCHECKS |
43 raw_entries_(zone), | 43 raw_entries_(zone), |
44 #endif | 44 #endif |
45 candidate_(kUninitializedCandidateOffset, 0, false) { | 45 previous_() { |
46 } | 46 } |
47 | 47 |
48 void AddStatementPosition(size_t bytecode_offset, int source_position); | 48 void AddStatementPosition(size_t bytecode_offset, int source_position); |
49 void AddExpressionPosition(size_t bytecode_offset, int source_position); | 49 void AddExpressionPosition(size_t bytecode_offset, int source_position); |
| 50 void AddPosition(size_t bytecode_offset, int source_position, |
| 51 bool is_statement); |
50 Handle<ByteArray> ToSourcePositionTable(); | 52 Handle<ByteArray> ToSourcePositionTable(); |
51 | 53 |
52 private: | 54 private: |
53 static const int kUninitializedCandidateOffset = -1; | |
54 | |
55 void AddEntry(const PositionTableEntry& entry); | 55 void AddEntry(const PositionTableEntry& entry); |
56 void CommitEntry(); | 56 void CommitEntry(); |
57 | 57 |
58 Isolate* isolate_; | 58 Isolate* isolate_; |
59 ZoneVector<byte> bytes_; | 59 ZoneVector<byte> bytes_; |
60 #ifdef ENABLE_SLOW_DCHECKS | 60 #ifdef ENABLE_SLOW_DCHECKS |
61 ZoneVector<PositionTableEntry> raw_entries_; | 61 ZoneVector<PositionTableEntry> raw_entries_; |
62 #endif | 62 #endif |
63 PositionTableEntry candidate_; // Next entry to be written, if initialized. | |
64 PositionTableEntry previous_; // Previously written entry, to compute delta. | 63 PositionTableEntry previous_; // Previously written entry, to compute delta. |
65 }; | 64 }; |
66 | 65 |
67 class SourcePositionTableIterator { | 66 class SourcePositionTableIterator { |
68 public: | 67 public: |
69 explicit SourcePositionTableIterator(ByteArray* byte_array); | 68 explicit SourcePositionTableIterator(ByteArray* byte_array); |
70 | 69 |
71 void Advance(); | 70 void Advance(); |
72 | 71 |
73 int bytecode_offset() const { | 72 int bytecode_offset() const { |
(...skipping 17 matching lines...) Expand all Loading... |
91 int index_; | 90 int index_; |
92 PositionTableEntry current_; | 91 PositionTableEntry current_; |
93 DisallowHeapAllocation no_gc; | 92 DisallowHeapAllocation no_gc; |
94 }; | 93 }; |
95 | 94 |
96 } // namespace interpreter | 95 } // namespace interpreter |
97 } // namespace internal | 96 } // namespace internal |
98 } // namespace v8 | 97 } // namespace v8 |
99 | 98 |
100 #endif // V8_INTERPRETER_SOURCE_POSITION_TABLE_H_ | 99 #endif // V8_INTERPRETER_SOURCE_POSITION_TABLE_H_ |
OLD | NEW |