summaryrefslogtreecommitdiff
path: root/deps/v8/src/inspector
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/inspector')
-rw-r--r--deps/v8/src/inspector/DEPS3
-rw-r--r--deps/v8/src/inspector/injected-script-source.js10
-rw-r--r--deps/v8/src/inspector/injected-script.cc5
-rw-r--r--deps/v8/src/inspector/string-16.cc7
-rw-r--r--deps/v8/src/inspector/string-16.h6
-rw-r--r--deps/v8/src/inspector/string-util.cc10
-rw-r--r--deps/v8/src/inspector/string-util.h4
-rw-r--r--deps/v8/src/inspector/v8-console-message.cc14
-rw-r--r--deps/v8/src/inspector/v8-console.cc26
-rw-r--r--deps/v8/src/inspector/v8-debugger-agent-impl.cc29
-rw-r--r--deps/v8/src/inspector/v8-debugger-script.cc15
-rw-r--r--deps/v8/src/inspector/v8-debugger.cc4
-rw-r--r--deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc11
-rw-r--r--deps/v8/src/inspector/v8-injected-script-host.cc5
-rw-r--r--deps/v8/src/inspector/v8-inspector-impl.cc11
-rw-r--r--deps/v8/src/inspector/v8-inspector-impl.h2
-rw-r--r--deps/v8/src/inspector/v8-inspector-session-impl.cc16
-rw-r--r--deps/v8/src/inspector/v8-inspector-session-impl.h2
-rw-r--r--deps/v8/src/inspector/v8-profiler-agent-impl.cc20
-rw-r--r--deps/v8/src/inspector/v8-regex.cc2
-rw-r--r--deps/v8/src/inspector/v8-runtime-agent-impl.cc12
-rw-r--r--deps/v8/src/inspector/v8-stack-trace-impl.cc10
-rw-r--r--deps/v8/src/inspector/v8-stack-trace-impl.h2
-rw-r--r--deps/v8/src/inspector/v8-value-utils.cc9
-rw-r--r--deps/v8/src/inspector/wasm-translation.cc3
25 files changed, 153 insertions, 85 deletions
diff --git a/deps/v8/src/inspector/DEPS b/deps/v8/src/inspector/DEPS
index e3457ca0f9..8624d47bf4 100644
--- a/deps/v8/src/inspector/DEPS
+++ b/deps/v8/src/inspector/DEPS
@@ -2,13 +2,14 @@ include_rules = [
"-src",
"-include/v8-debug.h",
"+src/base/atomicops.h",
+ "+src/base/compiler-specific.h",
"+src/base/macros.h",
"+src/base/logging.h",
"+src/base/platform/platform.h",
"+src/base/platform/mutex.h",
"+src/conversions.h",
"+src/flags.h",
- "+src/utils.h",
+ "+src/v8memory.h",
"+src/unicode-cache.h",
"+src/inspector",
"+src/tracing",
diff --git a/deps/v8/src/inspector/injected-script-source.js b/deps/v8/src/inspector/injected-script-source.js
index 5e5302fbbe..ea0d871248 100644
--- a/deps/v8/src/inspector/injected-script-source.js
+++ b/deps/v8/src/inspector/injected-script-source.js
@@ -401,9 +401,12 @@ InjectedScript.prototype = {
var isAccessorProperty = descriptor && ("get" in descriptor || "set" in descriptor);
if (accessorPropertiesOnly && !isAccessorProperty)
continue;
- if (descriptor && "get" in descriptor && "set" in descriptor && name !== "__proto__" &&
+ // Special case for Symbol.prototype.description where the receiver of the getter is not an actual object.
+ // Should only occur for nested previews.
+ var isSymbolDescription = isSymbol(object) && name === 'description';
+ if (isSymbolDescription || (descriptor && "get" in descriptor && "set" in descriptor && name !== "__proto__" &&
InjectedScriptHost.formatAccessorsAsProperties(object, descriptor.get) &&
- !doesAttributeHaveObservableSideEffectOnGet(object, name)) {
+ !doesAttributeHaveObservableSideEffectOnGet(object, name))) {
descriptor.value = object[property];
descriptor.isOwn = true;
delete descriptor.get;
@@ -594,6 +597,9 @@ InjectedScript.prototype = {
return toString(obj);
if (subtype === "node") {
+ // We should warmup blink dom binding before calling anything,
+ // see (crbug.com/827585) for details.
+ InjectedScriptHost.getOwnPropertyDescriptor(/** @type {!Object} */(obj), "nodeName");
var description = "";
var nodeName = InjectedScriptHost.getProperty(obj, "nodeName");
if (nodeName) {
diff --git a/deps/v8/src/inspector/injected-script.cc b/deps/v8/src/inspector/injected-script.cc
index 5852b227e7..0d1b8d6e89 100644
--- a/deps/v8/src/inspector/injected-script.cc
+++ b/deps/v8/src/inspector/injected-script.cc
@@ -204,6 +204,7 @@ class InjectedScript::ProtocolPromiseHandler {
v8::Isolate* isolate = session->inspector()->isolate();
if (result->IsNativeError()) {
message = " " + toProtocolString(
+ isolate,
result->ToDetailString(isolate->GetCurrentContext())
.ToLocalChecked());
v8::Local<v8::StackTrace> stackTrace = v8::debug::GetDetailedStackTrace(
@@ -564,7 +565,9 @@ Response InjectedScript::createExceptionDetails(
v8::Local<v8::Message> message = tryCatch.Message();
v8::Local<v8::Value> exception = tryCatch.Exception();
String16 messageText =
- message.IsEmpty() ? String16() : toProtocolString(message->Get());
+ message.IsEmpty()
+ ? String16()
+ : toProtocolString(m_context->isolate(), message->Get());
std::unique_ptr<protocol::Runtime::ExceptionDetails> exceptionDetails =
protocol::Runtime::ExceptionDetails::create()
.setExceptionId(m_context->inspector()->nextExceptionId())
diff --git a/deps/v8/src/inspector/string-16.cc b/deps/v8/src/inspector/string-16.cc
index f5d8556da8..fbcb0f4338 100644
--- a/deps/v8/src/inspector/string-16.cc
+++ b/deps/v8/src/inspector/string-16.cc
@@ -375,8 +375,9 @@ String16::String16() {}
String16::String16(const String16& other)
: m_impl(other.m_impl), hash_code(other.hash_code) {}
-String16::String16(String16&& other)
- : m_impl(std::move(other.m_impl)), hash_code(other.hash_code) {}
+String16::String16(String16&& other) V8_NOEXCEPT
+ : m_impl(std::move(other.m_impl)),
+ hash_code(other.hash_code) {}
String16::String16(const UChar* characters, size_t size)
: m_impl(characters, size) {}
@@ -399,7 +400,7 @@ String16& String16::operator=(const String16& other) {
return *this;
}
-String16& String16::operator=(String16&& other) {
+String16& String16::operator=(String16&& other) V8_NOEXCEPT {
m_impl = std::move(other.m_impl);
hash_code = other.hash_code;
return *this;
diff --git a/deps/v8/src/inspector/string-16.h b/deps/v8/src/inspector/string-16.h
index 461b2961e1..7c6f9e992d 100644
--- a/deps/v8/src/inspector/string-16.h
+++ b/deps/v8/src/inspector/string-16.h
@@ -12,6 +12,8 @@
#include <string>
#include <vector>
+#include "src/base/compiler-specific.h"
+
namespace v8_inspector {
using UChar = uint16_t;
@@ -22,7 +24,7 @@ class String16 {
String16();
String16(const String16& other);
- String16(String16&& other);
+ String16(String16&& other) V8_NOEXCEPT;
String16(const UChar* characters, size_t size);
String16(const UChar* characters); // NOLINT(runtime/explicit)
String16(const char* characters); // NOLINT(runtime/explicit)
@@ -30,7 +32,7 @@ class String16 {
explicit String16(const std::basic_string<UChar>& impl);
String16& operator=(const String16& other);
- String16& operator=(String16&& other);
+ String16& operator=(String16&& other) V8_NOEXCEPT;
static String16 fromInteger(int);
static String16 fromInteger(size_t);
diff --git a/deps/v8/src/inspector/string-util.cc b/deps/v8/src/inspector/string-util.cc
index 508229365f..79c5dcc9cf 100644
--- a/deps/v8/src/inspector/string-util.cc
+++ b/deps/v8/src/inspector/string-util.cc
@@ -52,16 +52,18 @@ v8::Local<v8::String> toV8String(v8::Isolate* isolate,
.ToLocalChecked();
}
-String16 toProtocolString(v8::Local<v8::String> value) {
+String16 toProtocolString(v8::Isolate* isolate, v8::Local<v8::String> value) {
if (value.IsEmpty() || value->IsNullOrUndefined()) return String16();
std::unique_ptr<UChar[]> buffer(new UChar[value->Length()]);
- value->Write(reinterpret_cast<uint16_t*>(buffer.get()), 0, value->Length());
+ value->Write(isolate, reinterpret_cast<uint16_t*>(buffer.get()), 0,
+ value->Length());
return String16(buffer.get(), value->Length());
}
-String16 toProtocolStringWithTypeCheck(v8::Local<v8::Value> value) {
+String16 toProtocolStringWithTypeCheck(v8::Isolate* isolate,
+ v8::Local<v8::Value> value) {
if (value.IsEmpty() || !value->IsString()) return String16();
- return toProtocolString(value.As<v8::String>());
+ return toProtocolString(isolate, value.As<v8::String>());
}
String16 toString16(const StringView& string) {
diff --git a/deps/v8/src/inspector/string-util.h b/deps/v8/src/inspector/string-util.h
index 0c025ef93a..97aaa93eb7 100644
--- a/deps/v8/src/inspector/string-util.h
+++ b/deps/v8/src/inspector/string-util.h
@@ -67,8 +67,8 @@ v8::Local<v8::String> toV8StringInternalized(v8::Isolate*, const String16&);
v8::Local<v8::String> toV8StringInternalized(v8::Isolate*, const char*);
v8::Local<v8::String> toV8String(v8::Isolate*, const StringView&);
// TODO(dgozman): rename to toString16.
-String16 toProtocolString(v8::Local<v8::String>);
-String16 toProtocolStringWithTypeCheck(v8::Local<v8::Value>);
+String16 toProtocolString(v8::Isolate*, v8::Local<v8::String>);
+String16 toProtocolStringWithTypeCheck(v8::Isolate*, v8::Local<v8::Value>);
String16 toString16(const StringView&);
StringView toStringView(const String16&);
bool stringViewStartsWith(const StringView&, const char*);
diff --git a/deps/v8/src/inspector/v8-console-message.cc b/deps/v8/src/inspector/v8-console-message.cc
index 408f88bc1d..4bb0bf904e 100644
--- a/deps/v8/src/inspector/v8-console-message.cc
+++ b/deps/v8/src/inspector/v8-console-message.cc
@@ -118,13 +118,11 @@ class V8ValueStringBuilder {
!value->IsNativeError() && !value->IsRegExp()) {
v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
v8::Local<v8::String> stringValue;
- if (object->ObjectProtoToString(m_isolate->GetCurrentContext())
- .ToLocal(&stringValue))
+ if (object->ObjectProtoToString(m_context).ToLocal(&stringValue))
return append(stringValue);
}
v8::Local<v8::String> stringValue;
- if (!value->ToString(m_isolate->GetCurrentContext()).ToLocal(&stringValue))
- return false;
+ if (!value->ToString(m_context).ToLocal(&stringValue)) return false;
return append(stringValue);
}
@@ -160,7 +158,9 @@ class V8ValueStringBuilder {
}
bool append(v8::Local<v8::BigInt> bigint) {
- bool result = append(bigint->ToString());
+ v8::Local<v8::String> bigint_string;
+ if (!bigint->ToString(m_context).ToLocal(&bigint_string)) return false;
+ bool result = append(bigint_string);
if (m_tryCatch.HasCaught()) return false;
m_builder.append('n');
return result;
@@ -168,7 +168,9 @@ class V8ValueStringBuilder {
bool append(v8::Local<v8::String> string) {
if (m_tryCatch.HasCaught()) return false;
- if (!string.IsEmpty()) m_builder.append(toProtocolString(string));
+ if (!string.IsEmpty()) {
+ m_builder.append(toProtocolString(m_isolate, string));
+ }
return true;
}
diff --git a/deps/v8/src/inspector/v8-console.cc b/deps/v8/src/inspector/v8-console.cc
index faba4a082b..752b50fa36 100644
--- a/deps/v8/src/inspector/v8-console.cc
+++ b/deps/v8/src/inspector/v8-console.cc
@@ -24,9 +24,9 @@ namespace v8_inspector {
namespace {
String16 consoleContextToString(
- const v8::debug::ConsoleContext& consoleContext) {
+ v8::Isolate* isolate, const v8::debug::ConsoleContext& consoleContext) {
if (consoleContext.id() == 0) return String16();
- return toProtocolString(consoleContext.name()) + "#" +
+ return toProtocolString(isolate, consoleContext.name()) + "#" +
String16::fromInteger(consoleContext.id());
}
@@ -88,7 +88,7 @@ class ConsoleHelper {
V8ConsoleMessage::createForConsoleAPI(
m_context, m_contextId, m_groupId, m_inspector,
m_inspector->client()->currentTimeMS(), type, arguments,
- consoleContextToString(m_consoleContext),
+ consoleContextToString(m_isolate, m_consoleContext),
m_inspector->debugger()->captureStackTrace(false));
consoleMessageStorage()->addMessage(std::move(message));
}
@@ -124,7 +124,7 @@ class ConsoleHelper {
if (!m_info[0]->ToString(m_context).ToLocal(&titleValue))
return defaultValue;
}
- return toProtocolString(titleValue);
+ return toProtocolString(m_context->GetIsolate(), titleValue);
}
v8::MaybeLocal<v8::Object> firstArgAsObject() {
@@ -297,7 +297,8 @@ static String16 identifierFromTitleOrStackTrace(
} else {
identifier = title + "@";
}
- identifier = consoleContextToString(consoleContext) + "@" + identifier;
+ identifier = consoleContextToString(inspector->isolate(), consoleContext) +
+ "@" + identifier;
return identifier;
}
@@ -370,7 +371,8 @@ static void timeFunction(const v8::debug::ConsoleCallArguments& info,
String16 protocolTitle = helper.firstArgToString("default", false);
if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'";
const String16& timerId =
- protocolTitle + "@" + consoleContextToString(consoleContext);
+ protocolTitle + "@" +
+ consoleContextToString(inspector->isolate(), consoleContext);
if (helper.consoleMessageStorage()->hasTimer(helper.contextId(), timerId)) {
helper.reportCallWithArgument(
ConsoleAPIType::kWarning,
@@ -388,7 +390,8 @@ static void timeEndFunction(const v8::debug::ConsoleCallArguments& info,
String16 protocolTitle = helper.firstArgToString("default", false);
if (timelinePrefix) protocolTitle = "Timeline '" + protocolTitle + "'";
const String16& timerId =
- protocolTitle + "@" + consoleContextToString(consoleContext);
+ protocolTitle + "@" +
+ consoleContextToString(inspector->isolate(), consoleContext);
if (!helper.consoleMessageStorage()->hasTimer(helper.contextId(), timerId)) {
helper.reportCallWithArgument(
ConsoleAPIType::kWarning,
@@ -398,7 +401,8 @@ static void timeEndFunction(const v8::debug::ConsoleCallArguments& info,
inspector->client()->consoleTimeEnd(toStringView(protocolTitle));
double elapsed = helper.consoleMessageStorage()->timeEnd(
helper.contextId(),
- protocolTitle + "@" + consoleContextToString(consoleContext));
+ protocolTitle + "@" +
+ consoleContextToString(inspector->isolate(), consoleContext));
String16 message =
protocolTitle + ": " + String16::fromDouble(elapsed) + "ms";
helper.reportCallWithArgument(ConsoleAPIType::kTimeEnd, message);
@@ -527,7 +531,8 @@ void V8Console::monitorFunctionCallback(
v8::Local<v8::Value> name = function->GetName();
if (!name->IsString() || !v8::Local<v8::String>::Cast(name)->Length())
name = function->GetInferredName();
- String16 functionName = toProtocolStringWithTypeCheck(name);
+ String16 functionName =
+ toProtocolStringWithTypeCheck(info.GetIsolate(), name);
String16Builder builder;
builder.append("console.log(\"function ");
if (functionName.isEmpty())
@@ -779,7 +784,8 @@ void V8Console::CommandLineAPIScope::accessorGetterCallback(
v8::Local<v8::Value> value;
if (!commandLineAPI->Get(context, name).ToLocal(&value)) return;
- if (isCommandLineAPIGetter(toProtocolStringWithTypeCheck(name))) {
+ if (isCommandLineAPIGetter(
+ toProtocolStringWithTypeCheck(info.GetIsolate(), name))) {
DCHECK(value->IsFunction());
v8::MicrotasksScope microtasks(info.GetIsolate(),
v8::MicrotasksScope::kDoNotRunMicrotasks);
diff --git a/deps/v8/src/inspector/v8-debugger-agent-impl.cc b/deps/v8/src/inspector/v8-debugger-agent-impl.cc
index d9cb49b1d4..a27af98d8d 100644
--- a/deps/v8/src/inspector/v8-debugger-agent-impl.cc
+++ b/deps/v8/src/inspector/v8-debugger-agent-impl.cc
@@ -250,7 +250,7 @@ String16 scopeType(v8::debug::ScopeIterator::ScopeType type) {
namespace {
-Response buildScopes(v8::debug::ScopeIterator* iterator,
+Response buildScopes(v8::Isolate* isolate, v8::debug::ScopeIterator* iterator,
InjectedScript* injectedScript,
std::unique_ptr<Array<Scope>>* scopes) {
*scopes = Array<Scope>::create();
@@ -270,8 +270,8 @@ Response buildScopes(v8::debug::ScopeIterator* iterator,
.setObject(std::move(object))
.build();
- String16 name =
- toProtocolStringWithTypeCheck(iterator->GetFunctionDebugName());
+ String16 name = toProtocolStringWithTypeCheck(
+ isolate, iterator->GetFunctionDebugName());
if (!name.isEmpty()) scope->setName(name);
if (iterator->HasLocationInfo()) {
@@ -878,7 +878,7 @@ Response V8DebuggerAgentImpl::setScriptSource(
*optOutCompileError =
protocol::Runtime::ExceptionDetails::create()
.setExceptionId(m_inspector->nextExceptionId())
- .setText(toProtocolString(result.message))
+ .setText(toProtocolString(m_isolate, result.message))
.setLineNumber(result.line_number != -1 ? result.line_number - 1
: 0)
.setColumnNumber(result.column_number != -1 ? result.column_number
@@ -1265,7 +1265,8 @@ Response V8DebuggerAgentImpl::currentCallFrames(
std::unique_ptr<Array<Scope>> scopes;
auto scopeIterator = iterator->GetScopeIterator();
- Response res = buildScopes(scopeIterator.get(), injectedScript, &scopes);
+ Response res =
+ buildScopes(m_isolate, scopeIterator.get(), injectedScript, &scopes);
if (!res.isSuccess()) return res;
std::unique_ptr<RemoteObject> protocolReceiver;
@@ -1300,15 +1301,15 @@ Response V8DebuggerAgentImpl::currentCallFrames(
url = scriptIterator->second->sourceURL();
}
- auto frame =
- CallFrame::create()
- .setCallFrameId(callFrameId)
- .setFunctionName(toProtocolString(iterator->GetFunctionDebugName()))
- .setLocation(std::move(location))
- .setUrl(url)
- .setScopeChain(std::move(scopes))
- .setThis(std::move(protocolReceiver))
- .build();
+ auto frame = CallFrame::create()
+ .setCallFrameId(callFrameId)
+ .setFunctionName(toProtocolString(
+ m_isolate, iterator->GetFunctionDebugName()))
+ .setLocation(std::move(location))
+ .setUrl(url)
+ .setScopeChain(std::move(scopes))
+ .setThis(std::move(protocolReceiver))
+ .build();
v8::Local<v8::Function> func = iterator->GetFunction();
if (!func.IsEmpty()) {
diff --git a/deps/v8/src/inspector/v8-debugger-script.cc b/deps/v8/src/inspector/v8-debugger-script.cc
index d861265e14..babb7700c6 100644
--- a/deps/v8/src/inspector/v8-debugger-script.cc
+++ b/deps/v8/src/inspector/v8-debugger-script.cc
@@ -8,7 +8,7 @@
#include "src/inspector/string-util.h"
#include "src/inspector/v8-inspector-impl.h"
#include "src/inspector/wasm-translation.h"
-#include "src/utils.h"
+#include "src/v8memory.h"
namespace v8_inspector {
@@ -113,7 +113,7 @@ class ActualScript : public V8DebuggerScript {
ActualScript(v8::Isolate* isolate, v8::Local<v8::debug::Script> script,
bool isLiveEdit, V8InspectorClient* client)
: V8DebuggerScript(isolate, String16::fromInteger(script->Id()),
- GetScriptURL(script, client)),
+ GetScriptURL(isolate, script, client)),
m_isLiveEdit(isLiveEdit) {
Initialize(script);
}
@@ -219,14 +219,15 @@ class ActualScript : public V8DebuggerScript {
}
private:
- String16 GetScriptURL(v8::Local<v8::debug::Script> script,
+ String16 GetScriptURL(v8::Isolate* isolate,
+ v8::Local<v8::debug::Script> script,
V8InspectorClient* client) {
v8::Local<v8::String> sourceURL;
if (script->SourceURL().ToLocal(&sourceURL) && sourceURL->Length() > 0)
- return toProtocolString(sourceURL);
+ return toProtocolString(isolate, sourceURL);
v8::Local<v8::String> v8Name;
if (script->Name().ToLocal(&v8Name) && v8Name->Length() > 0) {
- String16 name = toProtocolString(v8Name);
+ String16 name = toProtocolString(isolate, v8Name);
std::unique_ptr<StringBuffer> url =
client->resourceNameToUrl(toStringView(name));
return url ? toString16(url->string()) : name;
@@ -243,7 +244,7 @@ class ActualScript : public V8DebuggerScript {
m_hasSourceURLComment =
script->SourceURL().ToLocal(&tmp) && tmp->Length() > 0;
if (script->SourceMappingURL().ToLocal(&tmp))
- m_sourceMappingURL = toProtocolString(tmp);
+ m_sourceMappingURL = toProtocolString(m_isolate, tmp);
m_startLine = script->LineOffset();
m_startColumn = script->ColumnOffset();
std::vector<int> lineEnds = script->LineEnds();
@@ -264,7 +265,7 @@ class ActualScript : public V8DebuggerScript {
USE(script->ContextId().To(&m_executionContextId));
if (script->Source().ToLocal(&tmp)) {
- m_source = toProtocolString(tmp);
+ m_source = toProtocolString(m_isolate, tmp);
}
m_isModule = script->IsModule();
diff --git a/deps/v8/src/inspector/v8-debugger.cc b/deps/v8/src/inspector/v8-debugger.cc
index 7d1f7cefd1..ccc674af43 100644
--- a/deps/v8/src/inspector/v8-debugger.cc
+++ b/deps/v8/src/inspector/v8-debugger.cc
@@ -722,7 +722,7 @@ v8::MaybeLocal<v8::Value> V8Debugger::getTargetScopes(
String16 name;
v8::Local<v8::Value> maybe_name = iterator->GetFunctionDebugName();
if (!maybe_name->IsUndefined()) {
- name = toProtocolStringWithTypeCheck(maybe_name);
+ name = toProtocolStringWithTypeCheck(m_isolate, maybe_name);
}
v8::Local<v8::Object> object = iterator->GetObject();
createDataProperty(context, scope,
@@ -1134,7 +1134,7 @@ std::shared_ptr<StackFrame> V8Debugger::symbolize(
if (it != m_framesCache.end() && !it->second.expired()) {
return std::shared_ptr<StackFrame>(it->second);
}
- std::shared_ptr<StackFrame> frame(new StackFrame(v8Frame));
+ std::shared_ptr<StackFrame> frame(new StackFrame(isolate(), v8Frame));
// TODO(clemensh): Figure out a way to do this translation only right before
// sending the stack trace over wire.
if (v8Frame->IsWasm()) frame->translate(&m_wasmTranslation);
diff --git a/deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc b/deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc
index b876a956b2..f255287c03 100644
--- a/deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc
+++ b/deps/v8/src/inspector/v8-heap-profiler-agent-impl.cc
@@ -335,19 +335,20 @@ Response V8HeapProfilerAgentImpl::startSampling(
namespace {
std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfileNode>
-buildSampingHeapProfileNode(const v8::AllocationProfile::Node* node) {
+buildSampingHeapProfileNode(v8::Isolate* isolate,
+ const v8::AllocationProfile::Node* node) {
auto children = protocol::Array<
protocol::HeapProfiler::SamplingHeapProfileNode>::create();
for (const auto* child : node->children)
- children->addItem(buildSampingHeapProfileNode(child));
+ children->addItem(buildSampingHeapProfileNode(isolate, child));
size_t selfSize = 0;
for (const auto& allocation : node->allocations)
selfSize += allocation.size * allocation.count;
std::unique_ptr<protocol::Runtime::CallFrame> callFrame =
protocol::Runtime::CallFrame::create()
- .setFunctionName(toProtocolString(node->name))
+ .setFunctionName(toProtocolString(isolate, node->name))
.setScriptId(String16::fromInteger(node->script_id))
- .setUrl(toProtocolString(node->script_name))
+ .setUrl(toProtocolString(isolate, node->script_name))
.setLineNumber(node->line_number - 1)
.setColumnNumber(node->column_number - 1)
.build();
@@ -383,7 +384,7 @@ Response V8HeapProfilerAgentImpl::getSamplingProfile(
return Response::Error("V8 sampling heap profiler was not started.");
v8::AllocationProfile::Node* root = v8Profile->GetRootNode();
*profile = protocol::HeapProfiler::SamplingHeapProfile::create()
- .setHead(buildSampingHeapProfileNode(root))
+ .setHead(buildSampingHeapProfileNode(m_isolate, root))
.build();
return Response::OK();
}
diff --git a/deps/v8/src/inspector/v8-injected-script-host.cc b/deps/v8/src/inspector/v8-injected-script-host.cc
index 23f56f93e2..d9c1d59aa8 100644
--- a/deps/v8/src/inspector/v8-injected-script-host.cc
+++ b/deps/v8/src/inspector/v8-injected-script-host.cc
@@ -299,7 +299,7 @@ void V8InjectedScriptHost::getInternalPropertiesCallback(
tryCatch.Reset();
continue;
}
- String16 keyString = toProtocolStringWithTypeCheck(key);
+ String16 keyString = toProtocolStringWithTypeCheck(isolate, key);
if (keyString.isEmpty() ||
allowedProperties.find(keyString) == allowedProperties.end())
continue;
@@ -337,7 +337,8 @@ void V8InjectedScriptHost::bindCallback(
v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
v8::Local<v8::String> v8groupName =
info[1]->ToString(context).ToLocalChecked();
- String16 groupName = toProtocolStringWithTypeCheck(v8groupName);
+ String16 groupName =
+ toProtocolStringWithTypeCheck(info.GetIsolate(), v8groupName);
int id = injectedScript->bindObject(info[0], groupName);
info.GetReturnValue().Set(id);
}
diff --git a/deps/v8/src/inspector/v8-inspector-impl.cc b/deps/v8/src/inspector/v8-inspector-impl.cc
index 6272e4b4b2..62790a6335 100644
--- a/deps/v8/src/inspector/v8-inspector-impl.cc
+++ b/deps/v8/src/inspector/v8-inspector-impl.cc
@@ -188,6 +188,17 @@ InspectedContext* V8InspectorImpl::getContext(int contextId) const {
return getContext(contextGroupId(contextId), contextId);
}
+v8::MaybeLocal<v8::Context> V8InspectorImpl::contextById(
+ int groupId, v8::Maybe<int> contextId) {
+ if (contextId.IsNothing()) {
+ v8::Local<v8::Context> context =
+ client()->ensureDefaultContextInGroup(groupId);
+ return context.IsEmpty() ? v8::MaybeLocal<v8::Context>() : context;
+ }
+ InspectedContext* context = getContext(contextId.FromJust());
+ return context ? context->context() : v8::MaybeLocal<v8::Context>();
+}
+
void V8InspectorImpl::contextCreated(const V8ContextInfo& info) {
int contextId = ++m_lastContextId;
InspectedContext* context = new InspectedContext(this, info, contextId);
diff --git a/deps/v8/src/inspector/v8-inspector-impl.h b/deps/v8/src/inspector/v8-inspector-impl.h
index b255feed40..2124ba6250 100644
--- a/deps/v8/src/inspector/v8-inspector-impl.h
+++ b/deps/v8/src/inspector/v8-inspector-impl.h
@@ -78,6 +78,8 @@ class V8InspectorImpl : public V8Inspector {
const StringView& state) override;
void contextCreated(const V8ContextInfo&) override;
void contextDestroyed(v8::Local<v8::Context>) override;
+ v8::MaybeLocal<v8::Context> contextById(int groupId,
+ v8::Maybe<int> contextId) override;
void contextCollected(int contextGroupId, int contextId);
void resetContextGroup(int contextGroupId) override;
void idleStarted() override;
diff --git a/deps/v8/src/inspector/v8-inspector-session-impl.cc b/deps/v8/src/inspector/v8-inspector-session-impl.cc
index 1d8d12ac0d..d37f87a2a7 100644
--- a/deps/v8/src/inspector/v8-inspector-session-impl.cc
+++ b/deps/v8/src/inspector/v8-inspector-session-impl.cc
@@ -170,6 +170,12 @@ void V8InspectorSessionImpl::sendProtocolNotification(
m_channel->sendNotification(MessageBuffer::create(std::move(message)));
}
+void V8InspectorSessionImpl::fallThrough(int callId, const String16& method,
+ const String16& message) {
+ // There's no other layer to handle the command.
+ UNREACHABLE();
+}
+
void V8InspectorSessionImpl::flushProtocolNotifications() {
m_channel->flushProtocolNotifications();
}
@@ -313,7 +319,15 @@ void V8InspectorSessionImpl::reportAllContexts(V8RuntimeAgentImpl* agent) {
void V8InspectorSessionImpl::dispatchProtocolMessage(
const StringView& message) {
- m_dispatcher.dispatch(protocol::StringUtil::parseJSON(message));
+ int callId;
+ String16 method;
+ std::unique_ptr<protocol::Value> parsedMessage =
+ protocol::StringUtil::parseJSON(message);
+ if (m_dispatcher.parseCommand(parsedMessage.get(), &callId, &method)) {
+ // Pass empty string instead of the actual message to save on a conversion.
+ // We're allowed to do so because fall-through is not implemented.
+ m_dispatcher.dispatch(callId, method, std::move(parsedMessage), "");
+ }
}
std::unique_ptr<StringBuffer> V8InspectorSessionImpl::stateJSON() {
diff --git a/deps/v8/src/inspector/v8-inspector-session-impl.h b/deps/v8/src/inspector/v8-inspector-session-impl.h
index 8ca0915b66..85861a05bf 100644
--- a/deps/v8/src/inspector/v8-inspector-session-impl.h
+++ b/deps/v8/src/inspector/v8-inspector-session-impl.h
@@ -101,6 +101,8 @@ class V8InspectorSessionImpl : public V8InspectorSession,
int callId, std::unique_ptr<protocol::Serializable> message) override;
void sendProtocolNotification(
std::unique_ptr<protocol::Serializable> message) override;
+ void fallThrough(int callId, const String16& method,
+ const String16& message) override;
void flushProtocolNotifications() override;
int m_contextGroupId;
diff --git a/deps/v8/src/inspector/v8-profiler-agent-impl.cc b/deps/v8/src/inspector/v8-profiler-agent-impl.cc
index f14815fdc4..1e16218e1c 100644
--- a/deps/v8/src/inspector/v8-profiler-agent-impl.cc
+++ b/deps/v8/src/inspector/v8-profiler-agent-impl.cc
@@ -34,7 +34,7 @@ namespace {
String16 resourceNameToUrl(V8InspectorImpl* inspector,
v8::Local<v8::String> v8Name) {
- String16 name = toProtocolString(v8Name);
+ String16 name = toProtocolString(inspector->isolate(), v8Name);
if (!inspector) return name;
std::unique_ptr<StringBuffer> url =
inspector->client()->resourceNameToUrl(toStringView(name));
@@ -66,7 +66,7 @@ std::unique_ptr<protocol::Profiler::ProfileNode> buildInspectorObjectFor(
v8::HandleScope handleScope(isolate);
auto callFrame =
protocol::Runtime::CallFrame::create()
- .setFunctionName(toProtocolString(node->GetFunctionName()))
+ .setFunctionName(toProtocolString(isolate, node->GetFunctionName()))
.setScriptId(String16::fromInteger(node->GetScriptId()))
.setUrl(resourceNameToUrl(inspector, node->GetScriptResourceName()))
.setLineNumber(node->GetLineNumber() - 1)
@@ -337,6 +337,7 @@ Response coverageToProtocol(
out_result) {
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>> result =
protocol::Array<protocol::Profiler::ScriptCoverage>::create();
+ v8::Isolate* isolate = inspector->isolate();
for (size_t i = 0; i < coverage.ScriptCount(); i++) {
v8::debug::Coverage::ScriptData script_data = coverage.GetScriptData(i);
v8::Local<v8::debug::Script> script = script_data.GetScript();
@@ -366,6 +367,7 @@ Response coverageToProtocol(
functions->addItem(
protocol::Profiler::FunctionCoverage::create()
.setFunctionName(toProtocolString(
+ isolate,
function_data.Name().FromMaybe(v8::Local<v8::String>())))
.setRanges(std::move(ranges))
.setIsBlockCoverage(function_data.HasBlockCoverage())
@@ -374,7 +376,7 @@ Response coverageToProtocol(
String16 url;
v8::Local<v8::String> name;
if (script->SourceURL().ToLocal(&name) && name->Length()) {
- url = toProtocolString(name);
+ url = toProtocolString(isolate, name);
} else if (script->Name().ToLocal(&name) && name->Length()) {
url = resourceNameToUrl(inspector, name);
}
@@ -416,6 +418,7 @@ typeProfileToProtocol(V8InspectorImpl* inspector,
const v8::debug::TypeProfile& type_profile) {
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptTypeProfile>>
result = protocol::Array<protocol::Profiler::ScriptTypeProfile>::create();
+ v8::Isolate* isolate = inspector->isolate();
for (size_t i = 0; i < type_profile.ScriptCount(); i++) {
v8::debug::TypeProfile::ScriptData script_data =
type_profile.GetScriptData(i);
@@ -428,10 +431,11 @@ typeProfileToProtocol(V8InspectorImpl* inspector,
std::unique_ptr<protocol::Array<protocol::Profiler::TypeObject>> types =
protocol::Array<protocol::Profiler::TypeObject>::create();
for (const auto& type : entry.Types()) {
- types->addItem(protocol::Profiler::TypeObject::create()
- .setName(toProtocolString(
- type.FromMaybe(v8::Local<v8::String>())))
- .build());
+ types->addItem(
+ protocol::Profiler::TypeObject::create()
+ .setName(toProtocolString(
+ isolate, type.FromMaybe(v8::Local<v8::String>())))
+ .build());
}
entries->addItem(protocol::Profiler::TypeProfileEntry::create()
.setOffset(entry.SourcePosition())
@@ -441,7 +445,7 @@ typeProfileToProtocol(V8InspectorImpl* inspector,
String16 url;
v8::Local<v8::String> name;
if (script->SourceURL().ToLocal(&name) && name->Length()) {
- url = toProtocolString(name);
+ url = toProtocolString(isolate, name);
} else if (script->Name().ToLocal(&name) && name->Length()) {
url = resourceNameToUrl(inspector, name);
}
diff --git a/deps/v8/src/inspector/v8-regex.cc b/deps/v8/src/inspector/v8-regex.cc
index 0bab4364c4..5f43d84e2c 100644
--- a/deps/v8/src/inspector/v8-regex.cc
+++ b/deps/v8/src/inspector/v8-regex.cc
@@ -32,7 +32,7 @@ V8Regex::V8Regex(V8InspectorImpl* inspector, const String16& pattern,
.ToLocal(&regex))
m_regex.Reset(isolate, regex);
else if (tryCatch.HasCaught())
- m_errorMessage = toProtocolString(tryCatch.Message()->Get());
+ m_errorMessage = toProtocolString(isolate, tryCatch.Message()->Get());
else
m_errorMessage = "Internal error";
}
diff --git a/deps/v8/src/inspector/v8-runtime-agent-impl.cc b/deps/v8/src/inspector/v8-runtime-agent-impl.cc
index 31111add16..d0ae633945 100644
--- a/deps/v8/src/inspector/v8-runtime-agent-impl.cc
+++ b/deps/v8/src/inspector/v8-runtime-agent-impl.cc
@@ -426,7 +426,8 @@ Response V8RuntimeAgentImpl::getProperties(
if (!response.isSuccess()) return response;
propertiesProtocolArray->addItem(
InternalPropertyDescriptor::create()
- .setName(toProtocolString(name.As<v8::String>()))
+ .setName(
+ toProtocolString(m_inspector->isolate(), name.As<v8::String>()))
.setValue(std::move(wrappedValue))
.build());
}
@@ -622,7 +623,8 @@ Response V8RuntimeAgentImpl::globalLexicalScopeNames(
v8::debug::GlobalLexicalScopeNames(scope.context(), &names);
*outNames = protocol::Array<String16>::create();
for (size_t i = 0; i < names.Size(); ++i) {
- (*outNames)->addItem(toProtocolString(names.Get(i)));
+ (*outNames)->addItem(
+ toProtocolString(m_inspector->isolate(), names.Get(i)));
}
return Response::OK();
}
@@ -690,8 +692,10 @@ void V8RuntimeAgentImpl::bindingCallback(
int contextId = InspectedContext::contextId(isolate->GetCurrentContext());
int contextGroupId = inspector->contextGroupId(contextId);
- String16 name = toProtocolString(v8::Local<v8::String>::Cast(info.Data()));
- String16 payload = toProtocolString(v8::Local<v8::String>::Cast(info[0]));
+ String16 name =
+ toProtocolString(isolate, v8::Local<v8::String>::Cast(info.Data()));
+ String16 payload =
+ toProtocolString(isolate, v8::Local<v8::String>::Cast(info[0]));
inspector->forEachSession(
contextGroupId,
diff --git a/deps/v8/src/inspector/v8-stack-trace-impl.cc b/deps/v8/src/inspector/v8-stack-trace-impl.cc
index 9be0d4fa38..21ca98d911 100644
--- a/deps/v8/src/inspector/v8-stack-trace-impl.cc
+++ b/deps/v8/src/inspector/v8-stack-trace-impl.cc
@@ -28,7 +28,8 @@ std::vector<std::shared_ptr<StackFrame>> toFramesVector(
int frameCount = std::min(v8StackTrace->GetFrameCount(), maxStackSize);
std::vector<std::shared_ptr<StackFrame>> frames(frameCount);
for (int i = 0; i < frameCount; ++i) {
- frames[i] = debugger->symbolize(v8StackTrace->GetFrame(i));
+ frames[i] =
+ debugger->symbolize(v8StackTrace->GetFrame(debugger->isolate(), i));
}
return frames;
}
@@ -116,10 +117,11 @@ V8StackTraceId::V8StackTraceId(uintptr_t id,
bool V8StackTraceId::IsInvalid() const { return !id; }
-StackFrame::StackFrame(v8::Local<v8::StackFrame> v8Frame)
- : m_functionName(toProtocolString(v8Frame->GetFunctionName())),
+StackFrame::StackFrame(v8::Isolate* isolate, v8::Local<v8::StackFrame> v8Frame)
+ : m_functionName(toProtocolString(isolate, v8Frame->GetFunctionName())),
m_scriptId(String16::fromInteger(v8Frame->GetScriptId())),
- m_sourceURL(toProtocolString(v8Frame->GetScriptNameOrSourceURL())),
+ m_sourceURL(
+ toProtocolString(isolate, v8Frame->GetScriptNameOrSourceURL())),
m_lineNumber(v8Frame->GetLineNumber() - 1),
m_columnNumber(v8Frame->GetColumn() - 1),
m_hasSourceURLComment(v8Frame->GetScriptName() !=
diff --git a/deps/v8/src/inspector/v8-stack-trace-impl.h b/deps/v8/src/inspector/v8-stack-trace-impl.h
index 019fd469cd..abda0f12ee 100644
--- a/deps/v8/src/inspector/v8-stack-trace-impl.h
+++ b/deps/v8/src/inspector/v8-stack-trace-impl.h
@@ -23,7 +23,7 @@ struct V8StackTraceId;
class StackFrame {
public:
- explicit StackFrame(v8::Local<v8::StackFrame> frame);
+ explicit StackFrame(v8::Isolate* isolate, v8::Local<v8::StackFrame> frame);
~StackFrame() = default;
void translate(WasmTranslation* wasmTranslation);
diff --git a/deps/v8/src/inspector/v8-value-utils.cc b/deps/v8/src/inspector/v8-value-utils.cc
index 3835f34f6d..feaffd36d0 100644
--- a/deps/v8/src/inspector/v8-value-utils.cc
+++ b/deps/v8/src/inspector/v8-value-utils.cc
@@ -39,8 +39,8 @@ protocol::Response toProtocolValue(v8::Local<v8::Context> context,
return Response::OK();
}
if (value->IsString()) {
- *result =
- protocol::StringValue::create(toProtocolString(value.As<v8::String>()));
+ *result = protocol::StringValue::create(
+ toProtocolString(context->GetIsolate(), value.As<v8::String>()));
return Response::OK();
}
if (value->IsArray()) {
@@ -90,8 +90,9 @@ protocol::Response toProtocolValue(v8::Local<v8::Context> context,
Response response =
toProtocolValue(context, property, maxDepth, &propertyValue);
if (!response.isSuccess()) return response;
- jsonObject->setValue(toProtocolString(propertyName),
- std::move(propertyValue));
+ jsonObject->setValue(
+ toProtocolString(context->GetIsolate(), propertyName),
+ std::move(propertyValue));
}
*result = std::move(jsonObject);
return Response::OK();
diff --git a/deps/v8/src/inspector/wasm-translation.cc b/deps/v8/src/inspector/wasm-translation.cc
index 4754af5442..f049871202 100644
--- a/deps/v8/src/inspector/wasm-translation.cc
+++ b/deps/v8/src/inspector/wasm-translation.cc
@@ -219,7 +219,8 @@ class WasmTranslation::TranslatorImpl::DisassemblingTranslator
private:
String16 GetFakeScriptUrl(v8::Isolate* isolate, int func_index) {
v8::Local<v8::debug::WasmScript> script = script_.Get(isolate);
- String16 script_name = toProtocolString(script->Name().ToLocalChecked());
+ String16 script_name =
+ toProtocolString(isolate, script->Name().ToLocalChecked());
int numFunctions = script->NumFunctions();
int numImported = script->NumImportedFunctions();
String16Builder builder;