GeezerVison is showing github.com — deps: cherry-pick dbfcc48 from upstream V8 by alexkozy · Pull Request #22251 · nodejs/node
deps: cherry-pick dbfcc48 from upstream V8
#22251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.cc
(10)
.gypi
(1)
.h
(5)
.js
(9)
.txt
(1)
All 5 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -29,7 +29,7 @@
# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.10 ',
'v8_embedder_string': '-node.11 ',
# Enable disassembler for `--print-code` v8 options
'v8_enable_disassembler': 1,
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -215,6 +215,11 @@ class V8_EXPORT V8InspectorClient {
virtual bool canExecuteScripts(int contextGroupId) { return true; }
virtual void maxAsyncCallStackDepthChanged(int depth) {}
virtual std::unique_ptr<StringBuffer> resourceNameToUrl(
const StringView& resourceName) {
return nullptr;
}
};
// These stack trace ids are intended to be passed between debuggers and be
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -1396,7 +1396,7 @@ void V8DebuggerAgentImpl::didParseSource(
protocol::StringUtil::parseJSON(inspected->auxData()));
}
bool isLiveEdit = script->isLiveEdit();
bool hasSourceURL = script->hasSourceURL ();
bool hasSourceURLComment = script->hasSourceURLComment ();
bool isModule = script->isModule();
String16 scriptId = script->scriptId();
String16 scriptURL = script->sourceURL();
Expand All
@@ -1416,7 +1416,8 @@ void V8DebuggerAgentImpl::didParseSource(
Maybe<protocol::DictionaryValue> executionContextAuxDataParam(
std::move(executionContextAuxData));
const bool* isLiveEditParam = isLiveEdit ? &isLiveEdit : nullptr;
const bool* hasSourceURLParam = hasSourceURL ? &hasSourceURL : nullptr;
const bool* hasSourceURLParam =
hasSourceURLComment ? &hasSourceURLComment : nullptr;
const bool* isModuleParam = isModule ? &isModule : nullptr;
std::unique_ptr<V8StackTraceImpl> stack =
V8StackTraceImpl::capture(m_inspector->debugger(), contextGroupId, 1);
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -6,6 +6,7 @@
#include "src/inspector/inspected-context.h"
#include "src/inspector/string-util.h"
#include "src/inspector/v8-inspector-impl.h"
#include "src/inspector/wasm-translation.h"
#include "src/utils.h"
Expand Down
Expand Up
@@ -110,9 +111,9 @@ class ActualScript : public V8DebuggerScript {
public:
ActualScript(v8::Isolate* isolate, v8::Local<v8::debug::Script> script,
bool isLiveEdit)
bool isLiveEdit, V8InspectorClient* client )
: V8DebuggerScript(isolate, String16::fromInteger(script->Id()),
GetNameOrSourceUrl (script)),
GetScriptURL (script, client )),
m_isLiveEdit(isLiveEdit) {
Initialize(script);
}
Expand Down
Expand Up
@@ -218,10 +219,18 @@ class ActualScript : public V8DebuggerScript {
}
private:
String16 GetNameOrSourceUrl(v8::Local<v8::debug::Script> script) {
v8::Local<v8::String> name;
if (script->Name().ToLocal(&name) || script->SourceURL().ToLocal(&name))
return toProtocolString(name);
String16 GetScriptURL(v8::Local<v8::debug::Script> script,
V8InspectorClient* client) {
v8::Local<v8::String> sourceURL;
if (script->SourceURL().ToLocal(&sourceURL) && sourceURL->Length() > 0)
return toProtocolString(sourceURL);
v8::Local<v8::String> v8Name;
if (script->Name().ToLocal(&v8Name) && v8Name->Length() > 0) {
String16 name = toProtocolString(v8Name);
std::unique_ptr<StringBuffer> url =
client->resourceNameToUrl(toStringView(name));
return url ? toString16(url->string()) : name;
}
return String16();
}
Expand All
@@ -231,7 +240,8 @@ class ActualScript : public V8DebuggerScript {
void Initialize(v8::Local<v8::debug::Script> script) {
v8::Local<v8::String> tmp;
if (script->SourceURL().ToLocal(&tmp)) m_sourceURL = toProtocolString(tmp);
m_hasSourceURLComment =
script->SourceURL().ToLocal(&tmp) && tmp->Length() > 0;
if (script->SourceMappingURL().ToLocal(&tmp))
m_sourceMappingURL = toProtocolString(tmp);
m_startLine = script->LineOffset();
Expand Down
Expand Up
@@ -398,9 +408,9 @@ class WasmVirtualScript : public V8DebuggerScript {
std::unique_ptr<V8DebuggerScript> V8DebuggerScript::Create(
v8::Isolate* isolate, v8::Local<v8::debug::Script> scriptObj,
bool isLiveEdit) {
bool isLiveEdit, V8InspectorClient* client ) {
return std::unique_ptr<ActualScript>(
new ActualScript(isolate, scriptObj, isLiveEdit));
new ActualScript(isolate, scriptObj, isLiveEdit, client ));
}
std::unique_ptr<V8DebuggerScript> V8DebuggerScript::CreateWasm(
Expand All
@@ -418,18 +428,16 @@ V8DebuggerScript::V8DebuggerScript(v8::Isolate* isolate, String16 id,
V8DebuggerScript::~V8DebuggerScript() {}
const String16& V8DebuggerScript::sourceURL() const {
return m_sourceURL.isEmpty() ? m_url : m_sourceURL;
}
void V8DebuggerScript::setSourceURL(const String16& sourceURL) {
m_sourceURL = sourceURL;
if (sourceURL.length() > 0) {
m_hasSourceURLComment = true;
m_url = sourceURL;
}
}
bool V8DebuggerScript::setBreakpoint(const String16& condition,
v8::debug::Location* loc, int* id) const {
v8::HandleScope scope(m_isolate);
return script()->SetBreakpoint(toV8String(m_isolate, condition), loc, id);
}
} // namespace v8_inspector
Original file line number
Diff line number
Diff line change
Expand Up
@@ -40,13 +40,14 @@
namespace v8_inspector {
// Forward declaration.
class V8InspectorClient;
class WasmTranslation;
class V8DebuggerScript {
public:
static std::unique_ptr<V8DebuggerScript> Create(
v8::Isolate* isolate, v8::Local<v8::debug::Script> script,
bool isLiveEdit);
bool isLiveEdit, V8InspectorClient* client );
static std::unique_ptr<V8DebuggerScript> CreateWasm(
v8::Isolate* isolate, WasmTranslation* wasmTranslation,
v8::Local<v8::debug::WasmScript> underlyingScript, String16 id,
Expand All
@@ -55,9 +56,9 @@ class V8DebuggerScript {
virtual ~V8DebuggerScript();
const String16& scriptId() const { return m_id; }
const String16& url () const { return m_url ; }
bool hasSourceURL () const { return !m_sourceURL.isEmpty() ; }
const String16& sourceURL() const;
bool hasSourceURLComment () const { return m_hasSourceURLComment ; }
const String16& sourceURL () const { return m_url ; }
virtual const String16& sourceMappingURL() const = 0;
virtual const String16& source() const = 0;
virtual const String16& hash() const = 0;
Expand Down
Expand Up
@@ -95,7 +96,7 @@ class V8DebuggerScript {
String16 m_id;
String16 m_url;
String16 m_sourceURL ;
bool m_hasSourceURLComment = false ;
int m_executionContextId = 0;
v8::Isolate* m_isolate;
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -226,13 +226,15 @@ void V8Debugger::getCompiledScripts(
v8::Local<v8::debug::Script> script = scripts.Get(i);
if (!script->WasCompiled()) continue;
if (script->IsEmbedded()) {
result.push_back(V8DebuggerScript::Create(m_isolate, script, false));
result.push_back(V8DebuggerScript::Create(m_isolate, script, false,
m_inspector->client()));
continue;
}
int contextId;
if (!script->ContextId().To(&contextId)) continue;
if (m_inspector->contextGroupId(contextId) != contextGroupId) continue;
result.push_back(V8DebuggerScript::Create(m_isolate, script, false));
result.push_back(V8DebuggerScript::Create(m_isolate, script, false,
m_inspector->client()));
}
}
Expand Down
Expand Up
@@ -585,13 +587,14 @@ void V8Debugger::ScriptCompiled(v8::Local<v8::debug::Script> script,
});
} else if (m_ignoreScriptParsedEventsCounter == 0) {
v8::Isolate* isolate = m_isolate;
V8InspectorClient* client = m_inspector->client();
m_inspector->forEachSession(
m_inspector->contextGroupId(contextId),
[&isolate, &script, &has_compile_error,
&is_live_edited ](V8InspectorSessionImpl* session) {
[&isolate, &script, &has_compile_error, &is_live_edited,
&client ](V8InspectorSessionImpl* session) {
if (!session->debuggerAgent()->enabled()) return;
session->debuggerAgent()->didParseSource(
V8DebuggerScript::Create(isolate, script, is_live_edited),
V8DebuggerScript::Create(isolate, script, is_live_edited, client ),
!has_compile_error);
});
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -7,6 +7,7 @@
#include <vector>
#include "src/base/atomicops.h"
#include "src/debug/debug-interface.h"
#include "src/flags.h" // TODO(jgruber): Remove include and DEPS entry.
#include "src/inspector/protocol/Protocol.h"
#include "src/inspector/string-util.h"
Expand All
@@ -31,6 +32,15 @@ static const char typeProfileStarted[] = "typeProfileStarted";
namespace {
String16 resourceNameToUrl(V8InspectorImpl* inspector,
v8::Local<v8::String> v8Name) {
String16 name = toProtocolString(v8Name);
if (!inspector) return name;
std::unique_ptr<StringBuffer> url =
inspector->client()->resourceNameToUrl(toStringView(name));
return url ? toString16(url->string()) : name;
}
std::unique_ptr<protocol::Array<protocol::Profiler::PositionTickInfo>>
buildInspectorObjectForPositionTicks(const v8::CpuProfileNode* node) {
unsigned lineCount = node->GetHitLineCount();
Expand All
@@ -51,13 +61,14 @@ buildInspectorObjectForPositionTicks(const v8::CpuProfileNode* node) {
}
std::unique_ptr<protocol::Profiler::ProfileNode> buildInspectorObjectFor(
v8::Isolate* isolate, const v8::CpuProfileNode* node) {
V8InspectorImpl* inspector, const v8::CpuProfileNode* node) {
v8::Isolate* isolate = inspector->isolate();
v8::HandleScope handleScope(isolate);
auto callFrame =
protocol::Runtime::CallFrame::create()
.setFunctionName(toProtocolString(node->GetFunctionName()))
.setScriptId(String16::fromInteger(node->GetScriptId()))
.setUrl(toProtocolString( node->GetScriptResourceName()))
.setUrl(resourceNameToUrl(inspector, node->GetScriptResourceName()))
.setLineNumber(node->GetLineNumber() - 1)
.setColumnNumber(node->GetColumnNumber() - 1)
.build();
Expand Down
Expand Up
@@ -107,18 +118,19 @@ std::unique_ptr<protocol::Array<int>> buildInspectorObjectForTimestamps(
return array;
}
void flattenNodesTree(v8::Isolate* isolate, const v8::CpuProfileNode* node,
void flattenNodesTree(V8InspectorImpl* inspector,
const v8::CpuProfileNode* node,
protocol::Array<protocol::Profiler::ProfileNode>* list) {
list->addItem(buildInspectorObjectFor(isolate , node));
list->addItem(buildInspectorObjectFor(inspector , node));
const int childrenCount = node->GetChildrenCount();
for (int i = 0; i < childrenCount; i++)
flattenNodesTree(isolate , node->GetChild(i), list);
flattenNodesTree(inspector , node->GetChild(i), list);
}
std::unique_ptr<protocol::Profiler::Profile> createCPUProfile(
v8::Isolate* isolate , v8::CpuProfile* v8profile) {
V8InspectorImpl* inspector , v8::CpuProfile* v8profile) {
auto nodes = protocol::Array<protocol::Profiler::ProfileNode>::create();
flattenNodesTree(isolate , v8profile->GetTopDownRoot(), nodes.get());
flattenNodesTree(inspector , v8profile->GetTopDownRoot(), nodes.get());
return protocol::Profiler::Profile::create()
.setNodes(std::move(nodes))
.setStartTime(static_cast<double>(v8profile->GetStartTime()))
Expand Down
Expand Up
@@ -320,7 +332,7 @@ std::unique_ptr<protocol::Profiler::CoverageRange> createCoverageRange(
}
Response coverageToProtocol(
v8::Isolate* isolate , const v8::debug::Coverage& coverage,
V8InspectorImpl* inspector , const v8::debug::Coverage& coverage,
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>>*
out_result) {
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptCoverage>> result =
Expand Down
Expand Up
@@ -361,8 +373,10 @@ Response coverageToProtocol(
}
String16 url;
v8::Local<v8::String> name;
if (script->Name ().ToLocal(&name) || script->SourceURL().ToLocal(&name )) {
if (script->SourceURL ().ToLocal(&name) && name->Length( )) {
url = toProtocolString(name);
} else if (script->Name().ToLocal(&name) && name->Length()) {
url = resourceNameToUrl(inspector, name);
}
result->addItem(protocol::Profiler::ScriptCoverage::create()
.setScriptId(String16::fromInteger(script->Id()))
Expand All
@@ -384,7 +398,7 @@ Response V8ProfilerAgentImpl::takePreciseCoverage(
}
v8::HandleScope handle_scope(m_isolate);
v8::debug::Coverage coverage = v8::debug::Coverage::CollectPrecise(m_isolate);
return coverageToProtocol(m_isolate , coverage, out_result);
return coverageToProtocol(m_session->inspector() , coverage, out_result);
}
Response V8ProfilerAgentImpl::getBestEffortCoverage(
Expand All
@@ -393,12 +407,12 @@ Response V8ProfilerAgentImpl::getBestEffortCoverage(
v8::HandleScope handle_scope(m_isolate);
v8::debug::Coverage coverage =
v8::debug::Coverage::CollectBestEffort(m_isolate);
return coverageToProtocol(m_isolate , coverage, out_result);
return coverageToProtocol(m_session->inspector() , coverage, out_result);
}
namespace {
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptTypeProfile>>
typeProfileToProtocol(v8::Isolate* isolate ,
typeProfileToProtocol(V8InspectorImpl* inspector ,
const v8::debug::TypeProfile& type_profile) {
std::unique_ptr<protocol::Array<protocol::Profiler::ScriptTypeProfile>>
result = protocol::Array<protocol::Profiler::ScriptTypeProfile>::create();
Expand Down
Expand Up
@@ -426,8 +440,10 @@ typeProfileToProtocol(v8::Isolate* isolate,
}
String16 url;
v8::Local<v8::String> name;
if (script->Name ().ToLocal(&name) || script->SourceURL().ToLocal(&name )) {
if (script->SourceURL ().ToLocal(&name) && name->Length( )) {
url = toProtocolString(name);
} else if (script->Name().ToLocal(&name) && name->Length()) {
url = resourceNameToUrl(inspector, name);
}
result->addItem(protocol::Profiler::ScriptTypeProfile::create()
.setScriptId(String16::fromInteger(script->Id()))
Expand Down
Expand Up
@@ -462,7 +478,7 @@ Response V8ProfilerAgentImpl::takeTypeProfile(
v8::HandleScope handle_scope(m_isolate);
v8::debug::TypeProfile type_profile =
v8::debug::TypeProfile::Collect(m_isolate);
*out_result = typeProfileToProtocol(m_isolate , type_profile);
*out_result = typeProfileToProtocol(m_session->inspector() , type_profile);
return Response::OK();
}
Expand Down
Expand Up
@@ -491,7 +507,7 @@ std::unique_ptr<protocol::Profiler::Profile> V8ProfilerAgentImpl::stopProfiling(
m_profiler->StopProfiling(toV8String(m_isolate, title));
std::unique_ptr<protocol::Profiler::Profile> result;
if (profile) {
if (serialize) result = createCPUProfile(m_isolate , profile);
if (serialize) result = createCPUProfile(m_session->inspector() , profile);
profile->Delete();
}
--m_startedProfilesCount;
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -7,6 +7,7 @@
#include <algorithm>
#include "src/inspector/v8-debugger.h"
#include "src/inspector/v8-inspector-impl.h"
#include "src/inspector/wasm-translation.h"
namespace v8_inspector {
Expand Down
Expand Up
@@ -73,7 +74,10 @@ std::unique_ptr<protocol::Runtime::StackTrace> buildInspectorObjectCommon(
std::unique_ptr<protocol::Array<protocol::Runtime::CallFrame>>
inspectorFrames = protocol::Array<protocol::Runtime::CallFrame>::create();
for (size_t i = 0; i < frames.size(); i++) {
inspectorFrames->addItem(frames[i]->buildInspectorObject());
V8InspectorClient* client = nullptr;
if (debugger && debugger->inspector())
client = debugger->inspector()->client();
inspectorFrames->addItem(frames[i]->buildInspectorObject(client));
}
std::unique_ptr<protocol::Runtime::StackTrace> stackTrace =
protocol::Runtime::StackTrace::create()
Expand Down
Expand Up
@@ -117,7 +121,9 @@ StackFrame::StackFrame(v8::Local<v8::StackFrame> v8Frame)
m_scriptId(String16::fromInteger(v8Frame->GetScriptId())),
m_sourceURL(toProtocolString(v8Frame->GetScriptNameOrSourceURL())),
m_lineNumber(v8Frame->GetLineNumber() - 1),
m_columnNumber(v8Frame->GetColumn() - 1) {
m_columnNumber(v8Frame->GetColumn() - 1),
m_hasSourceURLComment(v8Frame->GetScriptName() !=
v8Frame->GetScriptNameOrSourceURL()) {
DCHECK_NE(v8::Message::kNoLineNumberInfo, m_lineNumber + 1);
DCHECK_NE(v8::Message::kNoColumnInfo, m_columnNumber + 1);
}
Expand All
@@ -137,12 +143,20 @@ int StackFrame::lineNumber() const { return m_lineNumber; }
int StackFrame::columnNumber() const { return m_columnNumber; }
std::unique_ptr<protocol::Runtime::CallFrame> StackFrame::buildInspectorObject()
const {
std::unique_ptr<protocol::Runtime::CallFrame> StackFrame::buildInspectorObject(
V8InspectorClient* client) const {
String16 frameUrl = m_sourceURL;
if (client && !m_hasSourceURLComment && frameUrl.length() > 0) {
std::unique_ptr<StringBuffer> url =
client->resourceNameToUrl(toStringView(m_sourceURL));
if (url) {
frameUrl = toString16(url->string());
}
}
return protocol::Runtime::CallFrame::create()
.setFunctionName(m_functionName)
.setScriptId(m_scriptId)
.setUrl(m_sourceURL )
.setUrl(frameUrl )
.setLineNumber(m_lineNumber)
.setColumnNumber(m_columnNumber)
.build();
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.