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 #include "src/source-position-table.h" | 5 #include "src/source-position-table.h" |
6 | 6 |
| 7 #include "src/log.h" |
7 #include "src/objects-inl.h" | 8 #include "src/objects-inl.h" |
8 #include "src/objects.h" | 9 #include "src/objects.h" |
9 | 10 |
10 namespace v8 { | 11 namespace v8 { |
11 namespace internal { | 12 namespace internal { |
12 | 13 |
13 // We'll use a simple encoding scheme to record the source positions. | 14 // We'll use a simple encoding scheme to record the source positions. |
14 // Conceptually, each position consists of: | 15 // Conceptually, each position consists of: |
15 // - code_offset: An integer index into the BytecodeArray or code. | 16 // - code_offset: An integer index into the BytecodeArray or code. |
16 // - source_position: An integer index into the source string. | 17 // - source_position: An integer index into the source string. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 entry->code_offset = tmp; | 97 entry->code_offset = tmp; |
97 } else { | 98 } else { |
98 entry->is_statement = false; | 99 entry->is_statement = false; |
99 entry->code_offset = -(tmp + 1); | 100 entry->code_offset = -(tmp + 1); |
100 } | 101 } |
101 DecodeInt(bytes, index, &entry->source_position); | 102 DecodeInt(bytes, index, &entry->source_position); |
102 } | 103 } |
103 | 104 |
104 } // namespace | 105 } // namespace |
105 | 106 |
| 107 SourcePositionTableBuilder::SourcePositionTableBuilder(Isolate* isolate, |
| 108 Zone* zone) |
| 109 : isolate_(isolate), |
| 110 bytes_(zone), |
| 111 #ifdef ENABLE_SLOW_DCHECKS |
| 112 raw_entries_(zone), |
| 113 #endif |
| 114 previous_(), |
| 115 jit_handler_data_(nullptr) { |
| 116 LOG_CODE_EVENT(isolate_, CodeStartLinePosInfoRecordEvent(&jit_handler_data_)); |
| 117 } |
| 118 |
| 119 void SourcePositionTableBuilder::EndJitLogging(AbstractCode* code) { |
| 120 LOG_CODE_EVENT(isolate_, |
| 121 CodeEndLinePosInfoRecordEvent(code, jit_handler_data_)); |
| 122 } |
| 123 |
106 void SourcePositionTableBuilder::AddPosition(size_t code_offset, | 124 void SourcePositionTableBuilder::AddPosition(size_t code_offset, |
107 int source_position, | 125 int source_position, |
108 bool is_statement) { | 126 bool is_statement) { |
109 int offset = static_cast<int>(code_offset); | 127 int offset = static_cast<int>(code_offset); |
110 AddEntry({offset, source_position, is_statement}); | 128 AddEntry({offset, source_position, is_statement}); |
111 } | 129 } |
112 | 130 |
113 void SourcePositionTableBuilder::AddEntry(const PositionTableEntry& entry) { | 131 void SourcePositionTableBuilder::AddEntry(const PositionTableEntry& entry) { |
114 PositionTableEntry tmp(entry); | 132 PositionTableEntry tmp(entry); |
115 SubtractFromEntry(tmp, previous_); | 133 SubtractFromEntry(tmp, previous_); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 index_ = kDone; | 185 index_ = kDone; |
168 } else { | 186 } else { |
169 PositionTableEntry tmp; | 187 PositionTableEntry tmp; |
170 DecodeEntry(table_, &index_, &tmp); | 188 DecodeEntry(table_, &index_, &tmp); |
171 AddAndSetEntry(current_, tmp); | 189 AddAndSetEntry(current_, tmp); |
172 } | 190 } |
173 } | 191 } |
174 | 192 |
175 } // namespace internal | 193 } // namespace internal |
176 } // namespace v8 | 194 } // namespace v8 |
OLD | NEW |