[compiler] Support background finalization for Modules

Bug: chromium:1011762, chromium:1061857
Change-Id: I2b2661023215b7b2d05067e6f9fb894ad6274acd
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2617084
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75600}
This commit is contained in:
Camillo Bruni 2021-07-06 10:27:57 +02:00 committed by V8 LUCI CQ
parent 97a6c014ef
commit 2f50d30f57
3 changed files with 17 additions and 10 deletions

View File

@ -6,6 +6,7 @@
#include "src/ast/ast-value-factory.h"
#include "src/ast/scopes.h"
#include "src/common/globals.h"
#include "src/heap/local-factory-inl.h"
#include "src/objects/module-inl.h"
#include "src/objects/objects-inl.h"
@ -130,8 +131,10 @@ Handle<ModuleRequest> SourceTextModuleDescriptor::AstModuleRequest::Serialize(
// The import assertions will be stored in this array in the form:
// [key1, value1, location1, key2, value2, location2, ...]
Handle<FixedArray> import_assertions_array =
isolate->factory()->NewFixedArray(static_cast<int>(
import_assertions()->size() * ModuleRequest::kAssertionEntrySize));
isolate->factory()->NewFixedArray(
static_cast<int>(import_assertions()->size() *
ModuleRequest::kAssertionEntrySize),
AllocationType::kOld);
int i = 0;
for (auto iter = import_assertions()->cbegin();
@ -189,7 +192,8 @@ Handle<FixedArray> SourceTextModuleDescriptor::SerializeRegularExports(
++count;
} while (next != regular_exports_.end() && next->first == it->first);
Handle<FixedArray> export_names = isolate->factory()->NewFixedArray(count);
Handle<FixedArray> export_names =
isolate->factory()->NewFixedArray(count, AllocationType::kOld);
data[index + SourceTextModuleInfo::kRegularExportLocalNameOffset] =
it->second->local_name->string();
data[index + SourceTextModuleInfo::kRegularExportCellIndexOffset] =
@ -213,7 +217,8 @@ Handle<FixedArray> SourceTextModuleDescriptor::SerializeRegularExports(
// We cannot create the FixedArray earlier because we only now know the
// precise size.
Handle<FixedArray> result = isolate->factory()->NewFixedArray(index);
Handle<FixedArray> result =
isolate->factory()->NewFixedArray(index, AllocationType::kOld);
for (int i = 0; i < index; ++i) {
result->set(i, *data[i]);
}

View File

@ -1609,7 +1609,7 @@ void BackgroundCompileTask::Run() {
// Save the language mode.
language_mode_ = info_->language_mode();
if (!FLAG_finalize_streaming_on_background || info_->flags().is_module()) {
if (!FLAG_finalize_streaming_on_background) {
if (info_->literal() != nullptr) {
CompileOnBackgroundThread(info_.get(), compile_state_.allocator(),
&compilation_jobs_);
@ -3034,7 +3034,7 @@ Compiler::GetSharedFunctionInfoForStreamedScript(
DCHECK_EQ(task->flags().is_module(), origin_options.IsModule());
Handle<Script> script;
if (FLAG_finalize_streaming_on_background && !origin_options.IsModule()) {
if (FLAG_finalize_streaming_on_background) {
RCS_SCOPE(isolate,
RuntimeCallCounterId::kCompilePublishBackgroundFinalization);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),

View File

@ -1127,7 +1127,8 @@ Handle<SourceTextModuleInfo> SourceTextModuleInfo::New(
IsolateT* isolate, Zone* zone, SourceTextModuleDescriptor* descr) {
// Serialize module requests.
int size = static_cast<int>(descr->module_requests().size());
Handle<FixedArray> module_requests = isolate->factory()->NewFixedArray(size);
Handle<FixedArray> module_requests =
isolate->factory()->NewFixedArray(size, AllocationType::kOld);
for (const auto& elem : descr->module_requests()) {
Handle<ModuleRequest> serialized_module_request = elem->Serialize(isolate);
module_requests->set(elem->index(), *serialized_module_request);
@ -1135,7 +1136,7 @@ Handle<SourceTextModuleInfo> SourceTextModuleInfo::New(
// Serialize special exports.
Handle<FixedArray> special_exports = isolate->factory()->NewFixedArray(
static_cast<int>(descr->special_exports().size()));
static_cast<int>(descr->special_exports().size()), AllocationType::kOld);
{
int i = 0;
for (auto entry : descr->special_exports()) {
@ -1147,7 +1148,8 @@ Handle<SourceTextModuleInfo> SourceTextModuleInfo::New(
// Serialize namespace imports.
Handle<FixedArray> namespace_imports = isolate->factory()->NewFixedArray(
static_cast<int>(descr->namespace_imports().size()));
static_cast<int>(descr->namespace_imports().size()),
AllocationType::kOld);
{
int i = 0;
for (auto entry : descr->namespace_imports()) {
@ -1163,7 +1165,7 @@ Handle<SourceTextModuleInfo> SourceTextModuleInfo::New(
// Serialize regular imports.
Handle<FixedArray> regular_imports = isolate->factory()->NewFixedArray(
static_cast<int>(descr->regular_imports().size()));
static_cast<int>(descr->regular_imports().size()), AllocationType::kOld);
{
int i = 0;
for (const auto& elem : descr->regular_imports()) {