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 <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/wasm/wasm-macro-gen.h" | 9 #include "src/wasm/wasm-macro-gen.h" |
10 | 10 |
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 BUILD(r, | 1707 BUILD(r, |
1708 B2(WASM_BRV_IF(0, WASM_I8(45), WASM_GET_LOCAL(0)), WASM_INFINITE_LOOP)); | 1708 B2(WASM_BRV_IF(0, WASM_I8(45), WASM_GET_LOCAL(0)), WASM_INFINITE_LOOP)); |
1709 // Run the code, but don't go into the infinite loop. | 1709 // Run the code, but don't go into the infinite loop. |
1710 CHECK_EQ(45, r.Call(1)); | 1710 CHECK_EQ(45, r.Call(1)); |
1711 } | 1711 } |
1712 | 1712 |
1713 | 1713 |
1714 static void TestBuildGraphForSimpleExpression(WasmOpcode opcode) { | 1714 static void TestBuildGraphForSimpleExpression(WasmOpcode opcode) { |
1715 if (!WasmOpcodes::IsSupported(opcode)) return; | 1715 if (!WasmOpcodes::IsSupported(opcode)) return; |
1716 | 1716 |
1717 Zone zone; | 1717 ZoneForTesting zone; |
1718 Isolate* isolate = CcTest::InitIsolateOnce(); | 1718 Isolate* isolate = CcTest::InitIsolateOnce(); |
1719 HandleScope scope(isolate); | 1719 HandleScope scope(isolate); |
1720 // Enable all optional operators. | 1720 // Enable all optional operators. |
1721 CommonOperatorBuilder common(&zone); | 1721 CommonOperatorBuilder common(&zone); |
1722 MachineOperatorBuilder machine(&zone, MachineType::PointerRepresentation(), | 1722 MachineOperatorBuilder machine(&zone, MachineType::PointerRepresentation(), |
1723 MachineOperatorBuilder::kAllOptionalOps); | 1723 MachineOperatorBuilder::kAllOptionalOps); |
1724 Graph graph(&zone); | 1724 Graph graph(&zone); |
1725 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); | 1725 JSGraph jsgraph(isolate, &graph, &common, nullptr, nullptr, &machine); |
1726 FunctionSig* sig = WasmOpcodes::Signature(opcode); | 1726 FunctionSig* sig = WasmOpcodes::Signature(opcode); |
1727 | 1727 |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2134 #else | 2134 #else |
2135 static MachineType mixed[] = { | 2135 static MachineType mixed[] = { |
2136 MachineType::Int32(), MachineType::Float32(), MachineType::Float64(), | 2136 MachineType::Int32(), MachineType::Float32(), MachineType::Float64(), |
2137 MachineType::Float32(), MachineType::Int32(), MachineType::Float64(), | 2137 MachineType::Float32(), MachineType::Int32(), MachineType::Float64(), |
2138 MachineType::Float32(), MachineType::Float64(), MachineType::Int32(), | 2138 MachineType::Float32(), MachineType::Float64(), MachineType::Int32(), |
2139 MachineType::Int32(), MachineType::Int32()}; | 2139 MachineType::Int32(), MachineType::Int32()}; |
2140 #endif | 2140 #endif |
2141 | 2141 |
2142 int num_params = static_cast<int>(arraysize(mixed)) - start; | 2142 int num_params = static_cast<int>(arraysize(mixed)) - start; |
2143 for (int which = 0; which < num_params; which++) { | 2143 for (int which = 0; which < num_params; which++) { |
2144 Zone zone; | 2144 ZoneForTesting zone; |
2145 TestingModule module; | 2145 TestingModule module; |
2146 module.AddMemory(1024); | 2146 module.AddMemory(1024); |
2147 MachineType* memtypes = &mixed[start]; | 2147 MachineType* memtypes = &mixed[start]; |
2148 MachineType result = memtypes[which]; | 2148 MachineType result = memtypes[which]; |
2149 | 2149 |
2150 // ========================================================================= | 2150 // ========================================================================= |
2151 // Build the selector function. | 2151 // Build the selector function. |
2152 // ========================================================================= | 2152 // ========================================================================= |
2153 uint32_t index; | 2153 uint32_t index; |
2154 FunctionSig::Builder b(&zone, 1, num_params); | 2154 FunctionSig::Builder b(&zone, 1, num_params); |
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2777 FOR_FLOAT32_INPUTS(i) { | 2777 FOR_FLOAT32_INPUTS(i) { |
2778 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(copysign(*i, *j), r.Call(*i, *j)); } | 2778 FOR_FLOAT32_INPUTS(j) { CHECK_FLOAT_EQ(copysign(*i, *j), r.Call(*i, *j)); } |
2779 } | 2779 } |
2780 } | 2780 } |
2781 | 2781 |
2782 void CompileCallIndirectMany(LocalType param) { | 2782 void CompileCallIndirectMany(LocalType param) { |
2783 // Make sure we don't run out of registers when compiling indirect calls | 2783 // Make sure we don't run out of registers when compiling indirect calls |
2784 // with many many parameters. | 2784 // with many many parameters. |
2785 TestSignatures sigs; | 2785 TestSignatures sigs; |
2786 for (byte num_params = 0; num_params < 40; num_params++) { | 2786 for (byte num_params = 0; num_params < 40; num_params++) { |
2787 Zone zone; | 2787 ZoneForTesting zone; |
2788 HandleScope scope(CcTest::InitIsolateOnce()); | 2788 HandleScope scope(CcTest::InitIsolateOnce()); |
2789 TestingModule module; | 2789 TestingModule module; |
2790 FunctionSig* sig = sigs.many(&zone, kAstStmt, param, num_params); | 2790 FunctionSig* sig = sigs.many(&zone, kAstStmt, param, num_params); |
2791 | 2791 |
2792 module.AddSignature(sig); | 2792 module.AddSignature(sig); |
2793 module.AddSignature(sig); | 2793 module.AddSignature(sig); |
2794 module.AddIndirectFunctionTable(nullptr, 0); | 2794 module.AddIndirectFunctionTable(nullptr, 0); |
2795 | 2795 |
2796 WasmFunctionCompiler t(sig, &module); | 2796 WasmFunctionCompiler t(sig, &module); |
2797 | 2797 |
(...skipping 15 matching lines...) Expand all Loading... |
2813 | 2813 |
2814 #if WASM_64 | 2814 #if WASM_64 |
2815 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } | 2815 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } |
2816 #endif | 2816 #endif |
2817 | 2817 |
2818 | 2818 |
2819 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } | 2819 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } |
2820 | 2820 |
2821 | 2821 |
2822 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } | 2822 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } |
OLD | NEW |