| Index: src/wasm/wasm-module.cc
|
| diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
|
| index c9a42797eb93b5781e5c5ed6c2151e680879efa9..75e0030acb25b466127bc90d8121021c5e20b22f 100644
|
| --- a/src/wasm/wasm-module.cc
|
| +++ b/src/wasm/wasm-module.cc
|
| @@ -148,9 +148,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
|
| + ? 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]]);
|
| }
|
| }
|
| }
|
| @@ -233,7 +243,16 @@ Handle<FixedArray> BuildFunctionTable(Isolate* isolate, WasmModule* module) {
|
| 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
|
| + ? 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++) {
|
| WasmFunction* function = &module->functions[module->function_table[i]];
|
| fixed->set(i, Smi::FromInt(function->sig_index));
|
| @@ -683,6 +702,9 @@ MaybeHandle<JSObject> WasmModule::Instantiate(Isolate* isolate,
|
| 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, functions.size());
|
| ModuleEnv module_env;
|
| module_env.module = this;
|
| @@ -914,6 +936,9 @@ int32_t CompileAndRunWasmModule(Isolate* isolate, 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, module->functions.size());
|
|
|