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 explicit SourcePositionTableBuilder(Isolate* isolate, Zone* zone) | 39 explicit 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 previous_() { | 45 candidate_(kUninitializedCandidateOffset, 0, false) { |
46 } | 46 } |
47 | 47 |
48 void AddStatementPosition(size_t bytecode_offset, int source_position); | 48 enum OnDuplicateCodeOffset { |
vogelheim
2016/03/14 10:41:15
style nitpick: c++ style wants an enum declaration
Yang
2016/03/14 11:32:34
Done.
| |
49 DISCARD_DUPLICATE, | |
50 OVERWRITE_DUPLICATE, | |
51 }; | |
52 | |
53 void AddStatementPosition( | |
54 size_t bytecode_offset, int source_position, | |
55 OnDuplicateCodeOffset on_duplicate = DISCARD_DUPLICATE); | |
49 void AddExpressionPosition(size_t bytecode_offset, int source_position); | 56 void AddExpressionPosition(size_t bytecode_offset, int source_position); |
50 Handle<ByteArray> ToSourcePositionTable(); | 57 Handle<ByteArray> ToSourcePositionTable(); |
51 | 58 |
52 private: | 59 private: |
53 void AddEntry(const PositionTableEntry& entry); | 60 void AddEntry(const PositionTableEntry& entry, |
61 OnDuplicateCodeOffset on_duplicate = DISCARD_DUPLICATE); | |
62 void CommitEntry(); | |
63 | |
64 static const int kUninitializedCandidateOffset = -1; | |
vogelheim
2016/03/14 10:41:15
Also style nitpick: consts also go before methods.
Yang
2016/03/14 11:32:34
Done.
| |
54 | 65 |
55 Isolate* isolate_; | 66 Isolate* isolate_; |
56 ZoneVector<byte> bytes_; | 67 ZoneVector<byte> bytes_; |
57 #ifdef ENABLE_SLOW_DCHECKS | 68 #ifdef ENABLE_SLOW_DCHECKS |
58 ZoneVector<PositionTableEntry> raw_entries_; | 69 ZoneVector<PositionTableEntry> raw_entries_; |
59 #endif | 70 #endif |
71 PositionTableEntry candidate_; | |
vogelheim
2016/03/14 10:41:15
Maybe add mini-comments on what these do, e.g.:
.
Yang
2016/03/14 11:32:34
Done.
| |
60 PositionTableEntry previous_; | 72 PositionTableEntry previous_; |
61 }; | 73 }; |
62 | 74 |
63 class SourcePositionTableIterator { | 75 class SourcePositionTableIterator { |
64 public: | 76 public: |
65 explicit SourcePositionTableIterator(ByteArray* byte_array); | 77 explicit SourcePositionTableIterator(ByteArray* byte_array); |
66 | 78 |
67 void Advance(); | 79 void Advance(); |
68 | 80 |
69 int bytecode_offset() const { | 81 int bytecode_offset() const { |
(...skipping 17 matching lines...) Expand all Loading... | |
87 int index_; | 99 int index_; |
88 PositionTableEntry current_; | 100 PositionTableEntry current_; |
89 DisallowHeapAllocation no_gc; | 101 DisallowHeapAllocation no_gc; |
90 }; | 102 }; |
91 | 103 |
92 } // namespace interpreter | 104 } // namespace interpreter |
93 } // namespace internal | 105 } // namespace internal |
94 } // namespace v8 | 106 } // namespace v8 |
95 | 107 |
96 #endif // V8_INTERPRETER_SOURCE_POSITION_TABLE_H_ | 108 #endif // V8_INTERPRETER_SOURCE_POSITION_TABLE_H_ |
OLD | NEW |