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..dfc40a2c194ec18892d52215c645ea5cda3d38da 100644 |
--- a/src/interpreter/bytecode-peephole-optimizer.cc |
+++ b/src/interpreter/bytecode-peephole-optimizer.cc |
@@ -138,6 +138,17 @@ void TransformLdaZeroBinaryOpToBinaryOpWithZero(Bytecode new_bytecode, |
} |
} |
+void TransformEqualityWithNullOrUndefinedToTestUndetectable( |
+ BytecodeNode* const last, BytecodeNode* const current) { |
+ DCHECK((last->bytecode() == Bytecode::kLdaNull) || |
+ (last->bytecode() == Bytecode::kLdaUndefined)); |
+ DCHECK_EQ(current->bytecode(), Bytecode::kTestEqual); |
+ current->set_bytecode(Bytecode::kTestUndetectable, current->operand(0)); |
+ if (last->source_info().is_valid()) { |
+ current->set_source_info(last->source_info()); |
+ } |
+} |
+ |
} // namespace |
void BytecodePeepholeOptimizer::DefaultAction( |
@@ -251,6 +262,16 @@ void BytecodePeepholeOptimizer:: |
} |
} |
+void BytecodePeepholeOptimizer:: |
+ TransformEqualityWithNullOrUndefinedToTestUndetectableAction( |
+ BytecodeNode* const node, const PeepholeActionAndData* action_data) { |
+ DCHECK(LastIsValid()); |
+ DCHECK(!Bytecodes::IsJump(node->bytecode())); |
+ // Fused last and current into current. |
+ TransformEqualityWithNullOrUndefinedToTestUndetectable(last(), node); |
+ SetLast(node); |
+} |
+ |
void BytecodePeepholeOptimizer::DefaultJumpAction( |
BytecodeNode* const node, const PeepholeActionAndData* action_data) { |
DCHECK(LastIsValid()); |