REGRESSION: Inspector crashes when debugger is paused and injected scripts access window.screen().
<https://webkit.org/b/135656>

Not reviewed.

Rolling out r170680 which was merged to ToT in r172129.

Source/JavaScriptCore:

* debugger/Debugger.h:
* debugger/DebuggerCallFrame.cpp:
(JSC::DebuggerCallFrame::scope):
(JSC::DebuggerCallFrame::evaluate):
(JSC::DebuggerCallFrame::invalidate):
* debugger/DebuggerCallFrame.h:
* debugger/DebuggerScope.cpp:
(JSC::DebuggerScope::DebuggerScope):
(JSC::DebuggerScope::finishCreation):
(JSC::DebuggerScope::visitChildren):
(JSC::DebuggerScope::className):
(JSC::DebuggerScope::getOwnPropertySlot):
(JSC::DebuggerScope::put):
(JSC::DebuggerScope::deleteProperty):
(JSC::DebuggerScope::getOwnPropertyNames):
(JSC::DebuggerScope::defineOwnProperty):
(JSC::DebuggerScope::next): Deleted.
(JSC::DebuggerScope::invalidateChain): Deleted.
(JSC::DebuggerScope::isWithScope): Deleted.
(JSC::DebuggerScope::isGlobalScope): Deleted.
(JSC::DebuggerScope::isFunctionScope): Deleted.
* debugger/DebuggerScope.h:
(JSC::DebuggerScope::create):
(JSC::DebuggerScope::Iterator::Iterator): Deleted.
(JSC::DebuggerScope::Iterator::get): Deleted.
(JSC::DebuggerScope::Iterator::operator++): Deleted.
(JSC::DebuggerScope::Iterator::operator==): Deleted.
(JSC::DebuggerScope::Iterator::operator!=): Deleted.
(JSC::DebuggerScope::isValid): Deleted.
(JSC::DebuggerScope::jsScope): Deleted.
(JSC::DebuggerScope::begin): Deleted.
(JSC::DebuggerScope::end): Deleted.
* inspector/JSJavaScriptCallFrame.cpp:
(Inspector::JSJavaScriptCallFrame::scopeType):
(Inspector::JSJavaScriptCallFrame::scopeChain):
* inspector/JavaScriptCallFrame.h:
(Inspector::JavaScriptCallFrame::scopeChain):
* inspector/ScriptDebugServer.cpp:
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::reset):
(JSC::JSGlobalObject::visitChildren):
* runtime/JSGlobalObject.h:
(JSC::JSGlobalObject::debuggerScopeStructure): Deleted.
* runtime/JSObject.h:
(JSC::JSObject::isWithScope): Deleted.
* runtime/JSScope.h:
* runtime/VM.cpp:
(JSC::VM::VM):
* runtime/VM.h:

Source/WebCore:

* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::attachDebugger):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@172372 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp b/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp
index c8a0179..83fb67f 100644
--- a/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp
+++ b/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp
@@ -30,14 +30,12 @@
 #include "DebuggerCallFrame.h"
 
 #include "CodeBlock.h"
-#include "DebuggerScope.h"
 #include "Interpreter.h"
 #include "JSActivation.h"
 #include "JSFunction.h"
 #include "JSCInlines.h"
 #include "Parser.h"
 #include "StackVisitor.h"
-#include "StrongInlines.h"
 
 namespace JSC {
 
@@ -108,25 +106,20 @@
     return getCalculatedDisplayName(m_callFrame, function);
 }
 
-DebuggerScope* DebuggerCallFrame::scope()
+JSScope* DebuggerCallFrame::scope() const
 {
     ASSERT(isValid());
     if (!isValid())
         return 0;
 
-    if (!m_scope) {
-        VM& vm = m_callFrame->vm();
-        CodeBlock* codeBlock = m_callFrame->codeBlock();
-        if (codeBlock && codeBlock->needsActivation() && !m_callFrame->hasActivation()) {
-            ASSERT(!m_callFrame->scope()->isWithScope());
-            JSActivation* activation = JSActivation::create(vm, m_callFrame, codeBlock);
-            m_callFrame->setActivation(activation);
-            m_callFrame->setScope(activation);
-        }
-
-        m_scope.set(vm, DebuggerScope::create(vm, m_callFrame->scope()));
+    CodeBlock* codeBlock = m_callFrame->codeBlock();
+    if (codeBlock && codeBlock->needsActivation() && !m_callFrame->hasActivation()) {
+        JSActivation* activation = JSActivation::create(*codeBlock->vm(), m_callFrame, codeBlock);
+        m_callFrame->setActivation(activation);
+        m_callFrame->setScope(activation);
     }
-    return m_scope.get();
+
+    return m_callFrame->scope();
 }
 
 DebuggerCallFrame::Type DebuggerCallFrame::type() const
@@ -169,7 +162,7 @@
     }
 
     JSValue thisValue = thisValueForCallFrame(callFrame);
-    JSValue result = vm.interpreter->execute(eval, callFrame, thisValue, scope()->jsScope());
+    JSValue result = vm.interpreter->execute(eval, callFrame, thisValue, scope());
     if (vm.exception()) {
         exception = vm.exception();
         vm.clearException();
@@ -181,10 +174,6 @@
 void DebuggerCallFrame::invalidate()
 {
     m_callFrame = nullptr;
-    if (m_scope) {
-        m_scope->invalidateChain();
-        m_scope.clear();
-    }
     RefPtr<DebuggerCallFrame> frame = m_caller.release();
     while (frame) {
         frame->m_callFrame = nullptr;