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

Unified Diff: src/interpreter/bytecode-generator.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/bytecode-generator.cc
diff --git a/src/interpreter/bytecode-generator.cc b/src/interpreter/bytecode-generator.cc
index d611cafd3a3b8bc18281cef25cdff6cd3242fd4b..f406b245652cccaf6f3d63245f6b4bdbb876537a 100644
--- a/src/interpreter/bytecode-generator.cc
+++ b/src/interpreter/bytecode-generator.cc
@@ -1831,8 +1831,14 @@ void BytecodeGenerator::BuildVariableLoad(Variable* variable,
break;
}
case VariableLocation::UNALLOCATED: {
- builder()->LoadGlobal(variable->name(), feedback_index(slot),
- typeof_mode);
+ // The global identifier "undefined" is immutable. Everything
+ // else could be reassigned.
+ if (variable->raw_name()->IsOneByteEqualTo("undefined")) {
mythria 2016/12/05 17:48:12 I took this logic from here: https://cs.chromium.o
rmcilroy 2016/12/05 19:08:09 It's possibly slow to check IsOneByteEqualTo each
mythria 2016/12/06 10:13:27 Nice one. Done.
+ builder()->LoadUndefined();
+ } else {
+ builder()->LoadGlobal(variable->name(), feedback_index(slot),
+ typeof_mode);
+ }
break;
}
case VariableLocation::CONTEXT: {

Powered by Google App Engine
This is Rietveld 408576698