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> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 return raw_mem_start<byte>(); | 105 return raw_mem_start<byte>(); |
106 } | 106 } |
107 | 107 |
108 template <typename T> | 108 template <typename T> |
109 T* AddMemoryElems(uint32_t count) { | 109 T* AddMemoryElems(uint32_t count) { |
110 AddMemory(count * sizeof(T)); | 110 AddMemory(count * sizeof(T)); |
111 return raw_mem_start<T>(); | 111 return raw_mem_start<T>(); |
112 } | 112 } |
113 | 113 |
114 template <typename T> | 114 template <typename T> |
115 T* AddGlobal(MachineType mem_type) { | 115 T* AddGlobal(LocalType type) { |
116 const WasmGlobal* global = AddGlobal(mem_type); | 116 const WasmGlobal* global = AddGlobal(type); |
117 return reinterpret_cast<T*>(instance->globals_start + global->offset); | 117 return reinterpret_cast<T*>(instance->globals_start + global->offset); |
118 } | 118 } |
119 | 119 |
120 byte AddSignature(FunctionSig* sig) { | 120 byte AddSignature(FunctionSig* sig) { |
121 module_.signatures.push_back(sig); | 121 module_.signatures.push_back(sig); |
122 size_t size = module->signatures.size(); | 122 size_t size = module->signatures.size(); |
123 CHECK(size < 127); | 123 CHECK(size < 127); |
124 return static_cast<byte>(size - 1); | 124 return static_cast<byte>(size - 1); |
125 } | 125 } |
126 | 126 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 private: | 250 private: |
251 WasmExecutionMode execution_mode_; | 251 WasmExecutionMode execution_mode_; |
252 WasmModule module_; | 252 WasmModule module_; |
253 WasmModuleInstance instance_; | 253 WasmModuleInstance instance_; |
254 Isolate* isolate_; | 254 Isolate* isolate_; |
255 v8::base::AccountingAllocator allocator_; | 255 v8::base::AccountingAllocator allocator_; |
256 uint32_t global_offset; | 256 uint32_t global_offset; |
257 V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; // preallocated global data. | 257 V8_ALIGNED(8) byte global_data[kMaxGlobalsSize]; // preallocated global data. |
258 WasmInterpreter* interpreter_; | 258 WasmInterpreter* interpreter_; |
259 | 259 |
260 const WasmGlobal* AddGlobal(MachineType mem_type) { | 260 const WasmGlobal* AddGlobal(LocalType type) { |
261 byte size = WasmOpcodes::MemSize(mem_type); | 261 byte size = WasmOpcodes::MemSize(WasmOpcodes::MachineTypeFor(type)); |
262 global_offset = (global_offset + size - 1) & ~(size - 1); // align | 262 global_offset = (global_offset + size - 1) & ~(size - 1); // align |
263 module_.globals.push_back({0, 0, mem_type, global_offset, false}); | 263 module_.globals.push_back({0, 0, type, global_offset, false}); |
264 global_offset += size; | 264 global_offset += size; |
265 // limit number of globals. | 265 // limit number of globals. |
266 CHECK_LT(global_offset, kMaxGlobalsSize); | 266 CHECK_LT(global_offset, kMaxGlobalsSize); |
267 return &module->globals.back(); | 267 return &module->globals.back(); |
268 } | 268 } |
269 }; | 269 }; |
270 | 270 |
271 inline void TestBuildingGraph(Zone* zone, JSGraph* jsgraph, ModuleEnv* module, | 271 inline void TestBuildingGraph(Zone* zone, JSGraph* jsgraph, ModuleEnv* module, |
272 FunctionSig* sig, | 272 FunctionSig* sig, |
273 SourcePositionTable* source_position_table, | 273 SourcePositionTable* source_position_table, |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 // interpreter. | 767 // interpreter. |
768 #define WASM_EXEC_TEST(name) \ | 768 #define WASM_EXEC_TEST(name) \ |
769 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 769 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
770 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 770 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
771 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ | 771 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ |
772 void RunWasm_##name(WasmExecutionMode execution_mode) | 772 void RunWasm_##name(WasmExecutionMode execution_mode) |
773 | 773 |
774 } // namespace | 774 } // namespace |
775 | 775 |
776 #endif | 776 #endif |
OLD | NEW |