Commit 62a2a6ef authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] Only Table 0 can be the indirect-function-table

The {indirect_function_table_size} field of the instance was initialized
with the size of the first anyfunc table. However, this field should
only be set if Table 0 is of type anyfunc.

R=clemensh@chromium.org

Bug: chromium:977101
Change-Id: I4729feb6b67387ccda53d17179a34d719347efed
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1669697Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62314}
parent c4233951
......@@ -231,7 +231,7 @@ class InstanceBuilder {
// and globals.
void ProcessExports(Handle<WasmInstanceObject> instance);
void InitializeTables(Handle<WasmInstanceObject> instance);
void InitializeIndirectFunctionTable(Handle<WasmInstanceObject> instance);
void LoadTableSegments(Handle<WasmInstanceObject> instance);
......@@ -422,7 +422,7 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
// Initialize the indirect tables.
//--------------------------------------------------------------------------
if (table_count > 0) {
InitializeTables(instance);
InitializeIndirectFunctionTable(instance);
}
//--------------------------------------------------------------------------
......@@ -1594,16 +1594,15 @@ void InstanceBuilder::ProcessExports(Handle<WasmInstanceObject> instance) {
}
}
void InstanceBuilder::InitializeTables(Handle<WasmInstanceObject> instance) {
size_t table_count = module_->tables.size();
for (size_t index = 0; index < table_count; ++index) {
const WasmTable& table = module_->tables[index];
void InstanceBuilder::InitializeIndirectFunctionTable(
Handle<WasmInstanceObject> instance) {
DCHECK_GT(module_->tables.size(), 0);
if (!instance->has_indirect_function_table() &&
table.type == kWasmAnyFunc) {
WasmInstanceObject::EnsureIndirectFunctionTableWithMinimumSize(
instance, table.initial_size);
}
const WasmTable& table = module_->tables[0];
if (!instance->has_indirect_function_table() && table.type == kWasmAnyFunc) {
WasmInstanceObject::EnsureIndirectFunctionTableWithMinimumSize(
instance, table.initial_size);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment