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

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

Issue 1947403002: [interpreter] Introduce bytecode generation pipeline. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Incorporate review comments. Created 4 years, 7 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
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 AddEntry({offset, source_position, true}); 121 AddEntry({offset, source_position, true});
122 } 122 }
123 123
124 void SourcePositionTableBuilder::AddExpressionPosition(size_t bytecode_offset, 124 void SourcePositionTableBuilder::AddExpressionPosition(size_t bytecode_offset,
125 int source_position) { 125 int source_position) {
126 int offset = static_cast<int>(bytecode_offset); 126 int offset = static_cast<int>(bytecode_offset);
127 AddEntry({offset, source_position, false}); 127 AddEntry({offset, source_position, false});
128 } 128 }
129 129
130 void SourcePositionTableBuilder::AddEntry(const PositionTableEntry& entry) { 130 void SourcePositionTableBuilder::AddEntry(const PositionTableEntry& entry) {
131 // Don't encode a new entry if this bytecode already has a source position 131 if (entry.bytecode_offset == kUninitializedCandidateOffset) return;
rmcilroy 2016/05/10 11:14:10 You can remove this line
oth 2016/05/11 13:17:31 Done.
132 // assigned. 132 PositionTableEntry tmp(entry);
133 if (candidate_.bytecode_offset == entry.bytecode_offset) {
134 if (entry.is_statement) candidate_ = entry;
135 return;
136 }
137
138 CommitEntry();
139 candidate_ = entry;
140 }
141
142 void SourcePositionTableBuilder::CommitEntry() {
143 if (candidate_.bytecode_offset == kUninitializedCandidateOffset) return;
144 PositionTableEntry tmp(candidate_);
145 SubtractFromEntry(tmp, previous_); 133 SubtractFromEntry(tmp, previous_);
146 EncodeEntry(bytes_, tmp); 134 EncodeEntry(bytes_, tmp);
147 previous_ = candidate_; 135 previous_ = entry;
148 136
149 if (candidate_.is_statement) { 137 if (entry.is_statement) {
150 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddStatementPositionEvent( 138 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddStatementPositionEvent(
151 jit_handler_data_, candidate_.bytecode_offset, 139 jit_handler_data_, entry.bytecode_offset,
152 candidate_.source_position)); 140 entry.source_position));
153 } 141 }
154 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddPositionEvent( 142 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddPositionEvent(
155 jit_handler_data_, candidate_.bytecode_offset, 143 jit_handler_data_, entry.bytecode_offset,
156 candidate_.source_position)); 144 entry.source_position));
157 145
158 #ifdef ENABLE_SLOW_DCHECKS 146 #ifdef ENABLE_SLOW_DCHECKS
159 raw_entries_.push_back(candidate_); 147 raw_entries_.push_back(entry);
160 #endif 148 #endif
161 } 149 }
162 150
163 Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable() { 151 Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable() {
164 CommitEntry();
165 if (bytes_.empty()) return isolate_->factory()->empty_byte_array(); 152 if (bytes_.empty()) return isolate_->factory()->empty_byte_array();
166 153
167 Handle<ByteArray> table = isolate_->factory()->NewByteArray( 154 Handle<ByteArray> table = isolate_->factory()->NewByteArray(
168 static_cast<int>(bytes_.size()), TENURED); 155 static_cast<int>(bytes_.size()), TENURED);
169 156
170 MemCopy(table->GetDataStartAddress(), &*bytes_.begin(), bytes_.size()); 157 MemCopy(table->GetDataStartAddress(), &*bytes_.begin(), bytes_.size());
171 158
172 #ifdef ENABLE_SLOW_DCHECKS 159 #ifdef ENABLE_SLOW_DCHECKS
173 // Brute force testing: Record all positions and decode 160 // Brute force testing: Record all positions and decode
174 // the entire table to verify they are identical. 161 // the entire table to verify they are identical.
(...skipping 24 matching lines...) Expand all
199 } else { 186 } else {
200 PositionTableEntry tmp; 187 PositionTableEntry tmp;
201 DecodeEntry(table_, &index_, &tmp); 188 DecodeEntry(table_, &index_, &tmp);
202 AddAndSetEntry(current_, tmp); 189 AddAndSetEntry(current_, tmp);
203 } 190 }
204 } 191 }
205 192
206 } // namespace interpreter 193 } // namespace interpreter
207 } // namespace internal 194 } // namespace internal
208 } // namespace v8 195 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698