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

Unified Diff: src/code-stub-assembler.cc

Issue 2617393002: [stubs] Ensure generated CalculateNewElementsCapacity is identical to runtime version (Closed)
Patch Set: Review feedback Created 3 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/code-stub-assembler.h ('k') | test/cctest/test-code-stub-assembler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stub-assembler.cc
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc
index 97f77e22244d1b043c4cadfe483a075a9425b256..1fb8a2152ee587eb5176e6c46707fbf7f679efd5 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -1492,8 +1492,7 @@ Node* CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* context,
Node* new_length =
IntPtrOrSmiAdd(WordToParameter(growth, mode), var_length.value(), mode);
GotoUnless(IntPtrOrSmiGreaterThan(new_length, capacity, mode), &fits);
- Node* new_capacity = CalculateNewElementsCapacity(
- IntPtrOrSmiAdd(new_length, IntPtrOrSmiConstant(1, mode), mode), mode);
+ Node* new_capacity = CalculateNewElementsCapacity(new_length, mode);
var_elements.Bind(GrowElementsCapacity(array, var_elements.value(), kind,
kind, capacity, new_capacity, mode,
&pre_bailout));
@@ -2346,18 +2345,10 @@ Node* CodeStubAssembler::LoadElementAndPrepareForStore(Node* array,
Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity,
ParameterMode mode) {
- if (mode == SMI_PARAMETERS) {
- old_capacity = BitcastTaggedToWord(old_capacity);
- }
- Node* half_old_capacity = WordShr(old_capacity, IntPtrConstant(1));
- Node* new_capacity = IntPtrAdd(half_old_capacity, old_capacity);
- Node* unconditioned_result = IntPtrAdd(new_capacity, IntPtrConstant(16));
- if (mode == SMI_PARAMETERS) {
- return SmiAnd(BitcastWordToTaggedSigned(unconditioned_result),
- SmiConstant(-1));
- } else {
- return unconditioned_result;
- }
+ Node* half_old_capacity = WordOrSmiShr(old_capacity, 1, mode);
+ Node* new_capacity = IntPtrOrSmiAdd(half_old_capacity, old_capacity, mode);
+ Node* padding = IntPtrOrSmiConstant(16, mode);
+ return IntPtrOrSmiAdd(new_capacity, padding, mode);
}
Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements,
« no previous file with comments | « src/code-stub-assembler.h ('k') | test/cctest/test-code-stub-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698