Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: test/cctest/wasm/wasm-run-utils.h

Issue 2174123002: [wasm] Add support for multiple indirect function tables (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix GC issue Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/wasm/test-run-wasm.cc ('k') | test/mjsunit/wasm/wasm-constants.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 isolate_, ret_code, name, 215 isolate_, ret_code, name,
216 static_cast<int>(this->module->functions[index].sig->parameter_count()), 216 static_cast<int>(this->module->functions[index].sig->parameter_count()),
217 module_object); 217 module_object);
218 return ret; 218 return ret;
219 } 219 }
220 220
221 void SetFunctionCode(uint32_t index, Handle<Code> code) { 221 void SetFunctionCode(uint32_t index, Handle<Code> code) {
222 instance->function_code[index] = code; 222 instance->function_code[index] = code;
223 } 223 }
224 224
225 void AddIndirectFunctionTable(int* functions, int table_size) { 225 void AddIndirectFunctionTable(uint16_t* functions, uint32_t table_size) {
226 Handle<FixedArray> fixed = 226 module_.function_tables.push_back(
227 isolate_->factory()->NewFixedArray(2 * table_size); 227 {table_size, table_size, std::vector<uint16_t>()});
228 instance->function_table = fixed; 228 for (uint32_t i = 0; i < table_size; ++i) {
229 DCHECK_EQ(0u, module->function_table.size()); 229 module_.function_tables.back().values.push_back(functions[i]);
230 for (int i = 0; i < table_size; i++) { 230 }
231 module_.function_table.push_back(functions[i]); 231
232 Handle<FixedArray> values = BuildFunctionTable(
233 isolate_, static_cast<int>(module_.function_tables.size() - 1),
234 &module_);
235 instance->function_tables.push_back(values);
236 }
237
238 void PopulateIndirectFunctionTable() {
239 for (uint32_t i = 0; i < instance->function_tables.size(); i++) {
240 PopulateFunctionTable(instance->function_tables[i],
241 module_.function_tables[i].size,
242 &instance->function_code);
232 } 243 }
233 } 244 }
234 245
235 void PopulateIndirectFunctionTable() {
236 if (instance->function_table.is_null()) return;
237 int table_size = static_cast<int>(module->function_table.size());
238 for (int i = 0; i < table_size; i++) {
239 int function_index = module->function_table[i];
240 const WasmFunction* function = &module->functions[function_index];
241 instance->function_table->set(i, Smi::FromInt(function->sig_index));
242 instance->function_table->set(i + table_size,
243 *instance->function_code[function_index]);
244 }
245 }
246
247 WasmFunction* GetFunctionAt(int index) { return &module_.functions[index]; } 246 WasmFunction* GetFunctionAt(int index) { return &module_.functions[index]; }
248 247
249 WasmInterpreter* interpreter() { return interpreter_; } 248 WasmInterpreter* interpreter() { return interpreter_; }
250 WasmExecutionMode execution_mode() { return execution_mode_; } 249 WasmExecutionMode execution_mode() { return execution_mode_; }
251 250
252 private: 251 private:
253 WasmExecutionMode execution_mode_; 252 WasmExecutionMode execution_mode_;
254 WasmModule module_; 253 WasmModule module_;
255 WasmModuleInstance instance_; 254 WasmModuleInstance instance_;
256 Isolate* isolate_; 255 Isolate* isolate_;
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 // interpreter. 768 // interpreter.
770 #define WASM_EXEC_TEST(name) \ 769 #define WASM_EXEC_TEST(name) \
771 void RunWasm_##name(WasmExecutionMode execution_mode); \ 770 void RunWasm_##name(WasmExecutionMode execution_mode); \
772 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \ 771 TEST(RunWasmCompiled_##name) { RunWasm_##name(kExecuteCompiled); } \
773 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \ 772 TEST(RunWasmInterpreted_##name) { RunWasm_##name(kExecuteInterpreted); } \
774 void RunWasm_##name(WasmExecutionMode execution_mode) 773 void RunWasm_##name(WasmExecutionMode execution_mode)
775 774
776 } // namespace 775 } // namespace
777 776
778 #endif 777 #endif
OLDNEW
« no previous file with comments | « test/cctest/wasm/test-run-wasm.cc ('k') | test/mjsunit/wasm/wasm-constants.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698