Commit 8adf294c authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[inspector] don't use v8::Isolate::GetCurrent in V8StackTraceImpl

In inspector code everywhere except V8StackTraceImpl we get pointer to isolate from inspector object or v8::FunctionCallbackInfo. We can avoid usage of v8::Isolate::GetCurrent in V8StackTraceImpl too. It will simplify a little embedder code by removing requirement to have v8::Isolate::Scope before calling to V8InspectorSession::dispatchProtocolMessage.

BUG=v8:5907
R=dgozman@chromium.org

Review-Url: https://codereview.chromium.org/2789593002
Cr-Commit-Position: refs/heads/master@{#44282}
parent 114d6b4b
...@@ -261,7 +261,7 @@ void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) { ...@@ -261,7 +261,7 @@ void V8Console::countCallback(const v8::FunctionCallbackInfo<v8::Value>& info) {
String16 identifier; String16 identifier;
if (title.isEmpty()) { if (title.isEmpty()) {
std::unique_ptr<V8StackTraceImpl> stackTrace = std::unique_ptr<V8StackTraceImpl> stackTrace =
V8StackTraceImpl::capture(nullptr, 0, 1); V8StackTraceImpl::capture(helper.inspector()->debugger(), 0, 1);
if (stackTrace && !stackTrace->isEmpty()) { if (stackTrace && !stackTrace->isEmpty()) {
identifier = toString16(stackTrace->topSourceURL()) + ":" + identifier = toString16(stackTrace->topSourceURL()) + ":" +
String16::fromInteger(stackTrace->topLineNumber()); String16::fromInteger(stackTrace->topLineNumber());
......
...@@ -40,7 +40,6 @@ V8StackTraceImpl::Frame toFrame(v8::Local<v8::StackFrame> frame, ...@@ -40,7 +40,6 @@ V8StackTraceImpl::Frame toFrame(v8::Local<v8::StackFrame> frame,
int sourceColumn = frame->GetColumn() - 1; int sourceColumn = frame->GetColumn() - 1;
// TODO(clemensh): Figure out a way to do this translation only right before // TODO(clemensh): Figure out a way to do this translation only right before
// sending the stack trace over wire. // sending the stack trace over wire.
if (wasmTranslation)
wasmTranslation->TranslateWasmScriptLocationToProtocolLocation( wasmTranslation->TranslateWasmScriptLocationToProtocolLocation(
&scriptId, &sourceLineNumber, &sourceColumn); &scriptId, &sourceLineNumber, &sourceColumn);
return V8StackTraceImpl::Frame(functionName, scriptId, sourceName, return V8StackTraceImpl::Frame(functionName, scriptId, sourceName,
...@@ -55,8 +54,7 @@ void toFramesVector(v8::Local<v8::StackTrace> stackTrace, ...@@ -55,8 +54,7 @@ void toFramesVector(v8::Local<v8::StackTrace> stackTrace,
int frameCount = stackTrace->GetFrameCount(); int frameCount = stackTrace->GetFrameCount();
if (frameCount > static_cast<int>(maxStackSize)) if (frameCount > static_cast<int>(maxStackSize))
frameCount = static_cast<int>(maxStackSize); frameCount = static_cast<int>(maxStackSize);
WasmTranslation* wasmTranslation = WasmTranslation* wasmTranslation = debugger->wasmTranslation();
debugger ? debugger->wasmTranslation() : nullptr;
for (int i = 0; i < frameCount; i++) { for (int i = 0; i < frameCount; i++) {
v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i); v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i);
frames.push_back(toFrame(stackFrame, wasmTranslation, contextGroupId)); frames.push_back(toFrame(stackFrame, wasmTranslation, contextGroupId));
...@@ -118,7 +116,8 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create( ...@@ -118,7 +116,8 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(
V8Debugger* debugger, int contextGroupId, V8Debugger* debugger, int contextGroupId,
v8::Local<v8::StackTrace> stackTrace, size_t maxStackSize, v8::Local<v8::StackTrace> stackTrace, size_t maxStackSize,
const String16& description) { const String16& description) {
v8::Isolate* isolate = v8::Isolate::GetCurrent(); DCHECK(debugger);
v8::Isolate* isolate = debugger->inspector()->isolate();
v8::HandleScope scope(isolate); v8::HandleScope scope(isolate);
std::vector<V8StackTraceImpl::Frame> frames; std::vector<V8StackTraceImpl::Frame> frames;
if (!stackTrace.IsEmpty()) if (!stackTrace.IsEmpty())
...@@ -127,7 +126,7 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create( ...@@ -127,7 +126,7 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(
int maxAsyncCallChainDepth = 1; int maxAsyncCallChainDepth = 1;
V8StackTraceImpl* asyncCallChain = nullptr; V8StackTraceImpl* asyncCallChain = nullptr;
if (debugger && maxStackSize > 1) { if (maxStackSize > 1) {
asyncCallChain = debugger->currentAsyncCallChain(); asyncCallChain = debugger->currentAsyncCallChain();
maxAsyncCallChainDepth = debugger->maxAsyncCallChainDepth(); maxAsyncCallChainDepth = debugger->maxAsyncCallChainDepth();
} }
...@@ -170,7 +169,8 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create( ...@@ -170,7 +169,8 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(
std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture( std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture(
V8Debugger* debugger, int contextGroupId, size_t maxStackSize, V8Debugger* debugger, int contextGroupId, size_t maxStackSize,
const String16& description) { const String16& description) {
v8::Isolate* isolate = v8::Isolate::GetCurrent(); DCHECK(debugger);
v8::Isolate* isolate = debugger->inspector()->isolate();
v8::HandleScope handleScope(isolate); v8::HandleScope handleScope(isolate);
v8::Local<v8::StackTrace> stackTrace; v8::Local<v8::StackTrace> stackTrace;
if (isolate->InContext()) { if (isolate->InContext()) {
...@@ -270,7 +270,8 @@ V8StackTraceImpl::buildInspectorObjectImpl() const { ...@@ -270,7 +270,8 @@ V8StackTraceImpl::buildInspectorObjectImpl() const {
std::unique_ptr<protocol::Runtime::StackTrace> std::unique_ptr<protocol::Runtime::StackTrace>
V8StackTraceImpl::buildInspectorObjectForTail(V8Debugger* debugger) const { V8StackTraceImpl::buildInspectorObjectForTail(V8Debugger* debugger) const {
v8::HandleScope handleScope(v8::Isolate::GetCurrent()); DCHECK(debugger);
v8::HandleScope handleScope(debugger->inspector()->isolate());
// Next call collapses possible empty stack and ensures // Next call collapses possible empty stack and ensures
// maxAsyncCallChainDepth. // maxAsyncCallChainDepth.
std::unique_ptr<V8StackTraceImpl> fullChain = V8StackTraceImpl::create( std::unique_ptr<V8StackTraceImpl> fullChain = V8StackTraceImpl::create(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment