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