Index: src/interpreter/mkpeephole.cc |
diff --git a/src/interpreter/mkpeephole.cc b/src/interpreter/mkpeephole.cc |
index 62d3a77e02c7faf513f1d8ff020217b6fd4785dd..08e0301625f12e14ed697b06eca521102eb90605 100644 |
--- a/src/interpreter/mkpeephole.cc |
+++ b/src/interpreter/mkpeephole.cc |
@@ -192,6 +192,19 @@ PeepholeActionAndData PeepholeActionTableWriter::LookupActionAndData( |
} |
} |
+ // Fuse LdaNull/LdaUndefined followed by a equality comparison with test |
+ // undetectable. Testing undetectable is a simple check on the map which is |
+ // more efficient than the full comparison operation. |
+ // Note: StrictEquals cannot use this, they need to compare it with the |
+ // Null/undefined map. |
+ if (last == Bytecode::kLdaNull || last == Bytecode::kLdaUndefined) { |
+ if (current == Bytecode::kTestEqual) { |
+ return {PeepholeAction:: |
+ kTransformEqualityWithNullOrUndefinedToTestUndetectableAction, |
+ Bytecode::kIllegal}; |
+ } |
+ } |
+ |
// If there is no last bytecode to optimize against, store the incoming |
// bytecode or for jumps emit incoming bytecode immediately. |
if (last == Bytecode::kIllegal) { |