Chromium Code Reviews| Index: src/compiler/wasm-compiler.cc |
| diff --git a/src/compiler/wasm-compiler.cc b/src/compiler/wasm-compiler.cc |
| index 09290af06aa7023f3da35cb95f735427f4b24834..93392ad66545551aac0d1f6ca4ba9a69ba7b3b49 100644 |
| --- a/src/compiler/wasm-compiler.cc |
| +++ b/src/compiler/wasm-compiler.cc |
| @@ -1931,10 +1931,22 @@ Node* WasmGraphBuilder::CallIndirect(uint32_t index, Node** args, |
| // Bounds check the index. |
| int table_size = static_cast<int>(module_->FunctionTableSize()); |
| if (table_size > 0) { |
| - // Bounds check against the table size. |
| - Node* size = Int32Constant(static_cast<int>(table_size)); |
| - Node* in_bounds = graph()->NewNode(machine->Uint32LessThan(), key, size); |
| - trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, in_bounds, position); |
| + if (FLAG_wasm_jit_prototype) { |
| + int indirect_table_size = |
|
bradn
2016/06/16 08:00:20
Can we move the computation of the size to Functio
|
| + static_cast<int>(module_->instance->function_table->length()); |
| + |
| + Node* lower_bound = Int32Constant(indirect_table_size / 2 - |
| + module_->instance->padded_entries); |
| + Node* more_than_lower_bound = |
| + graph()->NewNode(machine->Uint32LessThanOrEqual(), lower_bound, key); |
| + trap_->AddTrapIfTrue(wasm::kTrapFuncInvalid, more_than_lower_bound, |
| + position); |
| + } else { |
| + // Bounds check against the table size. |
| + Node* size = Int32Constant(static_cast<int>(table_size)); |
| + Node* in_bounds = graph()->NewNode(machine->Uint32LessThan(), key, size); |
| + trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, in_bounds, position); |
| + } |
| } else { |
| // No function table. Generate a trap and return a constant. |
| trap_->AddTrapIfFalse(wasm::kTrapFuncInvalid, Int32Constant(0), position); |