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

Unified Diff: src/runtime/runtime-maths.cc

Issue 977923002: Use bit_cast for Runtime_Double{Hi,Lo}. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-maths.cc
diff --git a/src/runtime/runtime-maths.cc b/src/runtime/runtime-maths.cc
index 68dfa49af839abb99a6027e021a400e83f77f674..24b794cf21782e89c775d08abfdca6caeaa58137 100644
--- a/src/runtime/runtime-maths.cc
+++ b/src/runtime/runtime-maths.cc
@@ -34,9 +34,10 @@ RUNTIME_FUNCTION(Runtime_DoubleHi) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- uint64_t integer = double_to_uint64(x);
- integer = (integer >> 32) & 0xFFFFFFFFu;
- return *isolate->factory()->NewNumber(static_cast<int32_t>(integer));
+ uint64_t unsigned64 = double_to_uint64(x);
+ uint32_t unsigned32 = static_cast<uint32_t>(unsigned64 >> 32);
+ int32_t signed32 = bit_cast<int32_t, uint32_t>(unsigned32);
+ return *isolate->factory()->NewNumber(signed32);
}
@@ -44,8 +45,10 @@ RUNTIME_FUNCTION(Runtime_DoubleLo) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- return *isolate->factory()->NewNumber(
- static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu));
+ uint64_t unsigned64 = double_to_uint64(x);
+ uint32_t unsigned32 = static_cast<uint32_t>(unsigned64);
+ int32_t signed32 = bit_cast<int32_t, uint32_t>(unsigned32);
+ return *isolate->factory()->NewNumber(signed32);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698