Chromium Code Reviews| Index: src/wasm/wasm-module.cc | 
| diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc | 
| index 07d2ef1113f725ea24bffd1efd64dbd4afa15999..e92f6a88e6b913791c375a92fe348f9c6a206ec3 100644 | 
| --- a/src/wasm/wasm-module.cc | 
| +++ b/src/wasm/wasm-module.cc | 
| @@ -140,9 +140,19 @@ class WasmLinker { | 
| } | 
| if (!function_table.is_null()) { | 
| int table_size = static_cast<int>(functions.size()); | 
| - DCHECK_EQ(function_table->length(), table_size * 2); | 
| + int indirect_table_size; | 
| + if (FLAG_wasm_jit_prototype) { | 
| + indirect_table_size = 4 * table_size < kMinimumIndirectTableSize | 
| 
 
bradn
2016/06/16 08:00:20
I'd thought we'd talked about adding a field to on
 
 | 
| + ? kMinimumIndirectTableSize | 
| + : 4 * table_size; | 
| + DCHECK_EQ(function_table->length(), indirect_table_size); | 
| + } else { | 
| + indirect_table_size = 2 * table_size; | 
| + DCHECK_EQ(function_table->length(), indirect_table_size); | 
| + } | 
| for (int i = 0; i < table_size; i++) { | 
| - function_table->set(i + table_size, *function_code()[functions[i]]); | 
| + function_table->set(i + indirect_table_size / 2, | 
| + *function_code()[functions[i]]); | 
| } | 
| } | 
| } | 
| @@ -232,7 +242,16 @@ Handle<FixedArray> BuildFunctionTable(Isolate* isolate, | 
| return Handle<FixedArray>::null(); | 
| } | 
| int table_size = static_cast<int>(module->function_table.size()); | 
| - Handle<FixedArray> fixed = isolate->factory()->NewFixedArray(2 * table_size); | 
| + int indirect_table_size; | 
| + if (FLAG_wasm_jit_prototype) | 
| + indirect_table_size = 4 * table_size < kMinimumIndirectTableSize | 
| 
 
bradn
2016/06/16 08:00:20
Definitely don't want to repeat this calculation a
 
 | 
| + ? kMinimumIndirectTableSize | 
| + : 4 * table_size; | 
| + else | 
| + indirect_table_size = 2 * table_size; | 
| + | 
| + Handle<FixedArray> fixed = | 
| + isolate->factory()->NewFixedArray(indirect_table_size); | 
| for (int i = 0; i < table_size; i++) { | 
| const WasmFunction* function = | 
| &module->functions[module->function_table[i]]; | 
| @@ -735,6 +754,9 @@ MaybeHandle<JSObject> WasmModule::Instantiate( | 
| isolate->counters()->wasm_compile_module_time()); | 
| instance.function_table = BuildFunctionTable(isolate, this); | 
| + instance.padded_entries = | 
| + static_cast<int>(instance.function_table->length() / 2) - | 
| + static_cast<int>(instance.module->function_table.size()); | 
| WasmLinker linker(isolate, &instance.function_code); | 
| ModuleEnv module_env; | 
| module_env.module = this; | 
| @@ -929,6 +951,9 @@ int32_t CompileAndRunWasmModule(Isolate* isolate, const WasmModule* module) { | 
| // Build the function table. | 
| instance.function_table = BuildFunctionTable(isolate, module); | 
| + instance.padded_entries = | 
| + static_cast<int>(instance.function_table->length() / 2) - | 
| + static_cast<int>(module->function_table.size()); | 
| // Create module environment. | 
| WasmLinker linker(isolate, &instance.function_code); |