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

Unified Diff: src/hydrogen.cc

Issue 1124443004: New hydrogen instruction to reduce cost of growing an array on keyed stores. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE. Created 5 years, 7 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/code-stubs-hydrogen.cc ('k') | src/hydrogen-instructions.h » ('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 ead064e3c34071f2961f567886dc529dbd21348c..af25700de72a7b6b8f1a69c14e9836d264d66cde 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -1331,38 +1331,23 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(
HValue* current_capacity = AddLoadFixedArrayLength(elements);
- IfBuilder capacity_checker(this);
-
- capacity_checker.If<HCompareNumericAndBranch>(key, current_capacity,
- Token::GTE);
- capacity_checker.Then();
-
- // BuildCheckAndGrowElementsCapacity could de-opt without profitable feedback
- // therefore we defer calling it to a stub in optimized functions. It is
- // okay to call directly in a code stub though, because a bailout to the
- // runtime is tolerable in the corner cases.
if (top_info()->IsStub()) {
+ IfBuilder capacity_checker(this);
+ capacity_checker.If<HCompareNumericAndBranch>(key, current_capacity,
+ Token::GTE);
+ capacity_checker.Then();
HValue* new_elements = BuildCheckAndGrowElementsCapacity(
object, elements, kind, length, current_capacity, key);
environment()->Push(new_elements);
+ capacity_checker.Else();
+ environment()->Push(elements);
+ capacity_checker.End();
} else {
- GrowArrayElementsStub stub(isolate(), is_js_array, kind);
- GrowArrayElementsDescriptor descriptor(isolate());
- HConstant* target = Add<HConstant>(stub.GetCode());
- HValue* op_vals[] = {context(), object, key, current_capacity};
- HValue* new_elements = Add<HCallWithDescriptor>(
- target, 0, descriptor, Vector<HValue*>(op_vals, 4));
- // If the object changed to a dictionary, GrowArrayElements will return a
- // smi to signal that deopt is required.
- Add<HCheckHeapObject>(new_elements);
- environment()->Push(new_elements);
+ HValue* result = Add<HMaybeGrowElements>(
+ object, elements, key, current_capacity, is_js_array, kind);
+ environment()->Push(result);
}
- capacity_checker.Else();
-
- environment()->Push(elements);
- capacity_checker.End();
-
if (is_js_array) {
HValue* new_length = AddUncasted<HAdd>(key, graph_->GetConstant1());
new_length->ClearFlag(HValue::kCanOverflow);
« no previous file with comments | « src/code-stubs-hydrogen.cc ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698