Chromium Code Reviews| Index: src/interpreter/bytecode-array-builder.cc |
| diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc |
| index f277d7ce187e0a5ba975b351e7190c731fea79ca..8115d2b467b65a097915cb8bf42afcdcb2a6c7ab 100644 |
| --- a/src/interpreter/bytecode-array-builder.cc |
| +++ b/src/interpreter/bytecode-array-builder.cc |
| @@ -124,8 +124,8 @@ Handle<BytecodeArray> BytecodeArrayBuilder::ToBytecodeArray() { |
| int frame_size = register_count * kPointerSize; |
| Handle<FixedArray> constant_pool = constant_array_builder()->ToFixedArray(); |
| Handle<FixedArray> handler_table = handler_table_builder()->ToHandlerTable(); |
| - Handle<FixedArray> source_position_table = |
| - source_position_table_builder()->ToFixedArray(); |
| + Handle<ByteArray> source_position_table = |
| + source_position_table_builder()->ToSourcePositionTable(); |
| Handle<BytecodeArray> output = isolate_->factory()->NewBytecodeArray( |
| bytecode_size, &bytecodes_.front(), frame_size, parameter_count(), |
| constant_pool); |
| @@ -139,10 +139,7 @@ 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_) { |
| - source_position_table_builder_.RevertPosition(bytecodes()->size()); |
| - return; |
| - } |
| + if (exit_seen_in_block_) return; |
| int operand_count = static_cast<int>(N); |
| DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), operand_count); |
| @@ -210,10 +207,7 @@ void BytecodeArrayBuilder::Output(Bytecode bytecode, uint32_t operand0) { |
| void BytecodeArrayBuilder::Output(Bytecode bytecode) { |
| // Don't output dead code. |
| - if (exit_seen_in_block_) { |
| - source_position_table_builder_.RevertPosition(bytecodes()->size()); |
| - return; |
| - } |
| + if (exit_seen_in_block_) return; |
| DCHECK_EQ(Bytecodes::NumberOfOperands(bytecode), 0); |
| last_bytecode_start_ = bytecodes()->size(); |
| @@ -880,10 +874,7 @@ void BytecodeArrayBuilder::PatchJump( |
| BytecodeArrayBuilder& BytecodeArrayBuilder::OutputJump(Bytecode jump_bytecode, |
| BytecodeLabel* label) { |
| // Don't emit dead code. |
| - if (exit_seen_in_block_) { |
| - source_position_table_builder_.RevertPosition(bytecodes()->size()); |
| - return *this; |
| - } |
| + if (exit_seen_in_block_) return *this; |
| // Check if the value in accumulator is boolean, if not choose an |
| // appropriate JumpIfToBoolean bytecode. |
| @@ -1081,6 +1072,7 @@ void BytecodeArrayBuilder::EnsureReturn(FunctionLiteral* literal) { |
| SetReturnPosition(literal); |
| Return(); |
| } |
| + DCHECK(exit_seen_in_block_); |
| } |
| BytecodeArrayBuilder& BytecodeArrayBuilder::Call(Register callable, |
| @@ -1210,17 +1202,20 @@ size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { |
| void BytecodeArrayBuilder::SetReturnPosition(FunctionLiteral* fun) { |
| int pos = std::max(fun->start_position(), fun->end_position() - 1); |
| + if (exit_seen_in_block_) return; |
|
rmcilroy
2016/02/22 20:51:52
nit - could do this before calculating pos.
Yang
2016/02/22 21:56:25
+1
Maybe also add a comment on why this is being
vogelheim
2016/02/24 12:29:30
Done.
vogelheim
2016/02/24 12:29:30
Done.
|
| source_position_table_builder_.AddStatementPosition(bytecodes_.size(), pos); |
| } |
| void BytecodeArrayBuilder::SetStatementPosition(Statement* stmt) { |
| if (stmt->position() == RelocInfo::kNoPosition) return; |
| + if (exit_seen_in_block_) return; |
| source_position_table_builder_.AddStatementPosition(bytecodes_.size(), |
| stmt->position()); |
| } |
| void BytecodeArrayBuilder::SetExpressionPosition(Expression* expr) { |
| if (expr->position() == RelocInfo::kNoPosition) return; |
| + if (exit_seen_in_block_) return; |
| source_position_table_builder_.AddExpressionPosition(bytecodes_.size(), |
| expr->position()); |
| } |