Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: src/interpreter/source-position-table.cc

Issue 1801473003: [ignition, debugger] correctly set position for return with elided bytecode. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: do not use --ignition flag Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/source-position-table.h ('k') | test/mjsunit/ignition/elided-instruction.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(size_t bytecode_offset, 118 void SourcePositionTableBuilder::AddStatementPosition(
119 int source_position) { 119 size_t bytecode_offset, int source_position,
120 SourcePositionTableBuilder::OnDuplicateCodeOffset on_duplicate) {
120 int offset = static_cast<int>(bytecode_offset); 121 int offset = static_cast<int>(bytecode_offset);
121 AddEntry({offset, source_position, true}); 122 AddEntry({offset, source_position, true}, on_duplicate);
122 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddStatementPositionEvent( 123 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddStatementPositionEvent(
123 jit_handler_data_, offset, source_position)); 124 jit_handler_data_, offset, source_position));
124 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddPositionEvent( 125 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddPositionEvent(
125 jit_handler_data_, offset, source_position)); 126 jit_handler_data_, offset, source_position));
126 } 127 }
127 128
128 void SourcePositionTableBuilder::AddExpressionPosition(size_t bytecode_offset, 129 void SourcePositionTableBuilder::AddExpressionPosition(size_t bytecode_offset,
129 int source_position) { 130 int source_position) {
130 int offset = static_cast<int>(bytecode_offset); 131 int offset = static_cast<int>(bytecode_offset);
131 AddEntry({offset, source_position, false}); 132 AddEntry({offset, source_position, false});
132 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddPositionEvent( 133 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddPositionEvent(
133 jit_handler_data_, offset, source_position)); 134 jit_handler_data_, offset, source_position));
134 } 135 }
135 136
136 void SourcePositionTableBuilder::AddEntry(const PositionTableEntry& entry) { 137 void SourcePositionTableBuilder::AddEntry(
138 const PositionTableEntry& entry,
139 SourcePositionTableBuilder::OnDuplicateCodeOffset on_duplicate) {
137 // Don't encode a new entry if this bytecode already has a source position 140 // Don't encode a new entry if this bytecode already has a source position
138 // assigned. 141 // assigned.
139 if (bytes_.size() > 0 && previous_.bytecode_offset == entry.bytecode_offset) { 142 if (candidate_.bytecode_offset == entry.bytecode_offset) {
143 if (on_duplicate == OVERWRITE_DUPLICATE) candidate_ = entry;
140 return; 144 return;
141 } 145 }
142 146
143 PositionTableEntry tmp(entry); 147 CommitEntry();
148 candidate_ = entry;
149 }
150
151 void SourcePositionTableBuilder::CommitEntry() {
152 if (candidate_.bytecode_offset == kUninitializedCandidateOffset) return;
153 PositionTableEntry tmp(candidate_);
144 SubtractFromEntry(tmp, previous_); 154 SubtractFromEntry(tmp, previous_);
145 EncodeEntry(bytes_, tmp); 155 EncodeEntry(bytes_, tmp);
146 previous_ = entry; 156 previous_ = candidate_;
147 157
148 #ifdef ENABLE_SLOW_DCHECKS 158 #ifdef ENABLE_SLOW_DCHECKS
149 raw_entries_.push_back(entry); 159 raw_entries_.push_back(candidate_);
150 #endif 160 #endif
151 } 161 }
152 162
153 Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable() { 163 Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable() {
164 CommitEntry();
154 if (bytes_.empty()) return isolate_->factory()->empty_byte_array(); 165 if (bytes_.empty()) return isolate_->factory()->empty_byte_array();
155 166
156 Handle<ByteArray> table = isolate_->factory()->NewByteArray( 167 Handle<ByteArray> table = isolate_->factory()->NewByteArray(
157 static_cast<int>(bytes_.size()), TENURED); 168 static_cast<int>(bytes_.size()), TENURED);
158 169
159 MemCopy(table->GetDataStartAddress(), &*bytes_.begin(), bytes_.size()); 170 MemCopy(table->GetDataStartAddress(), &*bytes_.begin(), bytes_.size());
160 171
161 #ifdef ENABLE_SLOW_DCHECKS 172 #ifdef ENABLE_SLOW_DCHECKS
162 // Brute force testing: Record all positions and decode 173 // Brute force testing: Record all positions and decode
163 // the entire table to verify they are identical. 174 // the entire table to verify they are identical.
(...skipping 24 matching lines...) Expand all
188 } else { 199 } else {
189 PositionTableEntry tmp; 200 PositionTableEntry tmp;
190 DecodeEntry(table_, &index_, &tmp); 201 DecodeEntry(table_, &index_, &tmp);
191 AddAndSetEntry(current_, tmp); 202 AddAndSetEntry(current_, tmp);
192 } 203 }
193 } 204 }
194 205
195 } // namespace interpreter 206 } // namespace interpreter
196 } // namespace internal 207 } // namespace internal
197 } // namespace v8 208 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/source-position-table.h ('k') | test/mjsunit/ignition/elided-instruction.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698