Commit 862d605c authored by Mircea Trofin's avatar Mircea Trofin Committed by Commit Bot

Revert "[wasm] Consolidate function table representation."

This reverts commit 4a45f35f.

Reason for revert: https://build.chromium.org/p/client.v8/builders/V8%20Linux64%20-%20debug%20builder/builds/25471 

Original change's description:
> [wasm] Consolidate function table representation.
> 
> This CL avoids the need to reference the function tables (and signatures)
> as either fixed arrays or vectors, preferring vectors.
> 
> The only place we need fixed arrays is on the compiled module, to support
> serialization. When we move off the GC heap, we'll also move away
> from fixed arrays in that last case.
> 
> The CL aids with getting wasm of the GC heap, by reducing the places 
> and representations we'll need to change  when changing the way we 
> reference fixed tables.
> 
> Bug: 
> Change-Id: Id4e43905a3df39062bf2839fa72dd5d9a0fe87da
> Reviewed-on: https://chromium-review.googlesource.com/588334
> Commit-Queue: Mircea Trofin <mtrofin@chromium.org>
> Reviewed-by: Brad Nelson <bradnelson@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#46917}

TBR=bradnelson@chromium.org,titzer@chromium.org,mtrofin@chromium.org,ahaas@chromium.org

Change-Id: Ie7d04f7ec74d6d0b3783df1c78c91c100ab784f4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/588627Reviewed-by: 's avatarMircea Trofin <mtrofin@chromium.org>
Commit-Queue: Mircea Trofin <mtrofin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46918}
parent 4a45f35f
......@@ -337,17 +337,23 @@ MaybeHandle<WasmModuleObject> ModuleCompiler::CompileToModuleObject(
// Initialize the indirect tables with placeholders.
int function_table_count = static_cast<int>(module_->function_tables.size());
Handle<FixedArray> function_tables =
factory->NewFixedArray(function_table_count, TENURED);
Handle<FixedArray> signature_tables =
factory->NewFixedArray(function_table_count, TENURED);
for (int i = 0; i < function_table_count; ++i) {
temp_instance.function_tables[i] = factory->NewFixedArray(1, TENURED);
temp_instance.signature_tables[i] = factory->NewFixedArray(1, TENURED);
function_tables->set(i, *temp_instance.function_tables[i]);
signature_tables->set(i, *temp_instance.signature_tables[i]);
}
TimedHistogramScope wasm_compile_module_time_scope(
module_->is_wasm() ? counters()->wasm_compile_wasm_module_time()
: counters()->wasm_compile_asm_module_time());
return CompileToModuleObjectInternal(thrower, wire_bytes, asm_js_script,
asm_js_offset_table_bytes, factory,
&temp_instance);
return CompileToModuleObjectInternal(
thrower, wire_bytes, asm_js_script, asm_js_offset_table_bytes, factory,
&temp_instance, &function_tables, &signature_tables);
}
namespace {
......@@ -556,7 +562,8 @@ void ResolvePromise(Isolate* isolate, Handle<Context> context,
MaybeHandle<WasmModuleObject> ModuleCompiler::CompileToModuleObjectInternal(
ErrorThrower* thrower, const ModuleWireBytes& wire_bytes,
Handle<Script> asm_js_script, Vector<const byte> asm_js_offset_table_bytes,
Factory* factory, WasmInstance* temp_instance) {
Factory* factory, WasmInstance* temp_instance,
Handle<FixedArray>* function_tables, Handle<FixedArray>* signature_tables) {
ModuleBytesEnv module_env(module_.get(), temp_instance, wire_bytes);
// The {code_table} array contains import wrappers and functions (which
......@@ -661,8 +668,7 @@ MaybeHandle<WasmModuleObject> ModuleCompiler::CompileToModuleObjectInternal(
// serializable. Instantiation may occur off a deserialized version of this
// object.
Handle<WasmCompiledModule> compiled_module = WasmCompiledModule::New(
isolate_, shared, code_table, *module_env.module_env.function_tables,
*module_env.module_env.signature_tables);
isolate_, shared, code_table, *function_tables, *signature_tables);
// If we created a wasm script, finish it now and make it public to the
// debugger.
......@@ -1906,6 +1912,8 @@ AsyncCompileJob::~AsyncCompileJob() {
void AsyncCompileJob::ReopenHandlesInDeferredScope() {
DeferredHandleScope deferred(isolate_);
function_tables_ = handle(*function_tables_, isolate_);
signature_tables_ = handle(*signature_tables_, isolate_);
code_table_ = handle(*code_table_, isolate_);
temp_instance_->ReopenHandles(isolate_);
compiler_->ReopenHandlesInDeferredScope();
......@@ -2071,11 +2079,18 @@ class AsyncCompileJob::PrepareAndStartCompile : public CompileStep {
// Initialize the indirect tables with placeholders.
int function_table_count =
static_cast<int>(module_->function_tables.size());
job_->function_tables_ =
factory->NewFixedArray(function_table_count, TENURED);
job_->signature_tables_ =
factory->NewFixedArray(function_table_count, TENURED);
for (int i = 0; i < function_table_count; ++i) {
job_->temp_instance_->function_tables[i] =
factory->NewFixedArray(1, TENURED);
job_->temp_instance_->signature_tables[i] =
factory->NewFixedArray(1, TENURED);
job_->function_tables_->set(i, *job_->temp_instance_->function_tables[i]);
job_->signature_tables_->set(i,
*job_->temp_instance_->signature_tables[i]);
}
// The {code_table} array contains import wrappers and functions (which
......@@ -2287,10 +2302,9 @@ class AsyncCompileJob::FinishCompile : public CompileStep {
// and information needed at instantiation time. This object needs to be
// serializable. Instantiation may occur off a deserialized version of
// this object.
job_->compiled_module_ =
WasmCompiledModule::New(job_->isolate_, shared, job_->code_table_,
job_->temp_instance_->function_tables,
job_->temp_instance_->signature_tables);
job_->compiled_module_ = WasmCompiledModule::New(
job_->isolate_, shared, job_->code_table_, job_->function_tables_,
job_->signature_tables_);
// Finish the wasm script now and make it public to the debugger.
script->set_wasm_compiled_module(*job_->compiled_module_);
......
......@@ -163,7 +163,8 @@ class ModuleCompiler {
ErrorThrower* thrower, const ModuleWireBytes& wire_bytes,
Handle<Script> asm_js_script,
Vector<const byte> asm_js_offset_table_bytes, Factory* factory,
WasmInstance* temp_instance);
WasmInstance* temp_instance, Handle<FixedArray>* function_tables,
Handle<FixedArray>* signature_tables);
Isolate* isolate_;
std::unique_ptr<WasmModule> module_;
......@@ -347,6 +348,8 @@ class AsyncCompileJob {
std::vector<DeferredHandles*> deferred_handles_;
Handle<WasmModuleObject> module_object_;
Handle<FixedArray> function_tables_;
Handle<FixedArray> signature_tables_;
Handle<WasmCompiledModule> compiled_module_;
Handle<FixedArray> code_table_;
std::unique_ptr<WasmInstance> temp_instance_ = nullptr;
......
......@@ -793,8 +793,8 @@ void WasmSharedModuleData::PrepareForLazyCompilation(
Handle<WasmCompiledModule> WasmCompiledModule::New(
Isolate* isolate, Handle<WasmSharedModuleData> shared,
Handle<FixedArray> code_table,
const std::vector<Handle<FixedArray>>& function_tables,
const std::vector<Handle<FixedArray>>& signature_tables) {
MaybeHandle<FixedArray> maybe_empty_function_tables,
MaybeHandle<FixedArray> maybe_signature_tables) {
Handle<FixedArray> ret =
isolate->factory()->NewFixedArray(PropertyIndices::Count, TENURED);
// WasmCompiledModule::cast would fail since fields are not set yet.
......@@ -804,22 +804,15 @@ Handle<WasmCompiledModule> WasmCompiledModule::New(
compiled_module->set_shared(shared);
compiled_module->set_native_context(isolate->native_context());
compiled_module->set_code_table(code_table);
size_t function_table_count = shared->module()->function_tables.size();
int function_table_count =
static_cast<int>(shared->module()->function_tables.size());
if (function_table_count > 0) {
DCHECK_EQ(function_tables.size(), signature_tables.size());
DCHECK_EQ(function_tables.size(), function_table_count);
int count_as_int = static_cast<int>(function_table_count);
Handle<FixedArray> sig_tables =
isolate->factory()->NewFixedArray(count_as_int, TENURED);
Handle<FixedArray> func_tables =
isolate->factory()->NewFixedArray(count_as_int, TENURED);
for (int i = 0; i < count_as_int; ++i) {
sig_tables->set(i, *(signature_tables[static_cast<size_t>(i)]));
func_tables->set(i, *(function_tables[static_cast<size_t>(i)]));
}
compiled_module->set_signature_tables(sig_tables);
compiled_module->set_empty_function_tables(func_tables);
compiled_module->set_function_tables(func_tables);
compiled_module->set_signature_tables(
maybe_signature_tables.ToHandleChecked());
compiled_module->set_empty_function_tables(
maybe_empty_function_tables.ToHandleChecked());
compiled_module->set_function_tables(
maybe_empty_function_tables.ToHandleChecked());
}
// TODO(mtrofin): we copy these because the order of finalization isn't
// reliable, and we need these at Reset (which is called at
......
......@@ -424,8 +424,8 @@ class WasmCompiledModule : public FixedArray {
static Handle<WasmCompiledModule> New(
Isolate* isolate, Handle<WasmSharedModuleData> shared,
Handle<FixedArray> code_table,
const std::vector<Handle<FixedArray>>& function_tables,
const std::vector<Handle<FixedArray>>& signature_tables);
MaybeHandle<FixedArray> maybe_empty_function_tables,
MaybeHandle<FixedArray> maybe_signature_tables);
static Handle<WasmCompiledModule> Clone(Isolate* isolate,
Handle<WasmCompiledModule> module);
......
......@@ -344,7 +344,8 @@ class TestingModule : public ModuleEnv {
Handle<FixedArray> code_table = isolate_->factory()->NewFixedArray(0);
Handle<WasmCompiledModule> compiled_module = WasmCompiledModule::New(
isolate_, shared_module_data, code_table, {}, {});
isolate_, shared_module_data, code_table, MaybeHandle<FixedArray>(),
MaybeHandle<FixedArray>());
Handle<FixedArray> weak_exported = isolate_->factory()->NewFixedArray(0);
compiled_module->set_weak_exported_functions(weak_exported);
DCHECK(WasmCompiledModule::IsWasmCompiledModule(*compiled_module));
......
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