[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 <yangguo@chromium.org> Reviewed-by: Yang Guo <yangguo@chromium.org> Auto-Submit: Leszek Swirski <leszeks@chromium.org> Cr-Commit-Position: refs/heads/master@{#60232}
This commit is contained in:
parent
77f9b28767
commit
d82c9afb8c
@ -1535,7 +1535,12 @@ class V8_EXPORT ScriptCompiler {
|
|||||||
public:
|
public:
|
||||||
enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 };
|
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<ExternalSourceStream> source_stream,
|
||||||
|
Encoding encoding);
|
||||||
~StreamedSource();
|
~StreamedSource();
|
||||||
|
|
||||||
internal::ScriptStreamingData* impl() const { return impl_.get(); }
|
internal::ScriptStreamingData* impl() const { return impl_.get(); }
|
||||||
|
@ -2072,7 +2072,11 @@ void ScriptCompiler::ExternalSourceStream::ResetToBookmark() { UNREACHABLE(); }
|
|||||||
|
|
||||||
ScriptCompiler::StreamedSource::StreamedSource(ExternalSourceStream* stream,
|
ScriptCompiler::StreamedSource::StreamedSource(ExternalSourceStream* stream,
|
||||||
Encoding encoding)
|
Encoding encoding)
|
||||||
: impl_(new i::ScriptStreamingData(stream, encoding)) {}
|
: StreamedSource(std::unique_ptr<ExternalSourceStream>(stream), encoding) {}
|
||||||
|
|
||||||
|
ScriptCompiler::StreamedSource::StreamedSource(
|
||||||
|
std::unique_ptr<ExternalSourceStream> stream, Encoding encoding)
|
||||||
|
: impl_(new i::ScriptStreamingData(std::move(stream), encoding)) {}
|
||||||
|
|
||||||
ScriptCompiler::StreamedSource::~StreamedSource() = default;
|
ScriptCompiler::StreamedSource::~StreamedSource() = default;
|
||||||
|
|
||||||
|
@ -2169,9 +2169,9 @@ void Compiler::PostInstantiation(Handle<JSFunction> function,
|
|||||||
// Implementation of ScriptStreamingData
|
// Implementation of ScriptStreamingData
|
||||||
|
|
||||||
ScriptStreamingData::ScriptStreamingData(
|
ScriptStreamingData::ScriptStreamingData(
|
||||||
ScriptCompiler::ExternalSourceStream* source_stream,
|
std::unique_ptr<ScriptCompiler::ExternalSourceStream> source_stream,
|
||||||
ScriptCompiler::StreamedSource::Encoding encoding)
|
ScriptCompiler::StreamedSource::Encoding encoding)
|
||||||
: source_stream(source_stream), encoding(encoding) {}
|
: source_stream(std::move(source_stream)), encoding(encoding) {}
|
||||||
|
|
||||||
ScriptStreamingData::~ScriptStreamingData() = default;
|
ScriptStreamingData::~ScriptStreamingData() = default;
|
||||||
|
|
||||||
|
@ -376,8 +376,9 @@ class V8_EXPORT_PRIVATE BackgroundCompileTask {
|
|||||||
// Contains all data which needs to be transmitted between threads for
|
// Contains all data which needs to be transmitted between threads for
|
||||||
// background parsing and compiling and finalizing it on the main thread.
|
// background parsing and compiling and finalizing it on the main thread.
|
||||||
struct ScriptStreamingData {
|
struct ScriptStreamingData {
|
||||||
ScriptStreamingData(ScriptCompiler::ExternalSourceStream* source_stream,
|
ScriptStreamingData(
|
||||||
ScriptCompiler::StreamedSource::Encoding encoding);
|
std::unique_ptr<ScriptCompiler::ExternalSourceStream> source_stream,
|
||||||
|
ScriptCompiler::StreamedSource::Encoding encoding);
|
||||||
~ScriptStreamingData();
|
~ScriptStreamingData();
|
||||||
|
|
||||||
void Release();
|
void Release();
|
||||||
|
@ -413,7 +413,7 @@ class BackgroundCompileThread : public base::Thread {
|
|||||||
BackgroundCompileThread(Isolate* isolate, Local<String> source)
|
BackgroundCompileThread(Isolate* isolate, Local<String> source)
|
||||||
: base::Thread(GetThreadOptions("BackgroundCompileThread")),
|
: base::Thread(GetThreadOptions("BackgroundCompileThread")),
|
||||||
source_(source),
|
source_(source),
|
||||||
streamed_source_(new DummySourceStream(source, isolate),
|
streamed_source_(base::make_unique<DummySourceStream>(source, isolate),
|
||||||
v8::ScriptCompiler::StreamedSource::UTF8),
|
v8::ScriptCompiler::StreamedSource::UTF8),
|
||||||
task_(v8::ScriptCompiler::StartStreamingScript(isolate,
|
task_(v8::ScriptCompiler::StartStreamingScript(isolate,
|
||||||
&streamed_source_)) {}
|
&streamed_source_)) {}
|
||||||
|
@ -24899,8 +24899,8 @@ void RunStreamingTest(const char** chunks,
|
|||||||
v8::HandleScope scope(isolate);
|
v8::HandleScope scope(isolate);
|
||||||
v8::TryCatch try_catch(isolate);
|
v8::TryCatch try_catch(isolate);
|
||||||
|
|
||||||
v8::ScriptCompiler::StreamedSource source(new TestSourceStream(chunks),
|
v8::ScriptCompiler::StreamedSource source(
|
||||||
encoding);
|
v8::base::make_unique<TestSourceStream>(chunks), encoding);
|
||||||
v8::ScriptCompiler::ScriptStreamingTask* task =
|
v8::ScriptCompiler::ScriptStreamingTask* task =
|
||||||
v8::ScriptCompiler::StartStreamingScript(isolate, &source);
|
v8::ScriptCompiler::StartStreamingScript(isolate, &source);
|
||||||
|
|
||||||
@ -25171,7 +25171,7 @@ TEST(StreamingWithDebuggingEnabledLate) {
|
|||||||
v8::TryCatch try_catch(isolate);
|
v8::TryCatch try_catch(isolate);
|
||||||
|
|
||||||
v8::ScriptCompiler::StreamedSource source(
|
v8::ScriptCompiler::StreamedSource source(
|
||||||
new TestSourceStream(chunks),
|
v8::base::make_unique<TestSourceStream>(chunks),
|
||||||
v8::ScriptCompiler::StreamedSource::ONE_BYTE);
|
v8::ScriptCompiler::StreamedSource::ONE_BYTE);
|
||||||
v8::ScriptCompiler::ScriptStreamingTask* task =
|
v8::ScriptCompiler::ScriptStreamingTask* task =
|
||||||
v8::ScriptCompiler::StartStreamingScript(isolate, &source);
|
v8::ScriptCompiler::StartStreamingScript(isolate, &source);
|
||||||
@ -25279,7 +25279,7 @@ TEST(StreamingWithHarmonyScopes) {
|
|||||||
|
|
||||||
v8::TryCatch try_catch(isolate);
|
v8::TryCatch try_catch(isolate);
|
||||||
v8::ScriptCompiler::StreamedSource source(
|
v8::ScriptCompiler::StreamedSource source(
|
||||||
new TestSourceStream(chunks),
|
v8::base::make_unique<TestSourceStream>(chunks),
|
||||||
v8::ScriptCompiler::StreamedSource::ONE_BYTE);
|
v8::ScriptCompiler::StreamedSource::ONE_BYTE);
|
||||||
v8::ScriptCompiler::ScriptStreamingTask* task =
|
v8::ScriptCompiler::ScriptStreamingTask* task =
|
||||||
v8::ScriptCompiler::StartStreamingScript(isolate, &source);
|
v8::ScriptCompiler::StartStreamingScript(isolate, &source);
|
||||||
|
Loading…
Reference in New Issue
Block a user