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

Unified Diff: test/cctest/test-code-stubs-ia32.cc

Issue 18333012: x64 support for d-to-i (truncated) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Feedback addressed Created 7 years, 5 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 | « test/cctest/test-code-stubs.cc ('k') | test/cctest/test-code-stubs-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-code-stubs-ia32.cc
diff --git a/test/cctest/test-code-stubs-ia32.cc b/test/cctest/test-code-stubs-ia32.cc
index 8e599b3741453df6e6b854cc5de45de04215832c..6f8de604715ad9a84dbadac6508c4c88c1ccda6c 100644
--- a/test/cctest/test-code-stubs-ia32.cc
+++ b/test/cctest/test-code-stubs-ia32.cc
@@ -33,110 +33,13 @@
#include "cctest.h"
#include "code-stubs.h"
+#include "test-code-stubs.h"
#include "factory.h"
#include "macro-assembler.h"
#include "platform.h"
-#if __GNUC__
-#define STDCALL __attribute__((stdcall))
-#else
-#define STDCALL __stdcall
-#endif
-
using namespace v8::internal;
-
-typedef int32_t STDCALL ConvertDToIFuncType(double input);
-typedef ConvertDToIFuncType* ConvertDToIFunc;
-
-
-int STDCALL ConvertDToICVersion(double d) {
- Address double_ptr = reinterpret_cast<Address>(&d);
- uint32_t exponent_bits = Memory::uint32_at(double_ptr + kDoubleSize / 2);
- int32_t shifted_mask = static_cast<int32_t>(Double::kExponentMask >> 32);
- int32_t exponent = (((exponent_bits & shifted_mask) >>
- (Double::kPhysicalSignificandSize - 32)) -
- HeapNumber::kExponentBias);
- uint32_t unsigned_exponent = static_cast<uint32_t>(exponent);
- int result = 0;
- uint32_t max_exponent =
- static_cast<uint32_t>(Double::kPhysicalSignificandSize);
- if (unsigned_exponent >= max_exponent) {
- if ((exponent - Double::kPhysicalSignificandSize) < 32) {
- result = Memory::uint32_at(double_ptr) <<
- (exponent - Double::kPhysicalSignificandSize);
- }
- } else {
- uint64_t big_result =
- (BitCast<uint64_t>(d) & Double::kSignificandMask) | Double::kHiddenBit;
- big_result = big_result >> (Double::kPhysicalSignificandSize - exponent);
- result = static_cast<uint32_t>(big_result);
- }
- if (static_cast<int32_t>(exponent_bits) < 0) {
- return (0 - result);
- } else {
- return result;
- }
-}
-
-
-void RunOneTruncationTestWithTest(ConvertDToIFunc func,
- double from,
- double raw) {
- uint64_t to = static_cast<int64_t>(raw);
- int result = (*func)(from);
- CHECK_EQ(static_cast<int>(to), result);
-}
-
-
-// #define NaN and Infinity so that it's possible to cut-and-paste these tests
-// directly to a .js file and run them.
-#define NaN (OS::nan_value())
-#define Infinity (std::numeric_limits<double>::infinity())
-#define RunOneTruncationTest(p1, p2) RunOneTruncationTestWithTest(func, p1, p2)
-
-void RunAllTruncationTests(ConvertDToIFunc func) {
- RunOneTruncationTest(0, 0);
- RunOneTruncationTest(0.5, 0);
- RunOneTruncationTest(-0.5, 0);
- RunOneTruncationTest(1.5, 1);
- RunOneTruncationTest(-1.5, -1);
- RunOneTruncationTest(5.5, 5);
- RunOneTruncationTest(-5.0, -5);
- RunOneTruncationTest(NaN, 0);
- RunOneTruncationTest(Infinity, 0);
- RunOneTruncationTest(-NaN, 0);
- RunOneTruncationTest(-Infinity, 0);
-
- RunOneTruncationTest(4.5036e+15, 0x1635E000);
- RunOneTruncationTest(-4.5036e+15, -372629504);
-
- RunOneTruncationTest(4503603922337791.0, -1);
- RunOneTruncationTest(-4503603922337791.0, 1);
- RunOneTruncationTest(4503601774854143.0, 2147483647);
- RunOneTruncationTest(-4503601774854143.0, -2147483647);
- RunOneTruncationTest(9007207844675582.0, -2);
- RunOneTruncationTest(-9007207844675582.0, 2);
- RunOneTruncationTest(2.4178527921507624e+24, -536870912);
- RunOneTruncationTest(-2.4178527921507624e+24, 536870912);
- RunOneTruncationTest(2.417853945072267e+24, -536870912);
- RunOneTruncationTest(-2.417853945072267e+24, 536870912);
-
- RunOneTruncationTest(4.8357055843015248e+24, -1073741824);
- RunOneTruncationTest(-4.8357055843015248e+24, 1073741824);
- RunOneTruncationTest(4.8357078901445341e+24, -1073741824);
- RunOneTruncationTest(-4.8357078901445341e+24, 1073741824);
-
- RunOneTruncationTest(9.6714111686030497e+24, -2147483648.0);
- RunOneTruncationTest(-9.6714111686030497e+24, -2147483648.0);
- RunOneTruncationTest(9.6714157802890681e+24, -2147483648.0);
- RunOneTruncationTest(-9.6714157802890681e+24, -2147483648.0);
-}
-
-#undef NaN
-#undef Infinity
-#undef RunOneTruncationTest
-
#define __ assm.
ConvertDToIFunc MakeConvertDToIFuncTrampoline(Isolate* isolate,
« no previous file with comments | « test/cctest/test-code-stubs.cc ('k') | test/cctest/test-code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698