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

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: Rebase 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
« no previous file with comments | « src/interpreter/source-position-table.h ('k') | src/log.cc » ('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::AddPosition(size_t bytecode_offset,
119 int source_position) { 119 int source_position,
120 bool is_statement) {
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, is_statement});
122 }
123
124 void SourcePositionTableBuilder::AddExpressionPosition(size_t bytecode_offset,
125 int source_position) {
126 int offset = static_cast<int>(bytecode_offset);
127 AddEntry({offset, source_position, false});
128 } 123 }
129 124
130 void SourcePositionTableBuilder::AddEntry(const PositionTableEntry& entry) { 125 void SourcePositionTableBuilder::AddEntry(const PositionTableEntry& entry) {
131 // Don't encode a new entry if this bytecode already has a source position 126 PositionTableEntry tmp(entry);
132 // assigned.
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_); 127 SubtractFromEntry(tmp, previous_);
146 EncodeEntry(bytes_, tmp); 128 EncodeEntry(bytes_, tmp);
147 previous_ = candidate_; 129 previous_ = entry;
148 130
149 if (candidate_.is_statement) { 131 if (entry.is_statement) {
150 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddStatementPositionEvent( 132 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddStatementPositionEvent(
151 jit_handler_data_, candidate_.bytecode_offset, 133 jit_handler_data_, entry.bytecode_offset,
152 candidate_.source_position)); 134 entry.source_position));
153 } 135 }
154 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddPositionEvent( 136 LOG_CODE_EVENT(isolate_, CodeLinePosInfoAddPositionEvent(
155 jit_handler_data_, candidate_.bytecode_offset, 137 jit_handler_data_, entry.bytecode_offset,
156 candidate_.source_position)); 138 entry.source_position));
157 139
158 #ifdef ENABLE_SLOW_DCHECKS 140 #ifdef ENABLE_SLOW_DCHECKS
159 raw_entries_.push_back(candidate_); 141 raw_entries_.push_back(entry);
160 #endif 142 #endif
161 } 143 }
162 144
163 Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable() { 145 Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable() {
164 CommitEntry();
165 if (bytes_.empty()) return isolate_->factory()->empty_byte_array(); 146 if (bytes_.empty()) return isolate_->factory()->empty_byte_array();
166 147
167 Handle<ByteArray> table = isolate_->factory()->NewByteArray( 148 Handle<ByteArray> table = isolate_->factory()->NewByteArray(
168 static_cast<int>(bytes_.size()), TENURED); 149 static_cast<int>(bytes_.size()), TENURED);
169 150
170 MemCopy(table->GetDataStartAddress(), &*bytes_.begin(), bytes_.size()); 151 MemCopy(table->GetDataStartAddress(), &*bytes_.begin(), bytes_.size());
171 152
172 #ifdef ENABLE_SLOW_DCHECKS 153 #ifdef ENABLE_SLOW_DCHECKS
173 // Brute force testing: Record all positions and decode 154 // Brute force testing: Record all positions and decode
174 // the entire table to verify they are identical. 155 // the entire table to verify they are identical.
(...skipping 24 matching lines...) Expand all
199 } else { 180 } else {
200 PositionTableEntry tmp; 181 PositionTableEntry tmp;
201 DecodeEntry(table_, &index_, &tmp); 182 DecodeEntry(table_, &index_, &tmp);
202 AddAndSetEntry(current_, tmp); 183 AddAndSetEntry(current_, tmp);
203 } 184 }
204 } 185 }
205 186
206 } // namespace interpreter 187 } // namespace interpreter
207 } // namespace internal 188 } // namespace internal
208 } // namespace v8 189 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/source-position-table.h ('k') | src/log.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698