| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 | 43 |
| 44 int STDCALL ConvertDToICVersion(double d) { | 44 int STDCALL ConvertDToICVersion(double d) { |
| 45 union { double d; uint32_t u[2]; } dbl; | 45 union { double d; uint32_t u[2]; } dbl; |
| 46 dbl.d = d; | 46 dbl.d = d; |
| 47 uint32_t exponent_bits = dbl.u[1]; | 47 uint32_t exponent_bits = dbl.u[1]; |
| 48 int32_t shifted_mask = static_cast<int32_t>(Double::kExponentMask >> 32); | 48 int32_t shifted_mask = static_cast<int32_t>(Double::kExponentMask >> 32); |
| 49 int32_t exponent = (((exponent_bits & shifted_mask) >> | 49 int32_t exponent = (((exponent_bits & shifted_mask) >> |
| 50 (Double::kPhysicalSignificandSize - 32)) - | 50 (Double::kPhysicalSignificandSize - 32)) - |
| 51 HeapNumber::kExponentBias); | 51 HeapNumber::kExponentBias); |
| 52 if (exponent < 0) { | |
| 53 return 0; | |
| 54 } | |
| 55 uint32_t unsigned_exponent = static_cast<uint32_t>(exponent); | 52 uint32_t unsigned_exponent = static_cast<uint32_t>(exponent); |
| 56 int result = 0; | 53 int result = 0; |
| 57 uint32_t max_exponent = | 54 uint32_t max_exponent = |
| 58 static_cast<uint32_t>(Double::kPhysicalSignificandSize); | 55 static_cast<uint32_t>(Double::kPhysicalSignificandSize); |
| 59 if (unsigned_exponent >= max_exponent) { | 56 if (unsigned_exponent >= max_exponent) { |
| 60 if ((exponent - Double::kPhysicalSignificandSize) < 32) { | 57 if ((exponent - Double::kPhysicalSignificandSize) < 32) { |
| 61 result = dbl.u[0] << (exponent - Double::kPhysicalSignificandSize); | 58 result = dbl.u[0] << (exponent - Double::kPhysicalSignificandSize); |
| 62 } | 59 } |
| 63 } else { | 60 } else { |
| 64 uint64_t big_result = | 61 uint64_t big_result = |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 RunOneTruncationTest(0.5, 0); | 106 RunOneTruncationTest(0.5, 0); |
| 110 RunOneTruncationTest(-0.5, 0); | 107 RunOneTruncationTest(-0.5, 0); |
| 111 RunOneTruncationTest(1.5, 1); | 108 RunOneTruncationTest(1.5, 1); |
| 112 RunOneTruncationTest(-1.5, -1); | 109 RunOneTruncationTest(-1.5, -1); |
| 113 RunOneTruncationTest(5.5, 5); | 110 RunOneTruncationTest(5.5, 5); |
| 114 RunOneTruncationTest(-5.0, -5); | 111 RunOneTruncationTest(-5.0, -5); |
| 115 RunOneTruncationTest(NaN, 0); | 112 RunOneTruncationTest(NaN, 0); |
| 116 RunOneTruncationTest(Infinity, 0); | 113 RunOneTruncationTest(Infinity, 0); |
| 117 RunOneTruncationTest(-NaN, 0); | 114 RunOneTruncationTest(-NaN, 0); |
| 118 RunOneTruncationTest(-Infinity, 0); | 115 RunOneTruncationTest(-Infinity, 0); |
| 119 RunOneTruncationTest(4.94065645841e-324, 0); | |
| 120 RunOneTruncationTest(-4.94065645841e-324, 0); | |
| 121 | 116 |
| 122 RunOneTruncationTest(0.9999999999999999, 0); | 117 RunOneTruncationTest(4.5036e+15, 0x1635E000); |
| 123 RunOneTruncationTest(-0.9999999999999999, 0); | |
| 124 RunOneTruncationTest(4294967296.0, 0); | |
| 125 RunOneTruncationTest(-4294967296.0, 0); | |
| 126 RunOneTruncationTest(9223372036854775000.0, 4294966272.0); | |
| 127 RunOneTruncationTest(-9223372036854775000.0, -4294966272.0); | |
| 128 RunOneTruncationTest(4.5036e+15, 372629504); | |
| 129 RunOneTruncationTest(-4.5036e+15, -372629504); | 118 RunOneTruncationTest(-4.5036e+15, -372629504); |
| 130 | 119 |
| 131 RunOneTruncationTest(287524199.5377777, 0x11234567); | |
| 132 RunOneTruncationTest(-287524199.5377777, -0x11234567); | |
| 133 RunOneTruncationTest(2300193596.302222, 2300193596.0); | |
| 134 RunOneTruncationTest(-2300193596.302222, -2300193596.0); | |
| 135 RunOneTruncationTest(4600387192.604444, 305419896); | |
| 136 RunOneTruncationTest(-4600387192.604444, -305419896); | |
| 137 RunOneTruncationTest(4823855600872397.0, 1737075661); | |
| 138 RunOneTruncationTest(-4823855600872397.0, -1737075661); | |
| 139 | |
| 140 RunOneTruncationTest(4503603922337791.0, -1); | 120 RunOneTruncationTest(4503603922337791.0, -1); |
| 141 RunOneTruncationTest(-4503603922337791.0, 1); | 121 RunOneTruncationTest(-4503603922337791.0, 1); |
| 142 RunOneTruncationTest(4503601774854143.0, 2147483647); | 122 RunOneTruncationTest(4503601774854143.0, 2147483647); |
| 143 RunOneTruncationTest(-4503601774854143.0, -2147483647); | 123 RunOneTruncationTest(-4503601774854143.0, -2147483647); |
| 144 RunOneTruncationTest(9007207844675582.0, -2); | 124 RunOneTruncationTest(9007207844675582.0, -2); |
| 145 RunOneTruncationTest(-9007207844675582.0, 2); | 125 RunOneTruncationTest(-9007207844675582.0, 2); |
| 146 | 126 |
| 147 RunOneTruncationTest(2.4178527921507624e+24, -536870912); | 127 RunOneTruncationTest(2.4178527921507624e+24, -536870912); |
| 148 RunOneTruncationTest(-2.4178527921507624e+24, 536870912); | 128 RunOneTruncationTest(-2.4178527921507624e+24, 536870912); |
| 149 RunOneTruncationTest(2.417853945072267e+24, -536870912); | 129 RunOneTruncationTest(2.417853945072267e+24, -536870912); |
| 150 RunOneTruncationTest(-2.417853945072267e+24, 536870912); | 130 RunOneTruncationTest(-2.417853945072267e+24, 536870912); |
| 151 | 131 |
| 152 RunOneTruncationTest(4.8357055843015248e+24, -1073741824); | 132 RunOneTruncationTest(4.8357055843015248e+24, -1073741824); |
| 153 RunOneTruncationTest(-4.8357055843015248e+24, 1073741824); | 133 RunOneTruncationTest(-4.8357055843015248e+24, 1073741824); |
| 154 RunOneTruncationTest(4.8357078901445341e+24, -1073741824); | 134 RunOneTruncationTest(4.8357078901445341e+24, -1073741824); |
| 155 RunOneTruncationTest(-4.8357078901445341e+24, 1073741824); | 135 RunOneTruncationTest(-4.8357078901445341e+24, 1073741824); |
| 156 | 136 |
| 157 RunOneTruncationTest(2147483647.0, 2147483647.0); | |
| 158 RunOneTruncationTest(-2147483648.0, -2147483648.0); | |
| 159 RunOneTruncationTest(9.6714111686030497e+24, -2147483648.0); | 137 RunOneTruncationTest(9.6714111686030497e+24, -2147483648.0); |
| 160 RunOneTruncationTest(-9.6714111686030497e+24, -2147483648.0); | 138 RunOneTruncationTest(-9.6714111686030497e+24, -2147483648.0); |
| 161 RunOneTruncationTest(9.6714157802890681e+24, -2147483648.0); | 139 RunOneTruncationTest(9.6714157802890681e+24, -2147483648.0); |
| 162 RunOneTruncationTest(-9.6714157802890681e+24, -2147483648.0); | 140 RunOneTruncationTest(-9.6714157802890681e+24, -2147483648.0); |
| 163 RunOneTruncationTest(1.9342813113834065e+25, 2147483648.0); | |
| 164 RunOneTruncationTest(-1.9342813113834065e+25, 2147483648.0); | |
| 165 | |
| 166 RunOneTruncationTest(3.868562622766813e+25, 0); | |
| 167 RunOneTruncationTest(-3.868562622766813e+25, 0); | |
| 168 RunOneTruncationTest(1.7976931348623157e+308, 0); | |
| 169 RunOneTruncationTest(-1.7976931348623157e+308, 0); | |
| 170 } | 141 } |
| 171 | 142 |
| 172 #undef NaN | 143 #undef NaN |
| 173 #undef Infinity | 144 #undef Infinity |
| 174 #undef RunOneTruncationTest | 145 #undef RunOneTruncationTest |
| OLD | NEW |