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/interpreter/source-position-table.h" | 5 #include "src/interpreter/source-position-table.h" |
6 | 6 |
7 #include "src/objects-inl.h" | 7 #include "src/objects-inl.h" |
8 #include "src/objects.h" | 8 #include "src/objects.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 | 108 |
109 // Note that '>>' needs to be arithmetic shift in order to handle negative | 109 // Note that '>>' needs to be arithmetic shift in order to handle negative |
110 // numbers properly. | 110 // numbers properly. |
111 entry->bytecode_offset = (tmp >> 1); | 111 entry->bytecode_offset = (tmp >> 1); |
112 | 112 |
113 DecodeInt(bytes, index, &entry->source_position); | 113 DecodeInt(bytes, index, &entry->source_position); |
114 } | 114 } |
115 | 115 |
116 } // namespace | 116 } // namespace |
117 | 117 |
118 void SourcePositionTableBuilder::AddStatementPosition( | 118 void SourcePositionTableBuilder::AddStatementPosition(size_t bytecode_offset, |
119 size_t bytecode_offset, int source_position, | 119 int source_position) { |
120 SourcePositionTableBuilder::OnDuplicateCodeOffset on_duplicate) { | |
121 int offset = static_cast<int>(bytecode_offset); | 120 int offset = static_cast<int>(bytecode_offset); |
122 AddEntry({offset, source_position, true}, on_duplicate); | 121 AddEntry({offset, source_position, true}); |
123 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddStatementPositionEvent( | |
124 jit_handler_data_, offset, source_position)); | |
125 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddPositionEvent( | |
126 jit_handler_data_, offset, source_position)); | |
127 } | 122 } |
128 | 123 |
129 void SourcePositionTableBuilder::AddExpressionPosition(size_t bytecode_offset, | 124 void SourcePositionTableBuilder::AddExpressionPosition(size_t bytecode_offset, |
130 int source_position) { | 125 int source_position) { |
131 int offset = static_cast<int>(bytecode_offset); | 126 int offset = static_cast<int>(bytecode_offset); |
132 AddEntry({offset, source_position, false}); | 127 AddEntry({offset, source_position, false}); |
133 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddPositionEvent( | 128 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddPositionEvent( |
Michael Starzinger
2016/04/04 17:16:45
Isn't this event now covered by the events fired i
Yang
2016/04/05 08:50:03
Correct. I forgot to remove this one.
| |
134 jit_handler_data_, offset, source_position)); | 129 jit_handler_data_, offset, source_position)); |
135 } | 130 } |
136 | 131 |
137 void SourcePositionTableBuilder::AddEntry( | 132 void SourcePositionTableBuilder::AddEntry(const PositionTableEntry& entry) { |
138 const PositionTableEntry& entry, | |
139 SourcePositionTableBuilder::OnDuplicateCodeOffset on_duplicate) { | |
140 // Don't encode a new entry if this bytecode already has a source position | 133 // Don't encode a new entry if this bytecode already has a source position |
141 // assigned. | 134 // assigned. |
142 if (candidate_.bytecode_offset == entry.bytecode_offset) { | 135 if (candidate_.bytecode_offset == entry.bytecode_offset) { |
143 if ((!candidate_.is_statement && entry.is_statement) || | 136 if (entry.is_statement) candidate_ = entry; |
144 on_duplicate == OVERWRITE_DUPLICATE) { | |
145 candidate_ = entry; | |
146 } | |
147 return; | 137 return; |
148 } | 138 } |
149 | 139 |
150 CommitEntry(); | 140 CommitEntry(); |
151 candidate_ = entry; | 141 candidate_ = entry; |
152 } | 142 } |
153 | 143 |
154 void SourcePositionTableBuilder::CommitEntry() { | 144 void SourcePositionTableBuilder::CommitEntry() { |
155 if (candidate_.bytecode_offset == kUninitializedCandidateOffset) return; | 145 if (candidate_.bytecode_offset == kUninitializedCandidateOffset) return; |
156 PositionTableEntry tmp(candidate_); | 146 PositionTableEntry tmp(candidate_); |
157 SubtractFromEntry(tmp, previous_); | 147 SubtractFromEntry(tmp, previous_); |
158 EncodeEntry(bytes_, tmp); | 148 EncodeEntry(bytes_, tmp); |
159 previous_ = candidate_; | 149 previous_ = candidate_; |
160 | 150 |
151 if (candidate_.is_statement) { | |
152 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddStatementPositionEvent( | |
153 jit_handler_data_, candidate_.bytecode_offset, | |
154 candidate_.source_position)); | |
155 } | |
156 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddPositionEvent( | |
157 jit_handler_data_, candidate_.bytecode_offset, | |
158 candidate_.source_position)); | |
159 | |
161 #ifdef ENABLE_SLOW_DCHECKS | 160 #ifdef ENABLE_SLOW_DCHECKS |
162 raw_entries_.push_back(candidate_); | 161 raw_entries_.push_back(candidate_); |
163 #endif | 162 #endif |
164 } | 163 } |
165 | 164 |
166 Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable() { | 165 Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable() { |
167 CommitEntry(); | 166 CommitEntry(); |
168 if (bytes_.empty()) return isolate_->factory()->empty_byte_array(); | 167 if (bytes_.empty()) return isolate_->factory()->empty_byte_array(); |
169 | 168 |
170 Handle<ByteArray> table = isolate_->factory()->NewByteArray( | 169 Handle<ByteArray> table = isolate_->factory()->NewByteArray( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 } else { | 201 } else { |
203 PositionTableEntry tmp; | 202 PositionTableEntry tmp; |
204 DecodeEntry(table_, &index_, &tmp); | 203 DecodeEntry(table_, &index_, &tmp); |
205 AddAndSetEntry(current_, tmp); | 204 AddAndSetEntry(current_, tmp); |
206 } | 205 } |
207 } | 206 } |
208 | 207 |
209 } // namespace interpreter | 208 } // namespace interpreter |
210 } // namespace internal | 209 } // namespace internal |
211 } // namespace v8 | 210 } // namespace v8 |
OLD | NEW |