Commit c931faa2 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] Remove the table_object instance field

The table_object instance field is not needed anymore because its
purpose is fulfilled now by the tables field I introduced to support
multiple tables.

In addition I removed {table_instances_} from the {InstanceBuilder}.
This field existed because tables could exist without a WasmTableObject.
With recent changes, WasmTableObjects always exist.

R=mstarzinger@chromium.org

Bug: v8:7581
Change-Id: I5e8e3d2910f7ed7ae74d61eff660f9451b3493ac
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1466641
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60149}
parent f3d1777d
...@@ -1831,8 +1831,8 @@ void WasmInstanceObject::WasmInstanceObjectPrint(std::ostream& os) { // NOLINT ...@@ -1831,8 +1831,8 @@ void WasmInstanceObject::WasmInstanceObjectPrint(std::ostream& os) { // NOLINT
if (has_debug_info()) { if (has_debug_info()) {
os << "\n - debug_info: " << Brief(debug_info()); os << "\n - debug_info: " << Brief(debug_info());
} }
if (has_table_object()) { for (int i = 0; i < tables()->length(); i++) {
os << "\n - table_object: " << Brief(table_object()); os << "\n - table " << i << ": " << Brief(tables()->get(i));
} }
os << "\n - imported_function_refs: " << Brief(imported_function_refs()); os << "\n - imported_function_refs: " << Brief(imported_function_refs());
if (has_indirect_function_table_refs()) { if (has_indirect_function_table_refs()) {
......
This diff is collapsed.
...@@ -223,8 +223,6 @@ OPTIONAL_ACCESSORS(WasmInstanceObject, imported_mutable_globals_buffers, ...@@ -223,8 +223,6 @@ OPTIONAL_ACCESSORS(WasmInstanceObject, imported_mutable_globals_buffers,
FixedArray, kImportedMutableGlobalsBuffersOffset) FixedArray, kImportedMutableGlobalsBuffersOffset)
OPTIONAL_ACCESSORS(WasmInstanceObject, debug_info, WasmDebugInfo, OPTIONAL_ACCESSORS(WasmInstanceObject, debug_info, WasmDebugInfo,
kDebugInfoOffset) kDebugInfoOffset)
OPTIONAL_ACCESSORS(WasmInstanceObject, table_object, WasmTableObject,
kTableObjectOffset)
OPTIONAL_ACCESSORS(WasmInstanceObject, tables, FixedArray, kTablesOffset) OPTIONAL_ACCESSORS(WasmInstanceObject, tables, FixedArray, kTablesOffset)
ACCESSORS(WasmInstanceObject, imported_function_refs, FixedArray, ACCESSORS(WasmInstanceObject, imported_function_refs, FixedArray,
kImportedFunctionRefsOffset) kImportedFunctionRefsOffset)
......
...@@ -1565,6 +1565,13 @@ bool WasmInstanceObject::CopyTableEntries(Isolate* isolate, ...@@ -1565,6 +1565,13 @@ bool WasmInstanceObject::CopyTableEntries(Isolate* isolate,
uint32_t table_dst_index, uint32_t table_dst_index,
uint32_t dst, uint32_t src, uint32_t dst, uint32_t src,
uint32_t count) { uint32_t count) {
if (static_cast<int>(table_dst_index) >= instance->tables()->length()) {
return false;
}
if (static_cast<int>(table_src_index) >= instance->tables()->length()) {
return false;
}
// TODO(titzer): multiple tables in TableCopy // TODO(titzer): multiple tables in TableCopy
CHECK_EQ(0, table_src_index); CHECK_EQ(0, table_src_index);
CHECK_EQ(0, table_dst_index); CHECK_EQ(0, table_dst_index);
...@@ -1580,14 +1587,9 @@ bool WasmInstanceObject::CopyTableEntries(Isolate* isolate, ...@@ -1580,14 +1587,9 @@ bool WasmInstanceObject::CopyTableEntries(Isolate* isolate,
if (dst == src || count == 0) return ok; // no-op if (dst == src || count == 0) return ok; // no-op
if (!instance->has_table_object()) { // TODO(titzer): multiple tables in TableCopy
// No table object, only need to update this instance. auto table = handle(
CopyTableEntriesImpl(instance, dst, src, count, copy_backward); WasmTableObject::cast(instance->tables()->get(table_src_index)), isolate);
return ok;
}
Handle<WasmTableObject> table =
Handle<WasmTableObject>(instance->table_object(), isolate);
// Broadcast table copy operation to all instances that import this table. // Broadcast table copy operation to all instances that import this table.
Handle<FixedArray> dispatch_tables(table->dispatch_tables(), isolate); Handle<FixedArray> dispatch_tables(table->dispatch_tables(), isolate);
for (int i = 0; i < dispatch_tables->length(); for (int i = 0; i < dispatch_tables->length();
...@@ -1600,14 +1602,18 @@ bool WasmInstanceObject::CopyTableEntries(Isolate* isolate, ...@@ -1600,14 +1602,18 @@ bool WasmInstanceObject::CopyTableEntries(Isolate* isolate,
} }
// Copy the function entries. // Copy the function entries.
Handle<FixedArray> functions(table->elements(), isolate); auto dst_table = handle(
WasmTableObject::cast(instance->tables()->get(table_dst_index)), isolate);
auto src_table = handle(
WasmTableObject::cast(instance->tables()->get(table_src_index)), isolate);
if (copy_backward) { if (copy_backward) {
for (uint32_t i = count; i > 0; i--) { for (uint32_t i = count; i > 0; i--) {
functions->set(dst + i - 1, functions->get(src + i - 1)); dst_table->elements()->set(dst + i - 1,
src_table->elements()->get(src + i - 1));
} }
} else { } else {
for (uint32_t i = 0; i < count; i++) { for (uint32_t i = 0; i < count; i++) {
functions->set(dst + i, functions->get(src + i)); dst_table->elements()->set(dst + i, src_table->elements()->get(src + i));
} }
} }
return ok; return ok;
......
...@@ -414,7 +414,6 @@ class WasmInstanceObject : public JSObject { ...@@ -414,7 +414,6 @@ class WasmInstanceObject : public JSObject {
DECL_OPTIONAL_ACCESSORS(tagged_globals_buffer, FixedArray) DECL_OPTIONAL_ACCESSORS(tagged_globals_buffer, FixedArray)
DECL_OPTIONAL_ACCESSORS(imported_mutable_globals_buffers, FixedArray) DECL_OPTIONAL_ACCESSORS(imported_mutable_globals_buffers, FixedArray)
DECL_OPTIONAL_ACCESSORS(debug_info, WasmDebugInfo) DECL_OPTIONAL_ACCESSORS(debug_info, WasmDebugInfo)
DECL_OPTIONAL_ACCESSORS(table_object, WasmTableObject)
DECL_OPTIONAL_ACCESSORS(tables, FixedArray) DECL_OPTIONAL_ACCESSORS(tables, FixedArray)
DECL_ACCESSORS(imported_function_refs, FixedArray) DECL_ACCESSORS(imported_function_refs, FixedArray)
DECL_OPTIONAL_ACCESSORS(indirect_function_table_refs, FixedArray) DECL_OPTIONAL_ACCESSORS(indirect_function_table_refs, FixedArray)
...@@ -461,7 +460,6 @@ class WasmInstanceObject : public JSObject { ...@@ -461,7 +460,6 @@ class WasmInstanceObject : public JSObject {
V(kTaggedGlobalsBufferOffset, kTaggedSize) \ V(kTaggedGlobalsBufferOffset, kTaggedSize) \
V(kImportedMutableGlobalsBuffersOffset, kTaggedSize) \ V(kImportedMutableGlobalsBuffersOffset, kTaggedSize) \
V(kDebugInfoOffset, kTaggedSize) \ V(kDebugInfoOffset, kTaggedSize) \
V(kTableObjectOffset, kTaggedSize) \
V(kTablesOffset, kTaggedSize) \ V(kTablesOffset, kTaggedSize) \
V(kImportedFunctionRefsOffset, kTaggedSize) \ V(kImportedFunctionRefsOffset, kTaggedSize) \
V(kIndirectFunctionTableRefsOffset, kTaggedSize) \ V(kIndirectFunctionTableRefsOffset, kTaggedSize) \
......
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