Commit 82b43a10 authored by jochen's avatar jochen Committed by Commit bot

Drop dependency on ScopedPersistent from inspector/v8

v8::Global also clears itself on destruction

R=pfeldman@chromium.org
BUG=580337

Review URL: https://codereview.chromium.org/1636343002

Cr-Commit-Position: refs/heads/master@{#371811}
parent 0049a9be
include_rules = [
"-bindings/core",
"+bindings/core/v8/ExceptionState.h",
"+bindings/core/v8/ScopedPersistent.h",
"+bindings/core/v8/ScriptCallStackFactory.h",
"+bindings/core/v8/ScriptRegexp.h",
"+bindings/core/v8/ScriptState.h",
......
......@@ -51,9 +51,9 @@ JavaScriptCallFrame* JavaScriptCallFrame::caller()
{
if (!m_caller) {
v8::HandleScope handleScope(m_isolate);
v8::Local<v8::Context> debuggerContext = m_debuggerContext.newLocal(m_isolate);
v8::Local<v8::Context> debuggerContext = v8::Local<v8::Context>::New(m_isolate, m_debuggerContext);
v8::Context::Scope contextScope(debuggerContext);
v8::Local<v8::Value> callerFrame = m_callFrame.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "caller"));
v8::Local<v8::Value> callerFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame)->Get(v8AtomicString(m_isolate, "caller"));
if (callerFrame.IsEmpty() || !callerFrame->IsObject())
return 0;
m_caller = JavaScriptCallFrame::create(debuggerContext, v8::Local<v8::Object>::Cast(callerFrame));
......@@ -64,8 +64,8 @@ JavaScriptCallFrame* JavaScriptCallFrame::caller()
int JavaScriptCallFrame::callV8FunctionReturnInt(const char* name) const
{
v8::HandleScope handleScope(m_isolate);
v8::Context::Scope contextScope(m_debuggerContext.newLocal(m_isolate));
v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate);
v8::Context::Scope contextScope(v8::Local<v8::Context>::New(m_isolate, m_debuggerContext));
v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame);
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(v8AtomicString(m_isolate, name)));
v8::Local<v8::Value> result;
if (!V8ScriptRunner::callInternalFunction(func, callFrame, 0, 0, m_isolate).ToLocal(&result) || !result->IsInt32())
......@@ -76,8 +76,8 @@ int JavaScriptCallFrame::callV8FunctionReturnInt(const char* name) const
String JavaScriptCallFrame::callV8FunctionReturnString(const char* name) const
{
v8::HandleScope handleScope(m_isolate);
v8::Context::Scope contextScope(m_debuggerContext.newLocal(m_isolate));
v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate);
v8::Context::Scope contextScope(v8::Local<v8::Context>::New(m_isolate, m_debuggerContext));
v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame);
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(v8AtomicString(m_isolate, name)));
v8::Local<v8::Value> result;
if (!V8ScriptRunner::callInternalFunction(func, callFrame, 0, 0, m_isolate).ToLocal(&result))
......@@ -122,7 +122,7 @@ int JavaScriptCallFrame::functionColumn() const
v8::Local<v8::Value> JavaScriptCallFrame::scopeChain() const
{
v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate);
v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame);
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(v8AtomicString(m_isolate, "scopeChain")));
v8::Local<v8::Array> scopeChain = v8::Local<v8::Array>::Cast(V8ScriptRunner::callInternalFunction(func, callFrame, 0, 0, m_isolate).ToLocalChecked());
v8::Local<v8::Array> result = v8::Array::New(m_isolate, scopeChain->Length());
......@@ -133,7 +133,7 @@ v8::Local<v8::Value> JavaScriptCallFrame::scopeChain() const
int JavaScriptCallFrame::scopeType(int scopeIndex) const
{
v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate);
v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame);
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(v8AtomicString(m_isolate, "scopeType")));
v8::Local<v8::Array> scopeType = v8::Local<v8::Array>::Cast(V8ScriptRunner::callInternalFunction(func, callFrame, 0, 0, m_isolate).ToLocalChecked());
return scopeType->Get(scopeIndex)->Int32Value();
......@@ -141,7 +141,7 @@ int JavaScriptCallFrame::scopeType(int scopeIndex) const
v8::Local<v8::String> JavaScriptCallFrame::scopeName(int scopeIndex) const
{
v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate);
v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame);
v8::Local<v8::Function> func = v8::Local<v8::Function>::Cast(callFrame->Get(v8AtomicString(m_isolate, "scopeName")));
v8::Local<v8::Array> scopeType = v8::Local<v8::Array>::Cast(V8ScriptRunner::callInternalFunction(func, callFrame, 0, 0, m_isolate).ToLocalChecked());
return scopeType->Get(scopeIndex)->ToString();
......@@ -149,7 +149,7 @@ v8::Local<v8::String> JavaScriptCallFrame::scopeName(int scopeIndex) const
v8::Local<v8::Value> JavaScriptCallFrame::thisObject() const
{
return m_callFrame.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "thisObject"));
return v8::Local<v8::Object>::New(m_isolate, m_callFrame)->Get(v8AtomicString(m_isolate, "thisObject"));
}
String JavaScriptCallFrame::stepInPositions() const
......@@ -160,8 +160,8 @@ String JavaScriptCallFrame::stepInPositions() const
bool JavaScriptCallFrame::isAtReturn() const
{
v8::HandleScope handleScope(m_isolate);
v8::Context::Scope contextScope(m_debuggerContext.newLocal(m_isolate));
v8::Local<v8::Value> result = m_callFrame.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "isAtReturn"));
v8::Context::Scope contextScope(v8::Local<v8::Context>::New(m_isolate, m_debuggerContext));
v8::Local<v8::Value> result = v8::Local<v8::Object>::New(m_isolate, m_callFrame)->Get(v8AtomicString(m_isolate, "isAtReturn"));
if (result.IsEmpty() || !result->IsBoolean())
return false;
return result->BooleanValue();
......@@ -169,12 +169,12 @@ bool JavaScriptCallFrame::isAtReturn() const
v8::Local<v8::Value> JavaScriptCallFrame::returnValue() const
{
return m_callFrame.newLocal(m_isolate)->Get(v8AtomicString(m_isolate, "returnValue"));
return v8::Local<v8::Object>::New(m_isolate, m_callFrame)->Get(v8AtomicString(m_isolate, "returnValue"));
}
v8::Local<v8::Value> JavaScriptCallFrame::evaluateWithExceptionDetails(v8::Local<v8::Value> expression, v8::Local<v8::Value> scopeExtension)
{
v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate);
v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame);
v8::Local<v8::Function> evalFunction = v8::Local<v8::Function>::Cast(callFrame->Get(v8AtomicString(m_isolate, "evaluate")));
v8::Local<v8::Value> argv[] = {
expression,
......@@ -195,7 +195,7 @@ v8::Local<v8::Value> JavaScriptCallFrame::evaluateWithExceptionDetails(v8::Local
v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart()
{
v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate);
v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame);
v8::Local<v8::Function> restartFunction = v8::Local<v8::Function>::Cast(callFrame->Get(v8AtomicString(m_isolate, "restart")));
v8::Debug::SetLiveEditEnabled(m_isolate, true);
v8::MaybeLocal<v8::Value> result = V8ScriptRunner::callInternalFunction(restartFunction, callFrame, 0, 0, m_isolate);
......@@ -205,7 +205,7 @@ v8::MaybeLocal<v8::Value> JavaScriptCallFrame::restart()
v8::MaybeLocal<v8::Value> JavaScriptCallFrame::setVariableValue(int scopeNumber, v8::Local<v8::Value> variableName, v8::Local<v8::Value> newValue)
{
v8::Local<v8::Object> callFrame = m_callFrame.newLocal(m_isolate);
v8::Local<v8::Object> callFrame = v8::Local<v8::Object>::New(m_isolate, m_callFrame);
v8::Local<v8::Function> setVariableValueFunction = v8::Local<v8::Function>::Cast(callFrame->Get(v8AtomicString(m_isolate, "setVariableValue")));
v8::Local<v8::Value> argv[] = {
v8::Local<v8::Value>(v8::Integer::New(m_isolate, scopeNumber)),
......
......@@ -32,7 +32,6 @@
#define JavaScriptCallFrame_h
#include "bindings/core/v8/ScopedPersistent.h"
#include "bindings/core/v8/ScriptState.h"
#include "wtf/RefCounted.h"
#include "wtf/text/WTFString.h"
......@@ -84,8 +83,8 @@ private:
v8::Isolate* m_isolate;
RefPtr<JavaScriptCallFrame> m_caller;
ScopedPersistent<v8::Context> m_debuggerContext;
ScopedPersistent<v8::Object> m_callFrame;
v8::Global<v8::Context> m_debuggerContext;
v8::Global<v8::Object> m_callFrame;
v8::Global<v8::FunctionTemplate> m_wrapperTemplate;
};
......
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