| 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( | |
| 134 jit_handler_data_, offset, source_position)); | |
| 135 } | 128 } |
| 136 | 129 |
| 137 void SourcePositionTableBuilder::AddEntry( | 130 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 | 131 // Don't encode a new entry if this bytecode already has a source position |
| 141 // assigned. | 132 // assigned. |
| 142 if (candidate_.bytecode_offset == entry.bytecode_offset) { | 133 if (candidate_.bytecode_offset == entry.bytecode_offset) { |
| 143 if ((!candidate_.is_statement && entry.is_statement) || | 134 if (entry.is_statement) candidate_ = entry; |
| 144 on_duplicate == OVERWRITE_DUPLICATE) { | |
| 145 candidate_ = entry; | |
| 146 } | |
| 147 return; | 135 return; |
| 148 } | 136 } |
| 149 | 137 |
| 150 CommitEntry(); | 138 CommitEntry(); |
| 151 candidate_ = entry; | 139 candidate_ = entry; |
| 152 } | 140 } |
| 153 | 141 |
| 154 void SourcePositionTableBuilder::CommitEntry() { | 142 void SourcePositionTableBuilder::CommitEntry() { |
| 155 if (candidate_.bytecode_offset == kUninitializedCandidateOffset) return; | 143 if (candidate_.bytecode_offset == kUninitializedCandidateOffset) return; |
| 156 PositionTableEntry tmp(candidate_); | 144 PositionTableEntry tmp(candidate_); |
| 157 SubtractFromEntry(tmp, previous_); | 145 SubtractFromEntry(tmp, previous_); |
| 158 EncodeEntry(bytes_, tmp); | 146 EncodeEntry(bytes_, tmp); |
| 159 previous_ = candidate_; | 147 previous_ = candidate_; |
| 160 | 148 |
| 149 if (candidate_.is_statement) { |
| 150 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddStatementPositionEvent( |
| 151 jit_handler_data_, candidate_.bytecode_offset, |
| 152 candidate_.source_position)); |
| 153 } |
| 154 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddPositionEvent( |
| 155 jit_handler_data_, candidate_.bytecode_offset, |
| 156 candidate_.source_position)); |
| 157 |
| 161 #ifdef ENABLE_SLOW_DCHECKS | 158 #ifdef ENABLE_SLOW_DCHECKS |
| 162 raw_entries_.push_back(candidate_); | 159 raw_entries_.push_back(candidate_); |
| 163 #endif | 160 #endif |
| 164 } | 161 } |
| 165 | 162 |
| 166 Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable() { | 163 Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable() { |
| 167 CommitEntry(); | 164 CommitEntry(); |
| 168 if (bytes_.empty()) return isolate_->factory()->empty_byte_array(); | 165 if (bytes_.empty()) return isolate_->factory()->empty_byte_array(); |
| 169 | 166 |
| 170 Handle<ByteArray> table = isolate_->factory()->NewByteArray( | 167 Handle<ByteArray> table = isolate_->factory()->NewByteArray( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } else { | 199 } else { |
| 203 PositionTableEntry tmp; | 200 PositionTableEntry tmp; |
| 204 DecodeEntry(table_, &index_, &tmp); | 201 DecodeEntry(table_, &index_, &tmp); |
| 205 AddAndSetEntry(current_, tmp); | 202 AddAndSetEntry(current_, tmp); |
| 206 } | 203 } |
| 207 } | 204 } |
| 208 | 205 |
| 209 } // namespace interpreter | 206 } // namespace interpreter |
| 210 } // namespace internal | 207 } // namespace internal |
| 211 } // namespace v8 | 208 } // namespace v8 |
| OLD | NEW |