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

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

Issue 2361363002: [stubs] Add TruncationMode argument to ToInteger (Closed)
Patch Set: Simplify Created 4 years, 3 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') | no next file » | 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 bf1cd8f14202d2fc21f1fac758129ef20a313e93..83b36e24fb7da684dcc5d1d64fec48f489555323 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -2985,7 +2985,8 @@ Node* CodeStubAssembler::ToNumber(Node* context, Node* input) {
return var_result.value();
}
-Node* CodeStubAssembler::ToInteger(Node* context, Node* input) {
+Node* CodeStubAssembler::ToInteger(Node* context, Node* input,
+ ToIntegerTruncationMode mode) {
// We might need to loop once for ToNumber conversion.
Variable var_arg(this, MachineRepresentation::kTagged);
Label loop(this, &var_arg), out(this);
@@ -3018,6 +3019,12 @@ Node* CodeStubAssembler::ToInteger(Node* context, Node* input) {
// Truncate {arg} towards zero.
Node* value = Float64Trunc(arg_value);
+
+ if (mode == kTruncateMinusZero) {
+ // Truncate -0.0 to 0.
+ GotoIf(Float64Equal(value, Float64Constant(0.0)), &return_zero);
+ }
+
var_arg.Bind(ChangeFloat64ToTagged(value));
Goto(&out);
}
« no previous file with comments | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698