OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 20 matching lines...) Expand all Loading... |
31 int filter = 1 << rmode; | 31 int filter = 1 << rmode; |
32 uint32_t ret = 0; | 32 uint32_t ret = 0; |
33 for (RelocIterator it(*code, filter); !it.done(); it.next()) { | 33 for (RelocIterator it(*code, filter); !it.done(); it.next()) { |
34 ++ret; | 34 ++ret; |
35 } | 35 } |
36 return ret; | 36 return ret; |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 WASM_EXEC_TEST(Int32AsmjsDivS) { | 40 WASM_EXEC_TEST(Int32AsmjsDivS) { |
41 WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); | 41 TestingModule module(execution_mode); |
42 r.module().ChangeOriginToAsmjs(); | 42 module.ChangeOriginToAsmjs(); |
| 43 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); |
43 BUILD(r, WASM_BINOP(kExprI32AsmjsDivS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 44 BUILD(r, WASM_BINOP(kExprI32AsmjsDivS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
44 const int32_t kMin = std::numeric_limits<int32_t>::min(); | 45 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
45 CHECK_EQ(0, r.Call(0, 100)); | 46 CHECK_EQ(0, r.Call(0, 100)); |
46 CHECK_EQ(0, r.Call(100, 0)); | 47 CHECK_EQ(0, r.Call(100, 0)); |
47 CHECK_EQ(0, r.Call(-1001, 0)); | 48 CHECK_EQ(0, r.Call(-1001, 0)); |
48 CHECK_EQ(kMin, r.Call(kMin, -1)); | 49 CHECK_EQ(kMin, r.Call(kMin, -1)); |
49 CHECK_EQ(0, r.Call(kMin, 0)); | 50 CHECK_EQ(0, r.Call(kMin, 0)); |
50 } | 51 } |
51 | 52 |
52 WASM_EXEC_TEST(Int32AsmjsRemS) { | 53 WASM_EXEC_TEST(Int32AsmjsRemS) { |
53 WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); | 54 TestingModule module(execution_mode); |
54 r.module().ChangeOriginToAsmjs(); | 55 module.ChangeOriginToAsmjs(); |
| 56 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); |
55 BUILD(r, WASM_BINOP(kExprI32AsmjsRemS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 57 BUILD(r, WASM_BINOP(kExprI32AsmjsRemS, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
56 const int32_t kMin = std::numeric_limits<int32_t>::min(); | 58 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
57 CHECK_EQ(33, r.Call(133, 100)); | 59 CHECK_EQ(33, r.Call(133, 100)); |
58 CHECK_EQ(0, r.Call(kMin, -1)); | 60 CHECK_EQ(0, r.Call(kMin, -1)); |
59 CHECK_EQ(0, r.Call(100, 0)); | 61 CHECK_EQ(0, r.Call(100, 0)); |
60 CHECK_EQ(0, r.Call(-1001, 0)); | 62 CHECK_EQ(0, r.Call(-1001, 0)); |
61 CHECK_EQ(0, r.Call(kMin, 0)); | 63 CHECK_EQ(0, r.Call(kMin, 0)); |
62 } | 64 } |
63 | 65 |
64 WASM_EXEC_TEST(Int32AsmjsDivU) { | 66 WASM_EXEC_TEST(Int32AsmjsDivU) { |
65 WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); | 67 TestingModule module(execution_mode); |
66 r.module().ChangeOriginToAsmjs(); | 68 module.ChangeOriginToAsmjs(); |
| 69 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); |
67 BUILD(r, WASM_BINOP(kExprI32AsmjsDivU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 70 BUILD(r, WASM_BINOP(kExprI32AsmjsDivU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
68 const int32_t kMin = std::numeric_limits<int32_t>::min(); | 71 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
69 CHECK_EQ(0, r.Call(0, 100)); | 72 CHECK_EQ(0, r.Call(0, 100)); |
70 CHECK_EQ(0, r.Call(kMin, -1)); | 73 CHECK_EQ(0, r.Call(kMin, -1)); |
71 CHECK_EQ(0, r.Call(100, 0)); | 74 CHECK_EQ(0, r.Call(100, 0)); |
72 CHECK_EQ(0, r.Call(-1001, 0)); | 75 CHECK_EQ(0, r.Call(-1001, 0)); |
73 CHECK_EQ(0, r.Call(kMin, 0)); | 76 CHECK_EQ(0, r.Call(kMin, 0)); |
74 } | 77 } |
75 | 78 |
76 WASM_EXEC_TEST(Int32AsmjsRemU) { | 79 WASM_EXEC_TEST(Int32AsmjsRemU) { |
77 WasmRunner<int32_t, int32_t, int32_t> r(execution_mode); | 80 TestingModule module(execution_mode); |
78 r.module().ChangeOriginToAsmjs(); | 81 module.ChangeOriginToAsmjs(); |
| 82 WasmRunner<int32_t> r(&module, MachineType::Int32(), MachineType::Int32()); |
79 BUILD(r, WASM_BINOP(kExprI32AsmjsRemU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 83 BUILD(r, WASM_BINOP(kExprI32AsmjsRemU, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
80 const int32_t kMin = std::numeric_limits<int32_t>::min(); | 84 const int32_t kMin = std::numeric_limits<int32_t>::min(); |
81 CHECK_EQ(17, r.Call(217, 100)); | 85 CHECK_EQ(17, r.Call(217, 100)); |
82 CHECK_EQ(0, r.Call(100, 0)); | 86 CHECK_EQ(0, r.Call(100, 0)); |
83 CHECK_EQ(0, r.Call(-1001, 0)); | 87 CHECK_EQ(0, r.Call(-1001, 0)); |
84 CHECK_EQ(0, r.Call(kMin, 0)); | 88 CHECK_EQ(0, r.Call(kMin, 0)); |
85 CHECK_EQ(kMin, r.Call(kMin, -1)); | 89 CHECK_EQ(kMin, r.Call(kMin, -1)); |
86 } | 90 } |
87 | 91 |
88 WASM_EXEC_TEST(I32AsmjsSConvertF32) { | 92 WASM_EXEC_TEST(I32AsmjsSConvertF32) { |
89 WasmRunner<int32_t, float> r(execution_mode); | 93 TestingModule module(execution_mode); |
90 r.module().ChangeOriginToAsmjs(); | 94 module.ChangeOriginToAsmjs(); |
| 95 WasmRunner<int32_t> r(&module, MachineType::Float32()); |
91 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0))); | 96 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0))); |
92 | 97 |
93 FOR_FLOAT32_INPUTS(i) { | 98 FOR_FLOAT32_INPUTS(i) { |
94 int32_t expected = DoubleToInt32(*i); | 99 int32_t expected = DoubleToInt32(*i); |
95 CHECK_EQ(expected, r.Call(*i)); | 100 CHECK_EQ(expected, r.Call(*i)); |
96 } | 101 } |
97 } | 102 } |
98 | 103 |
99 WASM_EXEC_TEST(I32AsmjsSConvertF64) { | 104 WASM_EXEC_TEST(I32AsmjsSConvertF64) { |
100 WasmRunner<int32_t, double> r(execution_mode); | 105 TestingModule module(execution_mode); |
101 r.module().ChangeOriginToAsmjs(); | 106 module.ChangeOriginToAsmjs(); |
| 107 WasmRunner<int32_t> r(&module, MachineType::Float64()); |
102 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0))); | 108 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0))); |
103 | 109 |
104 FOR_FLOAT64_INPUTS(i) { | 110 FOR_FLOAT64_INPUTS(i) { |
105 int32_t expected = DoubleToInt32(*i); | 111 int32_t expected = DoubleToInt32(*i); |
106 CHECK_EQ(expected, r.Call(*i)); | 112 CHECK_EQ(expected, r.Call(*i)); |
107 } | 113 } |
108 } | 114 } |
109 | 115 |
110 WASM_EXEC_TEST(I32AsmjsUConvertF32) { | 116 WASM_EXEC_TEST(I32AsmjsUConvertF32) { |
111 WasmRunner<uint32_t, float> r(execution_mode); | 117 TestingModule module(execution_mode); |
112 r.module().ChangeOriginToAsmjs(); | 118 module.ChangeOriginToAsmjs(); |
| 119 WasmRunner<uint32_t> r(&module, MachineType::Float32()); |
113 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0))); | 120 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0))); |
114 | 121 |
115 FOR_FLOAT32_INPUTS(i) { | 122 FOR_FLOAT32_INPUTS(i) { |
116 uint32_t expected = DoubleToUint32(*i); | 123 uint32_t expected = DoubleToUint32(*i); |
117 CHECK_EQ(expected, r.Call(*i)); | 124 CHECK_EQ(expected, r.Call(*i)); |
118 } | 125 } |
119 } | 126 } |
120 | 127 |
121 WASM_EXEC_TEST(I32AsmjsUConvertF64) { | 128 WASM_EXEC_TEST(I32AsmjsUConvertF64) { |
122 WasmRunner<uint32_t, double> r(execution_mode); | 129 TestingModule module(execution_mode); |
123 r.module().ChangeOriginToAsmjs(); | 130 module.ChangeOriginToAsmjs(); |
| 131 WasmRunner<uint32_t> r(&module, MachineType::Float64()); |
124 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0))); | 132 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0))); |
125 | 133 |
126 FOR_FLOAT64_INPUTS(i) { | 134 FOR_FLOAT64_INPUTS(i) { |
127 uint32_t expected = DoubleToUint32(*i); | 135 uint32_t expected = DoubleToUint32(*i); |
128 CHECK_EQ(expected, r.Call(*i)); | 136 CHECK_EQ(expected, r.Call(*i)); |
129 } | 137 } |
130 } | 138 } |
131 | 139 |
132 WASM_EXEC_TEST(LoadMemI32_oob_asm) { | 140 WASM_EXEC_TEST(LoadMemI32_oob_asm) { |
133 WasmRunner<int32_t, uint32_t> r(execution_mode); | 141 TestingModule module(execution_mode); |
134 r.module().ChangeOriginToAsmjs(); | 142 module.ChangeOriginToAsmjs(); |
135 int32_t* memory = r.module().AddMemoryElems<int32_t>(8); | 143 int32_t* memory = module.AddMemoryElems<int32_t>(8); |
136 r.module().RandomizeMemory(1112); | 144 WasmRunner<int32_t> r(&module, MachineType::Uint32()); |
| 145 module.RandomizeMemory(1112); |
137 | 146 |
138 BUILD(r, WASM_UNOP(kExprI32AsmjsLoadMem, WASM_GET_LOCAL(0))); | 147 BUILD(r, WASM_UNOP(kExprI32AsmjsLoadMem, WASM_GET_LOCAL(0))); |
139 | 148 |
140 memory[0] = 999999; | 149 memory[0] = 999999; |
141 CHECK_EQ(999999, r.Call(0u)); | 150 CHECK_EQ(999999, r.Call(0u)); |
142 // TODO(titzer): offset 29-31 should also be OOB. | 151 // TODO(titzer): offset 29-31 should also be OOB. |
143 for (uint32_t offset = 32; offset < 40; offset++) { | 152 for (uint32_t offset = 32; offset < 40; offset++) { |
144 CHECK_EQ(0, r.Call(offset)); | 153 CHECK_EQ(0, r.Call(offset)); |
145 } | 154 } |
146 | 155 |
147 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { | 156 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { |
148 CHECK_EQ(0, r.Call(offset)); | 157 CHECK_EQ(0, r.Call(offset)); |
149 } | 158 } |
150 } | 159 } |
151 | 160 |
152 WASM_EXEC_TEST(LoadMemF32_oob_asm) { | 161 WASM_EXEC_TEST(LoadMemF32_oob_asm) { |
153 WasmRunner<float, uint32_t> r(execution_mode); | 162 TestingModule module(execution_mode); |
154 r.module().ChangeOriginToAsmjs(); | 163 module.ChangeOriginToAsmjs(); |
155 float* memory = r.module().AddMemoryElems<float>(8); | 164 float* memory = module.AddMemoryElems<float>(8); |
156 r.module().RandomizeMemory(1112); | 165 WasmRunner<float> r(&module, MachineType::Uint32()); |
| 166 module.RandomizeMemory(1112); |
157 | 167 |
158 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); | 168 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); |
159 | 169 |
160 memory[0] = 9999.5f; | 170 memory[0] = 9999.5f; |
161 CHECK_EQ(9999.5f, r.Call(0u)); | 171 CHECK_EQ(9999.5f, r.Call(0u)); |
162 // TODO(titzer): offset 29-31 should also be OOB. | 172 // TODO(titzer): offset 29-31 should also be OOB. |
163 for (uint32_t offset = 32; offset < 40; offset++) { | 173 for (uint32_t offset = 32; offset < 40; offset++) { |
164 CHECK(std::isnan(r.Call(offset))); | 174 CHECK(std::isnan(r.Call(offset))); |
165 } | 175 } |
166 | 176 |
167 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { | 177 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { |
168 CHECK(std::isnan(r.Call(offset))); | 178 CHECK(std::isnan(r.Call(offset))); |
169 } | 179 } |
170 } | 180 } |
171 | 181 |
172 WASM_EXEC_TEST(LoadMemF64_oob_asm) { | 182 WASM_EXEC_TEST(LoadMemF64_oob_asm) { |
173 WasmRunner<double, uint32_t> r(execution_mode); | 183 TestingModule module(execution_mode); |
174 r.module().ChangeOriginToAsmjs(); | 184 module.ChangeOriginToAsmjs(); |
175 double* memory = r.module().AddMemoryElems<double>(8); | 185 double* memory = module.AddMemoryElems<double>(8); |
176 r.module().RandomizeMemory(1112); | 186 WasmRunner<double> r(&module, MachineType::Uint32()); |
| 187 module.RandomizeMemory(1112); |
177 | 188 |
178 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); | 189 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); |
179 | 190 |
180 memory[0] = 9799.5; | 191 memory[0] = 9799.5; |
181 CHECK_EQ(9799.5, r.Call(0u)); | 192 CHECK_EQ(9799.5, r.Call(0u)); |
182 memory[1] = 11799.25; | 193 memory[1] = 11799.25; |
183 CHECK_EQ(11799.25, r.Call(8u)); | 194 CHECK_EQ(11799.25, r.Call(8u)); |
184 // TODO(titzer): offset 57-63 should also be OOB. | 195 // TODO(titzer): offset 57-63 should also be OOB. |
185 for (uint32_t offset = 64; offset < 80; offset++) { | 196 for (uint32_t offset = 64; offset < 80; offset++) { |
186 CHECK(std::isnan(r.Call(offset))); | 197 CHECK(std::isnan(r.Call(offset))); |
187 } | 198 } |
188 | 199 |
189 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { | 200 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { |
190 CHECK(std::isnan(r.Call(offset))); | 201 CHECK(std::isnan(r.Call(offset))); |
191 } | 202 } |
192 } | 203 } |
193 | 204 |
194 WASM_EXEC_TEST(StoreMemI32_oob_asm) { | 205 WASM_EXEC_TEST(StoreMemI32_oob_asm) { |
195 WasmRunner<int32_t, uint32_t, uint32_t> r(execution_mode); | 206 TestingModule module(execution_mode); |
196 r.module().ChangeOriginToAsmjs(); | 207 module.ChangeOriginToAsmjs(); |
197 int32_t* memory = r.module().AddMemoryElems<int32_t>(8); | 208 int32_t* memory = module.AddMemoryElems<int32_t>(8); |
198 r.module().RandomizeMemory(1112); | 209 WasmRunner<int32_t> r(&module, MachineType::Uint32(), MachineType::Uint32()); |
| 210 module.RandomizeMemory(1112); |
199 | 211 |
200 BUILD(r, WASM_BINOP(kExprI32AsmjsStoreMem, WASM_GET_LOCAL(0), | 212 BUILD(r, WASM_BINOP(kExprI32AsmjsStoreMem, WASM_GET_LOCAL(0), |
201 WASM_GET_LOCAL(1))); | 213 WASM_GET_LOCAL(1))); |
202 | 214 |
203 memory[0] = 7777; | 215 memory[0] = 7777; |
204 CHECK_EQ(999999, r.Call(0u, 999999)); | 216 CHECK_EQ(999999, r.Call(0u, 999999)); |
205 CHECK_EQ(999999, memory[0]); | 217 CHECK_EQ(999999, memory[0]); |
206 // TODO(titzer): offset 29-31 should also be OOB. | 218 // TODO(titzer): offset 29-31 should also be OOB. |
207 for (uint32_t offset = 32; offset < 40; offset++) { | 219 for (uint32_t offset = 32; offset < 40; offset++) { |
208 CHECK_EQ(8888, r.Call(offset, 8888)); | 220 CHECK_EQ(8888, r.Call(offset, 8888)); |
209 } | 221 } |
210 | 222 |
211 for (uint32_t offset = 0x10000000; offset < 0xF0000000; offset += 0x1000000) { | 223 for (uint32_t offset = 0x10000000; offset < 0xF0000000; offset += 0x1000000) { |
212 CHECK_EQ(7777, r.Call(offset, 7777)); | 224 CHECK_EQ(7777, r.Call(offset, 7777)); |
213 } | 225 } |
214 } | 226 } |
215 | 227 |
216 #define FOREACH_INT_CHECKED_LOAD_OP(TEST_BODY) \ | 228 #define FOREACH_INT_CHECKED_LOAD_OP(TEST_BODY) \ |
217 TEST_BODY(kExprI32AsmjsLoadMem8S) \ | 229 TEST_BODY(kExprI32AsmjsLoadMem8S) \ |
218 TEST_BODY(kExprI32AsmjsLoadMem8U) \ | 230 TEST_BODY(kExprI32AsmjsLoadMem8U) \ |
219 TEST_BODY(kExprI32AsmjsLoadMem16S) \ | 231 TEST_BODY(kExprI32AsmjsLoadMem16S) \ |
220 TEST_BODY(kExprI32AsmjsLoadMem16U) \ | 232 TEST_BODY(kExprI32AsmjsLoadMem16U) \ |
221 TEST_BODY(kExprI32AsmjsLoadMem) | 233 TEST_BODY(kExprI32AsmjsLoadMem) |
222 | 234 |
223 #define FOREACH_INT_CHECKED_STORE_OP(TEST_BODY) \ | 235 #define FOREACH_INT_CHECKED_STORE_OP(TEST_BODY) \ |
224 TEST_BODY(kExprI32AsmjsStoreMem8) \ | 236 TEST_BODY(kExprI32AsmjsStoreMem8) \ |
225 TEST_BODY(kExprI32AsmjsStoreMem16) \ | 237 TEST_BODY(kExprI32AsmjsStoreMem16) \ |
226 TEST_BODY(kExprI32AsmjsStoreMem) | 238 TEST_BODY(kExprI32AsmjsStoreMem) |
227 | 239 |
228 #define INT_LOAD_TEST(OP_TYPE) \ | 240 #define INT_LOAD_TEST(OP_TYPE) \ |
229 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ | 241 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ |
230 WasmRunner<int32_t, uint32_t> r(kExecuteCompiled); \ | 242 TestingModule module(kExecuteCompiled); \ |
231 r.module().ChangeOriginToAsmjs(); \ | 243 module.ChangeOriginToAsmjs(); \ |
232 BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \ | 244 WasmRunner<int32_t> r(&module, MachineType::Uint32()); \ |
233 CHECK_EQ(1, \ | 245 BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \ |
234 GetMatchingRelocInfoCount(r.module().instance->function_code[0], \ | 246 CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], \ |
235 RelocInfo::WASM_MEMORY_REFERENCE)); \ | 247 RelocInfo::WASM_MEMORY_REFERENCE)); \ |
236 CHECK_NE( \ | 248 CHECK_NE( \ |
237 0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], \ | 249 0u, GetMatchingRelocInfoCount(module.instance->function_code[0], \ |
238 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ | 250 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ |
239 } | 251 } |
240 | 252 |
241 FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST) | 253 FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST) |
242 | 254 |
243 #define INT_STORE_TEST(OP_TYPE) \ | 255 #define INT_STORE_TEST(OP_TYPE) \ |
244 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ | 256 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ |
245 WasmRunner<int32_t, uint32_t, uint32_t> r(kExecuteCompiled); \ | 257 TestingModule module(kExecuteCompiled); \ |
246 r.module().ChangeOriginToAsmjs(); \ | 258 module.ChangeOriginToAsmjs(); \ |
247 BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \ | 259 WasmRunner<int32_t> r(&module, MachineType::Uint32(), \ |
248 CHECK_EQ(1, \ | 260 MachineType::Uint32()); \ |
249 GetMatchingRelocInfoCount(r.module().instance->function_code[0], \ | 261 BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \ |
250 RelocInfo::WASM_MEMORY_REFERENCE)); \ | 262 CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], \ |
251 CHECK_NE( \ | 263 RelocInfo::WASM_MEMORY_REFERENCE)); \ |
252 0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], \ | 264 CHECK_NE( \ |
253 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ | 265 0u, GetMatchingRelocInfoCount(module.instance->function_code[0], \ |
| 266 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ |
254 } | 267 } |
255 | 268 |
256 FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST) | 269 FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST) |
257 | 270 |
258 TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) { | 271 TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) { |
259 WasmRunner<float, uint32_t> r(kExecuteCompiled); | 272 TestingModule module(kExecuteCompiled); |
260 r.module().ChangeOriginToAsmjs(); | 273 module.ChangeOriginToAsmjs(); |
| 274 WasmRunner<float> r(&module, MachineType::Uint32()); |
261 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); | 275 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); |
262 | 276 |
263 CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().instance->function_code[0], | 277 CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], |
264 RelocInfo::WASM_MEMORY_REFERENCE)); | 278 RelocInfo::WASM_MEMORY_REFERENCE)); |
265 CHECK_NE(0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], | 279 CHECK_NE(0u, |
266 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); | 280 GetMatchingRelocInfoCount(module.instance->function_code[0], |
| 281 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
267 } | 282 } |
268 | 283 |
269 TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) { | 284 TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) { |
270 WasmRunner<float, uint32_t, float> r(kExecuteCompiled); | 285 TestingModule module(kExecuteCompiled); |
271 r.module().ChangeOriginToAsmjs(); | 286 module.ChangeOriginToAsmjs(); |
| 287 WasmRunner<float> r(&module, MachineType::Uint32(), MachineType::Float32()); |
272 BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, WASM_GET_LOCAL(0), | 288 BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, WASM_GET_LOCAL(0), |
273 WASM_GET_LOCAL(1))); | 289 WASM_GET_LOCAL(1))); |
274 | 290 |
275 CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().instance->function_code[0], | 291 CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], |
276 RelocInfo::WASM_MEMORY_REFERENCE)); | 292 RelocInfo::WASM_MEMORY_REFERENCE)); |
277 CHECK_NE(0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], | 293 CHECK_NE(0u, |
278 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); | 294 GetMatchingRelocInfoCount(module.instance->function_code[0], |
| 295 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
279 } | 296 } |
280 | 297 |
281 TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) { | 298 TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) { |
282 WasmRunner<double, uint32_t> r(kExecuteCompiled); | 299 TestingModule module(kExecuteCompiled); |
283 r.module().ChangeOriginToAsmjs(); | 300 module.ChangeOriginToAsmjs(); |
| 301 WasmRunner<double> r(&module, MachineType::Uint32()); |
284 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); | 302 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); |
285 | 303 |
286 CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().instance->function_code[0], | 304 CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], |
287 RelocInfo::WASM_MEMORY_REFERENCE)); | 305 RelocInfo::WASM_MEMORY_REFERENCE)); |
288 CHECK_NE(0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], | 306 CHECK_NE(0u, |
289 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); | 307 GetMatchingRelocInfoCount(module.instance->function_code[0], |
| 308 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
290 } | 309 } |
291 | 310 |
292 TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) { | 311 TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) { |
293 WasmRunner<double, uint32_t, double> r(kExecuteCompiled); | 312 TestingModule module(kExecuteCompiled); |
294 r.module().ChangeOriginToAsmjs(); | 313 module.ChangeOriginToAsmjs(); |
| 314 WasmRunner<double> r(&module, MachineType::Uint32(), MachineType::Float64()); |
295 BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, WASM_GET_LOCAL(0), | 315 BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, WASM_GET_LOCAL(0), |
296 WASM_GET_LOCAL(1))); | 316 WASM_GET_LOCAL(1))); |
297 | 317 |
298 CHECK_EQ(1, GetMatchingRelocInfoCount(r.module().instance->function_code[0], | 318 CHECK_EQ(1u, GetMatchingRelocInfoCount(module.instance->function_code[0], |
299 RelocInfo::WASM_MEMORY_REFERENCE)); | 319 RelocInfo::WASM_MEMORY_REFERENCE)); |
300 CHECK_NE(0, GetMatchingRelocInfoCount(r.module().instance->function_code[0], | 320 CHECK_NE(0u, |
301 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); | 321 GetMatchingRelocInfoCount(module.instance->function_code[0], |
| 322 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
302 } | 323 } |
OLD | NEW |