Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(681)

Unified Diff: src/interpreter/mkpeephole.cc

Issue 2547043002: [Interpreter] Optimize equality check with null/undefined with a check on the map. (Closed)
Patch Set: A couple of fixes: 1. TestUndetectable writes boolean to accumulator 2. New optimization to load un… Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/interpreter/mkpeephole.cc
diff --git a/src/interpreter/mkpeephole.cc b/src/interpreter/mkpeephole.cc
index 62d3a77e02c7faf513f1d8ff020217b6fd4785dd..81f35f670112ccf002c5c971cdbc14bb590a9dbc 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) {
mythria 2016/12/05 17:48:12 Ast Converts b != null to b == null. So we don't n
rmcilroy 2016/12/05 19:08:09 Great thanks for checking.
+ return {PeepholeAction::
+ kTransformEqualityWithNullOrUndefinedToTestUndetectableAction,
+ Bytecode::kTestUndetectable};
rmcilroy 2016/12/05 19:08:09 Still passing the bytecode as action data here. I
mythria 2016/12/06 10:13:27 Done.
+ }
+ }
+
// If there is no last bytecode to optimize against, store the incoming
// bytecode or for jumps emit incoming bytecode immediately.
if (last == Bytecode::kIllegal) {

Powered by Google App Engine
This is Rietveld 408576698