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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 memset(global_data, 0, sizeof(global_data)); | 89 memset(global_data, 0, sizeof(global_data)); |
90 } | 90 } |
91 | 91 |
92 ~TestingModule() { | 92 ~TestingModule() { |
93 if (instance->mem_start) { | 93 if (instance->mem_start) { |
94 free(instance->mem_start); | 94 free(instance->mem_start); |
95 } | 95 } |
96 if (interpreter_) delete interpreter_; | 96 if (interpreter_) delete interpreter_; |
97 } | 97 } |
98 | 98 |
99 byte* AddMemory(size_t size) { | 99 byte* AddMemory(uint32_t size) { |
100 CHECK_NULL(instance->mem_start); | 100 CHECK_NULL(instance->mem_start); |
101 CHECK_EQ(0, instance->mem_size); | 101 CHECK_EQ(0, instance->mem_size); |
102 instance->mem_start = reinterpret_cast<byte*>(malloc(size)); | 102 instance->mem_start = reinterpret_cast<byte*>(malloc(size)); |
103 CHECK(instance->mem_start); | 103 CHECK(instance->mem_start); |
104 memset(instance->mem_start, 0, size); | 104 memset(instance->mem_start, 0, size); |
105 instance->mem_size = size; | 105 instance->mem_size = size; |
106 return raw_mem_start<byte>(); | 106 return raw_mem_start<byte>(); |
107 } | 107 } |
108 | 108 |
109 template <typename T> | 109 template <typename T> |
110 T* AddMemoryElems(size_t count) { | 110 T* AddMemoryElems(uint32_t count) { |
111 AddMemory(count * sizeof(T)); | 111 AddMemory(count * sizeof(T)); |
112 return raw_mem_start<T>(); | 112 return raw_mem_start<T>(); |
113 } | 113 } |
114 | 114 |
115 template <typename T> | 115 template <typename T> |
116 T* AddGlobal(MachineType mem_type) { | 116 T* AddGlobal(MachineType mem_type) { |
117 const WasmGlobal* global = AddGlobal(mem_type); | 117 const WasmGlobal* global = AddGlobal(mem_type); |
118 return reinterpret_cast<T*>(instance->globals_start + global->offset); | 118 return reinterpret_cast<T*>(instance->globals_start + global->offset); |
119 } | 119 } |
120 | 120 |
(...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 // interpreter. | 755 // interpreter. |
756 #define WASM_EXEC_TEST(name) \ | 756 #define WASM_EXEC_TEST(name) \ |
757 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 757 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
758 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 758 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
759 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ | 759 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ |
760 void RunWasm_##name(WasmExecutionMode execution_mode) | 760 void RunWasm_##name(WasmExecutionMode execution_mode) |
761 | 761 |
762 } // namespace | 762 } // namespace |
763 | 763 |
764 #endif | 764 #endif |
OLD | NEW |