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

Unified Diff: src/hydrogen.cc

Issue 144913003: Reland (and fix) "Add hydrogen support for ArrayPop, and remove the handwritten call stubs." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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/arm/stub-cache-arm.cc ('k') | src/ia32/stub-cache-ia32.cc » ('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 44df621790d875f1534a839db80ecaecf4b80753..f127d805a344f2c096f4107ceb322cdf6112e4eb 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -7613,6 +7613,53 @@ bool HOptimizedGraphBuilder::TryInlineBuiltinMethodCall(
return true;
}
break;
+ case kArrayPop: {
+ if (!expr->IsMonomorphic() || expr->check_type() != RECEIVER_MAP_CHECK) {
+ return false;
+ }
+ if (receiver_map->instance_type() != JS_ARRAY_TYPE) return false;
+ ElementsKind elements_kind = receiver_map->elements_kind();
+ if (!IsFastElementsKind(elements_kind)) return false;
+ AddCheckConstantFunction(expr->holder(), receiver, receiver_map);
+
+ Drop(expr->arguments()->length());
+ HValue* result;
+ HValue* checked_object;
+ HValue* reduced_length;
+ HValue* receiver = Pop();
+ { NoObservableSideEffectsScope scope(this);
+ checked_object = AddCheckMap(receiver, receiver_map);
+ HValue* elements = AddLoadElements(checked_object);
+ // Ensure that we aren't popping from a copy-on-write array.
+ if (IsFastSmiOrObjectElementsKind(elements_kind)) {
+ Add<HCheckMaps>(
+ elements, isolate()->factory()->fixed_array_map(), top_info());
+ }
+ HValue* length = Add<HLoadNamedField>(
+ checked_object, HObjectAccess::ForArrayLength(elements_kind));
+ reduced_length = AddUncasted<HSub>(length, graph()->GetConstant1());
+ HValue* bounds_check = Add<HBoundsCheck>(
+ graph()->GetConstant0(), length);
+ result = AddElementAccess(elements, reduced_length, NULL,
+ bounds_check, elements_kind, false);
+ Factory* factory = isolate()->factory();
+ double nan_double = FixedDoubleArray::hole_nan_as_double();
+ HValue* hole = IsFastSmiOrObjectElementsKind(elements_kind)
+ ? Add<HConstant>(factory->the_hole_value())
+ : Add<HConstant>(nan_double);
+ if (IsFastSmiOrObjectElementsKind(elements_kind)) {
+ elements_kind = FAST_HOLEY_ELEMENTS;
+ }
+ AddElementAccess(
+ elements, reduced_length, hole, bounds_check, elements_kind, true);
+ }
+ Add<HStoreNamedField>(
+ checked_object, HObjectAccess::ForArrayLength(elements_kind),
+ reduced_length);
+ ast_context()->ReturnValue(result);
+ Add<HSimulate>(expr->id(), REMOVABLE_SIMULATE);
Jakob Kummerow 2014/01/24 08:34:46 This line causes a NULL deref every time it is exe
+ return true;
+ }
default:
// Not yet supported for inlining.
break;
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/ia32/stub-cache-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698