From a1f81530920cd02cc7913a4bddaba6fa87f352f4 Mon Sep 17 00:00:00 2001 From: Andreas Haas Date: Wed, 26 Jun 2019 16:29:45 +0200 Subject: [PATCH] [wasm] Import table only after checks With recent spec changes (I think in the bulk memory proposal), WebAssembly instances exist and can be used even when instantiation itself fails. Therefore the order of checks and assignents during instantiation may matter. That's why I move the table import after the checks of the import in this CL. Note that I'm not aware that this is a problem yet. I think in the worst case this CL has no effect. In the best case it helps. R=clemensh@chromium.org Bug: v8:9396 Change-Id: I83998ff98bded443b3f015cee778fa29a3374534 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1678656 Reviewed-by: Clemens Hammacher Commit-Queue: Andreas Haas Cr-Commit-Position: refs/heads/master@{#62409} --- src/wasm/module-instantiate.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wasm/module-instantiate.cc b/src/wasm/module-instantiate.cc index 00ac8766cf..a28b891602 100644 --- a/src/wasm/module-instantiate.cc +++ b/src/wasm/module-instantiate.cc @@ -941,7 +941,6 @@ bool InstanceBuilder::ProcessImportedTable(Handle instance, } const WasmTable& table = module_->tables[table_index]; - instance->tables().set(table_index, *value); auto table_object = Handle::cast(value); int imported_table_size = table_object->entries().length(); @@ -985,6 +984,7 @@ bool InstanceBuilder::ProcessImportedTable(Handle instance, return false; } + instance->tables().set(table_index, *value); return true; }