| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 if (instance->mem_start) { | 92 if (instance->mem_start) { |
| 93 free(instance->mem_start); | 93 free(instance->mem_start); |
| 94 } | 94 } |
| 95 if (interpreter_) delete interpreter_; | 95 if (interpreter_) delete interpreter_; |
| 96 } | 96 } |
| 97 | 97 |
| 98 void ChangeOriginToAsmjs() { origin = kAsmJsOrigin; } | 98 void ChangeOriginToAsmjs() { origin = kAsmJsOrigin; } |
| 99 | 99 |
| 100 byte* AddMemory(uint32_t size) { | 100 byte* AddMemory(uint32_t size) { |
| 101 CHECK_NULL(instance->mem_start); | 101 CHECK_NULL(instance->mem_start); |
| 102 CHECK_EQ(0, instance->mem_size); | 102 CHECK_EQ(0u, instance->mem_size); |
| 103 instance->mem_start = reinterpret_cast<byte*>(malloc(size)); | 103 instance->mem_start = reinterpret_cast<byte*>(malloc(size)); |
| 104 CHECK(instance->mem_start); | 104 CHECK(instance->mem_start); |
| 105 memset(instance->mem_start, 0, size); | 105 memset(instance->mem_start, 0, size); |
| 106 instance->mem_size = size; | 106 instance->mem_size = size; |
| 107 return raw_mem_start<byte>(); | 107 return raw_mem_start<byte>(); |
| 108 } | 108 } |
| 109 | 109 |
| 110 template <typename T> | 110 template <typename T> |
| 111 T* AddMemoryElems(uint32_t count) { | 111 T* AddMemoryElems(uint32_t count) { |
| 112 AddMemory(count * sizeof(T)); | 112 AddMemory(count * sizeof(T)); |
| (...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 // interpreter. | 789 // interpreter. |
| 790 #define WASM_EXEC_TEST(name) \ | 790 #define WASM_EXEC_TEST(name) \ |
| 791 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 791 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
| 792 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 792 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
| 793 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ | 793 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ |
| 794 void RunWasm_##name(WasmExecutionMode execution_mode) | 794 void RunWasm_##name(WasmExecutionMode execution_mode) |
| 795 | 795 |
| 796 } // namespace | 796 } // namespace |
| 797 | 797 |
| 798 #endif | 798 #endif |
| OLD | NEW |