1+ diff --git a/src/inspector/custom-preview.cc b/src/inspector/custom-preview.cc
2+ index 4e9c4a42ebeb..fd85866783c1 100644
3+ --- a/src/inspector/custom-preview.cc
4+ +++ b/src/inspector/custom-preview.cc
5+ @@ -35,15 +35,15 @@ void reportError(v8::Local<v8::Context> context, const v8::TryCatch& tryCatch) {
6+ v8::Local<v8::String> prefix =
7+ toV8String(isolate, "Custom Formatter Failed: ");
8+ message = v8::String::Concat(isolate, prefix, message);
9+ - std::vector<v8::Local<v8::Value>> arguments;
10+ + v8::LocalVector<v8::Value> arguments(isolate);
11+ arguments.push_back(message);
12+ V8ConsoleMessageStorage* storage =
13+ inspector->ensureConsoleMessageStorage(groupId);
14+ if (!storage) return;
15+ storage->addMessage(V8ConsoleMessage::createForConsoleAPI(
16+ context, contextId, groupId, inspector,
17+ - inspector->client()->currentTimeMS(), ConsoleAPIType::kError, arguments,
18+ - String16(), nullptr));
19+ + inspector->client()->currentTimeMS(), ConsoleAPIType::kError,
20+ + {arguments.begin(), arguments.end()}, String16(), nullptr));
21+ }
22+
23+ void reportError(v8::Local<v8::Context> context, const v8::TryCatch& tryCatch,
24+ diff --git a/src/inspector/v8-console-message.cc b/src/inspector/v8-console-message.cc
25+ index c63e523aab91..8b678c00f1d8 100644
26+ --- a/src/inspector/v8-console-message.cc
27+ +++ b/src/inspector/v8-console-message.cc
28+ @@ -87,6 +87,7 @@ class V8ValueStringBuilder {
29+ explicit V8ValueStringBuilder(v8::Local<v8::Context> context)
30+ : m_arrayLimit(maxArrayItemsLimit),
31+ m_isolate(context->GetIsolate()),
32+ + m_visitedArrays(context->GetIsolate()),
33+ m_tryCatch(context->GetIsolate()),
34+ m_context(context) {}
35+
36+ @@ -183,7 +184,7 @@ class V8ValueStringBuilder {
37+ uint32_t m_arrayLimit;
38+ v8::Isolate* m_isolate;
39+ String16Builder m_builder;
40+ - std::vector<v8::Local<v8::Array>> m_visitedArrays;
41+ + v8::LocalVector<v8::Array> m_visitedArrays;
42+ v8::TryCatch m_tryCatch;
43+ v8::Local<v8::Context> m_context;
44+ };
45+ @@ -425,7 +426,7 @@ ConsoleAPIType V8ConsoleMessage::type() const { return m_type; }
46+ std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(
47+ v8::Local<v8::Context> v8Context, int contextId, int groupId,
48+ V8InspectorImpl* inspector, double timestamp, ConsoleAPIType type,
49+ - const std::vector<v8::Local<v8::Value>>& arguments,
50+ + v8::MemorySpan<const v8::Local<v8::Value>> arguments,
51+ const String16& consoleContext,
52+ std::unique_ptr<V8StackTraceImpl> stackTrace) {
53+ v8::Isolate* isolate = v8Context->GetIsolate();
54+ @@ -441,18 +442,21 @@ std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(
55+ message->m_consoleContext = consoleContext;
56+ message->m_type = type;
57+ message->m_contextId = contextId;
58+ - for (size_t i = 0; i < arguments.size(); ++i) {
59+ + for (v8::Local<v8::Value> arg : arguments) {
60+ std::unique_ptr<v8::Global<v8::Value>> argument(
61+ - new v8::Global<v8::Value>(isolate, arguments.at(i)));
62+ + new v8::Global<v8::Value>(isolate, arg));
63+ argument->AnnotateStrongRetainer(kGlobalConsoleMessageHandleLabel);
64+ message->m_arguments.push_back(std::move(argument));
65+ - message->m_v8Size +=
66+ - v8::debug::EstimatedValueSize(isolate, arguments.at(i));
67+ + message->m_v8Size += v8::debug::EstimatedValueSize(isolate, arg);
68+ }
69+ - for (size_t i = 0, num_args = arguments.size(); i < num_args; ++i) {
70+ - if (i) message->m_message += String16(" ");
71+ - message->m_message +=
72+ - V8ValueStringBuilder::toString(arguments[i], v8Context);
73+ + bool sep = false;
74+ + for (v8::Local<v8::Value> arg : arguments) {
75+ + if (sep) {
76+ + message->m_message += String16(" ");
77+ + } else {
78+ + sep = true;
79+ + }
80+ + message->m_message += V8ValueStringBuilder::toString(arg, v8Context);
81+ }
82+
83+ v8::Isolate::MessageErrorLevel clientLevel = v8::Isolate::kMessageInfo;
84+ diff --git a/src/inspector/v8-console-message.h b/src/inspector/v8-console-message.h
85+ index cd960cf79787..7c0804da45cb 100644
86+ --- a/src/inspector/v8-console-message.h
87+ +++ b/src/inspector/v8-console-message.h
88+ @@ -51,7 +51,7 @@ class V8ConsoleMessage {
89+ static std::unique_ptr<V8ConsoleMessage> createForConsoleAPI(
90+ v8::Local<v8::Context> v8Context, int contextId, int groupId,
91+ V8InspectorImpl* inspector, double timestamp, ConsoleAPIType,
92+ - const std::vector<v8::Local<v8::Value>>& arguments,
93+ + v8::MemorySpan<const v8::Local<v8::Value>> arguments,
94+ const String16& consoleContext, std::unique_ptr<V8StackTraceImpl>);
95+
96+ static std::unique_ptr<V8ConsoleMessage> createForException(
197diff --git a/src/inspector/v8-console.cc b/src/inspector/v8-console.cc
298index f608d678505e..882be746310d 100644
399--- a/src/inspector/v8-console.cc
@@ -6,43 +102,75 @@ index f608d678505e..882be746310d 100644
6102
7103 void reportCall(ConsoleAPIType type) {
8104 if (!m_info.Length()) return;
105+ - std::vector<v8::Local<v8::Value>> arguments;
106+ + v8::LocalVector<v8::Value> arguments(m_isolate);
9107 arguments.reserve(m_info.Length());
10108 for (int i = 0; i < m_info.Length(); ++i) arguments.push_back(m_info[i]);
109+ - reportCall(type, arguments);
110+ + reportCall(type, {arguments.begin(), arguments.end()});
11111 }
12112
13113 void reportCallWithDefaultArgument(ConsoleAPIType type,
14114 const String16& message) {
115+ - std::vector<v8::Local<v8::Value>> arguments;
116+ + v8::LocalVector<v8::Value> arguments(m_isolate);
15117 arguments.reserve(m_info.Length());
16118 for (int i = 0; i < m_info.Length(); ++i) arguments.push_back(m_info[i]);
17119 if (!m_info.Length()) arguments.push_back(toV8String(m_isolate, message));
120+ - reportCall(type, arguments);
121+ + reportCall(type, {arguments.begin(), arguments.end()});
18122 }
19123
20124 void reportCallAndReplaceFirstArgument(ConsoleAPIType type,
21125 const String16& message) {
126+ - std::vector<v8::Local<v8::Value>> arguments;
127+ + v8::LocalVector<v8::Value> arguments(m_isolate);
22128 arguments.push_back(toV8String(m_isolate, message));
23129 for (int i = 1; i < m_info.Length(); ++i) arguments.push_back(m_info[i]);
130+ - reportCall(type, arguments);
131+ + reportCall(type, {arguments.begin(), arguments.end()});
24132 }
25133
26134 void reportCallWithArgument(ConsoleAPIType type, const String16& message) {
27- - auto arguments =
28- - v8::to_array<v8::Local<v8::Value>>({ toV8String(m_isolate, message)} );
135+ - std::vector<v8::Local<v8::Value>> arguments(1,
136+ - toV8String(m_isolate, message));
29137+ auto arguments =
30- + v8::to_array<v8::Local<v8::Value>>({toV8String(m_isolate, message)->Value() });
138+ + v8::to_array<v8::Local<v8::Value>>({toV8String(m_isolate, message)});
31139 reportCall(type, arguments);
32140 }
33141
34142 void reportCall(ConsoleAPIType type,
143+ - const std::vector<v8::Local<v8::Value>>& arguments) {
144+ + v8::MemorySpan<const v8::Local<v8::Value>> arguments) {
35145 if (!m_groupId) return;
36146 std::unique_ptr<V8ConsoleMessage> message =
37147 V8ConsoleMessage::createForConsoleAPI(
38148@@ -116,8 +116,8 @@ class ConsoleHelper {
39149 id)) {
40150 return;
41151 }
42- - auto arguments =
43- - v8::to_array<v8::Local<v8::Value>>({ toV8String(m_isolate, message)} );
152+ - std::vector<v8::Local<v8::Value>> arguments(1,
153+ - toV8String(m_isolate, message));
44154+ auto arguments =
45- + v8::to_array<v8::Local<v8::Value>>({toV8String(m_isolate, message)->Value() });
155+ + v8::to_array<v8::Local<v8::Value>>({toV8String(m_isolate, message)});
46156 reportCall(ConsoleAPIType::kWarning, arguments);
47157 }
48158
159+ @@ -355,12 +355,13 @@ void V8Console::Assert(const v8::debug::ConsoleCallArguments& info,
160+ ConsoleHelper helper(info, consoleContext, m_inspector);
161+ DCHECK(!helper.firstArgToBoolean(false));
162+
163+ - std::vector<v8::Local<v8::Value>> arguments;
164+ + v8::Isolate* isolate = m_inspector->isolate();
165+ + v8::LocalVector<v8::Value> arguments(isolate);
166+ for (int i = 1; i < info.Length(); ++i) arguments.push_back(info[i]);
167+ if (info.Length() < 2)
168+ - arguments.push_back(
169+ - toV8String(m_inspector->isolate(), String16("console.assert")));
170+ - helper.reportCall(ConsoleAPIType::kAssert, arguments);
171+ + arguments.push_back(toV8String(isolate, String16("console.assert")));
172+ + helper.reportCall(ConsoleAPIType::kAssert,
173+ + {arguments.begin(), arguments.end()});
174+ m_inspector->debugger()->breakProgramOnAssert(helper.groupId());
175+ }
176+
0 commit comments