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

Unified Diff: src/hydrogen.cc

Issue 880233002: Do not inline array push for arrays with dictionary mode elements. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 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 | « src/hydrogen.h ('k') | test/mjsunit/array-push12.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 54007c524a6cd376a357770eaeaaa28b6e04af8f..41845746c2fcacccb3bad2cfa839d6c3712271a1 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -8225,6 +8225,18 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinFunctionCall(Call* expr) {
}
+// static
+bool HOptimizedGraphBuilder::CanInlineArrayResizeOperation(
+ Handle<Map> receiver_map) {
+ return !receiver_map.is_null() &&
+ receiver_map->instance_type() == JS_ARRAY_TYPE &&
+ IsFastElementsKind(receiver_map->elements_kind()) &&
+ !receiver_map->is_dictionary_map() &&
+ !JSArray::IsReadOnlyLengthDescriptor(receiver_map) &&
+ !receiver_map->is_observed() && receiver_map->is_extensible();
+}
+
+
bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
Call* expr, Handle<JSFunction> function, Handle<Map> receiver_map,
int args_count_no_receiver) {
@@ -8344,13 +8356,8 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
}
break;
case kArrayPop: {
- if (receiver_map.is_null()) return false;
- if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false;
+ if (!CanInlineArrayResizeOperation(receiver_map)) return false;
ElementsKind elements_kind = receiver_map->elements_kind();
- if (JSArray::IsReadOnlyLengthDescriptor(receiver_map)) return false;
- if (!IsFastElementsKind(elements_kind)) return false;
- if (receiver_map->is_observed()) return false;
- if (!receiver_map->is_extensible()) return false;
Drop(args_count_no_receiver);
HValue* result;
@@ -8407,13 +8414,8 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
return true;
}
case kArrayPush: {
- if (receiver_map.is_null()) return false;
- if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false;
+ if (!CanInlineArrayResizeOperation(receiver_map)) return false;
ElementsKind elements_kind = receiver_map->elements_kind();
- if (!IsFastElementsKind(elements_kind)) return false;
- if (receiver_map->is_observed()) return false;
- if (JSArray::IsReadOnlyLengthDescriptor(receiver_map)) return false;
- if (!receiver_map->is_extensible()) return false;
// If there may be elements accessors in the prototype chain, the fast
// inlined version can't be used.
@@ -8460,13 +8462,8 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
return true;
}
case kArrayShift: {
- if (receiver_map.is_null()) return false;
- if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false;
+ if (!CanInlineArrayResizeOperation(receiver_map)) return false;
ElementsKind kind = receiver_map->elements_kind();
- if (JSArray::IsReadOnlyLengthDescriptor(receiver_map)) return false;
- if (!IsFastElementsKind(kind)) return false;
- if (receiver_map->is_observed()) return false;
- if (!receiver_map->is_extensible()) return false;
// If there may be elements accessors in the prototype chain, the fast
// inlined version can't be used.
« no previous file with comments | « src/hydrogen.h ('k') | test/mjsunit/array-push12.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698