Commit 5cabf1b8 authored by Clark DuVall's avatar Clark DuVall Committed by V8 LUCI CQ

Allow BackgroundStreamingCompileTask to eager compile scripts

Bug: chromium:1328448
Change-Id: If0c3d02070071b5bb25df5bca51cf8c4cfc424d3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3673420Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80827}
parent c8c17619
......@@ -587,7 +587,8 @@ class V8_EXPORT ScriptCompiler {
*/
static ScriptStreamingTask* StartStreaming(
Isolate* isolate, StreamedSource* source,
ScriptType type = ScriptType::kClassic);
ScriptType type = ScriptType::kClassic,
CompileOptions options = kNoCompileOptions);
static ConsumeCodeCacheTask* StartConsumingCodeCache(
Isolate* isolate, std::unique_ptr<CachedData> source);
......
......@@ -2708,13 +2708,18 @@ MaybeLocal<Function> ScriptCompiler::CompileFunctionInternal(
void ScriptCompiler::ScriptStreamingTask::Run() { data_->task->Run(); }
ScriptCompiler::ScriptStreamingTask* ScriptCompiler::StartStreaming(
Isolate* v8_isolate, StreamedSource* source, v8::ScriptType type) {
Isolate* v8_isolate, StreamedSource* source, v8::ScriptType type,
CompileOptions options) {
Utils::ApiCheck(options == kNoCompileOptions || options == kEagerCompile,
"v8::ScriptCompiler::StartStreaming",
"Invalid CompileOptions");
if (!i::FLAG_script_streaming) return nullptr;
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(v8_isolate);
DCHECK_NO_SCRIPT_NO_EXCEPTION(i_isolate);
i::ScriptStreamingData* data = source->impl();
std::unique_ptr<i::BackgroundCompileTask> task =
std::make_unique<i::BackgroundCompileTask>(data, i_isolate, type);
std::make_unique<i::BackgroundCompileTask>(data, i_isolate, type,
options);
data->task = std::move(task);
return new ScriptCompiler::ScriptStreamingTask(data);
}
......
......@@ -1527,12 +1527,16 @@ DeferredFinalizationJobData::DeferredFinalizationJobData(
: function_handle_(isolate->heap()->NewPersistentHandle(function_handle)),
job_(std::move(job)) {}
BackgroundCompileTask::BackgroundCompileTask(ScriptStreamingData* streamed_data,
Isolate* isolate, ScriptType type)
BackgroundCompileTask::BackgroundCompileTask(
ScriptStreamingData* streamed_data, Isolate* isolate, ScriptType type,
ScriptCompiler::CompileOptions options)
: isolate_for_local_isolate_(isolate),
flags_(UnoptimizedCompileFlags::ForToplevelCompile(
isolate, true, construct_language_mode(FLAG_use_strict),
REPLMode::kNo, type, FLAG_lazy_streaming)),
REPLMode::kNo, type,
options == ScriptCompiler::CompileOptions::kEagerCompile
? false
: FLAG_lazy_streaming)),
character_stream_(ScannerStream::For(streamed_data->source_stream.get(),
streamed_data->encoding)),
stack_size_(i::FLAG_stack_size),
......@@ -2834,8 +2838,9 @@ class StressBackgroundCompileThread : public base::Thread {
source_(source),
streamed_source_(std::make_unique<SourceStream>(source, isolate),
v8::ScriptCompiler::StreamedSource::UTF8) {
data()->task =
std::make_unique<i::BackgroundCompileTask>(data(), isolate, type);
data()->task = std::make_unique<i::BackgroundCompileTask>(
data(), isolate, type,
ScriptCompiler::CompileOptions::kNoCompileOptions);
}
void Run() override { data()->task->Run(); }
......
......@@ -517,7 +517,8 @@ class V8_EXPORT_PRIVATE BackgroundCompileTask {
// script associated with |data| and can be finalized with FinalizeScript.
// Note: does not take ownership of |data|.
BackgroundCompileTask(ScriptStreamingData* data, Isolate* isolate,
v8::ScriptType type);
v8::ScriptType type,
ScriptCompiler::CompileOptions options);
BackgroundCompileTask(const BackgroundCompileTask&) = delete;
BackgroundCompileTask& operator=(const BackgroundCompileTask&) = delete;
~BackgroundCompileTask();
......
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