summaryrefslogtreecommitdiff
path: root/deps/v8/src/inspector/v8-console.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/inspector/v8-console.cc')
-rw-r--r--deps/v8/src/inspector/v8-console.cc40
1 files changed, 31 insertions, 9 deletions
diff --git a/deps/v8/src/inspector/v8-console.cc b/deps/v8/src/inspector/v8-console.cc
index 752b50fa36..ef4c7ccd1d 100644
--- a/deps/v8/src/inspector/v8-console.cc
+++ b/deps/v8/src/inspector/v8-console.cc
@@ -63,6 +63,7 @@ class ConsoleHelper {
void reportCall(ConsoleAPIType type) {
if (!m_info.Length()) return;
std::vector<v8::Local<v8::Value>> arguments;
+ arguments.reserve(m_info.Length());
for (int i = 0; i < m_info.Length(); ++i) arguments.push_back(m_info[i]);
reportCall(type, arguments);
}
@@ -75,6 +76,14 @@ class ConsoleHelper {
reportCall(type, arguments);
}
+ void reportCallAndReplaceFirstArgument(ConsoleAPIType type,
+ const String16& message) {
+ std::vector<v8::Local<v8::Value>> arguments;
+ arguments.push_back(toV8String(m_isolate, message));
+ for (int i = 1; i < m_info.Length(); ++i) arguments.push_back(m_info[i]);
+ reportCall(type, arguments);
+ }
+
void reportCallWithArgument(ConsoleAPIType type, const String16& message) {
std::vector<v8::Local<v8::Value>> arguments(1,
toV8String(m_isolate, message));
@@ -106,7 +115,7 @@ class ConsoleHelper {
bool firstArgToBoolean(bool defaultValue) {
if (m_info.Length() < 1) return defaultValue;
if (m_info[0]->IsBoolean()) return m_info[0].As<v8::Boolean>()->Value();
- return m_info[0]->BooleanValue(m_context).FromMaybe(defaultValue);
+ return m_info[0]->BooleanValue(m_context->GetIsolate());
}
String16 firstArgToString(const String16& defaultValue,
@@ -143,7 +152,7 @@ class ConsoleHelper {
}
void forEachSession(std::function<void(V8InspectorSessionImpl*)> callback) {
- m_inspector->forEachSession(m_groupId, callback);
+ m_inspector->forEachSession(m_groupId, std::move(callback));
}
private:
@@ -385,10 +394,9 @@ static void timeFunction(const v8::debug::ConsoleCallArguments& info,
static void timeEndFunction(const v8::debug::ConsoleCallArguments& info,
const v8::debug::ConsoleContext& consoleContext,
- bool timelinePrefix, V8InspectorImpl* inspector) {
+ bool timeLog, V8InspectorImpl* inspector) {
ConsoleHelper helper(info, consoleContext, inspector);
String16 protocolTitle = helper.firstArgToString("default", false);
- if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'";
const String16& timerId =
protocolTitle + "@" +
consoleContextToString(inspector->isolate(), consoleContext);
@@ -399,13 +407,22 @@ static void timeEndFunction(const v8::debug::ConsoleCallArguments& info,
return;
}
inspector->client()->consoleTimeEnd(toStringView(protocolTitle));
- double elapsed = helper.consoleMessageStorage()->timeEnd(
- helper.contextId(),
- protocolTitle + "@" +
- consoleContextToString(inspector->isolate(), consoleContext));
+ String16 title = protocolTitle + "@" +
+ consoleContextToString(inspector->isolate(), consoleContext);
+ double elapsed;
+ if (timeLog) {
+ elapsed =
+ helper.consoleMessageStorage()->timeLog(helper.contextId(), title);
+ } else {
+ elapsed =
+ helper.consoleMessageStorage()->timeEnd(helper.contextId(), title);
+ }
String16 message =
protocolTitle + ": " + String16::fromDouble(elapsed) + "ms";
- helper.reportCallWithArgument(ConsoleAPIType::kTimeEnd, message);
+ if (timeLog)
+ helper.reportCallAndReplaceFirstArgument(ConsoleAPIType::kLog, message);
+ else
+ helper.reportCallWithArgument(ConsoleAPIType::kTimeEnd, message);
}
void V8Console::Time(const v8::debug::ConsoleCallArguments& info,
@@ -413,6 +430,11 @@ void V8Console::Time(const v8::debug::ConsoleCallArguments& info,
timeFunction(info, consoleContext, false, m_inspector);
}
+void V8Console::TimeLog(const v8::debug::ConsoleCallArguments& info,
+ const v8::debug::ConsoleContext& consoleContext) {
+ timeEndFunction(info, consoleContext, true, m_inspector);
+}
+
void V8Console::TimeEnd(const v8::debug::ConsoleCallArguments& info,
const v8::debug::ConsoleContext& consoleContext) {
timeEndFunction(info, consoleContext, false, m_inspector);