| Index: src/compiler/wasm-compiler.cc
|
| diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc
|
| index 4285f58f7e49640dd59024adf14c154884bfddfd..138e53537a0270f93b8d56a140fd9803ecf529e6 100644
|
| --- a/src/compiler/wasm-compiler.cc
|
| +++ b/src/compiler/wasm-compiler.cc
|
| @@ -1997,7 +1997,8 @@ Node* WasmGraphBuilder::CallImport(uint32_t index, Node** args,
|
| return BuildWasmCall(sig, args, position);
|
| }
|
|
|
| -Node* WasmGraphBuilder::CallIndirect(uint32_t index, Node** args,
|
| +Node* WasmGraphBuilder::CallIndirect(uint32_t entry_index, uint32_t table_index,
|
| + Node** args,
|
| wasm::WasmCodePosition position) {
|
| DCHECK_NOT_NULL(args[0]);
|
| DCHECK(module_ && module_->instance);
|
| @@ -2007,11 +2008,10 @@ Node* WasmGraphBuilder::CallIndirect(uint32_t index, Node** args,
|
| // Compute the code object by loading it from the function table.
|
| Node* key = args[0];
|
|
|
| - // Assume only one table for now.
|
| - DCHECK_LE(module_->instance->function_tables.size(), 1u);
|
| // Bounds check the index.
|
| - uint32_t table_size =
|
| - module_->IsValidTable(0) ? module_->GetTable(0)->max_size : 0;
|
| + uint32_t table_size = module_->IsValidTable(table_index)
|
| + ? module_->GetTable(table_index)->max_size
|
| + : 0;
|
| if (table_size > 0) {
|
| // Bounds check against the table size.
|
| Node* size = Uint32Constant(table_size);
|
| @@ -2020,28 +2020,15 @@ Node* WasmGraphBuilder::CallIndirect(uint32_t index, Node** args,
|
| } else {
|
| // No function table. Generate a trap and return a constant.
|
| trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, Int32Constant(0), position);
|
| - return trap_->GetTrapValue(module_->GetSignature(index));
|
| + return trap_->GetTrapValue(module_->GetSignature(entry_index));
|
| }
|
| - Node* table = FunctionTable(0);
|
| + Node* table = FunctionTable(table_index);
|
|
|
| - // Load signature from the table and check.
|
| + // Load signature from the table.
|
| // The table is a FixedArray; signatures are encoded as SMIs.
|
| // [sig1, sig2, sig3, ...., code1, code2, code3 ...]
|
| ElementAccess access = AccessBuilder::ForFixedArrayElement();
|
| const int fixed_offset = access.header_size - access.tag();
|
| - {
|
| - Node* load_sig = graph()->NewNode(
|
| - machine->Load(MachineType::AnyTagged()), table,
|
| - graph()->NewNode(machine->Int32Add(),
|
| - graph()->NewNode(machine->Word32Shl(), key,
|
| - Int32Constant(kPointerSizeLog2)),
|
| - Int32Constant(fixed_offset)),
|
| - *effect_, *control_);
|
| - Node* sig_match =
|
| - graph()->NewNode(machine->Word32Equal(),
|
| - BuildChangeSmiToInt32(load_sig), Int32Constant(index));
|
| - trap_->AddTrapIfFalse(wasm::kTrapFuncSigMismatch, sig_match, position);
|
| - }
|
|
|
| // Load code object from the table.
|
| uint32_t offset = fixed_offset + kPointerSize * table_size;
|
| @@ -2054,7 +2041,7 @@ Node* WasmGraphBuilder::CallIndirect(uint32_t index, Node** args,
|
| *effect_, *control_);
|
|
|
| args[0] = load_code;
|
| - wasm::FunctionSig* sig = module_->GetSignature(index);
|
| + wasm::FunctionSig* sig = module_->GetSignature(entry_index);
|
| return BuildWasmCall(sig, args, position);
|
| }
|
|
|
|
|