| 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 1759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1770 } | 1770 } |
| 1771 | 1771 |
| 1772 | 1772 |
| 1773 TEST(Run_Wasm_CheckMachIntsZero) { | 1773 TEST(Run_Wasm_CheckMachIntsZero) { |
| 1774 const int kNumElems = 55; | 1774 const int kNumElems = 55; |
| 1775 TestingModule module; | 1775 TestingModule module; |
| 1776 module.AddMemoryElems<uint32_t>(kNumElems); | 1776 module.AddMemoryElems<uint32_t>(kNumElems); |
| 1777 WasmRunner<uint32_t> r(&module, MachineType::Int32()); | 1777 WasmRunner<uint32_t> r(&module, MachineType::Int32()); |
| 1778 | 1778 |
| 1779 BUILD(r, kExprBlock, 2, kExprLoop, 1, kExprIf, kExprGetLocal, 0, kExprBr, 0, | 1779 BUILD(r, kExprBlock, 2, kExprLoop, 1, kExprIf, kExprGetLocal, 0, kExprBr, 0, |
| 1780 kExprIfElse, kExprI32LoadMem, 0, kExprGetLocal, 0, kExprBr, 2, | 1780 kExprIfElse, kExprI32LoadMem, ZERO_ALIGNMENT, ZERO_OFFSET, |
| 1781 kExprI8Const, 255, kExprSetLocal, 0, kExprI32Sub, kExprGetLocal, 0, | 1781 kExprGetLocal, 0, kExprBr, 2, kExprI8Const, 255, kExprSetLocal, 0, |
| 1782 kExprI8Const, 4, kExprI8Const, 0); | 1782 kExprI32Sub, kExprGetLocal, 0, kExprI8Const, 4, kExprI8Const, 0); |
| 1783 | 1783 |
| 1784 module.BlankMemory(); | 1784 module.BlankMemory(); |
| 1785 CHECK_EQ(0, r.Call((kNumElems - 1) * 4)); | 1785 CHECK_EQ(0, r.Call((kNumElems - 1) * 4)); |
| 1786 } | 1786 } |
| 1787 | 1787 |
| 1788 | 1788 |
| 1789 TEST(Run_Wasm_MemF32_Sum) { | 1789 TEST(Run_Wasm_MemF32_Sum) { |
| 1790 const int kSize = 5; | 1790 const int kSize = 5; |
| 1791 TestingModule module; | 1791 TestingModule module; |
| 1792 module.AddMemoryElems<float>(kSize); | 1792 module.AddMemoryElems<float>(kSize); |
| (...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2551 index = t.CompileAndAdd(); | 2551 index = t.CompileAndAdd(); |
| 2552 | 2552 |
| 2553 // ========================================================================= | 2553 // ========================================================================= |
| 2554 // Build the calling function. | 2554 // Build the calling function. |
| 2555 // ========================================================================= | 2555 // ========================================================================= |
| 2556 WasmRunner<int32_t> r(&module); | 2556 WasmRunner<int32_t> r(&module); |
| 2557 | 2557 |
| 2558 std::vector<byte> code; | 2558 std::vector<byte> code; |
| 2559 ADD_CODE(code, | 2559 ADD_CODE(code, |
| 2560 static_cast<byte>(WasmOpcodes::LoadStoreOpcodeOf(result, true)), | 2560 static_cast<byte>(WasmOpcodes::LoadStoreOpcodeOf(result, true)), |
| 2561 WasmOpcodes::LoadStoreAccessOf(false)); | 2561 ZERO_ALIGNMENT, ZERO_OFFSET); |
| 2562 ADD_CODE(code, WASM_ZERO); | 2562 ADD_CODE(code, WASM_ZERO); |
| 2563 ADD_CODE(code, kExprCallFunction, static_cast<byte>(index)); | 2563 ADD_CODE(code, kExprCallFunction, static_cast<byte>(index)); |
| 2564 | 2564 |
| 2565 for (int i = 0; i < num_params; i++) { | 2565 for (int i = 0; i < num_params; i++) { |
| 2566 int offset = (i + 1) * kElemSize; | 2566 int offset = (i + 1) * kElemSize; |
| 2567 ADD_CODE(code, WASM_LOAD_MEM(memtypes[i], WASM_I8(offset))); | 2567 ADD_CODE(code, WASM_LOAD_MEM(memtypes[i], WASM_I8(offset))); |
| 2568 } | 2568 } |
| 2569 | 2569 |
| 2570 ADD_CODE(code, WASM_I32V_2(kExpected)); | 2570 ADD_CODE(code, WASM_I32V_2(kExpected)); |
| 2571 size_t end = code.size(); | 2571 size_t end = code.size(); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2775 #if WASM_64 | 2775 #if WASM_64 |
| 2776 TEST(Run_Wasm_LoadStoreI64_sx) { | 2776 TEST(Run_Wasm_LoadStoreI64_sx) { |
| 2777 byte loads[] = {kExprI64LoadMem8S, kExprI64LoadMem16S, kExprI64LoadMem32S, | 2777 byte loads[] = {kExprI64LoadMem8S, kExprI64LoadMem16S, kExprI64LoadMem32S, |
| 2778 kExprI64LoadMem}; | 2778 kExprI64LoadMem}; |
| 2779 | 2779 |
| 2780 for (size_t m = 0; m < arraysize(loads); m++) { | 2780 for (size_t m = 0; m < arraysize(loads); m++) { |
| 2781 TestingModule module; | 2781 TestingModule module; |
| 2782 byte* memory = module.AddMemoryElems<byte>(16); | 2782 byte* memory = module.AddMemoryElems<byte>(16); |
| 2783 WasmRunner<int64_t> r(&module); | 2783 WasmRunner<int64_t> r(&module); |
| 2784 | 2784 |
| 2785 byte code[] = {kExprI64StoreMem, 0, kExprI8Const, 8, | 2785 byte code[] = {kExprI64StoreMem, ZERO_ALIGNMENT, |
| 2786 loads[m], 0, kExprI8Const, 0}; | 2786 ZERO_OFFSET, // -- |
| 2787 kExprI8Const, 8, // -- |
| 2788 loads[m], ZERO_ALIGNMENT, |
| 2789 ZERO_OFFSET, // -- |
| 2790 kExprI8Const, 0}; // -- |
| 2787 | 2791 |
| 2788 r.Build(code, code + arraysize(code)); | 2792 r.Build(code, code + arraysize(code)); |
| 2789 | 2793 |
| 2790 // Try a bunch of different negative values. | 2794 // Try a bunch of different negative values. |
| 2791 for (int i = -1; i >= -128; i -= 11) { | 2795 for (int i = -1; i >= -128; i -= 11) { |
| 2792 int size = 1 << m; | 2796 int size = 1 << m; |
| 2793 module.BlankMemory(); | 2797 module.BlankMemory(); |
| 2794 memory[size - 1] = static_cast<byte>(i); // set the high order byte. | 2798 memory[size - 1] = static_cast<byte>(i); // set the high order byte. |
| 2795 | 2799 |
| 2796 int64_t expected = static_cast<int64_t>(i) << ((size - 1) * 8); | 2800 int64_t expected = static_cast<int64_t>(i) << ((size - 1) * 8); |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3340 | 3344 |
| 3341 #if WASM_64 | 3345 #if WASM_64 |
| 3342 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } | 3346 TEST(Compile_Wasm_CallIndirect_Many_i64) { CompileCallIndirectMany(kAstI64); } |
| 3343 #endif | 3347 #endif |
| 3344 | 3348 |
| 3345 | 3349 |
| 3346 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } | 3350 TEST(Compile_Wasm_CallIndirect_Many_f32) { CompileCallIndirectMany(kAstF32); } |
| 3347 | 3351 |
| 3348 | 3352 |
| 3349 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } | 3353 TEST(Compile_Wasm_CallIndirect_Many_f64) { CompileCallIndirectMany(kAstF64); } |
| OLD | NEW |