Commit 3d25ad4d authored by mtrofin's avatar mtrofin Committed by Commit bot

[wasm] separate snapshot-able stages

This CLprepares the terrain for serialization/deserialization. It sets up
the instantiation stages such that we have a point wereh we can split off
obtaining the code from a snapshot, or snapshot. That point is after we
compile and produce the code table, but before we attach the
deoptimization info we use for stack tracing.

Opportunistically, performed more cleanup to improve maintainability:
- clarified sequential vs parallel compilation stages. FinishCompilation
was somewhat ambiguous in that it performed a few responsibilities:
compiling functions in the sequential case, and then populating the
linker and code tables.
- removed the "results" set, which is unnecessary. The linker simply
shares the function_code vector, and so do the compilation stages.
- populate the code table fixed array separately from compilation. This
falls out of the decisions above.

BUG=

Review-Url: https://codereview.chromium.org/2008043006
Cr-Commit-Position: refs/heads/master@{#36618}
parent 132f8980
......@@ -1908,7 +1908,7 @@ Node* WasmGraphBuilder::CallDirect(uint32_t index, Node** args,
DCHECK_NULL(args[0]);
// Add code object as constant.
args[0] = HeapConstant(module_->GetFunctionCode(index));
args[0] = HeapConstant(module_->GetCodeOrPlaceholder(index));
wasm::FunctionSig* sig = module_->GetFunctionSignature(index);
return BuildWasmCall(sig, args, position);
......@@ -3292,16 +3292,6 @@ Handle<Code> WasmCompilationUnit::FinishCompilation() {
}
Handle<Code> code = info_.code();
DCHECK(!code.is_null());
DCHECK(code->deoptimization_data() == nullptr ||
code->deoptimization_data()->length() == 0);
Handle<FixedArray> deopt_data =
isolate_->factory()->NewFixedArray(2, TENURED);
if (!module_env_->instance->js_object.is_null()) {
deopt_data->set(0, *module_env_->instance->js_object);
}
deopt_data->set(1, Smi::FromInt(function_->func_index));
deopt_data->set_length(2);
code->set_deoptimization_data(*deopt_data);
RecordFunctionCompilation(
Logger::FUNCTION_TAG, &info_, "WASM_function", function_->func_index,
......
This diff is collapsed.
......@@ -231,7 +231,11 @@ struct WasmModuleInstance {
byte* globals_start; // start of the globals area.
explicit WasmModuleInstance(const WasmModule* m)
: module(m), mem_start(nullptr), mem_size(0), globals_start(nullptr) {}
: module(m),
function_code(m->functions.size()),
mem_start(nullptr),
mem_size(0),
globals_start(nullptr) {}
};
// forward declaration.
......@@ -248,7 +252,7 @@ struct ModuleEnv {
bool IsValidGlobal(uint32_t index) {
return module && index < module->globals.size();
}
bool IsValidFunction(uint32_t index) {
bool IsValidFunction(uint32_t index) const {
return module && index < module->functions.size();
}
bool IsValidSignature(uint32_t index) {
......@@ -279,7 +283,7 @@ struct ModuleEnv {
bool asm_js() { return origin == kAsmJsOrigin; }
Handle<Code> GetFunctionCode(uint32_t index);
Handle<Code> GetCodeOrPlaceholder(uint32_t index) const;
Handle<Code> GetImportCode(uint32_t index);
Handle<FixedArray> GetFunctionTable();
......
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