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

Side by Side Diff: test/cctest/wasm/test-run-wasm.cc

Issue 2105313002: [wasm] Detect unrepresentability in the float32-to-int32 conversion correctly on arm. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Define the bounds properly in variables. Created 4 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 unified diff | Download patch
« no previous file with comments | « test/cctest/compiler/value-helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdint.h> 5 #include <stdint.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "src/base/platform/elapsed-timer.h" 9 #include "src/base/platform/elapsed-timer.h"
10 10
(...skipping 2713 matching lines...) Expand 10 before | Expand all | Expand 10 after
2724 CHECK_EQ(0x7ff800000000f1e2, bit_cast<uint64_t>(r.Call())); 2724 CHECK_EQ(0x7ff800000000f1e2, bit_cast<uint64_t>(r.Call()));
2725 } 2725 }
2726 } 2726 }
2727 2727
2728 #endif 2728 #endif
2729 2729
2730 WASM_EXEC_TEST(I32SConvertF32) { 2730 WASM_EXEC_TEST(I32SConvertF32) {
2731 WasmRunner<int32_t> r(execution_mode, MachineType::Float32()); 2731 WasmRunner<int32_t> r(execution_mode, MachineType::Float32());
2732 BUILD(r, WASM_I32_SCONVERT_F32(WASM_GET_LOCAL(0))); 2732 BUILD(r, WASM_I32_SCONVERT_F32(WASM_GET_LOCAL(0)));
2733 2733
2734 // The upper bound is (INT32_MAX + 1), which is the lowest float-representable
2735 // number above INT32_MAX which cannot be represented as int32.
2736 float upper_bound = 2147483648.0f;
2737 // We use INT32_MIN as a lower bound because (INT32_MIN - 1) is not
2738 // representable as float, and no number between (INT32_MIN - 1) and INT32_MIN
2739 // is.
2740 float lower_bound = static_cast<float>(INT32_MIN);
2734 FOR_FLOAT32_INPUTS(i) { 2741 FOR_FLOAT32_INPUTS(i) {
2735 if (*i < static_cast<float>(INT32_MAX) && 2742 if (*i < upper_bound && *i >= lower_bound) {
2736 *i >= static_cast<float>(INT32_MIN)) {
2737 CHECK_EQ(static_cast<int32_t>(*i), r.Call(*i)); 2743 CHECK_EQ(static_cast<int32_t>(*i), r.Call(*i));
2738 } else { 2744 } else {
2739 CHECK_TRAP32(r.Call(*i)); 2745 CHECK_TRAP32(r.Call(*i));
2740 } 2746 }
2741 } 2747 }
2742 } 2748 }
2743 2749
2744 WASM_EXEC_TEST(I32SConvertF64) { 2750 WASM_EXEC_TEST(I32SConvertF64) {
2745 WasmRunner<int32_t> r(execution_mode, MachineType::Float64()); 2751 WasmRunner<int32_t> r(execution_mode, MachineType::Float64());
2746 BUILD(r, WASM_I32_SCONVERT_F64(WASM_GET_LOCAL(0))); 2752 BUILD(r, WASM_I32_SCONVERT_F64(WASM_GET_LOCAL(0)));
2747 2753
2754 // The upper bound is (INT32_MAX + 1), which is the lowest double-
2755 // representable number above INT32_MAX which cannot be represented as int32.
2756 double upper_bound = 2147483648.0;
2757 // The lower bound is (INT32_MIN - 1), which is the greatest double-
2758 // representable number below INT32_MIN which cannot be represented as int32.
2759 double lower_bound = -2147483649.0;
2748 FOR_FLOAT64_INPUTS(i) { 2760 FOR_FLOAT64_INPUTS(i) {
2749 if (*i < (static_cast<double>(INT32_MAX) + 1.0) && 2761 if (*i<upper_bound&& * i> lower_bound) {
2750 *i > (static_cast<double>(INT32_MIN) - 1.0)) { 2762 CHECK_EQ(static_cast<int32_t>(*i), r.Call(*i));
2751 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i));
2752 } else { 2763 } else {
2753 CHECK_TRAP32(r.Call(*i)); 2764 CHECK_TRAP32(r.Call(*i));
2754 } 2765 }
2755 } 2766 }
2756 } 2767 }
2757 2768
2758 WASM_EXEC_TEST(I32UConvertF32) { 2769 WASM_EXEC_TEST(I32UConvertF32) {
2759 WasmRunner<uint32_t> r(execution_mode, MachineType::Float32()); 2770 WasmRunner<uint32_t> r(execution_mode, MachineType::Float32());
2760 BUILD(r, WASM_I32_UCONVERT_F32(WASM_GET_LOCAL(0))); 2771 BUILD(r, WASM_I32_UCONVERT_F32(WASM_GET_LOCAL(0)));
2761 2772 // The upper bound is (UINT32_MAX + 1), which is the lowest
2773 // float-representable number above UINT32_MAX which cannot be represented as
2774 // uint32.
2775 double upper_bound = 4294967296.0f;
2776 double lower_bound = -1.0f;
2762 FOR_FLOAT32_INPUTS(i) { 2777 FOR_FLOAT32_INPUTS(i) {
2763 if (*i < (static_cast<float>(UINT32_MAX) + 1.0) && *i > -1) { 2778 if (*i<upper_bound&& * i> lower_bound) {
2764 CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i)); 2779 CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i));
2765 } else { 2780 } else {
2766 CHECK_TRAP32(r.Call(*i)); 2781 CHECK_TRAP32(r.Call(*i));
2767 } 2782 }
2768 } 2783 }
2769 } 2784 }
2770 2785
2771 WASM_EXEC_TEST(I32UConvertF64) { 2786 WASM_EXEC_TEST(I32UConvertF64) {
2772 WasmRunner<uint32_t> r(execution_mode, MachineType::Float64()); 2787 WasmRunner<uint32_t> r(execution_mode, MachineType::Float64());
2773 BUILD(r, WASM_I32_UCONVERT_F64(WASM_GET_LOCAL(0))); 2788 BUILD(r, WASM_I32_UCONVERT_F64(WASM_GET_LOCAL(0)));
2774 2789 // The upper bound is (UINT32_MAX + 1), which is the lowest
2790 // double-representable number above UINT32_MAX which cannot be represented as
2791 // uint32.
2792 double upper_bound = 4294967296.0;
2793 double lower_bound = -1.0;
2775 FOR_FLOAT64_INPUTS(i) { 2794 FOR_FLOAT64_INPUTS(i) {
2776 if (*i < (static_cast<float>(UINT32_MAX) + 1.0) && *i > -1) { 2795 if (*i<upper_bound&& * i> lower_bound) {
2777 CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i)); 2796 CHECK_EQ(static_cast<uint32_t>(*i), r.Call(*i));
2778 } else { 2797 } else {
2779 CHECK_TRAP32(r.Call(*i)); 2798 CHECK_TRAP32(r.Call(*i));
2780 } 2799 }
2781 } 2800 }
2782 } 2801 }
2783 2802
2784 WASM_EXEC_TEST(F64CopySign) { 2803 WASM_EXEC_TEST(F64CopySign) {
2785 WasmRunner<double> r(execution_mode, MachineType::Float64(), 2804 WasmRunner<double> r(execution_mode, MachineType::Float64(),
2786 MachineType::Float64()); 2805 MachineType::Float64());
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2841 MachineType::Int32()); 2860 MachineType::Int32());
2842 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO); 2861 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_ZERO);
2843 const int32_t kMin = std::numeric_limits<int32_t>::min(); 2862 const int32_t kMin = std::numeric_limits<int32_t>::min();
2844 CHECK_EQ(0, r.Call(133, 100)); 2863 CHECK_EQ(0, r.Call(133, 100));
2845 CHECK_EQ(0, r.Call(kMin, -1)); 2864 CHECK_EQ(0, r.Call(kMin, -1));
2846 CHECK_EQ(0, r.Call(0, 1)); 2865 CHECK_EQ(0, r.Call(0, 1));
2847 CHECK_TRAP(r.Call(100, 0)); 2866 CHECK_TRAP(r.Call(100, 0));
2848 CHECK_TRAP(r.Call(-1001, 0)); 2867 CHECK_TRAP(r.Call(-1001, 0));
2849 CHECK_TRAP(r.Call(kMin, 0)); 2868 CHECK_TRAP(r.Call(kMin, 0));
2850 } 2869 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/value-helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698