| Index: src/interpreter/bytecode-peephole-optimizer.cc
|
| diff --git a/src/interpreter/bytecode-peephole-optimizer.cc b/src/interpreter/bytecode-peephole-optimizer.cc
|
| index 40552943f75dcb3b07d196b910f00cfd321d2946..03a5c573179e5fb3b33a3e3471ff5f4d4d0205db 100644
|
| --- a/src/interpreter/bytecode-peephole-optimizer.cc
|
| +++ b/src/interpreter/bytecode-peephole-optimizer.cc
|
| @@ -13,7 +13,8 @@ namespace interpreter {
|
|
|
| BytecodePeepholeOptimizer::BytecodePeepholeOptimizer(
|
| BytecodePipelineStage* next_stage)
|
| - : next_stage_(next_stage), last_(Bytecode::kIllegal, BytecodeSourceInfo()) {
|
| + : next_stage_(next_stage),
|
| + last_(BytecodeNode::Create<Bytecode::kIllegal>()) {
|
| InvalidateLast();
|
| }
|
|
|
| @@ -65,7 +66,7 @@ void BytecodePeepholeOptimizer::Flush() {
|
| }
|
|
|
| void BytecodePeepholeOptimizer::InvalidateLast() {
|
| - last_.set_bytecode(Bytecode::kIllegal);
|
| + last_ = BytecodeNode::Create<Bytecode::kIllegal>();
|
| }
|
|
|
| bool BytecodePeepholeOptimizer::LastIsValid() const {
|
| @@ -116,26 +117,28 @@ bool BytecodePeepholeOptimizer::CanElideLastBasedOnSourcePosition(
|
|
|
| namespace {
|
|
|
| -void TransformLdaSmiBinaryOpToBinaryOpWithSmi(Bytecode new_bytecode,
|
| - BytecodeNode* const last,
|
| - BytecodeNode* const current) {
|
| +BytecodeNode TransformLdaSmiBinaryOpToBinaryOpWithSmi(
|
| + Bytecode new_bytecode, BytecodeNode* const last,
|
| + BytecodeNode* const current) {
|
| DCHECK_EQ(last->bytecode(), Bytecode::kLdaSmi);
|
| - current->set_bytecode(new_bytecode, last->operand(0), current->operand(0),
|
| - current->operand(1));
|
| + BytecodeNode node(new_bytecode, last->operand(0), current->operand(0),
|
| + current->operand(1), current->source_info());
|
| if (last->source_info().is_valid()) {
|
| - current->set_source_info(last->source_info());
|
| + node.set_source_info(last->source_info());
|
| }
|
| + return node;
|
| }
|
|
|
| -void TransformLdaZeroBinaryOpToBinaryOpWithZero(Bytecode new_bytecode,
|
| - BytecodeNode* const last,
|
| - BytecodeNode* const current) {
|
| +BytecodeNode TransformLdaZeroBinaryOpToBinaryOpWithZero(
|
| + Bytecode new_bytecode, BytecodeNode* const last,
|
| + BytecodeNode* const current) {
|
| DCHECK_EQ(last->bytecode(), Bytecode::kLdaZero);
|
| - current->set_bytecode(new_bytecode, 0, current->operand(0),
|
| - current->operand(1));
|
| + BytecodeNode node(new_bytecode, 0, current->operand(0), current->operand(1),
|
| + current->source_info());
|
| if (last->source_info().is_valid()) {
|
| - current->set_source_info(last->source_info());
|
| + node.set_source_info(last->source_info());
|
| }
|
| + return node;
|
| }
|
|
|
| } // namespace
|
| @@ -175,8 +178,9 @@ void BytecodePeepholeOptimizer::ElideCurrentAction(
|
| if (node->source_info().is_valid()) {
|
| // Preserve the source information by replacing the node bytecode
|
| // with a no op bytecode.
|
| - node->set_bytecode(Bytecode::kNop);
|
| - DefaultAction(node);
|
| + BytecodeNode new_node =
|
| + BytecodeNode::Create<Bytecode::kNop>(node->source_info());
|
| + DefaultAction(&new_node);
|
| } else {
|
| // Nothing to do, keep last and wait for next bytecode to pair with it.
|
| }
|
| @@ -228,9 +232,9 @@ void BytecodePeepholeOptimizer::TransformLdaSmiBinaryOpToBinaryOpWithSmiAction(
|
|
|
| if (!node->source_info().is_valid() || !last()->source_info().is_valid()) {
|
| // Fused last and current into current.
|
| - TransformLdaSmiBinaryOpToBinaryOpWithSmi(action_data->bytecode, last(),
|
| - node);
|
| - SetLast(node);
|
| + BytecodeNode new_node(TransformLdaSmiBinaryOpToBinaryOpWithSmi(
|
| + action_data->bytecode, last(), node));
|
| + SetLast(&new_node);
|
| } else {
|
| DefaultAction(node);
|
| }
|
| @@ -243,9 +247,9 @@ void BytecodePeepholeOptimizer::
|
| DCHECK(!Bytecodes::IsJump(node->bytecode()));
|
| if (!node->source_info().is_valid() || !last()->source_info().is_valid()) {
|
| // Fused last and current into current.
|
| - TransformLdaZeroBinaryOpToBinaryOpWithZero(action_data->bytecode, last(),
|
| - node);
|
| - SetLast(node);
|
| + BytecodeNode new_node(TransformLdaZeroBinaryOpToBinaryOpWithZero(
|
| + action_data->bytecode, last(), node));
|
| + SetLast(&new_node);
|
| } else {
|
| DefaultAction(node);
|
| }
|
| @@ -273,7 +277,7 @@ void BytecodePeepholeOptimizer::ChangeJumpBytecodeAction(
|
|
|
| next_stage()->Write(last());
|
| InvalidateLast();
|
| - node->set_bytecode(action_data->bytecode, node->operand(0));
|
| + node->replace_bytecode(action_data->bytecode);
|
| }
|
|
|
| void BytecodePeepholeOptimizer::ElideLastBeforeJumpAction(
|
|
|