| 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 18 matching lines...) Expand all Loading... |
| 29 source_position(source), | 29 source_position(source), |
| 30 is_statement(statement) {} | 30 is_statement(statement) {} |
| 31 | 31 |
| 32 int bytecode_offset; | 32 int bytecode_offset; |
| 33 int source_position; | 33 int source_position; |
| 34 bool is_statement; | 34 bool is_statement; |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 class SourcePositionTableBuilder : public PositionsRecorder { | 37 class SourcePositionTableBuilder : public PositionsRecorder { |
| 38 public: | 38 public: |
| 39 enum OnDuplicateCodeOffset { | 39 SourcePositionTableBuilder(Isolate* isolate, Zone* zone) |
| 40 DISCARD_DUPLICATE, | |
| 41 OVERWRITE_DUPLICATE, | |
| 42 }; | |
| 43 | |
| 44 explicit SourcePositionTableBuilder(Isolate* isolate, Zone* zone) | |
| 45 : isolate_(isolate), | 40 : isolate_(isolate), |
| 46 bytes_(zone), | 41 bytes_(zone), |
| 47 #ifdef ENABLE_SLOW_DCHECKS | 42 #ifdef ENABLE_SLOW_DCHECKS |
| 48 raw_entries_(zone), | 43 raw_entries_(zone), |
| 49 #endif | 44 #endif |
| 50 candidate_(kUninitializedCandidateOffset, 0, false) { | 45 candidate_(kUninitializedCandidateOffset, 0, false) { |
| 51 } | 46 } |
| 52 | 47 |
| 53 void AddStatementPosition( | 48 void AddStatementPosition(size_t bytecode_offset, int source_position); |
| 54 size_t bytecode_offset, int source_position, | |
| 55 OnDuplicateCodeOffset on_duplicate = DISCARD_DUPLICATE); | |
| 56 void AddExpressionPosition(size_t bytecode_offset, int source_position); | 49 void AddExpressionPosition(size_t bytecode_offset, int source_position); |
| 57 Handle<ByteArray> ToSourcePositionTable(); | 50 Handle<ByteArray> ToSourcePositionTable(); |
| 58 | 51 |
| 59 private: | 52 private: |
| 60 static const int kUninitializedCandidateOffset = -1; | 53 static const int kUninitializedCandidateOffset = -1; |
| 61 | 54 |
| 62 void AddEntry(const PositionTableEntry& entry, | 55 void AddEntry(const PositionTableEntry& entry); |
| 63 OnDuplicateCodeOffset on_duplicate = DISCARD_DUPLICATE); | |
| 64 void CommitEntry(); | 56 void CommitEntry(); |
| 65 | 57 |
| 66 Isolate* isolate_; | 58 Isolate* isolate_; |
| 67 ZoneVector<byte> bytes_; | 59 ZoneVector<byte> bytes_; |
| 68 #ifdef ENABLE_SLOW_DCHECKS | 60 #ifdef ENABLE_SLOW_DCHECKS |
| 69 ZoneVector<PositionTableEntry> raw_entries_; | 61 ZoneVector<PositionTableEntry> raw_entries_; |
| 70 #endif | 62 #endif |
| 71 PositionTableEntry candidate_; // Next entry to be written, if initialized. | 63 PositionTableEntry candidate_; // Next entry to be written, if initialized. |
| 72 PositionTableEntry previous_; // Previously written entry, to compute delta. | 64 PositionTableEntry previous_; // Previously written entry, to compute delta. |
| 73 }; | 65 }; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 99 int index_; | 91 int index_; |
| 100 PositionTableEntry current_; | 92 PositionTableEntry current_; |
| 101 DisallowHeapAllocation no_gc; | 93 DisallowHeapAllocation no_gc; |
| 102 }; | 94 }; |
| 103 | 95 |
| 104 } // namespace interpreter | 96 } // namespace interpreter |
| 105 } // namespace internal | 97 } // namespace internal |
| 106 } // namespace v8 | 98 } // namespace v8 |
| 107 | 99 |
| 108 #endif // V8_INTERPRETER_SOURCE_POSITION_TABLE_H_ | 100 #endif // V8_INTERPRETER_SOURCE_POSITION_TABLE_H_ |
| OLD | NEW |