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

Unified 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: fix 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/interpreter/source-position-table.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecode-array-builder.cc
diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc
index 9795b0835756e2e7ba91f0d1a5bbc06f3d3c08c0..7d8089b90b6e39bfd023dd8afbe883a791d0f45f 100644
--- a/src/interpreter/bytecode-array-builder.cc
+++ b/src/interpreter/bytecode-array-builder.cc
@@ -138,7 +138,10 @@ Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() {
template <size_t N>
void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t(&operands)[N]) {
// Don't output dead code.
- if (exit_seen_in_block_) return;
+ if (exit_seen_in_block_) {
+ source_position_table_builder_.RevertPosition(bytecodes()->size());
+ return;
+ }
int operand_count = static_cast<int>(N);
DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count);
@@ -206,7 +209,10 @@ void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t operand0) {
void BytecodeArrayBuilder::Output(Bytecode bytecode) {
// Don't output dead code.
- if (exit_seen_in_block_) return;
+ if (exit_seen_in_block_) {
+ source_position_table_builder_.RevertPosition(bytecodes()->size());
+ return;
+ }
DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 0);
last_bytecode_start_ = bytecodes()->size();
@@ -886,7 +892,10 @@ void BytecodeArrayBuilder::PatchJump(
BytecodeArrayBuilder& BytecodeArrayBuilder::OutputJump(Bytecode jump_bytecode,
BytecodeLabel* label) {
// Don't emit dead code.
- if (exit_seen_in_block_) return *this;
+ if (exit_seen_in_block_) {
+ source_position_table_builder_.RevertPosition(bytecodes()->size());
+ return *this;
+ }
// Check if the value in accumulator is boolean, if not choose an
// appropriate JumpIfToBoolean bytecode.
@@ -1210,14 +1219,14 @@ size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) {
void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) {
if (stmt->position() == RelocInfo::kNoPosition) return;
- source_position_table_builder_.AddStatementPosition(
- static_cast<int>(bytecodes_.size()), stmt->position());
+ source_position_table_builder_.AddStatementPosition(bytecodes_.size(),
+ stmt->position());
}
void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) {
if (expr->position() == RelocInfo::kNoPosition) return;
- source_position_table_builder_.AddExpressionPosition(
- static_cast<int>(bytecodes_.size()), expr->position());
+ source_position_table_builder_.AddExpressionPosition(bytecodes_.size(),
+ expr->position());
}
bool BytecodeArrayBuilder::TemporaryRegisterIsLive(Register reg) const {
« no previous file with comments | « no previous file | src/interpreter/source-position-table.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698