| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 WasmFunction* GetFunctionAt(int index) { return &module_.functions[index]; } | 252 WasmFunction* GetFunctionAt(int index) { return &module_.functions[index]; } |
| 253 | 253 |
| 254 WasmInterpreter* interpreter() { return interpreter_; } | 254 WasmInterpreter* interpreter() { return interpreter_; } |
| 255 WasmExecutionMode execution_mode() { return execution_mode_; } | 255 WasmExecutionMode execution_mode() { return execution_mode_; } |
| 256 | 256 |
| 257 private: | 257 private: |
| 258 WasmExecutionMode execution_mode_; | 258 WasmExecutionMode execution_mode_; |
| 259 WasmModule module_; | 259 WasmModule module_; |
| 260 WasmModuleInstance instance_; | 260 WasmModuleInstance instance_; |
| 261 Isolate* isolate_; | 261 Isolate* isolate_; |
| 262 v8::base::AccountingAllocator allocator_; | 262 v8::internal::AccountingAllocator allocator_; |
| 263 uint32_t global_offset; | 263 uint32_t global_offset; |
| 264 V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; // preallocated global data. | 264 V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; // preallocated global data. |
| 265 WasmInterpreter* interpreter_; | 265 WasmInterpreter* interpreter_; |
| 266 | 266 |
| 267 const WasmGlobal* AddGlobal(LocalType type) { | 267 const WasmGlobal* AddGlobal(LocalType type) { |
| 268 byte size = WasmOpcodes::MemSize(WasmOpcodes::MachineTypeFor(type)); | 268 byte size = WasmOpcodes::MemSize(WasmOpcodes::MachineTypeFor(type)); |
| 269 global_offset = (global_offset + size - 1) & ~(size - 1); // align | 269 global_offset = (global_offset + size - 1) & ~(size - 1); // align |
| 270 module_.globals.push_back({0, 0, type, global_offset, false}); | 270 module_.globals.push_back({0, 0, type, global_offset, false}); |
| 271 global_offset += size; | 271 global_offset += size; |
| 272 // limit number of globals. | 272 // limit number of globals. |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 return val; | 742 return val; |
| 743 } | 743 } |
| 744 } | 744 } |
| 745 | 745 |
| 746 byte AllocateLocal(LocalType type) { return compiler_.AllocateLocal(type); } | 746 byte AllocateLocal(LocalType type) { return compiler_.AllocateLocal(type); } |
| 747 | 747 |
| 748 WasmFunction* function() { return compiler_.function_; } | 748 WasmFunction* function() { return compiler_.function_; } |
| 749 WasmInterpreter* interpreter() { return compiler_.interpreter_; } | 749 WasmInterpreter* interpreter() { return compiler_.interpreter_; } |
| 750 | 750 |
| 751 protected: | 751 protected: |
| 752 v8::base::AccountingAllocator allocator_; | 752 v8::internal::AccountingAllocator allocator_; |
| 753 Zone zone; | 753 Zone zone; |
| 754 bool compiled_; | 754 bool compiled_; |
| 755 LocalType storage_[WASM_RUNNER_MAX_NUM_PARAMETERS]; | 755 LocalType storage_[WASM_RUNNER_MAX_NUM_PARAMETERS]; |
| 756 FunctionSig signature_; | 756 FunctionSig signature_; |
| 757 WasmFunctionCompiler compiler_; | 757 WasmFunctionCompiler compiler_; |
| 758 WasmFunctionWrapper<ReturnType> wrapper_; | 758 WasmFunctionWrapper<ReturnType> wrapper_; |
| 759 | 759 |
| 760 bool interpret() { return compiler_.execution_mode_ == kExecuteInterpreted; } | 760 bool interpret() { return compiler_.execution_mode_ == kExecuteInterpreted; } |
| 761 | 761 |
| 762 static size_t GetParameterCount(MachineType p0, MachineType p1, | 762 static size_t GetParameterCount(MachineType p0, MachineType p1, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 775 // interpreter. | 775 // interpreter. |
| 776 #define WASM_EXEC_TEST(name) \ | 776 #define WASM_EXEC_TEST(name) \ |
| 777 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 777 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
| 778 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 778 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
| 779 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ | 779 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ |
| 780 void RunWasm_##name(WasmExecutionMode execution_mode) | 780 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 781 | 781 |
| 782 } // namespace | 782 } // namespace |
| 783 | 783 |
| 784 #endif | 784 #endif |
| OLD | NEW |