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

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

Issue 2776433003: [builtins] Implement Array.prototype.reduceRight in the CSA (Closed)
Patch Set: Add back accidental removals Created 3 years, 9 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') | src/debug/debug-evaluate.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 183a044953131492b29a62b2b859be6c34236eca..043bc41454f6c8be5ac4fc1af33ca21b54435742 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -7860,6 +7860,58 @@ Node* CodeStubAssembler::NumberInc(Node* value) {
return var_result.value();
}
+Node* CodeStubAssembler::NumberDec(Node* value) {
+ Variable var_result(this, MachineRepresentation::kTagged),
+ var_fdec_value(this, MachineRepresentation::kFloat64);
+ Label if_issmi(this), if_isnotsmi(this), do_fdec(this), end(this);
+ Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi);
+
+ Bind(&if_issmi);
+ {
+ // Try fast Smi addition first.
+ Node* one = SmiConstant(Smi::FromInt(1));
+ Node* pair = IntPtrSubWithOverflow(BitcastTaggedToWord(value),
+ BitcastTaggedToWord(one));
+ Node* overflow = Projection(1, pair);
+
+ // Check if the Smi addition overflowed.
+ Label if_overflow(this), if_notoverflow(this);
+ Branch(overflow, &if_overflow, &if_notoverflow);
+
+ Bind(&if_notoverflow);
+ var_result.Bind(BitcastWordToTaggedSigned(Projection(0, pair)));
+ Goto(&end);
+
+ Bind(&if_overflow);
+ {
+ var_fdec_value.Bind(SmiToFloat64(value));
+ Goto(&do_fdec);
+ }
+ }
+
+ Bind(&if_isnotsmi);
+ {
+ // Check if the value is a HeapNumber.
+ CSA_ASSERT(this, IsHeapNumberMap(LoadMap(value)));
+
+ // Load the HeapNumber value.
+ var_fdec_value.Bind(LoadHeapNumberValue(value));
+ Goto(&do_fdec);
+ }
+
+ Bind(&do_fdec);
+ {
+ Node* fdec_value = var_fdec_value.value();
+ Node* minus_one = Float64Constant(-1.0);
+ Node* fdec_result = Float64Add(fdec_value, minus_one);
+ var_result.Bind(AllocateHeapNumberWithValue(fdec_result));
+ Goto(&end);
+ }
+
+ Bind(&end);
+ return var_result.value();
+}
+
void CodeStubAssembler::GotoIfNotNumber(Node* input, Label* is_not_number) {
Label is_number(this);
GotoIf(TaggedIsSmi(input), &is_number);
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/debug/debug-evaluate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698