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 #ifndef WASM_RUN_UTILS_H | 5 #ifndef WASM_RUN_UTILS_H |
6 #define WASM_RUN_UTILS_H | 6 #define WASM_RUN_UTILS_H |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
11 | 11 |
12 #include <memory> | 12 #include <memory> |
13 | 13 |
14 #include "src/base/accounting-allocator.h" | |
15 #include "src/base/utils/random-number-generator.h" | 14 #include "src/base/utils/random-number-generator.h" |
| 15 #include "src/zone/accounting-allocator.h" |
16 | 16 |
17 #include "src/compiler/graph-visualizer.h" | 17 #include "src/compiler/graph-visualizer.h" |
18 #include "src/compiler/int64-lowering.h" | 18 #include "src/compiler/int64-lowering.h" |
19 #include "src/compiler/js-graph.h" | 19 #include "src/compiler/js-graph.h" |
20 #include "src/compiler/node.h" | 20 #include "src/compiler/node.h" |
21 #include "src/compiler/pipeline.h" | 21 #include "src/compiler/pipeline.h" |
22 #include "src/compiler/wasm-compiler.h" | 22 #include "src/compiler/wasm-compiler.h" |
23 #include "src/compiler/zone-pool.h" | 23 #include "src/compiler/zone-pool.h" |
24 | 24 |
25 #include "src/wasm/ast-decoder.h" | 25 #include "src/wasm/ast-decoder.h" |
26 #include "src/wasm/wasm-interpreter.h" | 26 #include "src/wasm/wasm-interpreter.h" |
27 #include "src/wasm/wasm-js.h" | 27 #include "src/wasm/wasm-js.h" |
28 #include "src/wasm/wasm-macro-gen.h" | 28 #include "src/wasm/wasm-macro-gen.h" |
29 #include "src/wasm/wasm-module.h" | 29 #include "src/wasm/wasm-module.h" |
30 #include "src/wasm/wasm-opcodes.h" | 30 #include "src/wasm/wasm-opcodes.h" |
31 | 31 |
32 #include "src/zone.h" | 32 #include "src/zone/zone.h" |
33 | 33 |
34 #include "test/cctest/cctest.h" | 34 #include "test/cctest/cctest.h" |
35 #include "test/cctest/compiler/call-tester.h" | 35 #include "test/cctest/compiler/call-tester.h" |
36 #include "test/cctest/compiler/graph-builder-tester.h" | 36 #include "test/cctest/compiler/graph-builder-tester.h" |
37 | 37 |
38 static const uint32_t kMaxFunctions = 10; | 38 static const uint32_t kMaxFunctions = 10; |
39 | 39 |
40 enum WasmExecutionMode { kExecuteInterpreted, kExecuteCompiled }; | 40 enum WasmExecutionMode { kExecuteInterpreted, kExecuteCompiled }; |
41 | 41 |
42 // TODO(titzer): check traps more robustly in tests. | 42 // TODO(titzer): check traps more robustly in tests. |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 WasmFunction* GetFunctionAt(int index) { return &module_.functions[index]; } | 253 WasmFunction* GetFunctionAt(int index) { return &module_.functions[index]; } |
254 | 254 |
255 WasmInterpreter* interpreter() { return interpreter_; } | 255 WasmInterpreter* interpreter() { return interpreter_; } |
256 WasmExecutionMode execution_mode() { return execution_mode_; } | 256 WasmExecutionMode execution_mode() { return execution_mode_; } |
257 | 257 |
258 private: | 258 private: |
259 WasmExecutionMode execution_mode_; | 259 WasmExecutionMode execution_mode_; |
260 WasmModule module_; | 260 WasmModule module_; |
261 WasmModuleInstance instance_; | 261 WasmModuleInstance instance_; |
262 Isolate* isolate_; | 262 Isolate* isolate_; |
263 v8::base::AccountingAllocator allocator_; | 263 v8::internal::AccountingAllocator allocator_; |
264 uint32_t global_offset; | 264 uint32_t global_offset; |
265 V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; // preallocated global data. | 265 V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; // preallocated global data. |
266 WasmInterpreter* interpreter_; | 266 WasmInterpreter* interpreter_; |
267 | 267 |
268 const WasmGlobal* AddGlobal(LocalType type) { | 268 const WasmGlobal* AddGlobal(LocalType type) { |
269 byte size = WasmOpcodes::MemSize(WasmOpcodes::MachineTypeFor(type)); | 269 byte size = WasmOpcodes::MemSize(WasmOpcodes::MachineTypeFor(type)); |
270 global_offset = (global_offset + size - 1) & ~(size - 1); // align | 270 global_offset = (global_offset + size - 1) & ~(size - 1); // align |
271 module_.globals.push_back({0, 0, type, global_offset, false}); | 271 module_.globals.push_back({0, 0, type, global_offset, false}); |
272 global_offset += size; | 272 global_offset += size; |
273 // limit number of globals. | 273 // limit number of globals. |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 return val; | 743 return val; |
744 } | 744 } |
745 } | 745 } |
746 | 746 |
747 byte AllocateLocal(LocalType type) { return compiler_.AllocateLocal(type); } | 747 byte AllocateLocal(LocalType type) { return compiler_.AllocateLocal(type); } |
748 | 748 |
749 WasmFunction* function() { return compiler_.function_; } | 749 WasmFunction* function() { return compiler_.function_; } |
750 WasmInterpreter* interpreter() { return compiler_.interpreter_; } | 750 WasmInterpreter* interpreter() { return compiler_.interpreter_; } |
751 | 751 |
752 protected: | 752 protected: |
753 v8::base::AccountingAllocator allocator_; | 753 v8::internal::AccountingAllocator allocator_; |
754 Zone zone; | 754 Zone zone; |
755 bool compiled_; | 755 bool compiled_; |
756 LocalType storage_[WASM_RUNNER_MAX_NUM_PARAMETERS]; | 756 LocalType storage_[WASM_RUNNER_MAX_NUM_PARAMETERS]; |
757 FunctionSig signature_; | 757 FunctionSig signature_; |
758 WasmFunctionCompiler compiler_; | 758 WasmFunctionCompiler compiler_; |
759 WasmFunctionWrapper<ReturnType> wrapper_; | 759 WasmFunctionWrapper<ReturnType> wrapper_; |
760 | 760 |
761 bool interpret() { return compiler_.execution_mode_ == kExecuteInterpreted; } | 761 bool interpret() { return compiler_.execution_mode_ == kExecuteInterpreted; } |
762 | 762 |
763 static size_t GetParameterCount(MachineType p0, MachineType p1, | 763 static size_t GetParameterCount(MachineType p0, MachineType p1, |
(...skipping 12 matching lines...) Expand all Loading... |
776 // interpreter. | 776 // interpreter. |
777 #define WASM_EXEC_TEST(name) \ | 777 #define WASM_EXEC_TEST(name) \ |
778 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 778 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
779 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 779 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
780 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ | 780 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ |
781 void RunWasm_##name(WasmExecutionMode execution_mode) | 781 void RunWasm_##name(WasmExecutionMode execution_mode) |
782 | 782 |
783 } // namespace | 783 } // namespace |
784 | 784 |
785 #endif | 785 #endif |
OLD | NEW |