[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 <leszeks@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70965}
This commit is contained in:
Camillo Bruni 2020-10-26 17:31:26 +01:00 committed by Commit Bot
parent 7257dc93c0
commit 5ce10a0b5e
5 changed files with 16 additions and 10 deletions

View File

@ -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).

View File

@ -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<i::Isolate*>(v8_isolate);
i::ScriptStreamingData* data = source->impl();
std::unique_ptr<i::BackgroundCompileTask> task =

View File

@ -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_);
}

View File

@ -23530,7 +23530,7 @@ void RunStreamingTest(const char** chunks,
v8::ScriptCompiler::StreamedSource source(
std::make_unique<TestSourceStream>(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<TestSourceStream>(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<TestSourceStream>(chunks),
v8::ScriptCompiler::StreamedSource::ONE_BYTE);
v8::ScriptCompiler::ScriptStreamingTask* task =
v8::ScriptCompiler::StartStreamingScript(isolate, &source);
v8::ScriptCompiler::StartStreaming(isolate, &source);
task->Run();
delete task;

View File

@ -1081,7 +1081,7 @@ TEST(ProfilerEnabledDuringBackgroundCompile) {
std::make_unique<DummySourceStream>(source),
v8::ScriptCompiler::StreamedSource::UTF8);
std::unique_ptr<v8::ScriptCompiler::ScriptStreamingTask> task(
v8::ScriptCompiler::StartStreamingScript(isolate, &streamed_source));
v8::ScriptCompiler::StartStreaming(isolate, &streamed_source));
// Run the background compilation task on the main thread.
task->Run();