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

Unified Diff: src/wasm/wasm-interpreter.cc

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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-interpreter.cc
diff --git a/src/wasm/wasm-interpreter.cc b/src/wasm/wasm-interpreter.cc
index 4d2d994e459db356d3572400f6636f42d4bf4e5d..9cfe521149eb46cf113ceeeda3123720ee1f02fa 100644
--- a/src/wasm/wasm-interpreter.cc
+++ b/src/wasm/wasm-interpreter.cc
@@ -915,9 +915,12 @@ class CodeMap {
return Preprocess(&interpreter_code_[function_index]);
}
- InterpreterCode* GetIndirectCode(uint32_t indirect_index) {
- if (indirect_index >= module_->function_table.size()) return nullptr;
- uint32_t index = module_->function_table[indirect_index];
+ InterpreterCode* GetIndirectCode(uint32_t table_index, uint32_t entry_index) {
+ if (table_index >= module_->function_tables.size()) return nullptr;
+ const WasmIndirectFunctionTable* table =
+ &module_->function_tables[table_index];
+ if (entry_index >= table->values.size()) return nullptr;
+ uint32_t index = table->values[entry_index];
if (index >= interpreter_code_.size()) return nullptr;
return GetCode(index);
}
@@ -1383,14 +1386,13 @@ class ThreadImpl : public WasmInterpreter::Thread {
CallIndirectOperand operand(&decoder, code->at(pc));
size_t index = stack_.size() - operand.arity - 1;
DCHECK_LT(index, stack_.size());
- uint32_t table_index = stack_[index].to<uint32_t>();
- if (table_index >= module()->function_table.size()) {
+ uint32_t entry_index = stack_[index].to<uint32_t>();
+ // Assume only one table for now.
+ DCHECK_LE(module()->function_tables.size(), 1u);
+ InterpreterCode* target = codemap()->GetIndirectCode(0, entry_index);
+ if (target == nullptr) {
return DoTrap(kTrapFuncInvalid, pc);
- }
- uint16_t function_index = module()->function_table[table_index];
- InterpreterCode* target = codemap()->GetCode(function_index);
- DCHECK(target);
- if (target->function->sig_index != operand.index) {
+ } else if (target->function->sig_index != operand.index) {
return DoTrap(kTrapFuncSigMismatch, pc);
}
« no previous file with comments | « src/wasm/module-decoder.cc ('k') | src/wasm/wasm-module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698