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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 rng.NextBytes(raw, end - raw); | 172 rng.NextBytes(raw, end - raw); |
173 } | 173 } |
174 | 174 |
175 uint32_t AddFunction(FunctionSig* sig, Handle<Code> code) { | 175 uint32_t AddFunction(FunctionSig* sig, Handle<Code> code) { |
176 if (module->functions.size() == 0) { | 176 if (module->functions.size() == 0) { |
177 // TODO(titzer): Reserving space here to avoid the underlying WasmFunction | 177 // TODO(titzer): Reserving space here to avoid the underlying WasmFunction |
178 // structs from moving. | 178 // structs from moving. |
179 module_.functions.reserve(kMaxFunctions); | 179 module_.functions.reserve(kMaxFunctions); |
180 } | 180 } |
181 uint32_t index = static_cast<uint32_t>(module->functions.size()); | 181 uint32_t index = static_cast<uint32_t>(module->functions.size()); |
182 module_.functions.push_back({sig, index, 0, 0, 0, 0, 0, false}); | 182 module_.functions.push_back({sig, index, 0, 0, 0, 0, 0}); |
183 instance->function_code.push_back(code); | 183 instance->function_code.push_back(code); |
184 if (interpreter_) { | 184 if (interpreter_) { |
185 const WasmFunction* function = &module->functions.back(); | 185 const WasmFunction* function = &module->functions.back(); |
186 int interpreter_index = interpreter_->AddFunctionForTesting(function); | 186 int interpreter_index = interpreter_->AddFunctionForTesting(function); |
187 CHECK_EQ(index, static_cast<uint32_t>(interpreter_index)); | 187 CHECK_EQ(index, static_cast<uint32_t>(interpreter_index)); |
188 } | 188 } |
189 DCHECK_LT(index, kMaxFunctions); // limited for testing. | 189 DCHECK_LT(index, kMaxFunctions); // limited for testing. |
190 return index; | 190 return index; |
191 } | 191 } |
192 | 192 |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 // interpreter. | 762 // interpreter. |
763 #define WASM_EXEC_TEST(name) \ | 763 #define WASM_EXEC_TEST(name) \ |
764 void RunWasm_##name(WasmExecutionMode execution_mode); \ | 764 void RunWasm_##name(WasmExecutionMode execution_mode); \ |
765 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ | 765 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ |
766 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ | 766 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ |
767 void RunWasm_##name(WasmExecutionMode execution_mode) | 767 void RunWasm_##name(WasmExecutionMode execution_mode) |
768 | 768 |
769 } // namespace | 769 } // namespace |
770 | 770 |
771 #endif | 771 #endif |
OLD | NEW |