| 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 <setjmp.h> | 8 #include <setjmp.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <stdlib.h> | 10 #include <stdlib.h> |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 ~TestingModule() { | 98 ~TestingModule() { |
| 99 if (instance->mem_start) { | 99 if (instance->mem_start) { |
| 100 free(instance->mem_start); | 100 free(instance->mem_start); |
| 101 } | 101 } |
| 102 if (interpreter_) delete interpreter_; | 102 if (interpreter_) delete interpreter_; |
| 103 } | 103 } |
| 104 | 104 |
| 105 void ChangeOriginToAsmjs() { module_.origin = kAsmJsOrigin; } | 105 void ChangeOriginToAsmjs() { module_.origin = kAsmJsOrigin; } |
| 106 | 106 |
| 107 byte* AddMemory(uint32_t size) { | 107 byte* AddMemory(uint32_t size) { |
| 108 CHECK(!module_.has_memory); |
| 108 CHECK_NULL(instance->mem_start); | 109 CHECK_NULL(instance->mem_start); |
| 109 CHECK_EQ(0, instance->mem_size); | 110 CHECK_EQ(0, instance->mem_size); |
| 111 module_.has_memory = true; |
| 110 instance->mem_start = reinterpret_cast<byte*>(malloc(size)); | 112 instance->mem_start = reinterpret_cast<byte*>(malloc(size)); |
| 111 CHECK(instance->mem_start); | 113 CHECK(instance->mem_start); |
| 112 memset(instance->mem_start, 0, size); | 114 memset(instance->mem_start, 0, size); |
| 113 instance->mem_size = size; | 115 instance->mem_size = size; |
| 114 return raw_mem_start<byte>(); | 116 return raw_mem_start<byte>(); |
| 115 } | 117 } |
| 116 | 118 |
| 117 template <typename T> | 119 template <typename T> |
| 118 T* AddMemoryElems(uint32_t count) { | 120 T* AddMemoryElems(uint32_t count) { |
| 119 AddMemory(count * sizeof(T)); | 121 AddMemory(count * sizeof(T)); |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 void RunWasm_##name(WasmExecutionMode execution_mode) | 813 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 812 | 814 |
| 813 #define WASM_EXEC_COMPILED_TEST(name) \ | 815 #define WASM_EXEC_COMPILED_TEST(name) \ |
| 814 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 816 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
| 815 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 817 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
| 816 void RunWasm_##name(WasmExecutionMode execution_mode) | 818 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 817 | 819 |
| 818 } // namespace | 820 } // namespace |
| 819 | 821 |
| 820 #endif | 822 #endif |
| OLD | NEW |