Skip to content

Commit 8181811

Browse files
addaleaxrefack
authored andcommitted
deps: V8: cherry-pick d82c9af
Original commit message: [api] Add unique_ptr constructor for StreamedSource Since StreamedSource takes ownership of the ExternalSourceStream passed into it, it should take it by unique_ptr rather than raw pointer to signal this transfer of ownership. The old constructor is now deprecated. Change-Id: I24681926c2f3141f7dd3664f72019a4c6deabfd7 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1520713 Commit-Queue: Yang Guo <[email protected]> Reviewed-by: Yang Guo <[email protected]> Auto-Submit: Leszek Swirski <[email protected]> Cr-Commit-Position: refs/heads/master@{#60232} Refs: v8/v8@d82c9af PR-URL: #26685 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
1 parent 1f03fb4 commit 8181811

File tree

7 files changed

+22
-12
lines changed

7 files changed

+22
-12
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
# Reset this number to 0 on major V8 upgrades.
3939
# Increment by one for each non-official patch applied to deps/v8.
40-
'v8_embedder_string': '-node.8',
40+
'v8_embedder_string': '-node.9',
4141

4242
##### V8 defaults for Node.js #####
4343

deps/v8/include/v8.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -1535,7 +1535,12 @@ class V8_EXPORT ScriptCompiler {
15351535
public:
15361536
enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 };
15371537

1538-
StreamedSource(ExternalSourceStream* source_stream, Encoding encoding);
1538+
V8_DEPRECATE_SOON(
1539+
"This class takes ownership of source_stream, so use the constructor "
1540+
"taking a unique_ptr to make these semantics clearer",
1541+
StreamedSource(ExternalSourceStream* source_stream, Encoding encoding));
1542+
StreamedSource(std::unique_ptr<ExternalSourceStream> source_stream,
1543+
Encoding encoding);
15391544
~StreamedSource();
15401545

15411546
internal::ScriptStreamingData* impl() const { return impl_.get(); }

deps/v8/src/api.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -2071,7 +2071,11 @@ void ScriptCompiler::ExternalSourceStream::ResetToBookmark() { UNREACHABLE(); }
20712071

20722072
ScriptCompiler::StreamedSource::StreamedSource(ExternalSourceStream* stream,
20732073
Encoding encoding)
2074-
: impl_(new i::ScriptStreamingData(stream, encoding)) {}
2074+
: StreamedSource(std::unique_ptr<ExternalSourceStream>(stream), encoding) {}
2075+
2076+
ScriptCompiler::StreamedSource::StreamedSource(
2077+
std::unique_ptr<ExternalSourceStream> stream, Encoding encoding)
2078+
: impl_(new i::ScriptStreamingData(std::move(stream), encoding)) {}
20752079

20762080
ScriptCompiler::StreamedSource::~StreamedSource() = default;
20772081

deps/v8/src/compiler.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -2173,9 +2173,9 @@ void Compiler::PostInstantiation(Handle<JSFunction> function,
21732173
// Implementation of ScriptStreamingData
21742174

21752175
ScriptStreamingData::ScriptStreamingData(
2176-
ScriptCompiler::ExternalSourceStream* source_stream,
2176+
std::unique_ptr<ScriptCompiler::ExternalSourceStream> source_stream,
21772177
ScriptCompiler::StreamedSource::Encoding encoding)
2178-
: source_stream(source_stream), encoding(encoding) {}
2178+
: source_stream(std::move(source_stream)), encoding(encoding) {}
21792179

21802180
ScriptStreamingData::~ScriptStreamingData() = default;
21812181

deps/v8/src/compiler.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,9 @@ class V8_EXPORT_PRIVATE BackgroundCompileTask {
376376
// Contains all data which needs to be transmitted between threads for
377377
// background parsing and compiling and finalizing it on the main thread.
378378
struct ScriptStreamingData {
379-
ScriptStreamingData(ScriptCompiler::ExternalSourceStream* source_stream,
380-
ScriptCompiler::StreamedSource::Encoding encoding);
379+
ScriptStreamingData(
380+
std::unique_ptr<ScriptCompiler::ExternalSourceStream> source_stream,
381+
ScriptCompiler::StreamedSource::Encoding encoding);
381382
~ScriptStreamingData();
382383

383384
void Release();

deps/v8/src/d8.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ class BackgroundCompileThread : public base::Thread {
413413
BackgroundCompileThread(Isolate* isolate, Local<String> source)
414414
: base::Thread(GetThreadOptions("BackgroundCompileThread")),
415415
source_(source),
416-
streamed_source_(new DummySourceStream(source, isolate),
416+
streamed_source_(base::make_unique<DummySourceStream>(source, isolate),
417417
v8::ScriptCompiler::StreamedSource::UTF8),
418418
task_(v8::ScriptCompiler::StartStreamingScript(isolate,
419419
&streamed_source_)) {}

deps/v8/test/cctest/test-api.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -24799,8 +24799,8 @@ void RunStreamingTest(const char** chunks,
2479924799
v8::HandleScope scope(isolate);
2480024800
v8::TryCatch try_catch(isolate);
2480124801

24802-
v8::ScriptCompiler::StreamedSource source(new TestSourceStream(chunks),
24803-
encoding);
24802+
v8::ScriptCompiler::StreamedSource source(
24803+
v8::base::make_unique<TestSourceStream>(chunks), encoding);
2480424804
v8::ScriptCompiler::ScriptStreamingTask* task =
2480524805
v8::ScriptCompiler::StartStreamingScript(isolate, &source);
2480624806

@@ -25071,7 +25071,7 @@ TEST(StreamingWithDebuggingEnabledLate) {
2507125071
v8::TryCatch try_catch(isolate);
2507225072

2507325073
v8::ScriptCompiler::StreamedSource source(
25074-
new TestSourceStream(chunks),
25074+
v8::base::make_unique<TestSourceStream>(chunks),
2507525075
v8::ScriptCompiler::StreamedSource::ONE_BYTE);
2507625076
v8::ScriptCompiler::ScriptStreamingTask* task =
2507725077
v8::ScriptCompiler::StartStreamingScript(isolate, &source);
@@ -25179,7 +25179,7 @@ TEST(StreamingWithHarmonyScopes) {
2517925179

2518025180
v8::TryCatch try_catch(isolate);
2518125181
v8::ScriptCompiler::StreamedSource source(
25182-
new TestSourceStream(chunks),
25182+
v8::base::make_unique<TestSourceStream>(chunks),
2518325183
v8::ScriptCompiler::StreamedSource::ONE_BYTE);
2518425184
v8::ScriptCompiler::ScriptStreamingTask* task =
2518525185
v8::ScriptCompiler::StartStreamingScript(isolate, &source);

0 commit comments

Comments
 (0)