OLD | NEW |
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 #include "src/utils.h" | 10 #include "src/utils.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 WASM_EXEC_TEST(Int32Const_many) { | 72 WASM_EXEC_TEST(Int32Const_many) { |
73 FOR_INT32_INPUTS(i) { | 73 FOR_INT32_INPUTS(i) { |
74 WasmRunner<int32_t> r(execution_mode); | 74 WasmRunner<int32_t> r(execution_mode); |
75 const int32_t kExpectedValue = *i; | 75 const int32_t kExpectedValue = *i; |
76 // return(kExpectedValue) | 76 // return(kExpectedValue) |
77 BUILD(r, WASM_I32V(kExpectedValue)); | 77 BUILD(r, WASM_I32V(kExpectedValue)); |
78 CHECK_EQ(kExpectedValue, r.Call()); | 78 CHECK_EQ(kExpectedValue, r.Call()); |
79 } | 79 } |
80 } | 80 } |
81 | 81 |
| 82 WASM_EXEC_TEST(MemorySize1) { |
| 83 TestingModule module(execution_mode); |
| 84 WasmRunner<int32_t> r(&module); |
| 85 module.AddMemory(WasmModule::kPageSize * 1); |
| 86 BUILD(r, kExprMemorySize); |
| 87 CHECK_EQ(1, r.Call()); |
| 88 } |
| 89 |
| 90 WASM_EXEC_TEST(MemorySize2) { |
| 91 TestingModule module(execution_mode); |
| 92 WasmRunner<int32_t> r(&module); |
| 93 module.AddMemory(WasmModule::kPageSize * 3); |
| 94 BUILD(r, kExprMemorySize); |
| 95 CHECK_EQ(3, r.Call()); |
| 96 } |
| 97 |
82 WASM_EXEC_TEST(Int32Param0) { | 98 WASM_EXEC_TEST(Int32Param0) { |
83 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); | 99 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
84 // return(local[0]) | 100 // return(local[0]) |
85 BUILD(r, WASM_GET_LOCAL(0)); | 101 BUILD(r, WASM_GET_LOCAL(0)); |
86 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } | 102 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, r.Call(*i)); } |
87 } | 103 } |
88 | 104 |
89 WASM_EXEC_TEST(Int32Param0_fallthru) { | 105 WASM_EXEC_TEST(Int32Param0_fallthru) { |
90 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); | 106 WasmRunner<int32_t> r(execution_mode, MachineType::Int32()); |
91 // local[0] | 107 // local[0] |
(...skipping 2773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2865 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP, | 2881 BUILD(r, WASM_I32_REMS(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)), WASM_DROP, |
2866 WASM_ZERO); | 2882 WASM_ZERO); |
2867 const int32_t kMin = std::numeric_limits<int32_t>::min(); | 2883 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
2868 CHECK_EQ(0, r.Call(133, 100)); | 2884 CHECK_EQ(0, r.Call(133, 100)); |
2869 CHECK_EQ(0, r.Call(kMin, -1)); | 2885 CHECK_EQ(0, r.Call(kMin, -1)); |
2870 CHECK_EQ(0, r.Call(0, 1)); | 2886 CHECK_EQ(0, r.Call(0, 1)); |
2871 CHECK_TRAP(r.Call(100, 0)); | 2887 CHECK_TRAP(r.Call(100, 0)); |
2872 CHECK_TRAP(r.Call(-1001, 0)); | 2888 CHECK_TRAP(r.Call(-1001, 0)); |
2873 CHECK_TRAP(r.Call(kMin, 0)); | 2889 CHECK_TRAP(r.Call(kMin, 0)); |
2874 } | 2890 } |
OLD | NEW |