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