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

Unified Diff: src/crankshaft/hydrogen.cc

Issue 1742253002: [crankshaft] Inline hasOwnProperty when used in fast-case for-in (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix: disable if OSR. Otherwise elements of for-in can have more elements in the phi (the OSR entry … Created 4 years, 10 months 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
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen.cc
diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc
index 8ff3f3ba3f05afbcade28d2f073afa6c5503fc77..0fa8daa6419335a7410bac8ba59641bc4fbcd573 100644
--- a/src/crankshaft/hydrogen.cc
+++ b/src/crankshaft/hydrogen.cc
@@ -8752,6 +8752,25 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
}
// Try to inline calls like Math.* as operations in the calling function.
switch (id) {
+ case kObjectHasOwnProperty: {
+ // It's not safe to look through the phi for elements if we're compiling
+ // for osr.
+ if (top_info()->is_osr()) return false;
+ if (argument_count != 2) return false;
+ HValue* key = Top();
+ if (!key->IsLoadKeyed()) return false;
+ HValue* elements = HLoadKeyed::cast(key)->elements();
+ if (!elements->IsPhi() || elements->OperandCount() != 1) return false;
+ if (!elements->OperandAt(0)->IsForInCacheArray()) return false;
+ HForInCacheArray* cache = HForInCacheArray::cast(elements->OperandAt(0));
+ HValue* receiver = environment()->ExpressionStackAt(1);
+ if (!receiver->IsPhi() || receiver->OperandCount() != 1) return false;
+ if (cache->enumerable() != receiver->OperandAt(0)) return false;
+ Drop(3); // key, receiver, function
+ Add<HCheckMapValue>(receiver, cache->map());
+ ast_context()->ReturnValue(graph()->GetConstantTrue());
+ return true;
+ }
case kStringCharCodeAt:
case kStringCharAt:
if (argument_count == 2) {
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698