Commit 072c6943 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[inspector] fixed all deprecated calls

BUG=chromium:635948
R=dgozman@chromium.org,alph@chromium.org

Review-Url: https://codereview.chromium.org/2332243002
Cr-Commit-Position: refs/heads/master@{#39506}
parent 04c8a368
...@@ -26,8 +26,7 @@ void InjectedScriptNative::setOnInjectedScriptHost( ...@@ -26,8 +26,7 @@ void InjectedScriptNative::setOnInjectedScriptHost(
} }
InjectedScriptNative* InjectedScriptNative::fromInjectedScriptHost( InjectedScriptNative* InjectedScriptNative::fromInjectedScriptHost(
v8::Local<v8::Object> injectedScriptObject) { v8::Isolate* isolate, v8::Local<v8::Object> injectedScriptObject) {
v8::Isolate* isolate = injectedScriptObject->GetIsolate();
v8::HandleScope handleScope(isolate); v8::HandleScope handleScope(isolate);
v8::Local<v8::Context> context = isolate->GetCurrentContext(); v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Private> privateKey = v8::Private::ForApi( v8::Local<v8::Private> privateKey = v8::Private::ForApi(
......
...@@ -19,7 +19,8 @@ class InjectedScriptNative final { ...@@ -19,7 +19,8 @@ class InjectedScriptNative final {
~InjectedScriptNative(); ~InjectedScriptNative();
void setOnInjectedScriptHost(v8::Local<v8::Object>); void setOnInjectedScriptHost(v8::Local<v8::Object>);
static InjectedScriptNative* fromInjectedScriptHost(v8::Local<v8::Object>); static InjectedScriptNative* fromInjectedScriptHost(v8::Isolate* isolate,
v8::Local<v8::Object>);
int bind(v8::Local<v8::Value>, const String16& groupName); int bind(v8::Local<v8::Value>, const String16& groupName);
void unbind(int id); void unbind(int id);
......
...@@ -53,7 +53,8 @@ int JavaScriptCallFrame::callV8FunctionReturnInt(const char* name) const { ...@@ -53,7 +53,8 @@ int JavaScriptCallFrame::callV8FunctionReturnInt(const char* name) const {
v8::Local<v8::Object> callFrame = v8::Local<v8::Object> callFrame =
v8::Local<v8::Object>::New(m_isolate, m_callFrame); v8::Local<v8::Object>::New(m_isolate, m_callFrame);
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast( v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(
callFrame->Get(toV8StringInternalized(m_isolate, name))); callFrame->Get(context, toV8StringInternalized(m_isolate, name))
.ToLocalChecked());
v8::Local<v8::Value> result; v8::Local<v8::Value> result;
if (!func->Call(context, callFrame, 0, nullptr).ToLocal(&result) || if (!func->Call(context, callFrame, 0, nullptr).ToLocal(&result) ||
!result->IsInt32()) !result->IsInt32())
...@@ -79,44 +80,56 @@ int JavaScriptCallFrame::contextId() const { ...@@ -79,44 +80,56 @@ int JavaScriptCallFrame::contextId() const {
bool JavaScriptCallFrame::isAtReturn() const { bool JavaScriptCallFrame::isAtReturn() const {
v8::HandleScope handleScope(m_isolate); v8::HandleScope handleScope(m_isolate);
v8::Local<v8::Value> result = v8::Local<v8::Context> context =
v8::Local<v8::Object>::New(m_isolate, m_callFrame) v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
->Get(toV8StringInternalized(m_isolate, "isAtReturn")); v8::Local<v8::Object> callFrame =
if (result.IsEmpty() || !result->IsBoolean()) return false; v8::Local<v8::Object>::New(m_isolate, m_callFrame);
return result->BooleanValue(); v8::Local<v8::Value> result;
if (!callFrame->Get(context, toV8StringInternalized(m_isolate, "isAtReturn"))
.ToLocal(&result) ||
!result->IsBoolean())
return false;
return result.As<v8::Boolean>()->BooleanValue(context).FromMaybe(false);
} }
v8::Local<v8::Object> JavaScriptCallFrame::details() const { v8::Local<v8::Object> JavaScriptCallFrame::details() const {
v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope microtasks(m_isolate,
v8::MicrotasksScope::kDoNotRunMicrotasks); v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
v8::Local<v8::Object> callFrame = v8::Local<v8::Object> callFrame =
v8::Local<v8::Object>::New(m_isolate, m_callFrame); v8::Local<v8::Object>::New(m_isolate, m_callFrame);
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast( v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(
callFrame->Get(toV8StringInternalized(m_isolate, "details"))); callFrame->Get(context, toV8StringInternalized(m_isolate, "details"))
return v8::Local<v8::Object>::Cast(
func->Call(m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr)
.ToLocalChecked()); .ToLocalChecked());
return v8::Local<v8::Object>::Cast(
func->Call(context, callFrame, 0, nullptr).ToLocalChecked());
} }
v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluate( v8::MaybeLocal<v8::Value> JavaScriptCallFrame::evaluate(
v8::Local<v8::Value> expression) { v8::Local<v8::Value> expression) {
v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope microtasks(m_isolate,
v8::MicrotasksScope::kRunMicrotasks); v8::MicrotasksScope::kRunMicrotasks);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
v8::Local<v8::Object> callFrame = v8::Local<v8::Object> callFrame =
v8::Local<v8::Object>::New(m_isolate, m_callFrame); v8::Local<v8::Object>::New(m_isolate, m_callFrame);
v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast( v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast(
callFrame->Get(toV8StringInternalized(m_isolate, "evaluate"))); callFrame->Get(context, toV8StringInternalized(m_isolate, "evaluate"))
return evalFunction->Call(m_debuggerContext.Get(m_isolate), callFrame, 1, .ToLocalChecked());
&expression); return evalFunction->Call(context, callFrame, 1, &expression);
} }
v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() { v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart() {
v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope microtasks(m_isolate,
v8::MicrotasksScope::kDoNotRunMicrotasks); v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
v8::Local<v8::Object> callFrame = v8::Local<v8::Object> callFrame =
v8::Local<v8::Object>::New(m_isolate, m_callFrame); v8::Local<v8::Object>::New(m_isolate, m_callFrame);
v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast( v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast(
callFrame->Get(toV8StringInternalized(m_isolate, "restart"))); callFrame->Get(context, toV8StringInternalized(m_isolate, "restart"))
.ToLocalChecked());
v8::Debug::SetLiveEditEnabled(m_isolate, true); v8::Debug::SetLiveEditEnabled(m_isolate, true);
v8::MaybeLocal<v8::Value> result = restartFunction->Call( v8::MaybeLocal<v8::Value> result = restartFunction->Call(
m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr); m_debuggerContext.Get(m_isolate), callFrame, 0, nullptr);
...@@ -129,16 +142,20 @@ v8::MaybeLocal<v8::Value> JavaScriptCallFrame::setVariableValue( ...@@ -129,16 +142,20 @@ v8::MaybeLocal<v8::Value> JavaScriptCallFrame::setVariableValue(
v8::Local<v8::Value> newValue) { v8::Local<v8::Value> newValue) {
v8::MicrotasksScope microtasks(m_isolate, v8::MicrotasksScope microtasks(m_isolate,
v8::MicrotasksScope::kDoNotRunMicrotasks); v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Context> context =
v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
v8::Local<v8::Object> callFrame = v8::Local<v8::Object> callFrame =
v8::Local<v8::Object>::New(m_isolate, m_callFrame); v8::Local<v8::Object>::New(m_isolate, m_callFrame);
v8::Local<v8::Function> setVariableValueFunction = v8::Local<v8::Function> setVariableValueFunction =
v8::Local<v8::Function>::Cast(callFrame->Get( v8::Local<v8::Function>::Cast(
toV8StringInternalized(m_isolate, "setVariableValue"))); callFrame
->Get(context,
toV8StringInternalized(m_isolate, "setVariableValue"))
.ToLocalChecked());
v8::Local<v8::Value> argv[] = { v8::Local<v8::Value> argv[] = {
v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)), v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)),
variableName, newValue}; variableName, newValue};
return setVariableValueFunction->Call(m_debuggerContext.Get(m_isolate), return setVariableValueFunction->Call(context, callFrame,
callFrame,
V8_INSPECTOR_ARRAY_LENGTH(argv), argv); V8_INSPECTOR_ARRAY_LENGTH(argv), argv);
} }
......
...@@ -63,8 +63,9 @@ const unsigned maxStackDepthLimit = 32; ...@@ -63,8 +63,9 @@ const unsigned maxStackDepthLimit = 32;
class V8ValueStringBuilder { class V8ValueStringBuilder {
public: public:
static String16 toString(v8::Local<v8::Value> value, v8::Isolate* isolate) { static String16 toString(v8::Local<v8::Value> value,
V8ValueStringBuilder builder(isolate); v8::Local<v8::Context> context) {
V8ValueStringBuilder builder(context);
if (!builder.append(value)) return String16(); if (!builder.append(value)) return String16();
return builder.toString(); return builder.toString();
} }
...@@ -75,10 +76,11 @@ class V8ValueStringBuilder { ...@@ -75,10 +76,11 @@ class V8ValueStringBuilder {
IgnoreUndefined = 1 << 1, IgnoreUndefined = 1 << 1,
}; };
V8ValueStringBuilder(v8::Isolate* isolate) V8ValueStringBuilder(v8::Local<v8::Context> context)
: m_arrayLimit(maxArrayItemsLimit), : m_arrayLimit(maxArrayItemsLimit),
m_isolate(isolate), m_isolate(context->GetIsolate()),
m_tryCatch(isolate) {} m_tryCatch(context->GetIsolate()),
m_context(context) {}
bool append(v8::Local<v8::Value> value, unsigned ignoreOptions = 0) { bool append(v8::Local<v8::Value> value, unsigned ignoreOptions = 0) {
if (value.IsEmpty()) return true; if (value.IsEmpty()) return true;
...@@ -133,7 +135,9 @@ class V8ValueStringBuilder { ...@@ -133,7 +135,9 @@ class V8ValueStringBuilder {
m_visitedArrays.push_back(array); m_visitedArrays.push_back(array);
for (uint32_t i = 0; i < length; ++i) { for (uint32_t i = 0; i < length; ++i) {
if (i) m_builder.append(','); if (i) m_builder.append(',');
if (!append(array->Get(i), IgnoreNull | IgnoreUndefined)) { v8::Local<v8::Value> value;
if (!array->Get(m_context, i).ToLocal(&value)) continue;
if (!append(value, IgnoreNull | IgnoreUndefined)) {
result = false; result = false;
break; break;
} }
...@@ -165,6 +169,7 @@ class V8ValueStringBuilder { ...@@ -165,6 +169,7 @@ class V8ValueStringBuilder {
String16Builder m_builder; String16Builder m_builder;
std::vector<v8::Local<v8::Array>> m_visitedArrays; std::vector<v8::Local<v8::Array>> m_visitedArrays;
v8::TryCatch m_tryCatch; v8::TryCatch m_tryCatch;
v8::Local<v8::Context> m_context;
}; };
} // namespace } // namespace
...@@ -336,11 +341,13 @@ ConsoleAPIType V8ConsoleMessage::type() const { return m_type; } ...@@ -336,11 +341,13 @@ ConsoleAPIType V8ConsoleMessage::type() const { return m_type; }
std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI( std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(
double timestamp, ConsoleAPIType type, double timestamp, ConsoleAPIType type,
const std::vector<v8::Local<v8::Value>>& arguments, const std::vector<v8::Local<v8::Value>>& arguments,
std::unique_ptr<V8StackTraceImpl> stackTrace, InspectedContext* context) { std::unique_ptr<V8StackTraceImpl> stackTrace,
v8::Isolate* isolate = context->isolate(); InspectedContext* inspectedContext) {
int contextId = context->contextId(); v8::Isolate* isolate = inspectedContext->isolate();
int contextGroupId = context->contextGroupId(); int contextId = inspectedContext->contextId();
V8InspectorImpl* inspector = context->inspector(); int contextGroupId = inspectedContext->contextGroupId();
V8InspectorImpl* inspector = inspectedContext->inspector();
v8::Local<v8::Context> context = inspectedContext->context();
std::unique_ptr<V8ConsoleMessage> message = wrapUnique( std::unique_ptr<V8ConsoleMessage> message = wrapUnique(
new V8ConsoleMessage(V8MessageOrigin::kConsole, timestamp, String16())); new V8ConsoleMessage(V8MessageOrigin::kConsole, timestamp, String16()));
...@@ -356,7 +363,7 @@ std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI( ...@@ -356,7 +363,7 @@ std::unique_ptr<V8ConsoleMessage> V8ConsoleMessage::createForConsoleAPI(
message->m_arguments.push_back( message->m_arguments.push_back(
wrapUnique(new v8::Global<v8::Value>(isolate, arguments.at(i)))); wrapUnique(new v8::Global<v8::Value>(isolate, arguments.at(i))));
if (arguments.size()) if (arguments.size())
message->m_message = V8ValueStringBuilder::toString(arguments[0], isolate); message->m_message = V8ValueStringBuilder::toString(arguments[0], context);
V8ConsoleAPIType clientType = V8ConsoleAPIType::kLog; V8ConsoleAPIType clientType = V8ConsoleAPIType::kLog;
if (type == ConsoleAPIType::kDebug || type == ConsoleAPIType::kCount || if (type == ConsoleAPIType::kDebug || type == ConsoleAPIType::kCount ||
......
This diff is collapsed.
...@@ -100,6 +100,8 @@ class V8Debugger { ...@@ -100,6 +100,8 @@ class V8Debugger {
void muteScriptParsedEvents(); void muteScriptParsedEvents();
void unmuteScriptParsedEvents(); void unmuteScriptParsedEvents();
V8InspectorImpl* inspector() { return m_inspector; }
private: private:
void compileDebuggerScript(); void compileDebuggerScript();
v8::MaybeLocal<v8::Value> callDebuggerMethod(const char* functionName, v8::MaybeLocal<v8::Value> callDebuggerMethod(const char* functionName,
......
...@@ -67,44 +67,50 @@ static String16 calculateHash(const String16& str) { ...@@ -67,44 +67,50 @@ static String16 calculateHash(const String16& str) {
return hash.toString(); return hash.toString();
} }
V8DebuggerScript::V8DebuggerScript(v8::Isolate* isolate, static v8::Local<v8::Value> GetChecked(v8::Local<v8::Context> context,
v8::Local<v8::Object> object,
const char* name) {
return object
->Get(context, toV8StringInternalized(context->GetIsolate(), name))
.ToLocalChecked();
}
static int64_t GetCheckedInt(v8::Local<v8::Context> context,
v8::Local<v8::Object> object, const char* name) {
return GetChecked(context, object, name)
->ToInteger(context)
.ToLocalChecked()
->Value();
}
V8DebuggerScript::V8DebuggerScript(v8::Local<v8::Context> context,
v8::Local<v8::Object> object, v8::Local<v8::Object> object,
bool isLiveEdit) { bool isLiveEdit) {
v8::Local<v8::Value> idValue = v8::Isolate* isolate = context->GetIsolate();
object->Get(toV8StringInternalized(isolate, "id")); v8::Local<v8::Value> idValue = GetChecked(context, object, "id");
DCHECK(!idValue.IsEmpty() && idValue->IsInt32()); DCHECK(!idValue.IsEmpty() && idValue->IsInt32());
m_id = String16::fromInteger(idValue->Int32Value()); m_id = String16::fromInteger(idValue->Int32Value(context).FromJust());
m_url = toProtocolStringWithTypeCheck( m_url = toProtocolStringWithTypeCheck(GetChecked(context, object, "name"));
object->Get(toV8StringInternalized(isolate, "name"))); m_sourceURL =
m_sourceURL = toProtocolStringWithTypeCheck( toProtocolStringWithTypeCheck(GetChecked(context, object, "sourceURL"));
object->Get(toV8StringInternalized(isolate, "sourceURL")));
m_sourceMappingURL = toProtocolStringWithTypeCheck( m_sourceMappingURL = toProtocolStringWithTypeCheck(
object->Get(toV8StringInternalized(isolate, "sourceMappingURL"))); GetChecked(context, object, "sourceMappingURL"));
m_startLine = object->Get(toV8StringInternalized(isolate, "startLine")) m_startLine = GetCheckedInt(context, object, "startLine");
->ToInteger(isolate) m_startColumn = GetCheckedInt(context, object, "startColumn");
->Value(); m_endLine = GetCheckedInt(context, object, "endLine");
m_startColumn = object->Get(toV8StringInternalized(isolate, "startColumn")) m_endColumn = GetCheckedInt(context, object, "endColumn");
->ToInteger(isolate)
->Value();
m_endLine = object->Get(toV8StringInternalized(isolate, "endLine"))
->ToInteger(isolate)
->Value();
m_endColumn = object->Get(toV8StringInternalized(isolate, "endColumn"))
->ToInteger(isolate)
->Value();
m_executionContextAuxData = toProtocolStringWithTypeCheck( m_executionContextAuxData = toProtocolStringWithTypeCheck(
object->Get(toV8StringInternalized(isolate, "executionContextAuxData"))); GetChecked(context, object, "executionContextAuxData"));
m_executionContextId = m_executionContextId = GetCheckedInt(context, object, "executionContextId");
object->Get(toV8StringInternalized(isolate, "executionContextId"))
->ToInteger(isolate)
->Value();
m_isLiveEdit = isLiveEdit; m_isLiveEdit = isLiveEdit;
v8::Local<v8::Value> sourceValue = v8::Local<v8::Value> sourceValue;
object->Get(toV8StringInternalized(isolate, "source")); if (!object->Get(context, toV8StringInternalized(isolate, "source"))
if (!sourceValue.IsEmpty() && sourceValue->IsString()) .ToLocal(&sourceValue) ||
setSource(isolate, sourceValue.As<v8::String>()); !sourceValue->IsString())
return;
setSource(isolate, sourceValue.As<v8::String>());
} }
V8DebuggerScript::~V8DebuggerScript() {} V8DebuggerScript::~V8DebuggerScript() {}
......
...@@ -41,7 +41,8 @@ class V8DebuggerScript { ...@@ -41,7 +41,8 @@ class V8DebuggerScript {
V8_INSPECTOR_DISALLOW_COPY(V8DebuggerScript); V8_INSPECTOR_DISALLOW_COPY(V8DebuggerScript);
public: public:
V8DebuggerScript(v8::Isolate*, v8::Local<v8::Object>, bool isLiveEdit); V8DebuggerScript(v8::Local<v8::Context>, v8::Local<v8::Object>,
bool isLiveEdit);
~V8DebuggerScript(); ~V8DebuggerScript();
const String16& scriptId() const { return m_id; } const String16& scriptId() const { return m_id; }
......
...@@ -189,10 +189,13 @@ void V8InjectedScriptHost::bindCallback( ...@@ -189,10 +189,13 @@ void V8InjectedScriptHost::bindCallback(
const v8::FunctionCallbackInfo<v8::Value>& info) { const v8::FunctionCallbackInfo<v8::Value>& info) {
if (info.Length() < 2 || !info[1]->IsString()) return; if (info.Length() < 2 || !info[1]->IsString()) return;
InjectedScriptNative* injectedScriptNative = InjectedScriptNative* injectedScriptNative =
InjectedScriptNative::fromInjectedScriptHost(info.Holder()); InjectedScriptNative::fromInjectedScriptHost(info.GetIsolate(),
info.Holder());
if (!injectedScriptNative) return; if (!injectedScriptNative) return;
v8::Local<v8::String> v8groupName = info[1]->ToString(info.GetIsolate()); 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(v8groupName);
int id = injectedScriptNative->bind(info[0], groupName); int id = injectedScriptNative->bind(info[0], groupName);
info.GetReturnValue().Set(id); info.GetReturnValue().Set(id);
......
...@@ -37,12 +37,11 @@ ...@@ -37,12 +37,11 @@
#include "src/inspector/V8Debugger.h" #include "src/inspector/V8Debugger.h"
#include "src/inspector/V8DebuggerAgentImpl.h" #include "src/inspector/V8DebuggerAgentImpl.h"
#include "src/inspector/V8InspectorSessionImpl.h" #include "src/inspector/V8InspectorSessionImpl.h"
#include "src/inspector/V8ProfilerAgentImpl.h"
#include "src/inspector/V8RuntimeAgentImpl.h" #include "src/inspector/V8RuntimeAgentImpl.h"
#include "src/inspector/V8StackTraceImpl.h" #include "src/inspector/V8StackTraceImpl.h"
#include "src/inspector/protocol/Protocol.h" #include "src/inspector/protocol/Protocol.h"
#include "include/v8-profiler.h"
namespace v8_inspector { namespace v8_inspector {
std::unique_ptr<V8Inspector> V8Inspector::create(v8::Isolate* isolate, std::unique_ptr<V8Inspector> V8Inspector::create(v8::Isolate* isolate,
...@@ -74,6 +73,13 @@ V8RuntimeAgentImpl* V8InspectorImpl::enabledRuntimeAgentForGroup( ...@@ -74,6 +73,13 @@ V8RuntimeAgentImpl* V8InspectorImpl::enabledRuntimeAgentForGroup(
return agent && agent->enabled() ? agent : nullptr; return agent && agent->enabled() ? agent : nullptr;
} }
V8ProfilerAgentImpl* V8InspectorImpl::enabledProfilerAgentForGroup(
int contextGroupId) {
V8InspectorSessionImpl* session = sessionForContextGroup(contextGroupId);
V8ProfilerAgentImpl* agent = session ? session->profilerAgent() : nullptr;
return agent && agent->enabled() ? agent : nullptr;
}
v8::MaybeLocal<v8::Value> V8InspectorImpl::runCompiledScript( v8::MaybeLocal<v8::Value> V8InspectorImpl::runCompiledScript(
v8::Local<v8::Context> context, v8::Local<v8::Script> script) { v8::Local<v8::Context> context, v8::Local<v8::Script> script) {
v8::MicrotasksScope microtasksScope(m_isolate, v8::MicrotasksScope microtasksScope(m_isolate,
...@@ -271,11 +277,15 @@ void V8InspectorImpl::didExecuteScript(v8::Local<v8::Context> context) { ...@@ -271,11 +277,15 @@ void V8InspectorImpl::didExecuteScript(v8::Local<v8::Context> context) {
} }
void V8InspectorImpl::idleStarted() { void V8InspectorImpl::idleStarted() {
m_isolate->GetCpuProfiler()->SetIdle(true); for (auto it = m_sessions.begin(); it != m_sessions.end(); ++it) {
if (it->second->profilerAgent()->idleStarted()) return;
}
} }
void V8InspectorImpl::idleFinished() { void V8InspectorImpl::idleFinished() {
m_isolate->GetCpuProfiler()->SetIdle(false); for (auto it = m_sessions.begin(); it != m_sessions.end(); ++it) {
if (it->second->profilerAgent()->idleFinished()) return;
}
} }
unsigned V8InspectorImpl::exceptionThrown( unsigned V8InspectorImpl::exceptionThrown(
......
...@@ -46,6 +46,7 @@ class V8ConsoleMessageStorage; ...@@ -46,6 +46,7 @@ class V8ConsoleMessageStorage;
class V8Debugger; class V8Debugger;
class V8DebuggerAgentImpl; class V8DebuggerAgentImpl;
class V8InspectorSessionImpl; class V8InspectorSessionImpl;
class V8ProfilerAgentImpl;
class V8RuntimeAgentImpl; class V8RuntimeAgentImpl;
class V8StackTraceImpl; class V8StackTraceImpl;
...@@ -119,6 +120,7 @@ class V8InspectorImpl : public V8Inspector { ...@@ -119,6 +120,7 @@ class V8InspectorImpl : public V8Inspector {
InspectedContext* getContext(int groupId, int contextId) const; InspectedContext* getContext(int groupId, int contextId) const;
V8DebuggerAgentImpl* enabledDebuggerAgentForGroup(int contextGroupId); V8DebuggerAgentImpl* enabledDebuggerAgentForGroup(int contextGroupId);
V8RuntimeAgentImpl* enabledRuntimeAgentForGroup(int contextGroupId); V8RuntimeAgentImpl* enabledRuntimeAgentForGroup(int contextGroupId);
V8ProfilerAgentImpl* enabledProfilerAgentForGroup(int contextGroupId);
private: private:
v8::Isolate* m_isolate; v8::Isolate* m_isolate;
......
...@@ -304,4 +304,18 @@ bool V8ProfilerAgentImpl::isRecording() const { ...@@ -304,4 +304,18 @@ bool V8ProfilerAgentImpl::isRecording() const {
return m_recordingCPUProfile || !m_startedProfiles.empty(); return m_recordingCPUProfile || !m_startedProfiles.empty();
} }
bool V8ProfilerAgentImpl::idleStarted() {
if (m_profiler) m_profiler->SetIdle(true);
return m_profiler;
}
bool V8ProfilerAgentImpl::idleFinished() {
if (m_profiler) m_profiler->SetIdle(false);
return m_profiler;
}
void V8ProfilerAgentImpl::collectSample() {
if (m_profiler) m_profiler->CollectSample();
}
} // namespace v8_inspector } // namespace v8_inspector
...@@ -43,6 +43,11 @@ class V8ProfilerAgentImpl : public protocol::Profiler::Backend { ...@@ -43,6 +43,11 @@ class V8ProfilerAgentImpl : public protocol::Profiler::Backend {
void consoleProfile(const String16& title); void consoleProfile(const String16& title);
void consoleProfileEnd(const String16& title); void consoleProfileEnd(const String16& title);
bool idleStarted();
bool idleFinished();
void collectSample();
private: private:
String16 nextProfileId(); String16 nextProfileId();
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "src/inspector/StringUtil.h" #include "src/inspector/StringUtil.h"
#include "src/inspector/V8Debugger.h" #include "src/inspector/V8Debugger.h"
#include "src/inspector/V8InspectorImpl.h"
#include "src/inspector/V8ProfilerAgentImpl.h"
#include "src/inspector/protocol/Protocol.h" #include "src/inspector/protocol/Protocol.h"
#include "include/v8-debug.h" #include "include/v8-debug.h"
...@@ -158,7 +160,12 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture( ...@@ -158,7 +160,12 @@ std::unique_ptr<V8StackTraceImpl> V8StackTraceImpl::capture(
v8::HandleScope handleScope(isolate); v8::HandleScope handleScope(isolate);
v8::Local<v8::StackTrace> stackTrace; v8::Local<v8::StackTrace> stackTrace;
if (isolate->InContext()) { if (isolate->InContext()) {
isolate->GetCpuProfiler()->CollectSample(); if (debugger) {
V8InspectorImpl* inspector = debugger->inspector();
V8ProfilerAgentImpl* profilerAgent =
inspector->enabledProfilerAgentForGroup(contextGroupId);
if (profilerAgent) profilerAgent->collectSample();
}
stackTrace = v8::StackTrace::CurrentStackTrace(isolate, maxStackSize, stackTrace = v8::StackTrace::CurrentStackTrace(isolate, maxStackSize,
stackTraceOptions); stackTraceOptions);
} }
......
...@@ -1753,11 +1753,9 @@ ...@@ -1753,11 +1753,9 @@
4324, # Struct padded due to declspec(align). 4324, # Struct padded due to declspec(align).
4714, # Function marked forceinline not inlined. 4714, # Function marked forceinline not inlined.
4800, # Value forced to bool. 4800, # Value forced to bool.
4996, # Deprecated function call.
], ],
'cflags': [ 'cflags': [
'-Wno-shorten-64-to-32', '-Wno-shorten-64-to-32',
'-Wno-deprecated-declarations',
], ],
}], }],
['OS=="win" and v8_enable_i18n_support==1', { ['OS=="win" and v8_enable_i18n_support==1', {
......
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