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

Unified Diff: src/builtins/builtins-math-gen.cc

Issue 2785773002: [turbofan] introduce Int32/64AbsWithOverflow optional operator (Closed)
Patch Set: add base impl 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 | « no previous file | src/compiler/arm/instruction-selector-arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins/builtins-math-gen.cc
diff --git a/src/builtins/builtins-math-gen.cc b/src/builtins/builtins-math-gen.cc
index 82993d7e1cec3abaaed39a885cad6a2c1c70e981..6210e20d84ed4c7ef121e4bba5ccf341c33659e5 100644
--- a/src/builtins/builtins-math-gen.cc
+++ b/src/builtins/builtins-math-gen.cc
@@ -48,36 +48,45 @@ TF_BUILTIN(MathAbs, CodeStubAssembler) {
Bind(&if_xissmi);
{
- // Check if {x} is already positive.
- Label if_xispositive(this), if_xisnotpositive(this);
- BranchIfSmiLessThanOrEqual(SmiConstant(Smi::FromInt(0)), x,
- &if_xispositive, &if_xisnotpositive);
+ Label if_overflow(this, Label::kDeferred), if_notoverflow(this);
+ Node* pair = NULL;
- Bind(&if_xispositive);
- {
- // Just return the input {x}.
- Return(x);
- }
-
- Bind(&if_xisnotpositive);
- {
- // Try to negate the {x} value.
- Node* pair =
- IntPtrSubWithOverflow(IntPtrConstant(0), BitcastTaggedToWord(x));
+ // check if support abs function
+ if (IsIntPtrAbsWithOverflowSupported()) {
+ pair = IntPtrAbsWithOverflow(x);
Node* overflow = Projection(1, pair);
- Label if_overflow(this, Label::kDeferred), if_notoverflow(this);
Branch(overflow, &if_overflow, &if_notoverflow);
+ } else {
+ // Check if {x} is already positive.
+ Label if_xispositive(this), if_xisnotpositive(this);
+ BranchIfSmiLessThanOrEqual(SmiConstant(Smi::FromInt(0)), x,
+ &if_xispositive, &if_xisnotpositive);
+
+ Bind(&if_xispositive);
+ {
+ // Just return the input {x}.
+ Return(x);
+ }
- Bind(&if_notoverflow);
+ Bind(&if_xisnotpositive);
{
- // There is a Smi representation for negated {x}.
- Node* result = Projection(0, pair);
- Return(BitcastWordToTagged(result));
+ // Try to negate the {x} value.
+ pair =
+ IntPtrSubWithOverflow(IntPtrConstant(0), BitcastTaggedToWord(x));
+ Node* overflow = Projection(1, pair);
+ Branch(overflow, &if_overflow, &if_notoverflow);
}
+ }
- Bind(&if_overflow);
- { Return(NumberConstant(0.0 - Smi::kMinValue)); }
+ Bind(&if_notoverflow);
+ {
+ // There is a Smi representation for negated {x}.
+ Node* result = Projection(0, pair);
+ Return(BitcastWordToTagged(result));
}
+
+ Bind(&if_overflow);
+ { Return(NumberConstant(0.0 - Smi::kMinValue)); }
}
Bind(&if_xisnotsmi);
« no previous file with comments | « no previous file | src/compiler/arm/instruction-selector-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698