diff options
Diffstat (limited to 'Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp')
-rw-r--r-- | Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp | 99 |
1 files changed, 27 insertions, 72 deletions
diff --git a/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp b/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp index f4794fd45..90cee8c23 100644 --- a/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp +++ b/Source/JavaScriptCore/debugger/DebuggerCallFrame.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2013, 2014 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2013 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -29,16 +29,13 @@ #include "config.h" #include "DebuggerCallFrame.h" +#include "JSFunction.h" #include "CodeBlock.h" -#include "DebuggerEvalEnabler.h" -#include "DebuggerScope.h" #include "Interpreter.h" -#include "JSFunction.h" -#include "JSLexicalEnvironment.h" -#include "JSCInlines.h" +#include "Operations.h" #include "Parser.h" #include "StackVisitor.h" -#include "StrongInlines.h" +#include "VMEntryScope.h" namespace JSC { @@ -58,36 +55,13 @@ private: unsigned m_column; }; -class FindCallerMidStackFunctor { -public: - FindCallerMidStackFunctor(CallFrame* callFrame) - : m_callFrame(callFrame) - , m_callerFrame(nullptr) - { } - - StackVisitor::Status operator()(StackVisitor& visitor) - { - if (visitor->callFrame() == m_callFrame) { - m_callerFrame = visitor->callerFrame(); - return StackVisitor::Done; - } - return StackVisitor::Continue; - } - - CallFrame* getCallerFrame() const { return m_callerFrame; } - -private: - CallFrame* m_callFrame; - CallFrame* m_callerFrame; -}; - DebuggerCallFrame::DebuggerCallFrame(CallFrame* callFrame) : m_callFrame(callFrame) { m_position = positionForCallFrame(m_callFrame); } -RefPtr<DebuggerCallFrame> DebuggerCallFrame::callerFrame() +PassRefPtr<DebuggerCallFrame> DebuggerCallFrame::callerFrame() { ASSERT(isValid()); if (!isValid()) @@ -96,12 +70,9 @@ RefPtr<DebuggerCallFrame> DebuggerCallFrame::callerFrame() if (m_caller) return m_caller; - FindCallerMidStackFunctor functor(m_callFrame); - m_callFrame->vm().topCallFrame->iterate(functor); - - CallFrame* callerFrame = functor.getCallerFrame(); + CallFrame* callerFrame = m_callFrame->callerFrameSkippingVMEntrySentinel(); if (!callerFrame) - return nullptr; + return 0; m_caller = DebuggerCallFrame::create(callerFrame); return m_caller; @@ -128,29 +99,19 @@ String DebuggerCallFrame::functionName() const ASSERT(isValid()); if (!isValid()) return String(); - return m_callFrame->friendlyFunctionName(); + JSObject* function = m_callFrame->callee(); + if (!function) + return String(); + + 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(); - JSScope* scope; - CodeBlock* codeBlock = m_callFrame->codeBlock(); - if (codeBlock && codeBlock->scopeRegister().isValid()) - scope = m_callFrame->scope(codeBlock->scopeRegister().offset()); - else if (JSCallee* callee = jsDynamicCast<JSCallee*>(m_callFrame->callee())) - scope = callee->scope(); - else - scope = m_callFrame->lexicalGlobalObject(); - - m_scope.set(vm, DebuggerScope::create(vm, scope)); - } - return m_scope.get(); + return m_callFrame->scope(); } DebuggerCallFrame::Type DebuggerCallFrame::type() const @@ -159,7 +120,7 @@ DebuggerCallFrame::Type DebuggerCallFrame::type() const if (!isValid()) return ProgramType; - if (jsDynamicCast<JSFunction*>(m_callFrame->callee())) + if (m_callFrame->callee()) return FunctionType; return ProgramType; @@ -172,10 +133,14 @@ JSValue DebuggerCallFrame::thisValue() const } // Evaluate some JavaScript code in the scope of this frame. -JSValue DebuggerCallFrame::evaluate(const String& script, NakedPtr<Exception>& exception) +JSValue DebuggerCallFrame::evaluate(const String& script, JSValue& exception) const { ASSERT(isValid()); - CallFrame* callFrame = m_callFrame; + return evaluateWithCallFrame(m_callFrame, script, exception); +} + +JSValue DebuggerCallFrame::evaluateWithCallFrame(CallFrame* callFrame, const String& script, JSValue& exception) +{ if (!callFrame) return jsNull(); @@ -184,15 +149,8 @@ JSValue DebuggerCallFrame::evaluate(const String& script, NakedPtr<Exception>& e if (!callFrame->codeBlock()) return JSValue(); - DebuggerEvalEnabler evalEnabler(callFrame); VM& vm = callFrame->vm(); - auto& codeBlock = *callFrame->codeBlock(); - ThisTDZMode thisTDZMode = codeBlock.unlinkedCodeBlock()->constructorKind() == ConstructorKind::Derived ? ThisTDZMode::AlwaysCheck : ThisTDZMode::CheckIfNeeded; - - VariableEnvironment variablesUnderTDZ; - JSScope::collectVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ); - - EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock.isStrictMode(), thisTDZMode, codeBlock.unlinkedCodeBlock()->derivedContextType(), codeBlock.unlinkedCodeBlock()->isArrowFunction(), &variablesUnderTDZ); + EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), callFrame->codeBlock()->isStrictMode()); if (vm.exception()) { exception = vm.exception(); vm.clearException(); @@ -200,7 +158,7 @@ JSValue DebuggerCallFrame::evaluate(const String& script, NakedPtr<Exception>& e } JSValue thisValue = thisValueForCallFrame(callFrame); - JSValue result = vm.interpreter->execute(eval, callFrame, thisValue, scope()->jsScope()); + JSValue result = vm.interpreter->execute(eval, callFrame, thisValue, callFrame->scope()); if (vm.exception()) { exception = vm.exception(); vm.clearException(); @@ -211,13 +169,10 @@ JSValue DebuggerCallFrame::evaluate(const String& script, NakedPtr<Exception>& e void DebuggerCallFrame::invalidate() { - RefPtr<DebuggerCallFrame> frame = this; + m_callFrame = nullptr; + RefPtr<DebuggerCallFrame> frame = m_caller.release(); while (frame) { frame->m_callFrame = nullptr; - if (frame->m_scope) { - frame->m_scope->invalidateChain(); - frame->m_scope.clear(); - } frame = frame->m_caller.release(); } } @@ -238,7 +193,7 @@ SourceID DebuggerCallFrame::sourceIDForCallFrame(CallFrame* callFrame) CodeBlock* codeBlock = callFrame->codeBlock(); if (!codeBlock) return noSourceID; - return codeBlock->ownerScriptExecutable()->sourceID(); + return codeBlock->ownerExecutable()->sourceID(); } JSValue DebuggerCallFrame::thisValueForCallFrame(CallFrame* callFrame) |