Chromium Code Reviews| 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..bccba16b7857ab5a5834c02003af4566b02a71ec 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( |
| + Bytecode new_bytecode, BytecodeNode* const last, |
| + BytecodeNode* const current) { |
| + DCHECK((last->bytecode() == Bytecode::kLdaNull) || |
| + (last->bytecode() == Bytecode::kLdaUndefined)); |
| + current->set_bytecode(new_bytecode, current->operand(0)); |
|
rmcilroy
2016/12/05 10:57:19
I don't think you need to pass the new_bytecode (
mythria
2016/12/05 14:53:11
Yes, we don't need action data. I did not think ab
|
| + if (last->source_info().is_valid()) { |
| + current->set_source_info(last->source_info()); |
| + } |
| +} |
| + |
| } // namespace |
| void BytecodePeepholeOptimizer::DefaultAction( |
| @@ -251,6 +262,21 @@ void BytecodePeepholeOptimizer:: |
| } |
| } |
| +void BytecodePeepholeOptimizer:: |
| + TransformEqualityWithNullOrUndefinedToTestUndetectableAction( |
| + BytecodeNode* const node, const PeepholeActionAndData* action_data) { |
| + DCHECK(LastIsValid()); |
| + DCHECK(!Bytecodes::IsJump(node->bytecode())); |
| + if (!node->source_info().is_valid() || !last()->source_info().is_valid()) { |
|
rmcilroy
2016/12/05 10:57:19
Do we need to do this check? LdaUndefined/null can
mythria
2016/12/05 14:53:11
I don't think we need, because if my understanding
rmcilroy
2016/12/05 19:08:09
Yeah we could think about removing for BinaryOpWit
|
| + // Fused last and current into current. |
| + TransformEqualityWithNullOrUndefinedToTestUndetectable( |
| + action_data->bytecode, last(), node); |
| + SetLast(node); |
| + } else { |
| + DefaultAction(node); |
| + } |
| +} |
| + |
| void BytecodePeepholeOptimizer::DefaultJumpAction( |
| BytecodeNode* const node, const PeepholeActionAndData* action_data) { |
| DCHECK(LastIsValid()); |