| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 __ Ret(); \ | 159 __ Ret(); \ |
| 160 __ GetCode(NULL); | 160 __ GetCode(NULL); |
| 161 | 161 |
| 162 #define TEARDOWN() \ | 162 #define TEARDOWN() \ |
| 163 delete pdis; \ | 163 delete pdis; \ |
| 164 delete[] buf; | 164 delete[] buf; |
| 165 | 165 |
| 166 #else // ifdef USE_SIMULATOR. | 166 #else // ifdef USE_SIMULATOR. |
| 167 // Run the test on real hardware or models. | 167 // Run the test on real hardware or models. |
| 168 #define SETUP_SIZE(buf_size) \ | 168 #define SETUP_SIZE(buf_size) \ |
| 169 Isolate* isolate = Isolate::Current(); \ |
| 170 HandleScope scope(isolate); \ |
| 171 ASSERT(isolate != NULL); \ |
| 169 byte* buf = new byte[buf_size]; \ | 172 byte* buf = new byte[buf_size]; \ |
| 170 MacroAssembler masm(isolate, buf, buf_size); \ | 173 MacroAssembler masm(isolate, buf, buf_size); \ |
| 171 RegisterDump core; \ | 174 RegisterDump core; \ |
| 172 CPU::SetUp(); | 175 CPU::SetUp(); |
| 173 | 176 |
| 174 #define RESET() \ | 177 #define RESET() \ |
| 175 __ Reset(); | 178 __ Reset(); |
| 176 | 179 |
| 177 #define START_AFTER_RESET() \ | 180 #define START_AFTER_RESET() \ |
| 178 __ SetStackPointer(csp); \ | 181 __ SetStackPointer(csp); \ |
| (...skipping 5603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5782 // Note that this test only checks ties-to-even rounding, because that is all | 5785 // Note that this test only checks ties-to-even rounding, because that is all |
| 5783 // that the simulator supports. | 5786 // that the simulator supports. |
| 5784 struct {double in; float expected;} test[] = { | 5787 struct {double in; float expected;} test[] = { |
| 5785 // Check some simple conversions. | 5788 // Check some simple conversions. |
| 5786 {0.0, 0.0f}, | 5789 {0.0, 0.0f}, |
| 5787 {1.0, 1.0f}, | 5790 {1.0, 1.0f}, |
| 5788 {1.5, 1.5f}, | 5791 {1.5, 1.5f}, |
| 5789 {2.0, 2.0f}, | 5792 {2.0, 2.0f}, |
| 5790 {FLT_MAX, FLT_MAX}, | 5793 {FLT_MAX, FLT_MAX}, |
| 5791 // - The smallest normalized float. | 5794 // - The smallest normalized float. |
| 5792 {pow(2, -126), powf(2, -126)}, | 5795 {pow(2.0, -126), powf(2, -126)}, |
| 5793 // - Normal floats that need (ties-to-even) rounding. | 5796 // - Normal floats that need (ties-to-even) rounding. |
| 5794 // For normalized numbers: | 5797 // For normalized numbers: |
| 5795 // bit 29 (0x0000000020000000) is the lowest-order bit which will | 5798 // bit 29 (0x0000000020000000) is the lowest-order bit which will |
| 5796 // fit in the float's mantissa. | 5799 // fit in the float's mantissa. |
| 5797 {rawbits_to_double(0x3ff0000000000000), rawbits_to_float(0x3f800000)}, | 5800 {rawbits_to_double(0x3ff0000000000000), rawbits_to_float(0x3f800000)}, |
| 5798 {rawbits_to_double(0x3ff0000000000001), rawbits_to_float(0x3f800000)}, | 5801 {rawbits_to_double(0x3ff0000000000001), rawbits_to_float(0x3f800000)}, |
| 5799 {rawbits_to_double(0x3ff0000010000000), rawbits_to_float(0x3f800000)}, | 5802 {rawbits_to_double(0x3ff0000010000000), rawbits_to_float(0x3f800000)}, |
| 5800 {rawbits_to_double(0x3ff0000010000001), rawbits_to_float(0x3f800001)}, | 5803 {rawbits_to_double(0x3ff0000010000001), rawbits_to_float(0x3f800001)}, |
| 5801 {rawbits_to_double(0x3ff0000020000000), rawbits_to_float(0x3f800001)}, | 5804 {rawbits_to_double(0x3ff0000020000000), rawbits_to_float(0x3f800001)}, |
| 5802 {rawbits_to_double(0x3ff0000020000001), rawbits_to_float(0x3f800001)}, | 5805 {rawbits_to_double(0x3ff0000020000001), rawbits_to_float(0x3f800001)}, |
| 5803 {rawbits_to_double(0x3ff0000030000000), rawbits_to_float(0x3f800002)}, | 5806 {rawbits_to_double(0x3ff0000030000000), rawbits_to_float(0x3f800002)}, |
| 5804 {rawbits_to_double(0x3ff0000030000001), rawbits_to_float(0x3f800002)}, | 5807 {rawbits_to_double(0x3ff0000030000001), rawbits_to_float(0x3f800002)}, |
| 5805 {rawbits_to_double(0x3ff0000040000000), rawbits_to_float(0x3f800002)}, | 5808 {rawbits_to_double(0x3ff0000040000000), rawbits_to_float(0x3f800002)}, |
| 5806 {rawbits_to_double(0x3ff0000040000001), rawbits_to_float(0x3f800002)}, | 5809 {rawbits_to_double(0x3ff0000040000001), rawbits_to_float(0x3f800002)}, |
| 5807 {rawbits_to_double(0x3ff0000050000000), rawbits_to_float(0x3f800002)}, | 5810 {rawbits_to_double(0x3ff0000050000000), rawbits_to_float(0x3f800002)}, |
| 5808 {rawbits_to_double(0x3ff0000050000001), rawbits_to_float(0x3f800003)}, | 5811 {rawbits_to_double(0x3ff0000050000001), rawbits_to_float(0x3f800003)}, |
| 5809 {rawbits_to_double(0x3ff0000060000000), rawbits_to_float(0x3f800003)}, | 5812 {rawbits_to_double(0x3ff0000060000000), rawbits_to_float(0x3f800003)}, |
| 5810 // - A mantissa that overflows into the exponent during rounding. | 5813 // - A mantissa that overflows into the exponent during rounding. |
| 5811 {rawbits_to_double(0x3feffffff0000000), rawbits_to_float(0x3f800000)}, | 5814 {rawbits_to_double(0x3feffffff0000000), rawbits_to_float(0x3f800000)}, |
| 5812 // - The largest double that rounds to a normal float. | 5815 // - The largest double that rounds to a normal float. |
| 5813 {rawbits_to_double(0x47efffffefffffff), rawbits_to_float(0x7f7fffff)}, | 5816 {rawbits_to_double(0x47efffffefffffff), rawbits_to_float(0x7f7fffff)}, |
| 5814 | 5817 |
| 5815 // Doubles that are too big for a float. | 5818 // Doubles that are too big for a float. |
| 5816 {kFP64PositiveInfinity, kFP32PositiveInfinity}, | 5819 {kFP64PositiveInfinity, kFP32PositiveInfinity}, |
| 5817 {DBL_MAX, kFP32PositiveInfinity}, | 5820 {DBL_MAX, kFP32PositiveInfinity}, |
| 5818 // - The smallest exponent that's too big for a float. | 5821 // - The smallest exponent that's too big for a float. |
| 5819 {pow(2, 128), kFP32PositiveInfinity}, | 5822 {pow(2.0, 128), kFP32PositiveInfinity}, |
| 5820 // - This exponent is in range, but the value rounds to infinity. | 5823 // - This exponent is in range, but the value rounds to infinity. |
| 5821 {rawbits_to_double(0x47effffff0000000), kFP32PositiveInfinity}, | 5824 {rawbits_to_double(0x47effffff0000000), kFP32PositiveInfinity}, |
| 5822 | 5825 |
| 5823 // Doubles that are too small for a float. | 5826 // Doubles that are too small for a float. |
| 5824 // - The smallest (subnormal) double. | 5827 // - The smallest (subnormal) double. |
| 5825 {DBL_MIN, 0.0}, | 5828 {DBL_MIN, 0.0}, |
| 5826 // - The largest double which is too small for a subnormal float. | 5829 // - The largest double which is too small for a subnormal float. |
| 5827 {rawbits_to_double(0x3690000000000000), rawbits_to_float(0x00000000)}, | 5830 {rawbits_to_double(0x3690000000000000), rawbits_to_float(0x00000000)}, |
| 5828 | 5831 |
| 5829 // Normal doubles that become subnormal floats. | 5832 // Normal doubles that become subnormal floats. |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6786 } | 6789 } |
| 6787 | 6790 |
| 6788 END(); | 6791 END(); |
| 6789 RUN(); | 6792 RUN(); |
| 6790 | 6793 |
| 6791 // Check the results. | 6794 // Check the results. |
| 6792 double expected_scvtf_base = rawbits_to_double(expected_scvtf_bits); | 6795 double expected_scvtf_base = rawbits_to_double(expected_scvtf_bits); |
| 6793 double expected_ucvtf_base = rawbits_to_double(expected_ucvtf_bits); | 6796 double expected_ucvtf_base = rawbits_to_double(expected_ucvtf_bits); |
| 6794 | 6797 |
| 6795 for (int fbits = 0; fbits <= 32; fbits++) { | 6798 for (int fbits = 0; fbits <= 32; fbits++) { |
| 6796 double expected_scvtf = expected_scvtf_base / pow(2, fbits); | 6799 double expected_scvtf = expected_scvtf_base / pow(2.0, fbits); |
| 6797 double expected_ucvtf = expected_ucvtf_base / pow(2, fbits); | 6800 double expected_ucvtf = expected_ucvtf_base / pow(2.0, fbits); |
| 6798 ASSERT_EQUAL_FP64(expected_scvtf, results_scvtf_x[fbits]); | 6801 ASSERT_EQUAL_FP64(expected_scvtf, results_scvtf_x[fbits]); |
| 6799 ASSERT_EQUAL_FP64(expected_ucvtf, results_ucvtf_x[fbits]); | 6802 ASSERT_EQUAL_FP64(expected_ucvtf, results_ucvtf_x[fbits]); |
| 6800 if (cvtf_s32) ASSERT_EQUAL_FP64(expected_scvtf, results_scvtf_w[fbits]); | 6803 if (cvtf_s32) ASSERT_EQUAL_FP64(expected_scvtf, results_scvtf_w[fbits]); |
| 6801 if (cvtf_u32) ASSERT_EQUAL_FP64(expected_ucvtf, results_ucvtf_w[fbits]); | 6804 if (cvtf_u32) ASSERT_EQUAL_FP64(expected_ucvtf, results_ucvtf_w[fbits]); |
| 6802 } | 6805 } |
| 6803 for (int fbits = 33; fbits <= 64; fbits++) { | 6806 for (int fbits = 33; fbits <= 64; fbits++) { |
| 6804 double expected_scvtf = expected_scvtf_base / pow(2, fbits); | 6807 double expected_scvtf = expected_scvtf_base / pow(2.0, fbits); |
| 6805 double expected_ucvtf = expected_ucvtf_base / pow(2, fbits); | 6808 double expected_ucvtf = expected_ucvtf_base / pow(2.0, fbits); |
| 6806 ASSERT_EQUAL_FP64(expected_scvtf, results_scvtf_x[fbits]); | 6809 ASSERT_EQUAL_FP64(expected_scvtf, results_scvtf_x[fbits]); |
| 6807 ASSERT_EQUAL_FP64(expected_ucvtf, results_ucvtf_x[fbits]); | 6810 ASSERT_EQUAL_FP64(expected_ucvtf, results_ucvtf_x[fbits]); |
| 6808 } | 6811 } |
| 6809 | 6812 |
| 6810 TEARDOWN(); | 6813 TEARDOWN(); |
| 6811 } | 6814 } |
| 6812 | 6815 |
| 6813 | 6816 |
| 6814 TEST(scvtf_ucvtf_double) { | 6817 TEST(scvtf_ucvtf_double) { |
| 6815 INIT_V8(); | 6818 INIT_V8(); |
| (...skipping 2558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9374 TEST(ecma_262_to_int32) { | 9377 TEST(ecma_262_to_int32) { |
| 9375 INIT_V8(); | 9378 INIT_V8(); |
| 9376 // ==== exponent < 64 ==== | 9379 // ==== exponent < 64 ==== |
| 9377 | 9380 |
| 9378 ECMA262ToInt32Helper(0, 0.0); | 9381 ECMA262ToInt32Helper(0, 0.0); |
| 9379 ECMA262ToInt32Helper(0, -0.0); | 9382 ECMA262ToInt32Helper(0, -0.0); |
| 9380 ECMA262ToInt32Helper(1, 1.0); | 9383 ECMA262ToInt32Helper(1, 1.0); |
| 9381 ECMA262ToInt32Helper(-1, -1.0); | 9384 ECMA262ToInt32Helper(-1, -1.0); |
| 9382 | 9385 |
| 9383 // The largest representable value that is less than 1. | 9386 // The largest representable value that is less than 1. |
| 9384 ECMA262ToInt32Helper(0, 0x001fffffffffffff * pow(2, -53)); | 9387 ECMA262ToInt32Helper(0, 0x001fffffffffffff * pow(2.0, -53)); |
| 9385 ECMA262ToInt32Helper(0, 0x001fffffffffffff * -pow(2, -53)); | 9388 ECMA262ToInt32Helper(0, 0x001fffffffffffff * -pow(2.0, -53)); |
| 9386 ECMA262ToInt32Helper(0, std::numeric_limits<double>::denorm_min()); | 9389 ECMA262ToInt32Helper(0, std::numeric_limits<double>::denorm_min()); |
| 9387 ECMA262ToInt32Helper(0, -std::numeric_limits<double>::denorm_min()); | 9390 ECMA262ToInt32Helper(0, -std::numeric_limits<double>::denorm_min()); |
| 9388 | 9391 |
| 9389 // The largest conversion which doesn't require the integer modulo-2^32 step. | 9392 // The largest conversion which doesn't require the integer modulo-2^32 step. |
| 9390 ECMA262ToInt32Helper(0x7fffffff, 0x7fffffff); | 9393 ECMA262ToInt32Helper(0x7fffffff, 0x7fffffff); |
| 9391 ECMA262ToInt32Helper(-0x80000000, -0x80000000); | 9394 ECMA262ToInt32Helper(-0x80000000, -0x80000000); |
| 9392 | 9395 |
| 9393 // The largest simple conversion, requiring module-2^32, but where the fcvt | 9396 // The largest simple conversion, requiring module-2^32, but where the fcvt |
| 9394 // does not saturate when converting to int64_t. | 9397 // does not saturate when converting to int64_t. |
| 9395 ECMA262ToInt32Helper(0xfffffc00, 0x7ffffffffffffc00); | 9398 ECMA262ToInt32Helper(0xfffffc00, 0x7ffffffffffffc00); |
| 9396 ECMA262ToInt32Helper(-0xfffffc00, 0x7ffffffffffffc00 * -1.0); | 9399 ECMA262ToInt32Helper(-0xfffffc00, 0x7ffffffffffffc00 * -1.0); |
| 9397 | 9400 |
| 9398 // ==== 64 <= exponent < 84 ==== | 9401 // ==== 64 <= exponent < 84 ==== |
| 9399 | 9402 |
| 9400 // The smallest conversion where the fcvt saturates. | 9403 // The smallest conversion where the fcvt saturates. |
| 9401 ECMA262ToInt32Helper(0, 0x8000000000000000); | 9404 ECMA262ToInt32Helper(0, 0x8000000000000000); |
| 9402 ECMA262ToInt32Helper(0, 0x8000000000000000 * -1.0); | 9405 ECMA262ToInt32Helper(0, 0x8000000000000000 * -1.0); |
| 9403 | 9406 |
| 9404 // The smallest conversion where the fcvt saturates, and where all the | 9407 // The smallest conversion where the fcvt saturates, and where all the |
| 9405 // mantissa bits are '1' (to check the shift logic). | 9408 // mantissa bits are '1' (to check the shift logic). |
| 9406 ECMA262ToInt32Helper(0xfffff800, 0xfffffffffffff800); | 9409 ECMA262ToInt32Helper(0xfffff800, 0xfffffffffffff800); |
| 9407 ECMA262ToInt32Helper(-0xfffff800, 0xfffffffffffff800 * -1.0); | 9410 ECMA262ToInt32Helper(-0xfffff800, 0xfffffffffffff800 * -1.0); |
| 9408 | 9411 |
| 9409 // The largest conversion which doesn't produce a zero result. | 9412 // The largest conversion which doesn't produce a zero result. |
| 9410 ECMA262ToInt32Helper(0x80000000, 0x001fffffffffffff * pow(2, 31)); | 9413 ECMA262ToInt32Helper(0x80000000, 0x001fffffffffffff * pow(2.0, 31)); |
| 9411 ECMA262ToInt32Helper(-0x80000000, 0x001fffffffffffff * -pow(2, 31)); | 9414 ECMA262ToInt32Helper(-0x80000000, 0x001fffffffffffff * -pow(2.0, 31)); |
| 9412 | 9415 |
| 9413 // Some large conversions to check the shifting function. | 9416 // Some large conversions to check the shifting function. |
| 9414 ECMA262ToInt32Helper(0x6789abcd, 0x001123456789abcd); | 9417 ECMA262ToInt32Helper(0x6789abcd, 0x001123456789abcd); |
| 9415 ECMA262ToInt32Helper(0x12345678, 0x001123456789abcd * pow(2, -20)); | 9418 ECMA262ToInt32Helper(0x12345678, 0x001123456789abcd * pow(2.0, -20)); |
| 9416 ECMA262ToInt32Helper(0x891a2b3c, 0x001123456789abcd * pow(2, -21)); | 9419 ECMA262ToInt32Helper(0x891a2b3c, 0x001123456789abcd * pow(2.0, -21)); |
| 9417 ECMA262ToInt32Helper(0x11234567, 0x001123456789abcd * pow(2, -24)); | 9420 ECMA262ToInt32Helper(0x11234567, 0x001123456789abcd * pow(2.0, -24)); |
| 9418 ECMA262ToInt32Helper(-0x6789abcd, 0x001123456789abcd * -1.0); | 9421 ECMA262ToInt32Helper(-0x6789abcd, 0x001123456789abcd * -1.0); |
| 9419 ECMA262ToInt32Helper(-0x12345678, 0x001123456789abcd * -pow(2, -20)); | 9422 ECMA262ToInt32Helper(-0x12345678, 0x001123456789abcd * -pow(2.0, -20)); |
| 9420 ECMA262ToInt32Helper(-0x891a2b3c, 0x001123456789abcd * -pow(2, -21)); | 9423 ECMA262ToInt32Helper(-0x891a2b3c, 0x001123456789abcd * -pow(2.0, -21)); |
| 9421 ECMA262ToInt32Helper(-0x11234567, 0x001123456789abcd * -pow(2, -24)); | 9424 ECMA262ToInt32Helper(-0x11234567, 0x001123456789abcd * -pow(2.0, -24)); |
| 9422 | 9425 |
| 9423 // ==== 84 <= exponent ==== | 9426 // ==== 84 <= exponent ==== |
| 9424 | 9427 |
| 9425 // The smallest conversion which produces a zero result by shifting the | 9428 // The smallest conversion which produces a zero result by shifting the |
| 9426 // mantissa out of the int32_t range. | 9429 // mantissa out of the int32_t range. |
| 9427 ECMA262ToInt32Helper(0, pow(2, 32)); | 9430 ECMA262ToInt32Helper(0, pow(2.0, 32)); |
| 9428 ECMA262ToInt32Helper(0, -pow(2, 32)); | 9431 ECMA262ToInt32Helper(0, -pow(2.0, 32)); |
| 9429 | 9432 |
| 9430 // Some very large conversions. | 9433 // Some very large conversions. |
| 9431 ECMA262ToInt32Helper(0, 0x001fffffffffffff * pow(2, 32)); | 9434 ECMA262ToInt32Helper(0, 0x001fffffffffffff * pow(2.0, 32)); |
| 9432 ECMA262ToInt32Helper(0, 0x001fffffffffffff * -pow(2, 32)); | 9435 ECMA262ToInt32Helper(0, 0x001fffffffffffff * -pow(2.0, 32)); |
| 9433 ECMA262ToInt32Helper(0, DBL_MAX); | 9436 ECMA262ToInt32Helper(0, DBL_MAX); |
| 9434 ECMA262ToInt32Helper(0, -DBL_MAX); | 9437 ECMA262ToInt32Helper(0, -DBL_MAX); |
| 9435 | 9438 |
| 9436 // ==== Special values. ==== | 9439 // ==== Special values. ==== |
| 9437 | 9440 |
| 9438 ECMA262ToInt32Helper(0, std::numeric_limits<double>::infinity()); | 9441 ECMA262ToInt32Helper(0, std::numeric_limits<double>::infinity()); |
| 9439 ECMA262ToInt32Helper(0, -std::numeric_limits<double>::infinity()); | 9442 ECMA262ToInt32Helper(0, -std::numeric_limits<double>::infinity()); |
| 9440 ECMA262ToInt32Helper(0, std::numeric_limits<double>::quiet_NaN()); | 9443 ECMA262ToInt32Helper(0, std::numeric_limits<double>::quiet_NaN()); |
| 9441 ECMA262ToInt32Helper(0, -std::numeric_limits<double>::quiet_NaN()); | 9444 ECMA262ToInt32Helper(0, -std::numeric_limits<double>::quiet_NaN()); |
| 9442 ECMA262ToInt32Helper(0, std::numeric_limits<double>::signaling_NaN()); | 9445 ECMA262ToInt32Helper(0, std::numeric_limits<double>::signaling_NaN()); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9563 AbsHelperX(-42); | 9566 AbsHelperX(-42); |
| 9564 AbsHelperX(kXMinInt); | 9567 AbsHelperX(kXMinInt); |
| 9565 AbsHelperX(kXMaxInt); | 9568 AbsHelperX(kXMaxInt); |
| 9566 | 9569 |
| 9567 AbsHelperW(0); | 9570 AbsHelperW(0); |
| 9568 AbsHelperW(42); | 9571 AbsHelperW(42); |
| 9569 AbsHelperW(-42); | 9572 AbsHelperW(-42); |
| 9570 AbsHelperW(kWMinInt); | 9573 AbsHelperW(kWMinInt); |
| 9571 AbsHelperW(kWMaxInt); | 9574 AbsHelperW(kWMaxInt); |
| 9572 } | 9575 } |
| OLD | NEW |