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) {
String16 identifier;
if (title.isEmpty()) {
std::unique_ptr<V8StackTraceImpl> stackTrace =
V8StackTraceImpl::capture(nullptr, 0, 1);
V8StackTraceImpl::capture(helper.inspector()->debugger(), 0, 1);
if (stackTrace && !stackTrace->isEmpty()) {
identifier = toString16(stackTrace->topSourceURL()) + ":" +
String16::fromInteger(stackTrace->topLineNumber());
......
......@@ -40,9 +40,8 @@ V8StackTraceImpl::Frame toFrame(v8::Local<v8::StackFrame> frame,
int sourceColumn = frame->GetColumn() - 1;
// TODO(clemensh): Figure out a way to do this translation only right before
// sending the stack trace over wire.
if (wasmTranslation)
wasmTranslation->TranslateWasmScriptLocationToProtocolLocation(
&scriptId, &sourceLineNumber, &sourceColumn);
wasmTranslation->TranslateWasmScriptLocationToProtocolLocation(
&scriptId, &sourceLineNumber, &sourceColumn);
return V8StackTraceImpl::Frame(functionName, scriptId, sourceName,
sourceLineNumber + 1, sourceColumn + 1);
}
......@@ -55,8 +54,7 @@ void toFramesVector(v8::Local<v8::StackTrace> stackTrace,
int frameCount = stackTrace->GetFrameCount();
if (frameCount > static_cast<int>(maxStackSize))
frameCount = static_cast<int>(maxStackSize);
WasmTranslation* wasmTranslation =
debugger ? debugger->wasmTranslation() : nullptr;
WasmTranslation* wasmTranslation = debugger->wasmTranslation();
for (int i = 0; i < frameCount; i++) {
v8::Local<v8::StackFrame> stackFrame = stackTrace->GetFrame(i);
frames.push_back(toFrame(stackFrame, wasmTranslation, contextGroupId));
......@@ -118,7 +116,8 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(
V8Debugger* debugger, int contextGroupId,
v8::Local<v8::StackTrace> stackTrace, size_t maxStackSize,
const String16& description) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
DCHECK(debugger);
v8::Isolate* isolate = debugger->inspector()->isolate();
v8::HandleScope scope(isolate);
std::vector<V8StackTraceImpl::Frame> frames;
if (!stackTrace.IsEmpty())
......@@ -127,7 +126,7 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(
int maxAsyncCallChainDepth = 1;
V8StackTraceImpl* asyncCallChain = nullptr;
if (debugger && maxStackSize > 1) {
if (maxStackSize > 1) {
asyncCallChain = debugger->currentAsyncCallChain();
maxAsyncCallChainDepth = debugger->maxAsyncCallChainDepth();
}
......@@ -170,7 +169,8 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::create(
std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture(
V8Debugger* debugger, int contextGroupId, size_t maxStackSize,
const String16& description) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
DCHECK(debugger);
v8::Isolate* isolate = debugger->inspector()->isolate();
v8::HandleScope handleScope(isolate);
v8::Local<v8::StackTrace> stackTrace;
if (isolate->InContext()) {
......@@ -270,7 +270,8 @@ V8StackTraceImpl::buildInspectorObjectImpl() const {
std::unique_ptr<protocol::Runtime::StackTrace>
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
// maxAsyncCallChainDepth.
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