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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include "src/base/utils/random-number-generator.h" | |
9 | |
8 #include "src/compiler/graph-visualizer.h" | 10 #include "src/compiler/graph-visualizer.h" |
9 #include "src/compiler/js-graph.h" | 11 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/wasm-compiler.h" | 12 #include "src/compiler/wasm-compiler.h" |
11 | 13 |
12 #include "src/wasm/ast-decoder.h" | 14 #include "src/wasm/ast-decoder.h" |
13 #include "src/wasm/wasm-macro-gen.h" | 15 #include "src/wasm/wasm-macro-gen.h" |
14 #include "src/wasm/wasm-module.h" | 16 #include "src/wasm/wasm-module.h" |
15 #include "src/wasm/wasm-opcodes.h" | 17 #include "src/wasm/wasm-opcodes.h" |
16 | 18 |
17 #include "test/cctest/cctest.h" | 19 #include "test/cctest/cctest.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 module = nullptr; | 69 module = nullptr; |
68 linker = nullptr; | 70 linker = nullptr; |
69 function_code = nullptr; | 71 function_code = nullptr; |
70 asm_js = false; | 72 asm_js = false; |
71 } | 73 } |
72 | 74 |
73 ~TestingModule() { | 75 ~TestingModule() { |
74 if (mem_start) { | 76 if (mem_start) { |
75 free(raw_mem_start<byte>()); | 77 free(raw_mem_start<byte>()); |
76 } | 78 } |
77 if (module) { | 79 if (function_code) delete function_code; |
78 if (module->globals) delete module->globals; | 80 if (module) delete module; |
79 if (module->signatures) delete module->signatures; | |
80 if (module->functions) delete module->functions; | |
81 if (globals_area) free(reinterpret_cast<byte*>(globals_area)); | |
82 delete module; | |
83 } | |
84 } | 81 } |
85 | 82 |
86 byte* AddMemory(size_t size) { | 83 byte* AddMemory(size_t size) { |
87 CHECK_EQ(0, mem_start); | 84 CHECK_EQ(0, mem_start); |
88 CHECK_EQ(0, mem_size); | 85 CHECK_EQ(0, mem_size); |
89 mem_start = reinterpret_cast<uintptr_t>(malloc(size)); | 86 mem_start = reinterpret_cast<uintptr_t>(malloc(size)); |
90 CHECK(mem_start); | 87 CHECK(mem_start); |
91 memset(raw_mem_start<byte>(), 0, size); | 88 byte* raw = raw_mem_start<byte>(); |
89 memset(raw, 0, size); | |
92 mem_end = mem_start + size; | 90 mem_end = mem_start + size; |
93 mem_size = size; | 91 mem_size = size; |
94 return raw_mem_start<byte>(); | 92 return raw_mem_start<byte>(); |
95 } | 93 } |
96 | 94 |
97 template <typename T> | 95 template <typename T> |
98 T* AddMemoryElems(size_t count) { | 96 T* AddMemoryElems(size_t count) { |
99 AddMemory(count * sizeof(T)); | 97 AddMemory(count * sizeof(T)); |
100 return raw_mem_start<T>(); | 98 return raw_mem_start<T>(); |
101 } | 99 } |
(...skipping 16 matching lines...) Expand all Loading... | |
118 } | 116 } |
119 | 117 |
120 template <typename T> | 118 template <typename T> |
121 T* raw_mem_start() { | 119 T* raw_mem_start() { |
122 DCHECK(mem_start); | 120 DCHECK(mem_start); |
123 return reinterpret_cast<T*>(mem_start); | 121 return reinterpret_cast<T*>(mem_start); |
124 } | 122 } |
125 | 123 |
126 template <typename T> | 124 template <typename T> |
127 T* raw_mem_end() { | 125 T* raw_mem_end() { |
128 DCHECK(mem_start); | 126 DCHECK(mem_end); |
129 return reinterpret_cast<T*>(mem_end); | 127 return reinterpret_cast<T*>(mem_end); |
130 } | 128 } |
131 | 129 |
132 template <typename T> | 130 template <typename T> |
133 T raw_mem_at(int i) { | 131 T raw_mem_at(int i) { |
134 DCHECK(mem_start); | 132 DCHECK(mem_start); |
135 return reinterpret_cast<T*>(mem_start)[i]; | 133 return reinterpret_cast<T*>(mem_start)[i]; |
136 } | 134 } |
137 | 135 |
138 template <typename T> | 136 template <typename T> |
139 T raw_val_at(int i) { | 137 T raw_val_at(int i) { |
140 T val; | 138 T val; |
141 memcpy(&val, reinterpret_cast<void*>(mem_start + i), sizeof(T)); | 139 memcpy(&val, reinterpret_cast<void*>(mem_start + i), sizeof(T)); |
142 return val; | 140 return val; |
143 } | 141 } |
144 | 142 |
145 // Zero-initialize the memory. | 143 // Zero-initialize the memory. |
146 void ZeroMemory() { memset(raw_mem_start<byte>(), 0, mem_size); } | 144 void BlankMemory() { |
145 byte* raw = raw_mem_start<byte>(); | |
146 memset(raw, 0, mem_size); | |
147 } | |
147 | 148 |
148 // Pseudo-randomly intialize the memory. | 149 // Pseudo-randomly intialize the memory. |
149 void RandomizeMemory(unsigned seed = 88) { | 150 void RandomizeMemory(unsigned int seed = 88) { |
150 byte* raw = raw_mem_start<byte>(); | 151 byte* raw = raw_mem_start<byte>(); |
151 byte* end = raw_mem_end<byte>(); | 152 byte* end = raw_mem_end<byte>(); |
152 while (raw < end) { | 153 v8::base::RandomNumberGenerator rng; |
153 *raw = static_cast<byte>(rand_r(&seed)); | 154 rng.SetSeed(seed); |
154 raw++; | 155 rng.NextBytes(raw, end - raw); |
155 } | |
156 } | 156 } |
157 | 157 |
158 WasmFunction* AddFunction(FunctionSig* sig, Handle<Code> code) { | 158 WasmFunction* AddFunction(FunctionSig* sig, Handle<Code> code) { |
159 AllocModule(); | 159 AllocModule(); |
160 if (module->functions == nullptr) { | 160 if (module->functions == nullptr) { |
161 module->functions = new std::vector<WasmFunction>(); | 161 module->functions = new std::vector<WasmFunction>(); |
162 function_code = new std::vector<Handle<Code>>(); | 162 function_code = new std::vector<Handle<Code>>(); |
163 } | 163 } |
164 module->functions->push_back({sig, 0, 0, 0, 0, 0, 0, 0, false, false}); | 164 module->functions->push_back({sig, 0, 0, 0, 0, 0, 0, 0, false, false}); |
165 function_code->push_back(code); | 165 function_code->push_back(code); |
166 return &module->functions->back(); | 166 return &module->functions->back(); |
167 } | 167 } |
168 | 168 |
169 private: | 169 private: |
170 size_t mem_size; | 170 size_t mem_size; |
171 unsigned global_offset; | 171 unsigned int global_offset; |
172 byte global_data[kMaxGlobalsSize]; | |
172 | 173 |
173 WasmGlobal* AddGlobal(MachineType mem_type) { | 174 WasmGlobal* AddGlobal(MachineType mem_type) { |
174 AllocModule(); | 175 AllocModule(); |
175 if (globals_area == 0) { | 176 if (globals_area == 0) { |
176 globals_area = reinterpret_cast<uintptr_t>(malloc(kMaxGlobalsSize)); | 177 globals_area = reinterpret_cast<uintptr_t>(global_data); |
177 module->globals = new std::vector<WasmGlobal>(); | 178 module->globals = new std::vector<WasmGlobal>(); |
178 } | 179 } |
179 byte size = WasmOpcodes::MemSize(mem_type); | 180 byte size = WasmOpcodes::MemSize(mem_type); |
180 global_offset = (global_offset + size - 1) & ~(size - 1); // align | 181 global_offset = (global_offset + size - 1) & ~(size - 1); // align |
181 module->globals->push_back({0, mem_type, global_offset, false}); | 182 module->globals->push_back({0, mem_type, global_offset, false}); |
182 global_offset += size; | 183 global_offset += size; |
183 CHECK_LT(global_offset, kMaxGlobalsSize); // limit number of globals. | 184 // limit number of globals. |
185 CHECK_LT(global_offset, static_cast<unsigned int>(kMaxGlobalsSize)); | |
184 return &module->globals->back(); | 186 return &module->globals->back(); |
185 } | 187 } |
186 void AllocModule() { | 188 void AllocModule() { |
187 if (module == nullptr) { | 189 if (module == nullptr) { |
188 module = new WasmModule(); | 190 module = new WasmModule(); |
189 module->globals = nullptr; | 191 module->globals = nullptr; |
190 module->functions = nullptr; | 192 module->functions = nullptr; |
191 module->data_segments = nullptr; | 193 module->data_segments = nullptr; |
192 } | 194 } |
193 } | 195 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 byte b = static_cast<byte>(result); | 244 byte b = static_cast<byte>(result); |
243 CHECK_EQ(result, b); | 245 CHECK_EQ(result, b); |
244 return b; | 246 return b; |
245 } | 247 } |
246 | 248 |
247 Handle<Code> Compile(ModuleEnv* module) { | 249 Handle<Code> Compile(ModuleEnv* module) { |
248 descriptor_ = module->GetWasmCallDescriptor(this->zone(), env.sig); | 250 descriptor_ = module->GetWasmCallDescriptor(this->zone(), env.sig); |
249 CompilationInfo info("wasm compile", this->isolate(), this->zone()); | 251 CompilationInfo info("wasm compile", this->isolate(), this->zone()); |
250 Handle<Code> result = | 252 Handle<Code> result = |
251 Pipeline::GenerateCodeForTesting(&info, descriptor_, this->graph()); | 253 Pipeline::GenerateCodeForTesting(&info, descriptor_, this->graph()); |
252 #if DEBUG | 254 #ifdef ENABLE_DISASSEMBLER |
253 if (!result.is_null() && FLAG_print_opt_code) { | 255 if (!result.is_null() && FLAG_print_opt_code) { |
254 OFStream os(stdout); | 256 OFStream os(stdout); |
255 result->Disassemble("wasm code", os); | 257 result->Disassemble("wasm code", os); |
256 } | 258 } |
257 #endif | 259 #endif |
258 | 260 |
259 return result; | 261 return result; |
260 } | 262 } |
261 | 263 |
262 unsigned CompileAndAdd(TestingModule* module) { | 264 unsigned int CompileAndAdd(TestingModule* module) { |
ahaas
2015/12/17 12:42:00
(nit) Can we use uint32_t here instead?
bradn
2015/12/17 12:56:35
Done.
| |
263 unsigned index = 0; | 265 unsigned int index = 0; |
264 if (module->module && module->module->functions) { | 266 if (module->module && module->module->functions) { |
265 index = static_cast<unsigned>(module->module->functions->size()); | 267 index = static_cast<unsigned int>(module->module->functions->size()); |
266 } | 268 } |
267 module->AddFunction(env.sig, Compile(module)); | 269 module->AddFunction(env.sig, Compile(module)); |
268 return index; | 270 return index; |
269 } | 271 } |
270 }; | 272 }; |
271 | 273 |
272 | 274 |
273 // A helper class to build graphs from Wasm bytecode, generate machine | 275 // A helper class to build graphs from Wasm bytecode, generate machine |
274 // code, and run that code. | 276 // code, and run that code. |
275 template <typename ReturnType> | 277 template <typename ReturnType> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 compilation_done_ = true; | 313 compilation_done_ = true; |
312 // Build the TF graph. | 314 // Build the TF graph. |
313 compiler_.Build(start, end); | 315 compiler_.Build(start, end); |
314 // Generate code. | 316 // Generate code. |
315 Handle<Code> code = compiler_.Compile(env()->module); | 317 Handle<Code> code = compiler_.Compile(env()->module); |
316 | 318 |
317 // Construct the call wrapper. | 319 // Construct the call wrapper. |
318 Node* inputs[5]; | 320 Node* inputs[5]; |
319 int input_count = 0; | 321 int input_count = 0; |
320 inputs[input_count++] = call_wrapper_.HeapConstant(code); | 322 inputs[input_count++] = call_wrapper_.HeapConstant(code); |
321 for (int i = 0; i < signature_.parameter_count(); i++) { | 323 for (size_t i = 0; i < signature_.parameter_count(); i++) { |
322 inputs[input_count++] = call_wrapper_.Parameter(i); | 324 inputs[input_count++] = call_wrapper_.Parameter(i); |
323 } | 325 } |
324 | 326 |
325 call_wrapper_.Return(call_wrapper_.AddNode( | 327 call_wrapper_.Return(call_wrapper_.AddNode( |
326 call_wrapper_.common()->Call(compiler_.descriptor()), input_count, | 328 call_wrapper_.common()->Call(compiler_.descriptor()), input_count, |
327 inputs)); | 329 inputs)); |
328 } | 330 } |
329 | 331 |
330 | 332 |
331 ReturnType Call() { return call_wrapper_.Call(); } | 333 ReturnType Call() { return call_wrapper_.Call(); } |
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1101 void TestFloat64UnopWithConvert(WasmOpcode opcode, int32_t expected, double a) { | 1103 void TestFloat64UnopWithConvert(WasmOpcode opcode, int32_t expected, double a) { |
1102 WasmRunner<int32_t> r; | 1104 WasmRunner<int32_t> r; |
1103 // return int(K op K) | 1105 // return int(K op K) |
1104 BUILD(r, WASM_I32_SCONVERT_F64(WASM_UNOP(opcode, WASM_F64(a)))); | 1106 BUILD(r, WASM_I32_SCONVERT_F64(WASM_UNOP(opcode, WASM_F64(a)))); |
1105 CHECK_EQ(expected, r.Call()); | 1107 CHECK_EQ(expected, r.Call()); |
1106 // TODO(titzer): test float parameters | 1108 // TODO(titzer): test float parameters |
1107 } | 1109 } |
1108 | 1110 |
1109 | 1111 |
1110 TEST(Run_WasmFloat32Binops) { | 1112 TEST(Run_WasmFloat32Binops) { |
1111 TestFloat32Binop(kExprF32Eq, 1, 8.125, 8.125); | 1113 TestFloat32Binop(kExprF32Eq, 1, 8.125f, 8.125f); |
1112 TestFloat32Binop(kExprF32Ne, 1, 8.125, 8.127); | 1114 TestFloat32Binop(kExprF32Ne, 1, 8.125f, 8.127f); |
1113 TestFloat32Binop(kExprF32Lt, 1, -9.5, -9); | 1115 TestFloat32Binop(kExprF32Lt, 1, -9.5f, -9.0f); |
1114 TestFloat32Binop(kExprF32Le, 1, -1111, -1111); | 1116 TestFloat32Binop(kExprF32Le, 1, -1111.0f, -1111.0f); |
1115 TestFloat32Binop(kExprF32Gt, 1, -9, -9.5); | 1117 TestFloat32Binop(kExprF32Gt, 1, -9.0f, -9.5f); |
1116 TestFloat32Binop(kExprF32Ge, 1, -1111, -1111); | 1118 TestFloat32Binop(kExprF32Ge, 1, -1111.0f, -1111.0f); |
1117 | 1119 |
1118 TestFloat32BinopWithConvert(kExprF32Add, 10, 3.5, 6.5); | 1120 TestFloat32BinopWithConvert(kExprF32Add, 10, 3.5f, 6.5f); |
1119 TestFloat32BinopWithConvert(kExprF32Sub, 2, 44.5, 42.5); | 1121 TestFloat32BinopWithConvert(kExprF32Sub, 2, 44.5f, 42.5f); |
1120 TestFloat32BinopWithConvert(kExprF32Mul, -66, -132.1, 0.5); | 1122 TestFloat32BinopWithConvert(kExprF32Mul, -66, -132.1f, 0.5f); |
1121 TestFloat32BinopWithConvert(kExprF32Div, 11, 22.1, 2); | 1123 TestFloat32BinopWithConvert(kExprF32Div, 11, 22.1f, 2.0f); |
1122 } | 1124 } |
1123 | 1125 |
1124 | 1126 |
1125 TEST(Run_WasmFloat32Unops) { | 1127 TEST(Run_WasmFloat32Unops) { |
1126 TestFloat32UnopWithConvert(kExprF32Abs, 8, 8.125); | 1128 TestFloat32UnopWithConvert(kExprF32Abs, 8, 8.125f); |
1127 TestFloat32UnopWithConvert(kExprF32Abs, 9, -9.125); | 1129 TestFloat32UnopWithConvert(kExprF32Abs, 9, -9.125f); |
1128 TestFloat32UnopWithConvert(kExprF32Neg, -213, 213.125); | 1130 TestFloat32UnopWithConvert(kExprF32Neg, -213, 213.125f); |
1129 TestFloat32UnopWithConvert(kExprF32Sqrt, 12, 144.4); | 1131 TestFloat32UnopWithConvert(kExprF32Sqrt, 12, 144.4f); |
1130 } | 1132 } |
1131 | 1133 |
1132 | 1134 |
1133 TEST(Run_WasmFloat64Binops) { | 1135 TEST(Run_WasmFloat64Binops) { |
1134 TestFloat64Binop(kExprF64Eq, 1, 16.25, 16.25); | 1136 TestFloat64Binop(kExprF64Eq, 1, 16.25, 16.25); |
1135 TestFloat64Binop(kExprF64Ne, 1, 16.25, 16.15); | 1137 TestFloat64Binop(kExprF64Ne, 1, 16.25, 16.15); |
1136 TestFloat64Binop(kExprF64Lt, 1, -32.4, 11.7); | 1138 TestFloat64Binop(kExprF64Lt, 1, -32.4, 11.7); |
1137 TestFloat64Binop(kExprF64Le, 1, -88.9, -88.9); | 1139 TestFloat64Binop(kExprF64Le, 1, -88.9, -88.9); |
1138 TestFloat64Binop(kExprF64Gt, 1, 11.7, -32.4); | 1140 TestFloat64Binop(kExprF64Gt, 1, 11.7, -32.4); |
1139 TestFloat64Binop(kExprF64Ge, 1, -88.9, -88.9); | 1141 TestFloat64Binop(kExprF64Ge, 1, -88.9, -88.9); |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1886 memory[3] = 99999999; | 1888 memory[3] = 99999999; |
1887 CHECK_EQ(kWritten, r.Call(i * 4)); | 1889 CHECK_EQ(kWritten, r.Call(i * 4)); |
1888 CHECK_EQ(66666666, memory[0]); | 1890 CHECK_EQ(66666666, memory[0]); |
1889 CHECK_EQ(i == 0 ? kWritten : 77777777, memory[1]); | 1891 CHECK_EQ(i == 0 ? kWritten : 77777777, memory[1]); |
1890 CHECK_EQ(i == 1 ? kWritten : 88888888, memory[2]); | 1892 CHECK_EQ(i == 1 ? kWritten : 88888888, memory[2]); |
1891 CHECK_EQ(i == 2 ? kWritten : 99999999, memory[3]); | 1893 CHECK_EQ(i == 2 ? kWritten : 99999999, memory[3]); |
1892 } | 1894 } |
1893 } | 1895 } |
1894 | 1896 |
1895 | 1897 |
1898 #if WASM_64 | |
1899 // TODO(titzer): Figure out why this fails on 32-bit architectures. | |
1896 TEST(Run_Wasm_StoreMem_offset_oob) { | 1900 TEST(Run_Wasm_StoreMem_offset_oob) { |
1897 TestingModule module; | 1901 TestingModule module; |
1898 byte* memory = module.AddMemoryElems<byte>(32); | 1902 byte* memory = module.AddMemoryElems<byte>(32); |
1899 | 1903 |
1900 #if WASM_64 | 1904 #if WASM_64 |
1901 static const MachineType machineTypes[] = { | 1905 static const MachineType machineTypes[] = { |
1902 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(), | 1906 MachineType::Int8(), MachineType::Uint8(), MachineType::Int16(), |
1903 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(), | 1907 MachineType::Uint16(), MachineType::Int32(), MachineType::Uint32(), |
1904 MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(), | 1908 MachineType::Int64(), MachineType::Uint64(), MachineType::Float32(), |
1905 MachineType::Float64()}; | 1909 MachineType::Float64()}; |
(...skipping 16 matching lines...) Expand all Loading... | |
1922 byte memsize = WasmOpcodes::MemSize(machineTypes[m]); | 1926 byte memsize = WasmOpcodes::MemSize(machineTypes[m]); |
1923 uint32_t boundary = 24 - memsize; | 1927 uint32_t boundary = 24 - memsize; |
1924 CHECK_EQ(0, r.Call(boundary)); // in bounds. | 1928 CHECK_EQ(0, r.Call(boundary)); // in bounds. |
1925 CHECK_EQ(0, memcmp(&memory[0], &memory[8 + boundary], memsize)); | 1929 CHECK_EQ(0, memcmp(&memory[0], &memory[8 + boundary], memsize)); |
1926 | 1930 |
1927 for (uint32_t offset = boundary + 1; offset < boundary + 19; offset++) { | 1931 for (uint32_t offset = boundary + 1; offset < boundary + 19; offset++) { |
1928 CHECK_TRAP(r.Call(offset)); // out of bounds. | 1932 CHECK_TRAP(r.Call(offset)); // out of bounds. |
1929 } | 1933 } |
1930 } | 1934 } |
1931 } | 1935 } |
1936 #endif | |
1932 | 1937 |
1933 | 1938 |
1934 #if WASM_64 | 1939 #if WASM_64 |
1935 TEST(Run_Wasm_F64ReinterpretI64) { | 1940 TEST(Run_Wasm_F64ReinterpretI64) { |
1936 WasmRunner<int64_t> r; | 1941 WasmRunner<int64_t> r; |
1937 TestingModule module; | 1942 TestingModule module; |
1938 int64_t* memory = module.AddMemoryElems<int64_t>(8); | 1943 int64_t* memory = module.AddMemoryElems<int64_t>(8); |
1939 r.env()->module = &module; | 1944 r.env()->module = &module; |
1940 | 1945 |
1941 BUILD(r, WASM_I64_REINTERPRET_F64( | 1946 BUILD(r, WASM_I64_REINTERPRET_F64( |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2044 const int kNumElems = 55; | 2049 const int kNumElems = 55; |
2045 TestingModule module; | 2050 TestingModule module; |
2046 module.AddMemoryElems<uint32_t>(kNumElems); | 2051 module.AddMemoryElems<uint32_t>(kNumElems); |
2047 r.env()->module = &module; | 2052 r.env()->module = &module; |
2048 | 2053 |
2049 BUILD(r, kExprBlock, 2, kExprLoop, 1, kExprIf, kExprGetLocal, 0, kExprBr, 0, | 2054 BUILD(r, kExprBlock, 2, kExprLoop, 1, kExprIf, kExprGetLocal, 0, kExprBr, 0, |
2050 kExprIfElse, kExprI32LoadMem, 0, kExprGetLocal, 0, kExprBr, 2, | 2055 kExprIfElse, kExprI32LoadMem, 0, kExprGetLocal, 0, kExprBr, 2, |
2051 kExprI8Const, 255, kExprSetLocal, 0, kExprI32Sub, kExprGetLocal, 0, | 2056 kExprI8Const, 255, kExprSetLocal, 0, kExprI32Sub, kExprGetLocal, 0, |
2052 kExprI8Const, 4, kExprI8Const, 0); | 2057 kExprI8Const, 4, kExprI8Const, 0); |
2053 | 2058 |
2054 module.ZeroMemory(); | 2059 module.BlankMemory(); |
2055 CHECK_EQ(0, r.Call((kNumElems - 1) * 4)); | 2060 CHECK_EQ(0, r.Call((kNumElems - 1) * 4)); |
2056 } | 2061 } |
2057 | 2062 |
2058 | 2063 |
2059 TEST(Run_Wasm_MemF32_Sum) { | 2064 TEST(Run_Wasm_MemF32_Sum) { |
2060 WasmRunner<int32_t> r(MachineType::Int32()); | 2065 WasmRunner<int32_t> r(MachineType::Int32()); |
2061 const byte kSum = r.AllocateLocal(kAstF32); | 2066 const byte kSum = r.AllocateLocal(kAstF32); |
2062 ModuleEnv module; | 2067 ModuleEnv module; |
2063 const int kSize = 5; | 2068 const int kSize = 5; |
2064 float buffer[kSize] = {-99.25, -888.25, -77.25, 66666.25, 5555.25}; | 2069 float buffer[kSize] = {-99.25, -888.25, -77.25, 66666.25, 5555.25}; |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2588 #endif | 2593 #endif |
2589 | 2594 |
2590 | 2595 |
2591 TEST(Run_WasmCallEmpty) { | 2596 TEST(Run_WasmCallEmpty) { |
2592 const int32_t kExpected = -414444; | 2597 const int32_t kExpected = -414444; |
2593 // Build the target function. | 2598 // Build the target function. |
2594 TestSignatures sigs; | 2599 TestSignatures sigs; |
2595 TestingModule module; | 2600 TestingModule module; |
2596 WasmFunctionCompiler t(sigs.i_v()); | 2601 WasmFunctionCompiler t(sigs.i_v()); |
2597 BUILD(t, WASM_I32(kExpected)); | 2602 BUILD(t, WASM_I32(kExpected)); |
2598 unsigned index = t.CompileAndAdd(&module); | 2603 unsigned int index = t.CompileAndAdd(&module); |
2599 | 2604 |
2600 // Build the calling function. | 2605 // Build the calling function. |
2601 WasmRunner<int32_t> r; | 2606 WasmRunner<int32_t> r; |
2602 r.env()->module = &module; | 2607 r.env()->module = &module; |
2603 BUILD(r, WASM_CALL_FUNCTION0(index)); | 2608 BUILD(r, WASM_CALL_FUNCTION0(index)); |
2604 | 2609 |
2605 int32_t result = r.Call(); | 2610 int32_t result = r.Call(); |
2606 CHECK_EQ(kExpected, result); | 2611 CHECK_EQ(kExpected, result); |
2607 } | 2612 } |
2608 | 2613 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2665 const int32_t kExpected = -414444; | 2670 const int32_t kExpected = -414444; |
2666 // Build the target function. | 2671 // Build the target function. |
2667 TestSignatures sigs; | 2672 TestSignatures sigs; |
2668 TestingModule module; | 2673 TestingModule module; |
2669 module.AddMemory(16); | 2674 module.AddMemory(16); |
2670 module.RandomizeMemory(); | 2675 module.RandomizeMemory(); |
2671 WasmFunctionCompiler t(sigs.v_v()); | 2676 WasmFunctionCompiler t(sigs.v_v()); |
2672 t.env.module = &module; | 2677 t.env.module = &module; |
2673 BUILD(t, WASM_STORE_MEM(MachineType::Int32(), WASM_I8(kMemOffset), | 2678 BUILD(t, WASM_STORE_MEM(MachineType::Int32(), WASM_I8(kMemOffset), |
2674 WASM_I32(kExpected))); | 2679 WASM_I32(kExpected))); |
2675 unsigned index = t.CompileAndAdd(&module); | 2680 unsigned int index = t.CompileAndAdd(&module); |
2676 | 2681 |
2677 // Build the calling function. | 2682 // Build the calling function. |
2678 WasmRunner<int32_t> r; | 2683 WasmRunner<int32_t> r; |
2679 r.env()->module = &module; | 2684 r.env()->module = &module; |
2680 BUILD(r, WASM_CALL_FUNCTION0(index), | 2685 BUILD(r, WASM_CALL_FUNCTION0(index), |
2681 WASM_LOAD_MEM(MachineType::Int32(), WASM_I8(kMemOffset))); | 2686 WASM_LOAD_MEM(MachineType::Int32(), WASM_I8(kMemOffset))); |
2682 | 2687 |
2683 int32_t result = r.Call(); | 2688 int32_t result = r.Call(); |
2684 CHECK_EQ(kExpected, result); | 2689 CHECK_EQ(kExpected, result); |
2685 CHECK_EQ(kExpected, module.raw_mem_start<int32_t>()[kElemNum]); | 2690 CHECK_EQ(kExpected, module.raw_mem_start<int32_t>()[kElemNum]); |
2686 } | 2691 } |
2687 | 2692 |
2688 | 2693 |
2689 TEST(Run_WasmCall_Int32Add) { | 2694 TEST(Run_WasmCall_Int32Add) { |
2690 // Build the target function. | 2695 // Build the target function. |
2691 TestSignatures sigs; | 2696 TestSignatures sigs; |
2692 TestingModule module; | 2697 TestingModule module; |
2693 WasmFunctionCompiler t(sigs.i_ii()); | 2698 WasmFunctionCompiler t(sigs.i_ii()); |
2694 BUILD(t, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 2699 BUILD(t, WASM_I32_ADD(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
2695 unsigned index = t.CompileAndAdd(&module); | 2700 unsigned int index = t.CompileAndAdd(&module); |
2696 | 2701 |
2697 // Build the caller function. | 2702 // Build the caller function. |
2698 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); | 2703 WasmRunner<int32_t> r(MachineType::Int32(), MachineType::Int32()); |
2699 r.env()->module = &module; | 2704 r.env()->module = &module; |
2700 BUILD(r, WASM_CALL_FUNCTION(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 2705 BUILD(r, WASM_CALL_FUNCTION(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
2701 | 2706 |
2702 FOR_INT32_INPUTS(i) { | 2707 FOR_INT32_INPUTS(i) { |
2703 FOR_INT32_INPUTS(j) { | 2708 FOR_INT32_INPUTS(j) { |
2704 int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*i) + | 2709 int32_t expected = static_cast<int32_t>(static_cast<uint32_t>(*i) + |
2705 static_cast<uint32_t>(*j)); | 2710 static_cast<uint32_t>(*j)); |
2706 CHECK_EQ(expected, r.Call(*i, *j)); | 2711 CHECK_EQ(expected, r.Call(*i, *j)); |
2707 } | 2712 } |
2708 } | 2713 } |
2709 } | 2714 } |
2710 | 2715 |
2711 | 2716 |
2712 #if WASM_64 | 2717 #if WASM_64 |
2713 TEST(Run_WasmCall_Int64Sub) { | 2718 TEST(Run_WasmCall_Int64Sub) { |
2714 // Build the target function. | 2719 // Build the target function. |
2715 TestSignatures sigs; | 2720 TestSignatures sigs; |
2716 TestingModule module; | 2721 TestingModule module; |
2717 WasmFunctionCompiler t(sigs.l_ll()); | 2722 WasmFunctionCompiler t(sigs.l_ll()); |
2718 BUILD(t, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 2723 BUILD(t, WASM_I64_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
2719 unsigned index = t.CompileAndAdd(&module); | 2724 unsigned int index = t.CompileAndAdd(&module); |
2720 | 2725 |
2721 // Build the caller function. | 2726 // Build the caller function. |
2722 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); | 2727 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); |
2723 r.env()->module = &module; | 2728 r.env()->module = &module; |
2724 BUILD(r, WASM_CALL_FUNCTION(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 2729 BUILD(r, WASM_CALL_FUNCTION(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
2725 | 2730 |
2726 FOR_INT32_INPUTS(i) { | 2731 FOR_INT32_INPUTS(i) { |
2727 FOR_INT32_INPUTS(j) { | 2732 FOR_INT32_INPUTS(j) { |
2728 int64_t a = static_cast<int64_t>(*i) << 32 | | 2733 int64_t a = static_cast<int64_t>(*i) << 32 | |
2729 (static_cast<int64_t>(*j) | 0xFFFFFFFF); | 2734 (static_cast<int64_t>(*j) | 0xFFFFFFFF); |
2730 int64_t b = static_cast<int64_t>(*j) << 32 | | 2735 int64_t b = static_cast<int64_t>(*j) << 32 | |
2731 (static_cast<int64_t>(*i) | 0xFFFFFFFF); | 2736 (static_cast<int64_t>(*i) | 0xFFFFFFFF); |
2732 | 2737 |
2733 int64_t expected = static_cast<int64_t>(static_cast<uint64_t>(a) - | 2738 int64_t expected = static_cast<int64_t>(static_cast<uint64_t>(a) - |
2734 static_cast<uint64_t>(b)); | 2739 static_cast<uint64_t>(b)); |
2735 CHECK_EQ(expected, r.Call(a, b)); | 2740 CHECK_EQ(expected, r.Call(a, b)); |
2736 } | 2741 } |
2737 } | 2742 } |
2738 } | 2743 } |
2739 #endif | 2744 #endif |
2740 | 2745 |
2741 | 2746 |
2742 TEST(Run_WasmCall_Float32Sub) { | 2747 TEST(Run_WasmCall_Float32Sub) { |
2743 TestSignatures sigs; | 2748 TestSignatures sigs; |
2744 WasmFunctionCompiler t(sigs.f_ff()); | 2749 WasmFunctionCompiler t(sigs.f_ff()); |
2745 | 2750 |
2746 // Build the target function. | 2751 // Build the target function. |
2747 TestingModule module; | 2752 TestingModule module; |
2748 BUILD(t, WASM_F32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 2753 BUILD(t, WASM_F32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
2749 unsigned index = t.CompileAndAdd(&module); | 2754 unsigned int index = t.CompileAndAdd(&module); |
2750 | 2755 |
2751 // Builder the caller function. | 2756 // Builder the caller function. |
2752 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); | 2757 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); |
2753 r.env()->module = &module; | 2758 r.env()->module = &module; |
2754 BUILD(r, WASM_CALL_FUNCTION(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 2759 BUILD(r, WASM_CALL_FUNCTION(index, WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
2755 | 2760 |
2756 FOR_FLOAT32_INPUTS(i) { | 2761 FOR_FLOAT32_INPUTS(i) { |
2757 FOR_FLOAT32_INPUTS(j) { CheckFloatEq(*i - *j, r.Call(*i, *j)); } | 2762 FOR_FLOAT32_INPUTS(j) { CheckFloatEq(*i - *j, r.Call(*i, *j)); } |
2758 } | 2763 } |
2759 } | 2764 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2820 for (int which = 0; which < num_params; which++) { | 2825 for (int which = 0; which < num_params; which++) { |
2821 Zone zone; | 2826 Zone zone; |
2822 TestingModule module; | 2827 TestingModule module; |
2823 module.AddMemory(1024); | 2828 module.AddMemory(1024); |
2824 MachineType* memtypes = &mixed[start]; | 2829 MachineType* memtypes = &mixed[start]; |
2825 MachineType result = memtypes[which]; | 2830 MachineType result = memtypes[which]; |
2826 | 2831 |
2827 // ========================================================================= | 2832 // ========================================================================= |
2828 // Build the selector function. | 2833 // Build the selector function. |
2829 // ========================================================================= | 2834 // ========================================================================= |
2830 unsigned index; | 2835 unsigned int index; |
2831 FunctionSig::Builder b(&zone, 1, num_params); | 2836 FunctionSig::Builder b(&zone, 1, num_params); |
2832 b.AddReturn(WasmOpcodes::LocalTypeFor(result)); | 2837 b.AddReturn(WasmOpcodes::LocalTypeFor(result)); |
2833 for (int i = 0; i < num_params; i++) { | 2838 for (int i = 0; i < num_params; i++) { |
2834 b.AddParam(WasmOpcodes::LocalTypeFor(memtypes[i])); | 2839 b.AddParam(WasmOpcodes::LocalTypeFor(memtypes[i])); |
2835 } | 2840 } |
2836 WasmFunctionCompiler t(b.Build()); | 2841 WasmFunctionCompiler t(b.Build()); |
2837 t.env.module = &module; | 2842 t.env.module = &module; |
2838 BUILD(t, WASM_GET_LOCAL(which)); | 2843 BUILD(t, WASM_GET_LOCAL(which)); |
2839 index = t.CompileAndAdd(&module); | 2844 index = t.CompileAndAdd(&module); |
2840 | 2845 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3060 r.env()->module = &module; | 3065 r.env()->module = &module; |
3061 | 3066 |
3062 byte code[] = {kExprI64StoreMem, 0, kExprI8Const, 8, | 3067 byte code[] = {kExprI64StoreMem, 0, kExprI8Const, 8, |
3063 loads[m], 0, kExprI8Const, 0}; | 3068 loads[m], 0, kExprI8Const, 0}; |
3064 | 3069 |
3065 r.Build(code, code + arraysize(code)); | 3070 r.Build(code, code + arraysize(code)); |
3066 | 3071 |
3067 // Try a bunch of different negative values. | 3072 // Try a bunch of different negative values. |
3068 for (int i = -1; i >= -128; i -= 11) { | 3073 for (int i = -1; i >= -128; i -= 11) { |
3069 int size = 1 << m; | 3074 int size = 1 << m; |
3070 module.ZeroMemory(); | 3075 module.BlankMemory(); |
3071 memory[size - 1] = static_cast<byte>(i); // set the high order byte. | 3076 memory[size - 1] = static_cast<byte>(i); // set the high order byte. |
3072 | 3077 |
3073 int64_t expected = static_cast<int64_t>(i) << ((size - 1) * 8); | 3078 int64_t expected = static_cast<int64_t>(i) << ((size - 1) * 8); |
3074 | 3079 |
3075 CHECK_EQ(expected, r.Call()); | 3080 CHECK_EQ(expected, r.Call()); |
3076 CHECK_EQ(static_cast<byte>(i), memory[8 + size - 1]); | 3081 CHECK_EQ(static_cast<byte>(i), memory[8 + size - 1]); |
3077 for (int j = size; j < 8; j++) { | 3082 for (int j = size; j < 8; j++) { |
3078 CHECK_EQ(255, memory[8 + j]); | 3083 CHECK_EQ(255, memory[8 + j]); |
3079 } | 3084 } |
3080 } | 3085 } |
(...skipping 19 matching lines...) Expand all Loading... | |
3100 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 3105 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
3101 t2.CompileAndAdd(&module); | 3106 t2.CompileAndAdd(&module); |
3102 | 3107 |
3103 // Signature table. | 3108 // Signature table. |
3104 module.AddSignature(sigs.f_ff()); | 3109 module.AddSignature(sigs.f_ff()); |
3105 module.AddSignature(sigs.i_ii()); | 3110 module.AddSignature(sigs.i_ii()); |
3106 module.AddSignature(sigs.d_dd()); | 3111 module.AddSignature(sigs.d_dd()); |
3107 | 3112 |
3108 // Function table. | 3113 // Function table. |
3109 int table_size = 2; | 3114 int table_size = 2; |
3110 std::vector<uint16_t> function_table; | 3115 module.module->function_table = new std::vector<uint16_t>; |
3111 module.module->function_table = &function_table; | |
3112 module.module->function_table->push_back(0); | 3116 module.module->function_table->push_back(0); |
3113 module.module->function_table->push_back(1); | 3117 module.module->function_table->push_back(1); |
3114 | 3118 |
3115 // Function table. | 3119 // Function table. |
3116 Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size); | 3120 Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size); |
3117 fixed->set(0, Smi::FromInt(1)); | 3121 fixed->set(0, Smi::FromInt(1)); |
3118 fixed->set(1, Smi::FromInt(1)); | 3122 fixed->set(1, Smi::FromInt(1)); |
3119 fixed->set(2, *module.function_code->at(0)); | 3123 fixed->set(2, *module.function_code->at(0)); |
3120 fixed->set(3, *module.function_code->at(1)); | 3124 fixed->set(3, *module.function_code->at(1)); |
3121 module.function_table = fixed; | 3125 module.function_table = fixed; |
(...skipping 23 matching lines...) Expand all Loading... | |
3145 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 3149 BUILD(t2, WASM_I32_SUB(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
3146 t2.CompileAndAdd(&module); | 3150 t2.CompileAndAdd(&module); |
3147 | 3151 |
3148 // Signature table. | 3152 // Signature table. |
3149 module.AddSignature(sigs.f_ff()); | 3153 module.AddSignature(sigs.f_ff()); |
3150 module.AddSignature(sigs.i_ii()); | 3154 module.AddSignature(sigs.i_ii()); |
3151 module.AddSignature(sigs.d_dd()); | 3155 module.AddSignature(sigs.d_dd()); |
3152 | 3156 |
3153 // Function table. | 3157 // Function table. |
3154 int table_size = 2; | 3158 int table_size = 2; |
3155 std::vector<uint16_t> function_table; | 3159 module.module->function_table = new std::vector<uint16_t>; |
3156 module.module->function_table = &function_table; | |
3157 module.module->function_table->push_back(0); | 3160 module.module->function_table->push_back(0); |
3158 module.module->function_table->push_back(1); | 3161 module.module->function_table->push_back(1); |
3159 | 3162 |
3160 // Function table. | 3163 // Function table. |
3161 Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size); | 3164 Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size); |
3162 fixed->set(0, Smi::FromInt(1)); | 3165 fixed->set(0, Smi::FromInt(1)); |
3163 fixed->set(1, Smi::FromInt(1)); | 3166 fixed->set(1, Smi::FromInt(1)); |
3164 fixed->set(2, *module.function_code->at(0)); | 3167 fixed->set(2, *module.function_code->at(0)); |
3165 fixed->set(3, *module.function_code->at(1)); | 3168 fixed->set(3, *module.function_code->at(1)); |
3166 module.function_table = fixed; | 3169 module.function_table = fixed; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3345 | 3348 |
3346 | 3349 |
3347 #if WASM_64 | 3350 #if WASM_64 |
3348 TEST(Run_Wasm_F32SConvertI64) { | 3351 TEST(Run_Wasm_F32SConvertI64) { |
3349 WasmRunner<float> r(MachineType::Int64()); | 3352 WasmRunner<float> r(MachineType::Int64()); |
3350 BUILD(r, WASM_F32_SCONVERT_I64(WASM_GET_LOCAL(0))); | 3353 BUILD(r, WASM_F32_SCONVERT_I64(WASM_GET_LOCAL(0))); |
3351 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<float>(*i), r.Call(*i)); } | 3354 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<float>(*i), r.Call(*i)); } |
3352 } | 3355 } |
3353 | 3356 |
3354 | 3357 |
3358 #if !defined(_WIN64) | |
3359 // TODO(ahaas): Fix this failure. | |
3355 TEST(Run_Wasm_F32UConvertI64) { | 3360 TEST(Run_Wasm_F32UConvertI64) { |
3356 WasmRunner<float> r(MachineType::Uint64()); | 3361 WasmRunner<float> r(MachineType::Uint64()); |
3357 BUILD(r, WASM_F32_UCONVERT_I64(WASM_GET_LOCAL(0))); | 3362 BUILD(r, WASM_F32_UCONVERT_I64(WASM_GET_LOCAL(0))); |
3358 FOR_UINT64_INPUTS(i) { CHECK_EQ(static_cast<float>(*i), r.Call(*i)); } | 3363 FOR_UINT64_INPUTS(i) { CHECK_EQ(static_cast<float>(*i), r.Call(*i)); } |
3359 } | 3364 } |
3365 #endif | |
3360 | 3366 |
3361 | 3367 |
3362 TEST(Run_Wasm_F64SConvertI64) { | 3368 TEST(Run_Wasm_F64SConvertI64) { |
3363 WasmRunner<double> r(MachineType::Int64()); | 3369 WasmRunner<double> r(MachineType::Int64()); |
3364 BUILD(r, WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))); | 3370 BUILD(r, WASM_F64_SCONVERT_I64(WASM_GET_LOCAL(0))); |
3365 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<double>(*i), r.Call(*i)); } | 3371 FOR_INT64_INPUTS(i) { CHECK_EQ(static_cast<double>(*i), r.Call(*i)); } |
3366 } | 3372 } |
3367 | 3373 |
3368 | 3374 |
3375 #if !defined(_WIN64) | |
3376 // TODO(ahaas): Fix this failure. | |
3369 TEST(Run_Wasm_F64UConvertI64) { | 3377 TEST(Run_Wasm_F64UConvertI64) { |
3370 WasmRunner<double> r(MachineType::Uint64()); | 3378 WasmRunner<double> r(MachineType::Uint64()); |
3371 BUILD(r, WASM_F64_UCONVERT_I64(WASM_GET_LOCAL(0))); | 3379 BUILD(r, WASM_F64_UCONVERT_I64(WASM_GET_LOCAL(0))); |
3372 FOR_UINT64_INPUTS(i) { CHECK_EQ(static_cast<double>(*i), r.Call(*i)); } | 3380 FOR_UINT64_INPUTS(i) { CHECK_EQ(static_cast<double>(*i), r.Call(*i)); } |
3373 } | 3381 } |
3382 #endif | |
3374 | 3383 |
3375 | 3384 |
3376 TEST(Run_Wasm_I64SConvertF32) { | 3385 TEST(Run_Wasm_I64SConvertF32) { |
3377 WasmRunner<int64_t> r(MachineType::Float32()); | 3386 WasmRunner<int64_t> r(MachineType::Float32()); |
3378 BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0))); | 3387 BUILD(r, WASM_I64_SCONVERT_F32(WASM_GET_LOCAL(0))); |
3379 | 3388 |
3380 FOR_FLOAT32_INPUTS(i) { | 3389 FOR_FLOAT32_INPUTS(i) { |
3381 if (*i < static_cast<float>(INT64_MAX) && | 3390 if (*i < static_cast<float>(INT64_MAX) && |
3382 *i >= static_cast<float>(INT64_MIN)) { | 3391 *i >= static_cast<float>(INT64_MIN)) { |
3383 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); | 3392 CHECK_EQ(static_cast<int64_t>(*i), r.Call(*i)); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3443 | 3452 |
3444 | 3453 |
3445 TEST(Run_Wasm_F32CopySign) { | 3454 TEST(Run_Wasm_F32CopySign) { |
3446 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); | 3455 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); |
3447 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); | 3456 BUILD(r, WASM_F32_COPYSIGN(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); |
3448 | 3457 |
3449 FOR_FLOAT32_INPUTS(i) { | 3458 FOR_FLOAT32_INPUTS(i) { |
3450 FOR_FLOAT32_INPUTS(j) { CheckFloatEq(copysign(*i, *j), r.Call(*i, *j)); } | 3459 FOR_FLOAT32_INPUTS(j) { CheckFloatEq(copysign(*i, *j), r.Call(*i, *j)); } |
3451 } | 3460 } |
3452 } | 3461 } |
OLD | NEW |