Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(602)

Unified Diff: src/wasm/wasm-module.cc

Issue 2784233004: [wasm] Further simplify WasmCompiledModule. (Closed)
Patch Set: . Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/wasm/wasm-objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-module.cc
diff --git a/src/wasm/wasm-module.cc b/src/wasm/wasm-module.cc
index 01e361cdccce32cfefb28542428d343a069afed0..245a58dfd0958852f9892c26fc5d2af5b9e2ac2f 100644
--- a/src/wasm/wasm-module.cc
+++ b/src/wasm/wasm-module.cc
@@ -608,17 +608,10 @@ class CompilationHelper {
// and information needed at instantiation time. This object needs to be
// serializable. Instantiation may occur off a deserialized version of this
// object.
- Handle<WasmCompiledModule> compiled_module =
- WasmCompiledModule::New(isolate_, shared);
- compiled_module->set_num_imported_functions(
- module_->num_imported_functions);
- compiled_module->set_code_table(code_table);
- compiled_module->set_min_mem_pages(module_->min_mem_pages);
ahaas 2017/04/05 11:34:56 Why is it okay to just not set min_mem_pages and m
Mircea Trofin 2017/04/05 19:09:17 Huh.. ya. We probably don't need them. Let me try
- compiled_module->set_max_mem_pages(module_->max_mem_pages);
+ Handle<WasmCompiledModule> compiled_module = WasmCompiledModule::New(
+ isolate_, shared, code_table, function_tables, signature_tables);
if (function_table_count > 0) {
compiled_module->set_function_tables(function_tables);
- compiled_module->set_signature_tables(signature_tables);
- compiled_module->set_empty_function_tables(function_tables);
}
// If we created a wasm script, finish it now and make it public to the
@@ -1098,6 +1091,9 @@ class InstantiationHelper {
// Reuse the compiled module (if no owner), otherwise clone.
//--------------------------------------------------------------------------
Handle<FixedArray> code_table;
+ // We keep around a copy of the old code table, because we'll be replacing
+ // imports for the new instance, and then we need the old imports to be
+ // able to relocate.
Handle<FixedArray> old_code_table;
MaybeHandle<WasmInstanceObject> owner;
@@ -1119,11 +1115,6 @@ class InstantiationHelper {
}
}
DCHECK(!original.is_null());
- // Always make a new copy of the code_table, since the old_code_table
- // may still have placeholders for imports.
- old_code_table = original->code_table();
- code_table = factory->CopyFixedArray(old_code_table);
-
if (original->has_weak_owning_instance()) {
// Clone, but don't insert yet the clone in the instances chain.
// We do that last. Since we are holding on to the owner instance,
@@ -1131,7 +1122,9 @@ class InstantiationHelper {
// won't be mutated by possible finalizer runs.
DCHECK(!owner.is_null());
TRACE("Cloning from %d\n", original->instance_id());
+ old_code_table = original->code_table();
compiled_module_ = WasmCompiledModule::Clone(isolate_, original);
+ code_table = compiled_module_->code_table();
// Avoid creating too many handles in the outer scope.
HandleScope scope(isolate_);
@@ -1169,10 +1162,12 @@ class InstantiationHelper {
} else {
// There was no owner, so we can reuse the original.
compiled_module_ = original;
+ old_code_table =
+ factory->CopyFixedArray(compiled_module_->code_table());
+ code_table = compiled_module_->code_table();
TRACE("Reusing existing instance %d\n",
compiled_module_->instance_id());
}
- compiled_module_->set_code_table(code_table);
compiled_module_->set_native_context(isolate_->native_context());
}
« no previous file with comments | « no previous file | src/wasm/wasm-objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698