From 5ce10a0b5e213d432f0306751ea3487a13d602a6 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Mon, 26 Oct 2020 17:31:26 +0100 Subject: [PATCH] [api] Add updated ScriptCompiler::StartStreaming API The new api removes the unused CompileOptions argument. Change-Id: Ie3c48cda5247da9ce87d70a90b7ab9c43d5e8e37 Bug: chromium:1061857 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2498698 Reviewed-by: Leszek Swirski Reviewed-by: Toon Verwaest Commit-Queue: Camillo Bruni Cr-Commit-Position: refs/heads/master@{#70965} --- include/v8.h | 5 ++++- src/api/api.cc | 9 ++++++--- src/d8/d8.cc | 4 ++-- test/cctest/test-api.cc | 6 +++--- test/cctest/test-compiler.cc | 2 +- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/v8.h b/include/v8.h index 57be29e230..7fa97d7491 100644 --- a/include/v8.h +++ b/include/v8.h @@ -1859,7 +1859,7 @@ class V8_EXPORT ScriptCompiler { /** * A streaming task which the embedder must run on a background thread to - * stream scripts into V8. Returned by ScriptCompiler::StartStreamingScript. + * stream scripts into V8. Returned by ScriptCompiler::StartStreaming. */ class V8_EXPORT ScriptStreamingTask final { public: @@ -1946,9 +1946,12 @@ class V8_EXPORT ScriptCompiler { * This API allows to start the streaming with as little data as possible, and * the remaining data (for example, the ScriptOrigin) is passed to Compile. */ + V8_DEPRECATE_SOON("Use ScriptCompiler::StartStreamingScript instead.") static ScriptStreamingTask* StartStreamingScript( Isolate* isolate, StreamedSource* source, CompileOptions options = kNoCompileOptions); + static ScriptStreamingTask* StartStreaming(Isolate* isolate, + StreamedSource* source); /** * Compiles a streamed script (bound to current context). diff --git a/src/api/api.cc b/src/api/api.cc index bbc38d1f56..2ee6d21a70 100644 --- a/src/api/api.cc +++ b/src/api/api.cc @@ -2633,12 +2633,15 @@ void ScriptCompiler::ScriptStreamingTask::Run() { data_->task->Run(); } ScriptCompiler::ScriptStreamingTask* ScriptCompiler::StartStreamingScript( Isolate* v8_isolate, StreamedSource* source, CompileOptions options) { - if (!i::FLAG_script_streaming) { - return nullptr; - } // We don't support other compile options on streaming background compiles. // TODO(rmcilroy): remove CompileOptions from the API. CHECK(options == ScriptCompiler::kNoCompileOptions); + return StartStreaming(v8_isolate, source); +} + +ScriptCompiler::ScriptStreamingTask* ScriptCompiler::StartStreaming( + Isolate* v8_isolate, StreamedSource* source) { + if (!i::FLAG_script_streaming) return nullptr; i::Isolate* isolate = reinterpret_cast(v8_isolate); i::ScriptStreamingData* data = source->impl(); std::unique_ptr task = diff --git a/src/d8/d8.cc b/src/d8/d8.cc index dfeb0e5189..da7f0e4dd1 100644 --- a/src/d8/d8.cc +++ b/src/d8/d8.cc @@ -540,8 +540,8 @@ class StreamingCompileTask final : public v8::Task { StreamingCompileTask(Isolate* isolate, v8::ScriptCompiler::StreamedSource* streamed_source) : isolate_(isolate), - script_streaming_task_(v8::ScriptCompiler::StartStreamingScript( - isolate, streamed_source)) { + script_streaming_task_( + v8::ScriptCompiler::StartStreaming(isolate, streamed_source)) { Shell::NotifyStartStreamingTask(isolate_); } diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 1d8f3f2397..afa57a5550 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -23530,7 +23530,7 @@ void RunStreamingTest(const char** chunks, v8::ScriptCompiler::StreamedSource source( std::make_unique(chunks), encoding); v8::ScriptCompiler::ScriptStreamingTask* task = - v8::ScriptCompiler::StartStreamingScript(isolate, &source); + v8::ScriptCompiler::StartStreaming(isolate, &source); // TestSourceStream::GetMoreData won't block, so it's OK to just run the // task here in the main thread. @@ -23802,7 +23802,7 @@ TEST(StreamingWithDebuggingEnabledLate) { std::make_unique(chunks), v8::ScriptCompiler::StreamedSource::ONE_BYTE); v8::ScriptCompiler::ScriptStreamingTask* task = - v8::ScriptCompiler::StartStreamingScript(isolate, &source); + v8::ScriptCompiler::StartStreaming(isolate, &source); task->Run(); delete task; @@ -23910,7 +23910,7 @@ TEST(StreamingWithHarmonyScopes) { std::make_unique(chunks), v8::ScriptCompiler::StreamedSource::ONE_BYTE); v8::ScriptCompiler::ScriptStreamingTask* task = - v8::ScriptCompiler::StartStreamingScript(isolate, &source); + v8::ScriptCompiler::StartStreaming(isolate, &source); task->Run(); delete task; diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc index 6a35f89a49..c3883d9576 100644 --- a/test/cctest/test-compiler.cc +++ b/test/cctest/test-compiler.cc @@ -1081,7 +1081,7 @@ TEST(ProfilerEnabledDuringBackgroundCompile) { std::make_unique(source), v8::ScriptCompiler::StreamedSource::UTF8); std::unique_ptr task( - v8::ScriptCompiler::StartStreamingScript(isolate, &streamed_source)); + v8::ScriptCompiler::StartStreaming(isolate, &streamed_source)); // Run the background compilation task on the main thread. task->Run();