| 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" | 8 #include "src/base/utils/random-number-generator.h" |
| 9 | 9 |
| 10 #include "src/compiler/graph-visualizer.h" | 10 #include "src/compiler/graph-visualizer.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 result->Disassemble("wasm code", os); | 257 result->Disassemble("wasm code", os); |
| 258 } | 258 } |
| 259 #endif | 259 #endif |
| 260 | 260 |
| 261 return result; | 261 return result; |
| 262 } | 262 } |
| 263 | 263 |
| 264 uint32_t CompileAndAdd(TestingModule* module) { | 264 uint32_t CompileAndAdd(TestingModule* module) { |
| 265 uint32_t index = 0; | 265 uint32_t index = 0; |
| 266 if (module->module && module->module->functions) { | 266 if (module->module && module->module->functions) { |
| 267 index = module->module->functions->size(); | 267 index = static_cast<uint32_t>(module->module->functions->size()); |
| 268 } | 268 } |
| 269 module->AddFunction(env.sig, Compile(module)); | 269 module->AddFunction(env.sig, Compile(module)); |
| 270 return index; | 270 return index; |
| 271 } | 271 } |
| 272 }; | 272 }; |
| 273 | 273 |
| 274 | 274 |
| 275 // A helper class to build graphs from Wasm bytecode, generate machine | 275 // A helper class to build graphs from Wasm bytecode, generate machine |
| 276 // code, and run that code. | 276 // code, and run that code. |
| 277 template <typename ReturnType> | 277 template <typename ReturnType> |
| (...skipping 2335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2613 | 2613 |
| 2614 | 2614 |
| 2615 TEST(Run_WasmCallF32StackParameter) { | 2615 TEST(Run_WasmCallF32StackParameter) { |
| 2616 // Build the target function. | 2616 // Build the target function. |
| 2617 LocalType param_types[20]; | 2617 LocalType param_types[20]; |
| 2618 for (int i = 0; i < 20; i++) param_types[i] = kAstF32; | 2618 for (int i = 0; i < 20; i++) param_types[i] = kAstF32; |
| 2619 FunctionSig sig(1, 19, param_types); | 2619 FunctionSig sig(1, 19, param_types); |
| 2620 TestingModule module; | 2620 TestingModule module; |
| 2621 WasmFunctionCompiler t(&sig); | 2621 WasmFunctionCompiler t(&sig); |
| 2622 BUILD(t, WASM_GET_LOCAL(17)); | 2622 BUILD(t, WASM_GET_LOCAL(17)); |
| 2623 unsigned index = t.CompileAndAdd(&module); | 2623 uint32_t index = t.CompileAndAdd(&module); |
| 2624 | 2624 |
| 2625 // Build the calling function. | 2625 // Build the calling function. |
| 2626 WasmRunner<float> r; | 2626 WasmRunner<float> r; |
| 2627 r.env()->module = &module; | 2627 r.env()->module = &module; |
| 2628 BUILD(r, WASM_CALL_FUNCTION( | 2628 BUILD(r, WASM_CALL_FUNCTION( |
| 2629 index, WASM_F32(1.0f), WASM_F32(2.0f), WASM_F32(4.0f), | 2629 index, WASM_F32(1.0f), WASM_F32(2.0f), WASM_F32(4.0f), |
| 2630 WASM_F32(8.0f), WASM_F32(16.0f), WASM_F32(32.0f), | 2630 WASM_F32(8.0f), WASM_F32(16.0f), WASM_F32(32.0f), |
| 2631 WASM_F32(64.0f), WASM_F32(128.0f), WASM_F32(256.0f), | 2631 WASM_F32(64.0f), WASM_F32(128.0f), WASM_F32(256.0f), |
| 2632 WASM_F32(1.5f), WASM_F32(2.5f), WASM_F32(4.5f), WASM_F32(8.5f), | 2632 WASM_F32(1.5f), WASM_F32(2.5f), WASM_F32(4.5f), WASM_F32(8.5f), |
| 2633 WASM_F32(16.5f), WASM_F32(32.5f), WASM_F32(64.5f), | 2633 WASM_F32(16.5f), WASM_F32(32.5f), WASM_F32(64.5f), |
| 2634 WASM_F32(128.5f), WASM_F32(256.5f), WASM_F32(512.5f))); | 2634 WASM_F32(128.5f), WASM_F32(256.5f), WASM_F32(512.5f))); |
| 2635 | 2635 |
| 2636 float result = r.Call(); | 2636 float result = r.Call(); |
| 2637 CHECK_EQ(256.5f, result); | 2637 CHECK_EQ(256.5f, result); |
| 2638 } | 2638 } |
| 2639 | 2639 |
| 2640 | 2640 |
| 2641 TEST(Run_WasmCallF64StackParameter) { | 2641 TEST(Run_WasmCallF64StackParameter) { |
| 2642 // Build the target function. | 2642 // Build the target function. |
| 2643 LocalType param_types[20]; | 2643 LocalType param_types[20]; |
| 2644 for (int i = 0; i < 20; i++) param_types[i] = kAstF64; | 2644 for (int i = 0; i < 20; i++) param_types[i] = kAstF64; |
| 2645 FunctionSig sig(1, 19, param_types); | 2645 FunctionSig sig(1, 19, param_types); |
| 2646 TestingModule module; | 2646 TestingModule module; |
| 2647 WasmFunctionCompiler t(&sig); | 2647 WasmFunctionCompiler t(&sig); |
| 2648 BUILD(t, WASM_GET_LOCAL(17)); | 2648 BUILD(t, WASM_GET_LOCAL(17)); |
| 2649 unsigned index = t.CompileAndAdd(&module); | 2649 uint32_t index = t.CompileAndAdd(&module); |
| 2650 | 2650 |
| 2651 // Build the calling function. | 2651 // Build the calling function. |
| 2652 WasmRunner<double> r; | 2652 WasmRunner<double> r; |
| 2653 r.env()->module = &module; | 2653 r.env()->module = &module; |
| 2654 BUILD(r, WASM_CALL_FUNCTION(index, WASM_F64(1.0), WASM_F64(2.0), | 2654 BUILD(r, WASM_CALL_FUNCTION(index, WASM_F64(1.0), WASM_F64(2.0), |
| 2655 WASM_F64(4.0), WASM_F64(8.0), WASM_F64(16.0), | 2655 WASM_F64(4.0), WASM_F64(8.0), WASM_F64(16.0), |
| 2656 WASM_F64(32.0), WASM_F64(64.0), WASM_F64(128.0), | 2656 WASM_F64(32.0), WASM_F64(64.0), WASM_F64(128.0), |
| 2657 WASM_F64(256.0), WASM_F64(1.5), WASM_F64(2.5), | 2657 WASM_F64(256.0), WASM_F64(1.5), WASM_F64(2.5), |
| 2658 WASM_F64(4.5), WASM_F64(8.5), WASM_F64(16.5), | 2658 WASM_F64(4.5), WASM_F64(8.5), WASM_F64(16.5), |
| 2659 WASM_F64(32.5), WASM_F64(64.5), WASM_F64(128.5), | 2659 WASM_F64(32.5), WASM_F64(64.5), WASM_F64(128.5), |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3452 | 3452 |
| 3453 | 3453 |
| 3454 TEST(Run_Wasm_F32CopySign) { | 3454 TEST(Run_Wasm_F32CopySign) { |
| 3455 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); | 3455 WasmRunner<float> r(MachineType::Float32(), MachineType::Float32()); |
| 3456 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))); |
| 3457 | 3457 |
| 3458 FOR_FLOAT32_INPUTS(i) { | 3458 FOR_FLOAT32_INPUTS(i) { |
| 3459 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)); } |
| 3460 } | 3460 } |
| 3461 } | 3461 } |
| OLD | NEW |