Skip to content

Commit 4a11a54

Browse files
addaleaxBethGriggs
authored andcommitted
deps: V8: backport 844fe8f7d965
Original commit message: Make StringBuffer::string return a StringView instead of a reference. A StringView is pretty light, so this should be similar to how absl::string_view is typically used, e.g. see the guidance here: https://github.com/abseil/abseil-cpp/blob/master/absl/strings/string_view.h I suspect this reasoning holds even though StringView (defined just above StringBuffer in v8-inspector.h) carries an additional bool. This yields a small simplification of the StringBuffer implementations. Change-Id: I03f850049afe2327913070838f39649fcdfa6fa8 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2045110 Commit-Queue: Yang Guo <[email protected]> Reviewed-by: Yang Guo <[email protected]> Cr-Commit-Position: refs/heads/master@{#66858} (Neighbouring-line conflicts were resolved while backporting.) Refs: v8/v8@844fe8f PR-URL: #32885 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Ujjwal Sharma <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Beth Griggs <[email protected]>
1 parent 1b78785 commit 4a11a54

9 files changed

+93
-97
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
# Reset this number to 0 on major V8 upgrades.
3737
# Increment by one for each non-official patch applied to deps/v8.
38-
'v8_embedder_string': '-node.14',
38+
'v8_embedder_string': '-node.15',
3939

4040
##### V8 defaults for Node.js #####
4141

deps/v8/include/v8-inspector.h

+28-28
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ class V8_EXPORT StringView {
6565
class V8_EXPORT StringBuffer {
6666
public:
6767
virtual ~StringBuffer() = default;
68-
virtual const StringView& string() = 0;
68+
virtual StringView string() const = 0;
6969
// This method copies contents.
70-
static std::unique_ptr<StringBuffer> create(const StringView&);
70+
static std::unique_ptr<StringBuffer> create(StringView);
7171
};
7272

7373
class V8_EXPORT V8ContextInfo {
7474
public:
7575
V8ContextInfo(v8::Local<v8::Context> context, int contextGroupId,
76-
const StringView& humanReadableName)
76+
StringView humanReadableName)
7777
: context(context),
7878
contextGroupId(contextGroupId),
7979
humanReadableName(humanReadableName),
@@ -132,37 +132,36 @@ class V8_EXPORT V8InspectorSession {
132132
virtual void addInspectedObject(std::unique_ptr<Inspectable>) = 0;
133133

134134
// Dispatching protocol messages.
135-
static bool canDispatchMethod(const StringView& method);
136-
virtual void dispatchProtocolMessage(const StringView& message) = 0;
135+
static bool canDispatchMethod(StringView method);
136+
virtual void dispatchProtocolMessage(StringView message) = 0;
137137
virtual std::vector<uint8_t> state() = 0;
138138
virtual std::vector<std::unique_ptr<protocol::Schema::API::Domain>>
139139
supportedDomains() = 0;
140140

141141
// Debugger actions.
142-
virtual void schedulePauseOnNextStatement(const StringView& breakReason,
143-
const StringView& breakDetails) = 0;
142+
virtual void schedulePauseOnNextStatement(StringView breakReason,
143+
StringView breakDetails) = 0;
144144
virtual void cancelPauseOnNextStatement() = 0;
145-
virtual void breakProgram(const StringView& breakReason,
146-
const StringView& breakDetails) = 0;
145+
virtual void breakProgram(StringView breakReason,
146+
StringView breakDetails) = 0;
147147
virtual void setSkipAllPauses(bool) = 0;
148148
virtual void resume() = 0;
149149
virtual void stepOver() = 0;
150150
virtual std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>>
151-
searchInTextByLines(const StringView& text, const StringView& query,
152-
bool caseSensitive, bool isRegex) = 0;
151+
searchInTextByLines(StringView text, StringView query, bool caseSensitive,
152+
bool isRegex) = 0;
153153

154154
// Remote objects.
155155
virtual std::unique_ptr<protocol::Runtime::API::RemoteObject> wrapObject(
156-
v8::Local<v8::Context>, v8::Local<v8::Value>, const StringView& groupName,
156+
v8::Local<v8::Context>, v8::Local<v8::Value>, StringView groupName,
157157
bool generatePreview) = 0;
158158

159159
virtual bool unwrapObject(std::unique_ptr<StringBuffer>* error,
160-
const StringView& objectId, v8::Local<v8::Value>*,
160+
StringView objectId, v8::Local<v8::Value>*,
161161
v8::Local<v8::Context>*,
162162
std::unique_ptr<StringBuffer>* objectGroup) = 0;
163-
virtual void releaseObjectGroup(const StringView&) = 0;
164-
virtual void triggerPreciseCoverageDeltaUpdate(
165-
const StringView& occassion) = 0;
163+
virtual void releaseObjectGroup(StringView) = 0;
164+
virtual void triggerPreciseCoverageDeltaUpdate(StringView occassion) = 0;
166165
};
167166

168167
class V8_EXPORT V8InspectorClient {
@@ -240,7 +239,7 @@ struct V8_EXPORT V8StackTraceId {
240239
V8StackTraceId(uintptr_t id, const std::pair<int64_t, int64_t> debugger_id);
241240
V8StackTraceId(uintptr_t id, const std::pair<int64_t, int64_t> debugger_id,
242241
bool should_pause);
243-
explicit V8StackTraceId(const StringView&);
242+
explicit V8StackTraceId(StringView);
244243
V8StackTraceId& operator=(const V8StackTraceId&) = default;
245244
V8StackTraceId& operator=(V8StackTraceId&&) noexcept = default;
246245
~V8StackTraceId() = default;
@@ -265,26 +264,26 @@ class V8_EXPORT V8Inspector {
265264
virtual void idleFinished() = 0;
266265

267266
// Async stack traces instrumentation.
268-
virtual void asyncTaskScheduled(const StringView& taskName, void* task,
267+
virtual void asyncTaskScheduled(StringView taskName, void* task,
269268
bool recurring) = 0;
270269
virtual void asyncTaskCanceled(void* task) = 0;
271270
virtual void asyncTaskStarted(void* task) = 0;
272271
virtual void asyncTaskFinished(void* task) = 0;
273272
virtual void allAsyncTasksCanceled() = 0;
274273

275-
virtual V8StackTraceId storeCurrentStackTrace(
276-
const StringView& description) = 0;
274+
virtual V8StackTraceId storeCurrentStackTrace(StringView description) = 0;
277275
virtual void externalAsyncTaskStarted(const V8StackTraceId& parent) = 0;
278276
virtual void externalAsyncTaskFinished(const V8StackTraceId& parent) = 0;
279277

280278
// Exceptions instrumentation.
281-
virtual unsigned exceptionThrown(
282-
v8::Local<v8::Context>, const StringView& message,
283-
v8::Local<v8::Value> exception, const StringView& detailedMessage,
284-
const StringView& url, unsigned lineNumber, unsigned columnNumber,
285-
std::unique_ptr<V8StackTrace>, int scriptId) = 0;
279+
virtual unsigned exceptionThrown(v8::Local<v8::Context>, StringView message,
280+
v8::Local<v8::Value> exception,
281+
StringView detailedMessage, StringView url,
282+
unsigned lineNumber, unsigned columnNumber,
283+
std::unique_ptr<V8StackTrace>,
284+
int scriptId) = 0;
286285
virtual void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId,
287-
const StringView& message) = 0;
286+
StringView message) = 0;
288287

289288
// Connection.
290289
class V8_EXPORT Channel {
@@ -295,8 +294,9 @@ class V8_EXPORT V8Inspector {
295294
virtual void sendNotification(std::unique_ptr<StringBuffer> message) = 0;
296295
virtual void flushProtocolNotifications() = 0;
297296
};
298-
virtual std::unique_ptr<V8InspectorSession> connect(
299-
int contextGroupId, Channel*, const StringView& state) = 0;
297+
virtual std::unique_ptr<V8InspectorSession> connect(int contextGroupId,
298+
Channel*,
299+
StringView state) = 0;
300300

301301
// API methods.
302302
virtual std::unique_ptr<V8StackTrace> createStackTrace(

deps/v8/src/inspector/string-util.cc

+10-13
Original file line numberDiff line numberDiff line change
@@ -129,41 +129,38 @@ namespace {
129129
// default-constructed StringView instance.
130130
class EmptyStringBuffer : public StringBuffer {
131131
public:
132-
const StringView& string() override { return string_; }
133-
134-
private:
135-
StringView string_;
132+
StringView string() const override { return StringView(); }
136133
};
137134

138135
// Contains LATIN1 text data or CBOR encoded binary data in a vector.
139136
class StringBuffer8 : public StringBuffer {
140137
public:
141-
explicit StringBuffer8(std::vector<uint8_t> data)
142-
: data_(std::move(data)), string_(data_.data(), data_.size()) {}
138+
explicit StringBuffer8(std::vector<uint8_t> data) : data_(std::move(data)) {}
143139

144-
const StringView& string() override { return string_; }
140+
StringView string() const override {
141+
return StringView(data_.data(), data_.size());
142+
}
145143

146144
private:
147145
std::vector<uint8_t> data_;
148-
StringView string_;
149146
};
150147

151148
// Contains a 16 bit string (String16).
152149
class StringBuffer16 : public StringBuffer {
153150
public:
154-
explicit StringBuffer16(String16 data)
155-
: data_(std::move(data)), string_(data_.characters16(), data_.length()) {}
151+
explicit StringBuffer16(String16 data) : data_(std::move(data)) {}
156152

157-
const StringView& string() override { return string_; }
153+
StringView string() const override {
154+
return StringView(data_.characters16(), data_.length());
155+
}
158156

159157
private:
160158
String16 data_;
161-
StringView string_;
162159
};
163160
} // namespace
164161

165162
// static
166-
std::unique_ptr<StringBuffer> StringBuffer::create(const StringView& string) {
163+
std::unique_ptr<StringBuffer> StringBuffer::create(StringView string) {
167164
if (string.length() == 0) return std::make_unique<EmptyStringBuffer>();
168165
if (string.is8Bit()) {
169166
return std::make_unique<StringBuffer8>(std::vector<uint8_t>(

deps/v8/src/inspector/v8-inspector-impl.cc

+7-9
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ std::unique_ptr<V8StackTrace> V8InspectorImpl::createStackTrace(
155155
}
156156

157157
std::unique_ptr<V8InspectorSession> V8InspectorImpl::connect(
158-
int contextGroupId, V8Inspector::Channel* channel,
159-
const StringView& state) {
158+
int contextGroupId, V8Inspector::Channel* channel, StringView state) {
160159
int sessionId = ++m_lastSessionId;
161160
std::unique_ptr<V8InspectorSessionImpl> session =
162161
V8InspectorSessionImpl::create(this, contextGroupId, sessionId, channel,
@@ -256,9 +255,9 @@ void V8InspectorImpl::idleStarted() { m_isolate->SetIdle(true); }
256255
void V8InspectorImpl::idleFinished() { m_isolate->SetIdle(false); }
257256

258257
unsigned V8InspectorImpl::exceptionThrown(
259-
v8::Local<v8::Context> context, const StringView& message,
260-
v8::Local<v8::Value> exception, const StringView& detailedMessage,
261-
const StringView& url, unsigned lineNumber, unsigned columnNumber,
258+
v8::Local<v8::Context> context, StringView message,
259+
v8::Local<v8::Value> exception, StringView detailedMessage, StringView url,
260+
unsigned lineNumber, unsigned columnNumber,
262261
std::unique_ptr<V8StackTrace> stackTrace, int scriptId) {
263262
int groupId = contextGroupId(context);
264263
if (!groupId || m_muteExceptionsMap[groupId]) return 0;
@@ -277,7 +276,7 @@ unsigned V8InspectorImpl::exceptionThrown(
277276

278277
void V8InspectorImpl::exceptionRevoked(v8::Local<v8::Context> context,
279278
unsigned exceptionId,
280-
const StringView& message) {
279+
StringView message) {
281280
int groupId = contextGroupId(context);
282281
if (!groupId) return;
283282

@@ -292,8 +291,7 @@ std::unique_ptr<V8StackTrace> V8InspectorImpl::captureStackTrace(
292291
return m_debugger->captureStackTrace(fullStack);
293292
}
294293

295-
V8StackTraceId V8InspectorImpl::storeCurrentStackTrace(
296-
const StringView& description) {
294+
V8StackTraceId V8InspectorImpl::storeCurrentStackTrace(StringView description) {
297295
return m_debugger->storeCurrentStackTrace(description);
298296
}
299297

@@ -305,7 +303,7 @@ void V8InspectorImpl::externalAsyncTaskFinished(const V8StackTraceId& parent) {
305303
m_debugger->externalAsyncTaskFinished(parent);
306304
}
307305

308-
void V8InspectorImpl::asyncTaskScheduled(const StringView& taskName, void* task,
306+
void V8InspectorImpl::asyncTaskScheduled(StringView taskName, void* task,
309307
bool recurring) {
310308
if (!task) return;
311309
m_debugger->asyncTaskScheduled(taskName, task, recurring);

deps/v8/src/inspector/v8-inspector-impl.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -77,33 +77,33 @@ class V8InspectorImpl : public V8Inspector {
7777
// V8Inspector implementation.
7878
std::unique_ptr<V8InspectorSession> connect(int contextGroupId,
7979
V8Inspector::Channel*,
80-
const StringView& state) override;
80+
StringView state) override;
8181
void contextCreated(const V8ContextInfo&) override;
8282
void contextDestroyed(v8::Local<v8::Context>) override;
8383
v8::MaybeLocal<v8::Context> contextById(int contextId) override;
8484
void contextCollected(int contextGroupId, int contextId);
8585
void resetContextGroup(int contextGroupId) override;
8686
void idleStarted() override;
8787
void idleFinished() override;
88-
unsigned exceptionThrown(v8::Local<v8::Context>, const StringView& message,
88+
unsigned exceptionThrown(v8::Local<v8::Context>, StringView message,
8989
v8::Local<v8::Value> exception,
90-
const StringView& detailedMessage,
91-
const StringView& url, unsigned lineNumber,
92-
unsigned columnNumber, std::unique_ptr<V8StackTrace>,
90+
StringView detailedMessage, StringView url,
91+
unsigned lineNumber, unsigned columnNumber,
92+
std::unique_ptr<V8StackTrace>,
9393
int scriptId) override;
9494
void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId,
95-
const StringView& message) override;
95+
StringView message) override;
9696
std::unique_ptr<V8StackTrace> createStackTrace(
9797
v8::Local<v8::StackTrace>) override;
9898
std::unique_ptr<V8StackTrace> captureStackTrace(bool fullStack) override;
99-
void asyncTaskScheduled(const StringView& taskName, void* task,
99+
void asyncTaskScheduled(StringView taskName, void* task,
100100
bool recurring) override;
101101
void asyncTaskCanceled(void* task) override;
102102
void asyncTaskStarted(void* task) override;
103103
void asyncTaskFinished(void* task) override;
104104
void allAsyncTasksCanceled() override;
105105

106-
V8StackTraceId storeCurrentStackTrace(const StringView& description) override;
106+
V8StackTraceId storeCurrentStackTrace(StringView description) override;
107107
void externalAsyncTaskStarted(const V8StackTraceId& parent) override;
108108
void externalAsyncTaskFinished(const V8StackTraceId& parent) override;
109109

0 commit comments

Comments
 (0)