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

Side by Side Diff: src/interpreter/bytecode-array-builder.cc

Issue 1668863002: [interpreter] source positions should not be emitted for dead code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/bytecode-array-builder.h" 5 #include "src/interpreter/bytecode-array-builder.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace interpreter { 9 namespace interpreter {
10 10
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 output->set_handler_table(*handler_table); 131 output->set_handler_table(*handler_table);
132 output->set_source_position_table(*source_position_table); 132 output->set_source_position_table(*source_position_table);
133 bytecode_generated_ = true; 133 bytecode_generated_ = true;
134 return output; 134 return output;
135 } 135 }
136 136
137 137
138 template <size_t N> 138 template <size_t N>
139 void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t(&operands)[N]) { 139 void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t(&operands)[N]) {
140 // Don't output dead code. 140 // Don't output dead code.
141 if (exit_seen_in_block_) return; 141 if (exit_seen_in_block_) {
142 source_position_table_builder_.RevertPosition(bytecodes()->size());
143 return;
144 }
142 145
143 int operand_count = static_cast<int>(N); 146 int operand_count = static_cast<int>(N);
144 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count); 147 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count);
145 148
146 int register_operand_count = Bytecodes::NumberOfRegisterOperands(bytecode); 149 int register_operand_count = Bytecodes::NumberOfRegisterOperands(bytecode);
147 if (register_operand_count > 0) { 150 if (register_operand_count > 0) {
148 register_translator()->TranslateInputRegisters(bytecode, operands, 151 register_translator()->TranslateInputRegisters(bytecode, operands,
149 operand_count); 152 operand_count);
150 } 153 }
151 154
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 202
200 203
201 void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t operand0) { 204 void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t operand0) {
202 uint32_t operands[] = {operand0}; 205 uint32_t operands[] = {operand0};
203 Output(bytecode, operands); 206 Output(bytecode, operands);
204 } 207 }
205 208
206 209
207 void BytecodeArrayBuilder::Output(Bytecode bytecode) { 210 void BytecodeArrayBuilder::Output(Bytecode bytecode) {
208 // Don't output dead code. 211 // Don't output dead code.
209 if (exit_seen_in_block_) return; 212 if (exit_seen_in_block_) {
213 source_position_table_builder_.RevertPosition(bytecodes()->size());
214 return;
215 }
210 216
211 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 0); 217 DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 0);
212 last_bytecode_start_ = bytecodes()->size(); 218 last_bytecode_start_ = bytecodes()->size();
213 bytecodes()->push_back(Bytecodes::ToByte(bytecode)); 219 bytecodes()->push_back(Bytecodes::ToByte(bytecode));
214 } 220 }
215 221
216 222
217 BytecodeArrayBuilder& BytecodeArrayBuilder::BinaryOperation(Token::Value op, 223 BytecodeArrayBuilder& BytecodeArrayBuilder::BinaryOperation(Token::Value op,
218 Register reg, 224 Register reg,
219 Strength strength) { 225 Strength strength) {
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 case OperandSize::kNone: 881 case OperandSize::kNone:
876 UNREACHABLE(); 882 UNREACHABLE();
877 } 883 }
878 unbound_jumps_--; 884 unbound_jumps_--;
879 } 885 }
880 886
881 887
882 BytecodeArrayBuilder& BytecodeArrayBuilder::OutputJump(Bytecode jump_bytecode, 888 BytecodeArrayBuilder& BytecodeArrayBuilder::OutputJump(Bytecode jump_bytecode,
883 BytecodeLabel* label) { 889 BytecodeLabel* label) {
884 // Don't emit dead code. 890 // Don't emit dead code.
885 if (exit_seen_in_block_) return *this; 891 if (exit_seen_in_block_) {
892 source_position_table_builder_.RevertPosition(bytecodes()->size());
893 return *this;
894 }
886 895
887 // Check if the value in accumulator is boolean, if not choose an 896 // Check if the value in accumulator is boolean, if not choose an
888 // appropriate JumpIfToBoolean bytecode. 897 // appropriate JumpIfToBoolean bytecode.
889 if (NeedToBooleanCast()) { 898 if (NeedToBooleanCast()) {
890 jump_bytecode = GetJumpWithToBoolean(jump_bytecode); 899 jump_bytecode = GetJumpWithToBoolean(jump_bytecode);
891 } 900 }
892 901
893 if (label->is_bound()) { 902 if (label->is_bound()) {
894 // Label has been bound already so this is a backwards jump. 903 // Label has been bound already so this is a backwards jump.
895 CHECK_GE(bytecodes()->size(), label->offset()); 904 CHECK_GE(bytecodes()->size(), label->offset());
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 return *this; 1200 return *this;
1192 } 1201 }
1193 1202
1194 1203
1195 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { 1204 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) {
1196 return constant_array_builder()->Insert(object); 1205 return constant_array_builder()->Insert(object);
1197 } 1206 }
1198 1207
1199 void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) { 1208 void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) {
1200 if (stmt->position() == RelocInfo::kNoPosition) return; 1209 if (stmt->position() == RelocInfo::kNoPosition) return;
1201 source_position_table_builder_.AddStatementPosition( 1210 source_position_table_builder_.AddStatementPosition(bytecodes_.size(),
1202 static_cast<int>(bytecodes_.size()), stmt->position()); 1211 stmt->position());
1203 } 1212 }
1204 1213
1205 void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) { 1214 void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) {
1206 if (expr->position() == RelocInfo::kNoPosition) return; 1215 if (expr->position() == RelocInfo::kNoPosition) return;
1207 source_position_table_builder_.AddExpressionPosition( 1216 source_position_table_builder_.AddExpressionPosition(bytecodes_.size(),
1208 static_cast<int>(bytecodes_.size()), expr->position()); 1217 expr->position());
1209 } 1218 }
1210 1219
1211 bool BytecodeArrayBuilder::TemporaryRegisterIsLive(Register reg) const { 1220 bool BytecodeArrayBuilder::TemporaryRegisterIsLive(Register reg) const {
1212 return temporary_register_allocator()->RegisterIsLive(reg); 1221 return temporary_register_allocator()->RegisterIsLive(reg);
1213 } 1222 }
1214 1223
1215 bool BytecodeArrayBuilder::OperandIsValid(Bytecode bytecode, int operand_index, 1224 bool BytecodeArrayBuilder::OperandIsValid(Bytecode bytecode, int operand_index,
1216 uint32_t operand_value) const { 1225 uint32_t operand_value) const {
1217 OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index); 1226 OperandType operand_type = Bytecodes::GetOperandType(bytecode, operand_index);
1218 switch (operand_type) { 1227 switch (operand_type) {
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1675 } 1684 }
1676 1685
1677 // static 1686 // static
1678 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) { 1687 bool BytecodeArrayBuilder::FitsInReg16OperandUntranslated(Register value) {
1679 return value.is_short_operand(); 1688 return value.is_short_operand();
1680 } 1689 }
1681 1690
1682 } // namespace interpreter 1691 } // namespace interpreter
1683 } // namespace internal 1692 } // namespace internal
1684 } // namespace v8 1693 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/interpreter/source-position-table.h » ('j') | src/interpreter/source-position-table.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698