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> r(execution_mode, MachineType::Int32(), | 41 TestingModule module(execution_mode); |
42 MachineType::Int32()); | 42 module.origin = kAsmJsOrigin; |
| 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> r(execution_mode, MachineType::Int32(), | 54 TestingModule module(execution_mode); |
54 MachineType::Int32()); | 55 module.origin = kAsmJsOrigin; |
| 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> r(execution_mode, MachineType::Int32(), | 67 TestingModule module(execution_mode); |
66 MachineType::Int32()); | 68 module.origin = kAsmJsOrigin; |
| 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> r(execution_mode, MachineType::Int32(), | 80 TestingModule module(execution_mode); |
78 MachineType::Int32()); | 81 module.origin = kAsmJsOrigin; |
| 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> r(execution_mode, MachineType::Float32()); | 93 TestingModule module(execution_mode); |
| 94 module.origin = kAsmJsOrigin; |
| 95 WasmRunner<int32_t> r(&module, MachineType::Float32()); |
90 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0))); | 96 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF32, WASM_GET_LOCAL(0))); |
91 | 97 |
92 FOR_FLOAT32_INPUTS(i) { | 98 FOR_FLOAT32_INPUTS(i) { |
93 int32_t expected = DoubleToInt32(*i); | 99 int32_t expected = DoubleToInt32(*i); |
94 CHECK_EQ(expected, r.Call(*i)); | 100 CHECK_EQ(expected, r.Call(*i)); |
95 } | 101 } |
96 } | 102 } |
97 | 103 |
98 WASM_EXEC_TEST(I32AsmjsSConvertF64) { | 104 WASM_EXEC_TEST(I32AsmjsSConvertF64) { |
99 WasmRunner<int32_t> r(execution_mode, MachineType::Float64()); | 105 TestingModule module(execution_mode); |
| 106 module.origin = kAsmJsOrigin; |
| 107 WasmRunner<int32_t> r(&module, MachineType::Float64()); |
100 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0))); | 108 BUILD(r, WASM_UNOP(kExprI32AsmjsSConvertF64, WASM_GET_LOCAL(0))); |
101 | 109 |
102 FOR_FLOAT64_INPUTS(i) { | 110 FOR_FLOAT64_INPUTS(i) { |
103 int32_t expected = DoubleToInt32(*i); | 111 int32_t expected = DoubleToInt32(*i); |
104 CHECK_EQ(expected, r.Call(*i)); | 112 CHECK_EQ(expected, r.Call(*i)); |
105 } | 113 } |
106 } | 114 } |
107 | 115 |
108 WASM_EXEC_TEST(I32AsmjsUConvertF32) { | 116 WASM_EXEC_TEST(I32AsmjsUConvertF32) { |
109 WasmRunner<uint32_t> r(execution_mode, MachineType::Float32()); | 117 TestingModule module(execution_mode); |
| 118 module.origin = kAsmJsOrigin; |
| 119 WasmRunner<uint32_t> r(&module, MachineType::Float32()); |
110 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0))); | 120 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF32, WASM_GET_LOCAL(0))); |
111 | 121 |
112 FOR_FLOAT32_INPUTS(i) { | 122 FOR_FLOAT32_INPUTS(i) { |
113 uint32_t expected = DoubleToUint32(*i); | 123 uint32_t expected = DoubleToUint32(*i); |
114 CHECK_EQ(expected, r.Call(*i)); | 124 CHECK_EQ(expected, r.Call(*i)); |
115 } | 125 } |
116 } | 126 } |
117 | 127 |
118 WASM_EXEC_TEST(I32AsmjsUConvertF64) { | 128 WASM_EXEC_TEST(I32AsmjsUConvertF64) { |
119 WasmRunner<uint32_t> r(execution_mode, MachineType::Float64()); | 129 TestingModule module(execution_mode); |
| 130 module.origin = kAsmJsOrigin; |
| 131 WasmRunner<uint32_t> r(&module, MachineType::Float64()); |
120 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0))); | 132 BUILD(r, WASM_UNOP(kExprI32AsmjsUConvertF64, WASM_GET_LOCAL(0))); |
121 | 133 |
122 FOR_FLOAT64_INPUTS(i) { | 134 FOR_FLOAT64_INPUTS(i) { |
123 uint32_t expected = DoubleToUint32(*i); | 135 uint32_t expected = DoubleToUint32(*i); |
124 CHECK_EQ(expected, r.Call(*i)); | 136 CHECK_EQ(expected, r.Call(*i)); |
125 } | 137 } |
126 } | 138 } |
127 | 139 |
128 WASM_EXEC_TEST(LoadMemI32_oob_asm) { | 140 WASM_EXEC_TEST(LoadMemI32_oob_asm) { |
129 TestingModule module(execution_mode); | 141 TestingModule module(execution_mode); |
| 142 module.origin = kAsmJsOrigin; |
130 int32_t* memory = module.AddMemoryElems<int32_t>(8); | 143 int32_t* memory = module.AddMemoryElems<int32_t>(8); |
131 WasmRunner<int32_t> r(&module, MachineType::Uint32()); | 144 WasmRunner<int32_t> r(&module, MachineType::Uint32()); |
132 module.RandomizeMemory(1112); | 145 module.RandomizeMemory(1112); |
133 | 146 |
134 BUILD(r, WASM_UNOP(kExprI32AsmjsLoadMem, WASM_GET_LOCAL(0))); | 147 BUILD(r, WASM_UNOP(kExprI32AsmjsLoadMem, WASM_GET_LOCAL(0))); |
135 | 148 |
136 memory[0] = 999999; | 149 memory[0] = 999999; |
137 CHECK_EQ(999999, r.Call(0u)); | 150 CHECK_EQ(999999, r.Call(0u)); |
138 // TODO(titzer): offset 29-31 should also be OOB. | 151 // TODO(titzer): offset 29-31 should also be OOB. |
139 for (uint32_t offset = 32; offset < 40; offset++) { | 152 for (uint32_t offset = 32; offset < 40; offset++) { |
140 CHECK_EQ(0, r.Call(offset)); | 153 CHECK_EQ(0, r.Call(offset)); |
141 } | 154 } |
142 | 155 |
143 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { | 156 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { |
144 CHECK_EQ(0, r.Call(offset)); | 157 CHECK_EQ(0, r.Call(offset)); |
145 } | 158 } |
146 } | 159 } |
147 | 160 |
148 WASM_EXEC_TEST(LoadMemF32_oob_asm) { | 161 WASM_EXEC_TEST(LoadMemF32_oob_asm) { |
149 TestingModule module(execution_mode); | 162 TestingModule module(execution_mode); |
| 163 module.origin = kAsmJsOrigin; |
150 float* memory = module.AddMemoryElems<float>(8); | 164 float* memory = module.AddMemoryElems<float>(8); |
151 WasmRunner<float> r(&module, MachineType::Uint32()); | 165 WasmRunner<float> r(&module, MachineType::Uint32()); |
152 module.RandomizeMemory(1112); | 166 module.RandomizeMemory(1112); |
153 | 167 |
154 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); | 168 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); |
155 | 169 |
156 memory[0] = 9999.5f; | 170 memory[0] = 9999.5f; |
157 CHECK_EQ(9999.5f, r.Call(0u)); | 171 CHECK_EQ(9999.5f, r.Call(0u)); |
158 // TODO(titzer): offset 29-31 should also be OOB. | 172 // TODO(titzer): offset 29-31 should also be OOB. |
159 for (uint32_t offset = 32; offset < 40; offset++) { | 173 for (uint32_t offset = 32; offset < 40; offset++) { |
160 CHECK(std::isnan(r.Call(offset))); | 174 CHECK(std::isnan(r.Call(offset))); |
161 } | 175 } |
162 | 176 |
163 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { | 177 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { |
164 CHECK(std::isnan(r.Call(offset))); | 178 CHECK(std::isnan(r.Call(offset))); |
165 } | 179 } |
166 } | 180 } |
167 | 181 |
168 WASM_EXEC_TEST(LoadMemF64_oob_asm) { | 182 WASM_EXEC_TEST(LoadMemF64_oob_asm) { |
169 TestingModule module(execution_mode); | 183 TestingModule module(execution_mode); |
| 184 module.origin = kAsmJsOrigin; |
170 double* memory = module.AddMemoryElems<double>(8); | 185 double* memory = module.AddMemoryElems<double>(8); |
171 WasmRunner<double> r(&module, MachineType::Uint32()); | 186 WasmRunner<double> r(&module, MachineType::Uint32()); |
172 module.RandomizeMemory(1112); | 187 module.RandomizeMemory(1112); |
173 | 188 |
174 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); | 189 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); |
175 | 190 |
176 memory[0] = 9799.5; | 191 memory[0] = 9799.5; |
177 CHECK_EQ(9799.5, r.Call(0u)); | 192 CHECK_EQ(9799.5, r.Call(0u)); |
178 memory[1] = 11799.25; | 193 memory[1] = 11799.25; |
179 CHECK_EQ(11799.25, r.Call(8u)); | 194 CHECK_EQ(11799.25, r.Call(8u)); |
180 // TODO(titzer): offset 57-63 should also be OOB. | 195 // TODO(titzer): offset 57-63 should also be OOB. |
181 for (uint32_t offset = 64; offset < 80; offset++) { | 196 for (uint32_t offset = 64; offset < 80; offset++) { |
182 CHECK(std::isnan(r.Call(offset))); | 197 CHECK(std::isnan(r.Call(offset))); |
183 } | 198 } |
184 | 199 |
185 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { | 200 for (uint32_t offset = 0x80000000; offset < 0x80000010; offset++) { |
186 CHECK(std::isnan(r.Call(offset))); | 201 CHECK(std::isnan(r.Call(offset))); |
187 } | 202 } |
188 } | 203 } |
189 | 204 |
190 WASM_EXEC_TEST(StoreMemI32_oob_asm) { | 205 WASM_EXEC_TEST(StoreMemI32_oob_asm) { |
191 TestingModule module(execution_mode); | 206 TestingModule module(execution_mode); |
| 207 module.origin = kAsmJsOrigin; |
192 int32_t* memory = module.AddMemoryElems<int32_t>(8); | 208 int32_t* memory = module.AddMemoryElems<int32_t>(8); |
193 WasmRunner<int32_t> r(&module, MachineType::Uint32(), MachineType::Uint32()); | 209 WasmRunner<int32_t> r(&module, MachineType::Uint32(), MachineType::Uint32()); |
194 module.RandomizeMemory(1112); | 210 module.RandomizeMemory(1112); |
195 | 211 |
196 BUILD(r, WASM_BINOP(kExprI32AsmjsStoreMem, WASM_GET_LOCAL(0), | 212 BUILD(r, WASM_BINOP(kExprI32AsmjsStoreMem, WASM_GET_LOCAL(0), |
197 WASM_GET_LOCAL(1))); | 213 WASM_GET_LOCAL(1))); |
198 | 214 |
199 memory[0] = 7777; | 215 memory[0] = 7777; |
200 CHECK_EQ(999999, r.Call(0u, 999999)); | 216 CHECK_EQ(999999, r.Call(0u, 999999)); |
201 CHECK_EQ(999999, memory[0]); | 217 CHECK_EQ(999999, memory[0]); |
(...skipping 15 matching lines...) Expand all Loading... |
217 TEST_BODY(kExprI32AsmjsLoadMem) | 233 TEST_BODY(kExprI32AsmjsLoadMem) |
218 | 234 |
219 #define FOREACH_INT_CHECKED_STORE_OP(TEST_BODY) \ | 235 #define FOREACH_INT_CHECKED_STORE_OP(TEST_BODY) \ |
220 TEST_BODY(kExprI32AsmjsStoreMem8) \ | 236 TEST_BODY(kExprI32AsmjsStoreMem8) \ |
221 TEST_BODY(kExprI32AsmjsStoreMem16) \ | 237 TEST_BODY(kExprI32AsmjsStoreMem16) \ |
222 TEST_BODY(kExprI32AsmjsStoreMem) | 238 TEST_BODY(kExprI32AsmjsStoreMem) |
223 | 239 |
224 #define INT_LOAD_TEST(OP_TYPE) \ | 240 #define INT_LOAD_TEST(OP_TYPE) \ |
225 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ | 241 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ |
226 TestingModule module(kExecuteCompiled); \ | 242 TestingModule module(kExecuteCompiled); \ |
| 243 module.origin = kAsmJsOrigin; \ |
227 WasmRunner<int32_t> r(&module, MachineType::Uint32()); \ | 244 WasmRunner<int32_t> r(&module, MachineType::Uint32()); \ |
228 BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \ | 245 BUILD(r, WASM_UNOP(OP_TYPE, WASM_GET_LOCAL(0))); \ |
229 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], \ | 246 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], \ |
230 RelocInfo::WASM_MEMORY_REFERENCE)); \ | 247 RelocInfo::WASM_MEMORY_REFERENCE)); \ |
231 CHECK_NE( \ | 248 CHECK_NE( \ |
232 0, GetMatchingRelocInfoCount(module.instance->function_code[0], \ | 249 0, GetMatchingRelocInfoCount(module.instance->function_code[0], \ |
233 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ | 250 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ |
234 } | 251 } |
235 | 252 |
236 FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST) | 253 FOREACH_INT_CHECKED_LOAD_OP(INT_LOAD_TEST) |
237 | 254 |
238 #define INT_STORE_TEST(OP_TYPE) \ | 255 #define INT_STORE_TEST(OP_TYPE) \ |
239 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ | 256 TEST(RunWasm_AsmCheckedRelocInfo##OP_TYPE) { \ |
240 TestingModule module(kExecuteCompiled); \ | 257 TestingModule module(kExecuteCompiled); \ |
| 258 module.origin = kAsmJsOrigin; \ |
241 WasmRunner<int32_t> r(&module, MachineType::Uint32(), \ | 259 WasmRunner<int32_t> r(&module, MachineType::Uint32(), \ |
242 MachineType::Uint32()); \ | 260 MachineType::Uint32()); \ |
243 BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \ | 261 BUILD(r, WASM_BINOP(OP_TYPE, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); \ |
244 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], \ | 262 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], \ |
245 RelocInfo::WASM_MEMORY_REFERENCE)); \ | 263 RelocInfo::WASM_MEMORY_REFERENCE)); \ |
246 CHECK_NE( \ | 264 CHECK_NE( \ |
247 0, GetMatchingRelocInfoCount(module.instance->function_code[0], \ | 265 0, GetMatchingRelocInfoCount(module.instance->function_code[0], \ |
248 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ | 266 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); \ |
249 } | 267 } |
250 | 268 |
251 FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST) | 269 FOREACH_INT_CHECKED_STORE_OP(INT_STORE_TEST) |
252 | 270 |
253 TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) { | 271 TEST(RunWasm_AsmCheckedLoadFloat32RelocInfo) { |
254 TestingModule module(kExecuteCompiled); | 272 TestingModule module(kExecuteCompiled); |
| 273 module.origin = kAsmJsOrigin; |
255 WasmRunner<float> r(&module, MachineType::Uint32()); | 274 WasmRunner<float> r(&module, MachineType::Uint32()); |
256 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); | 275 BUILD(r, WASM_UNOP(kExprF32AsmjsLoadMem, WASM_GET_LOCAL(0))); |
257 | 276 |
258 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], | 277 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], |
259 RelocInfo::WASM_MEMORY_REFERENCE)); | 278 RelocInfo::WASM_MEMORY_REFERENCE)); |
260 CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0], | 279 CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0], |
261 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); | 280 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
262 } | 281 } |
263 | 282 |
264 TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) { | 283 TEST(RunWasm_AsmCheckedStoreFloat32RelocInfo) { |
265 TestingModule module(kExecuteCompiled); | 284 TestingModule module(kExecuteCompiled); |
| 285 module.origin = kAsmJsOrigin; |
266 WasmRunner<float> r(&module, MachineType::Uint32(), MachineType::Float32()); | 286 WasmRunner<float> r(&module, MachineType::Uint32(), MachineType::Float32()); |
267 BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, WASM_GET_LOCAL(0), | 287 BUILD(r, WASM_BINOP(kExprF32AsmjsStoreMem, WASM_GET_LOCAL(0), |
268 WASM_GET_LOCAL(1))); | 288 WASM_GET_LOCAL(1))); |
269 | 289 |
270 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], | 290 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], |
271 RelocInfo::WASM_MEMORY_REFERENCE)); | 291 RelocInfo::WASM_MEMORY_REFERENCE)); |
272 CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0], | 292 CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0], |
273 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); | 293 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
274 } | 294 } |
275 | 295 |
276 TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) { | 296 TEST(RunWasm_AsmCheckedLoadFloat64RelocInfo) { |
277 TestingModule module(kExecuteCompiled); | 297 TestingModule module(kExecuteCompiled); |
| 298 module.origin = kAsmJsOrigin; |
278 WasmRunner<double> r(&module, MachineType::Uint32()); | 299 WasmRunner<double> r(&module, MachineType::Uint32()); |
279 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); | 300 BUILD(r, WASM_UNOP(kExprF64AsmjsLoadMem, WASM_GET_LOCAL(0))); |
280 | 301 |
281 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], | 302 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], |
282 RelocInfo::WASM_MEMORY_REFERENCE)); | 303 RelocInfo::WASM_MEMORY_REFERENCE)); |
283 CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0], | 304 CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0], |
284 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); | 305 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
285 } | 306 } |
286 | 307 |
287 TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) { | 308 TEST(RunWasm_AsmCheckedStoreFloat64RelocInfo) { |
288 TestingModule module(kExecuteCompiled); | 309 TestingModule module(kExecuteCompiled); |
| 310 module.origin = kAsmJsOrigin; |
289 WasmRunner<double> r(&module, MachineType::Uint32(), MachineType::Float64()); | 311 WasmRunner<double> r(&module, MachineType::Uint32(), MachineType::Float64()); |
290 BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, WASM_GET_LOCAL(0), | 312 BUILD(r, WASM_BINOP(kExprF64AsmjsStoreMem, WASM_GET_LOCAL(0), |
291 WASM_GET_LOCAL(1))); | 313 WASM_GET_LOCAL(1))); |
292 | 314 |
293 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], | 315 CHECK_EQ(1, GetMatchingRelocInfoCount(module.instance->function_code[0], |
294 RelocInfo::WASM_MEMORY_REFERENCE)); | 316 RelocInfo::WASM_MEMORY_REFERENCE)); |
295 CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0], | 317 CHECK_NE(0, GetMatchingRelocInfoCount(module.instance->function_code[0], |
296 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); | 318 RelocInfo::WASM_MEMORY_SIZE_REFERENCE)); |
297 } | 319 } |
OLD | NEW |