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

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

Issue 2805783003: [csa] Fix CSA::ToUint32 rounding for negative HeapNumbers (Closed)
Patch Set: Fix Smi::IsValid test Created 3 years, 8 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 | test/cctest/compiler/function-tester.h » ('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 5ec80a78b933b4b2be3fcadb8c940271cefe419f..4cdbd01d99db583c379cd6caa8fb8d8a8c0d55ce 100644
--- a/src/code-stub-assembler.cc
+++ b/src/code-stub-assembler.cc
@@ -4060,6 +4060,7 @@ Node* CodeStubAssembler::ToNumber(Node* context, Node* input) {
return var_result.value();
}
+// ES#sec-touint32
Node* CodeStubAssembler::ToUint32(Node* context, Node* input) {
Node* const float_zero = Float64Constant(0.0);
Node* const float_two_32 = Float64Constant(static_cast<double>(1ULL << 32));
@@ -4137,10 +4138,12 @@ Node* CodeStubAssembler::ToUint32(Node* context, Node* input) {
BIND(&next);
}
- // Return floor({input}) mod 2^32 (assuming mod semantics that always return
- // positive results).
+ // * Let int be the mathematical value that is the same sign as number and
+ // whose magnitude is floor(abs(number)).
+ // * Let int32bit be int modulo 2^32.
+ // * Return int32bit.
{
- Node* x = Float64Floor(value);
+ Node* x = Float64Trunc(value);
x = Float64Mod(x, float_two_32);
x = Float64Add(x, float_two_32);
x = Float64Mod(x, float_two_32);
« no previous file with comments | « no previous file | test/cctest/compiler/function-tester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698