diff --git a/common.gypi b/common.gypi index 925d85f4fc1009..0c7c6b577d7fdf 100644 --- a/common.gypi +++ b/common.gypi @@ -37,7 +37,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.8', + 'v8_embedder_string': '-node.9', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 0a19d1aef36699..e165ec92a158df 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -1535,7 +1535,12 @@ class V8_EXPORT ScriptCompiler { public: enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 }; - StreamedSource(ExternalSourceStream* source_stream, Encoding encoding); + V8_DEPRECATE_SOON( + "This class takes ownership of source_stream, so use the constructor " + "taking a unique_ptr to make these semantics clearer", + StreamedSource(ExternalSourceStream* source_stream, Encoding encoding)); + StreamedSource(std::unique_ptr source_stream, + Encoding encoding); ~StreamedSource(); internal::ScriptStreamingData* impl() const { return impl_.get(); } diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 6742907a700d25..360bb7840757e6 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -2071,7 +2071,11 @@ void ScriptCompiler::ExternalSourceStream::ResetToBookmark() { UNREACHABLE(); } ScriptCompiler::StreamedSource::StreamedSource(ExternalSourceStream* stream, Encoding encoding) - : impl_(new i::ScriptStreamingData(stream, encoding)) {} + : StreamedSource(std::unique_ptr(stream), encoding) {} + +ScriptCompiler::StreamedSource::StreamedSource( + std::unique_ptr stream, Encoding encoding) + : impl_(new i::ScriptStreamingData(std::move(stream), encoding)) {} ScriptCompiler::StreamedSource::~StreamedSource() = default; diff --git a/deps/v8/src/compiler.cc b/deps/v8/src/compiler.cc index ea471e97d1fc87..f7893ace57d6e1 100644 --- a/deps/v8/src/compiler.cc +++ b/deps/v8/src/compiler.cc @@ -2173,9 +2173,9 @@ void Compiler::PostInstantiation(Handle function, // Implementation of ScriptStreamingData ScriptStreamingData::ScriptStreamingData( - ScriptCompiler::ExternalSourceStream* source_stream, + std::unique_ptr source_stream, ScriptCompiler::StreamedSource::Encoding encoding) - : source_stream(source_stream), encoding(encoding) {} + : source_stream(std::move(source_stream)), encoding(encoding) {} ScriptStreamingData::~ScriptStreamingData() = default; diff --git a/deps/v8/src/compiler.h b/deps/v8/src/compiler.h index b370cdebf5e59c..24e4c998f317f9 100644 --- a/deps/v8/src/compiler.h +++ b/deps/v8/src/compiler.h @@ -376,8 +376,9 @@ class V8_EXPORT_PRIVATE BackgroundCompileTask { // Contains all data which needs to be transmitted between threads for // background parsing and compiling and finalizing it on the main thread. struct ScriptStreamingData { - ScriptStreamingData(ScriptCompiler::ExternalSourceStream* source_stream, - ScriptCompiler::StreamedSource::Encoding encoding); + ScriptStreamingData( + std::unique_ptr source_stream, + ScriptCompiler::StreamedSource::Encoding encoding); ~ScriptStreamingData(); void Release(); diff --git a/deps/v8/src/d8.cc b/deps/v8/src/d8.cc index 0c069ba7132f25..563c7cb77855b9 100644 --- a/deps/v8/src/d8.cc +++ b/deps/v8/src/d8.cc @@ -413,7 +413,7 @@ class BackgroundCompileThread : public base::Thread { BackgroundCompileThread(Isolate* isolate, Local source) : base::Thread(GetThreadOptions("BackgroundCompileThread")), source_(source), - streamed_source_(new DummySourceStream(source, isolate), + streamed_source_(base::make_unique(source, isolate), v8::ScriptCompiler::StreamedSource::UTF8), task_(v8::ScriptCompiler::StartStreamingScript(isolate, &streamed_source_)) {} diff --git a/deps/v8/test/cctest/test-api.cc b/deps/v8/test/cctest/test-api.cc index bd8180fb122683..aae1b3674e5771 100644 --- a/deps/v8/test/cctest/test-api.cc +++ b/deps/v8/test/cctest/test-api.cc @@ -24799,8 +24799,8 @@ void RunStreamingTest(const char** chunks, v8::HandleScope scope(isolate); v8::TryCatch try_catch(isolate); - v8::ScriptCompiler::StreamedSource source(new TestSourceStream(chunks), - encoding); + v8::ScriptCompiler::StreamedSource source( + v8::base::make_unique(chunks), encoding); v8::ScriptCompiler::ScriptStreamingTask* task = v8::ScriptCompiler::StartStreamingScript(isolate, &source); @@ -25071,7 +25071,7 @@ TEST(StreamingWithDebuggingEnabledLate) { v8::TryCatch try_catch(isolate); v8::ScriptCompiler::StreamedSource source( - new TestSourceStream(chunks), + v8::base::make_unique(chunks), v8::ScriptCompiler::StreamedSource::ONE_BYTE); v8::ScriptCompiler::ScriptStreamingTask* task = v8::ScriptCompiler::StartStreamingScript(isolate, &source); @@ -25179,7 +25179,7 @@ TEST(StreamingWithHarmonyScopes) { v8::TryCatch try_catch(isolate); v8::ScriptCompiler::StreamedSource source( - new TestSourceStream(chunks), + v8::base::make_unique(chunks), v8::ScriptCompiler::StreamedSource::ONE_BYTE); v8::ScriptCompiler::ScriptStreamingTask* task = v8::ScriptCompiler::StartStreamingScript(isolate, &source);