mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 1 | /* |
fpizlo@apple.com | 39303e0 | 2016-04-05 22:17:35 +0000 | [diff] [blame] | 2 | * Copyright (C) 2008, 2013-2014, 2016 Apple Inc. All rights reserved. |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
mjs@apple.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 13 | * 3. Neither the name of Apple Inc. ("Apple") nor the names of |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 14 | * its contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 18 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 19 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 20 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 21 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 22 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 23 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 24 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | */ |
| 28 | |
| 29 | #include "config.h" |
| 30 | #include "DebuggerCallFrame.h" |
| 31 | |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 32 | #include "CodeBlock.h" |
commit-queue@webkit.org | 31d2ef0 | 2014-09-05 21:08:14 +0000 | [diff] [blame] | 33 | #include "DebuggerEvalEnabler.h" |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 34 | #include "DebuggerScope.h" |
ggaren@apple.com | 901a8a2 | 2008-11-17 20:57:18 +0000 | [diff] [blame] | 35 | #include "Interpreter.h" |
joepeck@webkit.org | 70d6a30 | 2016-05-10 19:16:19 +0000 | [diff] [blame] | 36 | #include "JSCInlines.h" |
mark.lam@apple.com | 65a636f | 2014-02-01 01:24:39 +0000 | [diff] [blame] | 37 | #include "JSFunction.h" |
oliver@apple.com | a7dfb4d | 2014-09-11 18:18:14 +0000 | [diff] [blame] | 38 | #include "JSLexicalEnvironment.h" |
joepeck@webkit.org | 70d6a30 | 2016-05-10 19:16:19 +0000 | [diff] [blame] | 39 | #include "JSWithScope.h" |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 40 | #include "Parser.h" |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 41 | #include "ShadowChickenInlines.h" |
mark.lam@apple.com | e72693d | 2013-09-24 23:52:57 +0000 | [diff] [blame] | 42 | #include "StackVisitor.h" |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 43 | #include "StrongInlines.h" |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 44 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 45 | namespace JSC { |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 46 | |
mark.lam@apple.com | e72693d | 2013-09-24 23:52:57 +0000 | [diff] [blame] | 47 | class LineAndColumnFunctor { |
| 48 | public: |
fpizlo@apple.com | 39303e0 | 2016-04-05 22:17:35 +0000 | [diff] [blame] | 49 | StackVisitor::Status operator()(StackVisitor& visitor) const |
mark.lam@apple.com | e72693d | 2013-09-24 23:52:57 +0000 | [diff] [blame] | 50 | { |
| 51 | visitor->computeLineAndColumn(m_line, m_column); |
| 52 | return StackVisitor::Done; |
| 53 | } |
| 54 | |
| 55 | unsigned line() const { return m_line; } |
| 56 | unsigned column() const { return m_column; } |
| 57 | |
| 58 | private: |
fpizlo@apple.com | 39303e0 | 2016-04-05 22:17:35 +0000 | [diff] [blame] | 59 | mutable unsigned m_line; |
| 60 | mutable unsigned m_column; |
mark.lam@apple.com | e72693d | 2013-09-24 23:52:57 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 63 | Ref<DebuggerCallFrame> DebuggerCallFrame::create(CallFrame* callFrame) |
mark.lam@apple.com | e72693d | 2013-09-24 23:52:57 +0000 | [diff] [blame] | 64 | { |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 65 | Vector<ShadowChicken::Frame> frames; |
| 66 | callFrame->vm().shadowChicken().iterate(callFrame->vm(), callFrame, [&] (const ShadowChicken::Frame& frame) -> bool { |
| 67 | frames.append(frame); |
| 68 | return true; |
| 69 | }); |
| 70 | |
| 71 | RELEASE_ASSERT(frames.size()); |
sbarati@apple.com | ed3e9f5 | 2016-05-27 20:26:06 +0000 | [diff] [blame^] | 72 | ASSERT(!frames[0].isTailDeleted); // The top frame should never be tail deleted. |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 73 | |
| 74 | RefPtr<DebuggerCallFrame> currentParent = nullptr; |
sbarati@apple.com | ed3e9f5 | 2016-05-27 20:26:06 +0000 | [diff] [blame^] | 75 | ExecState* exec = callFrame->lexicalGlobalObject()->globalExec(); |
| 76 | // This walks the stack from the entry stack frame to the top of the stack. |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 77 | for (unsigned i = frames.size(); i--; ) { |
| 78 | const ShadowChicken::Frame& frame = frames[i]; |
| 79 | if (!frame.isTailDeleted) |
| 80 | exec = frame.frame; |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 81 | Ref<DebuggerCallFrame> currentFrame = adoptRef(*new DebuggerCallFrame(exec, frame)); |
| 82 | currentFrame->m_caller = currentParent; |
| 83 | currentParent = WTFMove(currentFrame); |
| 84 | } |
| 85 | return *currentParent; |
| 86 | } |
| 87 | |
| 88 | DebuggerCallFrame::DebuggerCallFrame(CallFrame* callFrame, const ShadowChicken::Frame& frame) |
| 89 | : m_validMachineFrame(callFrame) |
| 90 | , m_shadowChickenFrame(frame) |
| 91 | { |
| 92 | m_position = currentPosition(); |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 93 | } |
| 94 | |
gyuyoung.kim@webkit.org | be3842f | 2015-06-13 03:52:06 +0000 | [diff] [blame] | 95 | RefPtr<DebuggerCallFrame> DebuggerCallFrame::callerFrame() |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 96 | { |
| 97 | ASSERT(isValid()); |
| 98 | if (!isValid()) |
gyuyoung.kim@webkit.org | be3842f | 2015-06-13 03:52:06 +0000 | [diff] [blame] | 99 | return nullptr; |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 100 | |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 101 | return m_caller; |
| 102 | } |
| 103 | |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 104 | ExecState* DebuggerCallFrame::globalExec() |
| 105 | { |
| 106 | return scope()->globalObject()->globalExec(); |
| 107 | } |
| 108 | |
mark.lam@apple.com | 3072125 | 2013-11-21 05:29:42 +0000 | [diff] [blame] | 109 | JSC::JSGlobalObject* DebuggerCallFrame::vmEntryGlobalObject() const |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 110 | { |
| 111 | ASSERT(isValid()); |
| 112 | if (!isValid()) |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 113 | return nullptr; |
| 114 | return m_validMachineFrame->vmEntryGlobalObject(); |
mark.lam@apple.com | e72693d | 2013-09-24 23:52:57 +0000 | [diff] [blame] | 115 | } |
| 116 | |
mark.lam@apple.com | 26c5340 | 2013-11-08 20:03:50 +0000 | [diff] [blame] | 117 | SourceID DebuggerCallFrame::sourceID() const |
mark.lam@apple.com | 649480f | 2013-09-12 16:27:55 +0000 | [diff] [blame] | 118 | { |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 119 | ASSERT(isValid()); |
| 120 | if (!isValid()) |
mark.lam@apple.com | 26c5340 | 2013-11-08 20:03:50 +0000 | [diff] [blame] | 121 | return noSourceID; |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 122 | if (isTailDeleted()) |
| 123 | return m_shadowChickenFrame.codeBlock->ownerScriptExecutable()->sourceID(); |
| 124 | return sourceIDForCallFrame(m_validMachineFrame); |
mark.lam@apple.com | 649480f | 2013-09-12 16:27:55 +0000 | [diff] [blame] | 125 | } |
| 126 | |
ggaren@apple.com | 0030e13 | 2012-09-12 06:14:56 +0000 | [diff] [blame] | 127 | String DebuggerCallFrame::functionName() const |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 128 | { |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 129 | ASSERT(isValid()); |
| 130 | if (!isValid()) |
ggaren@apple.com | 0030e13 | 2012-09-12 06:14:56 +0000 | [diff] [blame] | 131 | return String(); |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 132 | |
| 133 | if (isTailDeleted()) { |
| 134 | if (JSFunction* func = jsDynamicCast<JSFunction*>(m_shadowChickenFrame.callee)) |
| 135 | return func->calculatedDisplayName(m_validMachineFrame); |
| 136 | return m_shadowChickenFrame.codeBlock->inferredName().data(); |
| 137 | } |
| 138 | |
| 139 | return m_validMachineFrame->friendlyFunctionName(); |
aroben@apple.com | 261f1ff | 2009-05-15 18:13:28 +0000 | [diff] [blame] | 140 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 141 | |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 142 | DebuggerScope* DebuggerCallFrame::scope() |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 143 | { |
| 144 | ASSERT(isValid()); |
| 145 | if (!isValid()) |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 146 | return nullptr; |
mark.lam@apple.com | 65a636f | 2014-02-01 01:24:39 +0000 | [diff] [blame] | 147 | |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 148 | if (!m_scope) { |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 149 | VM& vm = m_validMachineFrame->vm(); |
msaboff@apple.com | 5e62e3f | 2014-11-21 23:41:26 +0000 | [diff] [blame] | 150 | JSScope* scope; |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 151 | CodeBlock* codeBlock = m_validMachineFrame->codeBlock(); |
| 152 | if (isTailDeleted()) |
| 153 | scope = m_shadowChickenFrame.scope; |
| 154 | else if (codeBlock && codeBlock->scopeRegister().isValid()) |
| 155 | scope = m_validMachineFrame->scope(codeBlock->scopeRegister().offset()); |
| 156 | else if (JSCallee* callee = jsDynamicCast<JSCallee*>(m_validMachineFrame->callee())) |
msaboff@apple.com | 95c4315 | 2015-02-26 06:05:02 +0000 | [diff] [blame] | 157 | scope = callee->scope(); |
msaboff@apple.com | 5e62e3f | 2014-11-21 23:41:26 +0000 | [diff] [blame] | 158 | else |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 159 | scope = m_validMachineFrame->lexicalGlobalObject()->globalLexicalEnvironment(); |
mark.lam@apple.com | 8fe56b8 | 2014-08-09 06:50:19 +0000 | [diff] [blame] | 160 | |
msaboff@apple.com | 5e62e3f | 2014-11-21 23:41:26 +0000 | [diff] [blame] | 161 | m_scope.set(vm, DebuggerScope::create(vm, scope)); |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 162 | } |
| 163 | return m_scope.get(); |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 164 | } |
| 165 | |
timothy@apple.com | c14b52c | 2008-06-17 22:33:07 +0000 | [diff] [blame] | 166 | DebuggerCallFrame::Type DebuggerCallFrame::type() const |
| 167 | { |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 168 | ASSERT(isValid()); |
| 169 | if (!isValid()) |
| 170 | return ProgramType; |
| 171 | |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 172 | if (isTailDeleted()) |
| 173 | return FunctionType; |
| 174 | |
| 175 | if (jsDynamicCast<JSFunction*>(m_validMachineFrame->callee())) |
timothy@apple.com | c14b52c | 2008-06-17 22:33:07 +0000 | [diff] [blame] | 176 | return FunctionType; |
| 177 | |
| 178 | return ProgramType; |
| 179 | } |
| 180 | |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 181 | JSValue DebuggerCallFrame::thisValue() const |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 182 | { |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 183 | ASSERT(isValid()); |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 184 | if (!isValid()) |
| 185 | return jsUndefined(); |
| 186 | |
| 187 | CodeBlock* codeBlock = nullptr; |
| 188 | JSValue thisValue; |
| 189 | if (isTailDeleted()) { |
| 190 | thisValue = m_shadowChickenFrame.thisValue; |
| 191 | codeBlock = m_shadowChickenFrame.codeBlock; |
| 192 | } else { |
| 193 | thisValue = m_validMachineFrame->thisValue(); |
| 194 | codeBlock = m_validMachineFrame->codeBlock(); |
| 195 | } |
| 196 | |
| 197 | if (!thisValue) |
| 198 | return jsUndefined(); |
| 199 | |
| 200 | ECMAMode ecmaMode = NotStrictMode; |
| 201 | if (codeBlock && codeBlock->isStrictMode()) |
| 202 | ecmaMode = StrictMode; |
| 203 | return thisValue.toThis(m_validMachineFrame, ecmaMode); |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 204 | } |
| 205 | |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 206 | // Evaluate some JavaScript code in the scope of this frame. |
joepeck@webkit.org | 70d6a30 | 2016-05-10 19:16:19 +0000 | [diff] [blame] | 207 | JSValue DebuggerCallFrame::evaluateWithScopeExtension(const String& script, JSObject* scopeExtensionObject, NakedPtr<Exception>& exception) |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 208 | { |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 209 | ASSERT(isValid()); |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 210 | CallFrame* callFrame = m_validMachineFrame; |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 211 | if (!callFrame) |
joepeck@webkit.org | 70d6a30 | 2016-05-10 19:16:19 +0000 | [diff] [blame] | 212 | return jsUndefined(); |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 213 | |
| 214 | JSLockHolder lock(callFrame); |
| 215 | |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 216 | CodeBlock* codeBlock = nullptr; |
| 217 | if (isTailDeleted()) |
| 218 | codeBlock = m_shadowChickenFrame.codeBlock; |
| 219 | else |
| 220 | codeBlock = callFrame->codeBlock(); |
| 221 | if (!codeBlock) |
joepeck@webkit.org | 70d6a30 | 2016-05-10 19:16:19 +0000 | [diff] [blame] | 222 | return jsUndefined(); |
oliver@apple.com | ba10bec | 2011-03-08 23:17:32 +0000 | [diff] [blame] | 223 | |
commit-queue@webkit.org | 31d2ef0 | 2014-09-05 21:08:14 +0000 | [diff] [blame] | 224 | DebuggerEvalEnabler evalEnabler(callFrame); |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 225 | VM& vm = callFrame->vm(); |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 226 | |
gskachkov@gmail.com | a3f0cdf | 2016-04-03 07:59:19 +0000 | [diff] [blame] | 227 | EvalContextType evalContextType; |
| 228 | |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 229 | if (isFunctionParseMode(codeBlock->unlinkedCodeBlock()->parseMode())) |
gskachkov@gmail.com | a3f0cdf | 2016-04-03 07:59:19 +0000 | [diff] [blame] | 230 | evalContextType = EvalContextType::FunctionEvalContext; |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 231 | else if (codeBlock->unlinkedCodeBlock()->codeType() == EvalCode) |
| 232 | evalContextType = codeBlock->unlinkedCodeBlock()->evalContextType(); |
gskachkov@gmail.com | a3f0cdf | 2016-04-03 07:59:19 +0000 | [diff] [blame] | 233 | else |
| 234 | evalContextType = EvalContextType::None; |
| 235 | |
saambarati1@gmail.com | 144f17c | 2015-07-15 21:41:08 +0000 | [diff] [blame] | 236 | VariableEnvironment variablesUnderTDZ; |
| 237 | JSScope::collectVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ); |
| 238 | |
utatane.tea@gmail.com | c202907 | 2016-05-24 12:04:35 +0000 | [diff] [blame] | 239 | EvalExecutable* eval = EvalExecutable::create(callFrame, makeSource(script), codeBlock->isStrictMode(), codeBlock->unlinkedCodeBlock()->derivedContextType(), codeBlock->unlinkedCodeBlock()->isArrowFunction(), evalContextType, &variablesUnderTDZ); |
commit-queue@webkit.org | 3f922f9 | 2013-08-29 00:28:42 +0000 | [diff] [blame] | 240 | if (vm.exception()) { |
| 241 | exception = vm.exception(); |
| 242 | vm.clearException(); |
mark.lam@apple.com | 8f98b6b | 2014-01-25 03:15:13 +0000 | [diff] [blame] | 243 | return jsUndefined(); |
oliver@apple.com | ba10bec | 2011-03-08 23:17:32 +0000 | [diff] [blame] | 244 | } |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 245 | |
joepeck@webkit.org | 70d6a30 | 2016-05-10 19:16:19 +0000 | [diff] [blame] | 246 | JSGlobalObject* globalObject = callFrame->vmEntryGlobalObject(); |
| 247 | if (scopeExtensionObject) { |
| 248 | JSScope* ignoredPreviousScope = globalObject->globalScope(); |
| 249 | globalObject->setGlobalScopeExtension(JSWithScope::create(vm, globalObject, scopeExtensionObject, ignoredPreviousScope)); |
| 250 | } |
| 251 | |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 252 | JSValue thisValue = this->thisValue(); |
mark.lam@apple.com | 268dda7 | 2014-08-29 00:48:59 +0000 | [diff] [blame] | 253 | JSValue result = vm.interpreter->execute(eval, callFrame, thisValue, scope()->jsScope()); |
commit-queue@webkit.org | 3f922f9 | 2013-08-29 00:28:42 +0000 | [diff] [blame] | 254 | if (vm.exception()) { |
| 255 | exception = vm.exception(); |
| 256 | vm.clearException(); |
barraclough@apple.com | 2607dd0 | 2010-10-27 20:46:09 +0000 | [diff] [blame] | 257 | } |
joepeck@webkit.org | 70d6a30 | 2016-05-10 19:16:19 +0000 | [diff] [blame] | 258 | |
| 259 | if (scopeExtensionObject) |
| 260 | globalObject->clearGlobalScopeExtension(); |
| 261 | |
barraclough@apple.com | 2607dd0 | 2010-10-27 20:46:09 +0000 | [diff] [blame] | 262 | ASSERT(result); |
| 263 | return result; |
mrowe@apple.com | 2f6dfdf | 2008-05-22 01:20:45 +0000 | [diff] [blame] | 264 | } |
| 265 | |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 266 | void DebuggerCallFrame::invalidate() |
mark.lam@apple.com | 649480f | 2013-09-12 16:27:55 +0000 | [diff] [blame] | 267 | { |
mark.lam@apple.com | 51d1315 | 2014-09-23 22:29:35 +0000 | [diff] [blame] | 268 | RefPtr<DebuggerCallFrame> frame = this; |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 269 | while (frame) { |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 270 | frame->m_validMachineFrame = nullptr; |
mark.lam@apple.com | 51d1315 | 2014-09-23 22:29:35 +0000 | [diff] [blame] | 271 | if (frame->m_scope) { |
| 272 | frame->m_scope->invalidateChain(); |
| 273 | frame->m_scope.clear(); |
| 274 | } |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 275 | frame = frame->m_caller.release(); |
| 276 | } |
| 277 | } |
| 278 | |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 279 | TextPosition DebuggerCallFrame::currentPosition() |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 280 | { |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 281 | if (!m_validMachineFrame) |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 282 | return TextPosition(); |
| 283 | |
sbarati@apple.com | ce5b05e | 2016-05-16 23:31:39 +0000 | [diff] [blame] | 284 | if (isTailDeleted()) { |
| 285 | CodeBlock* codeBlock = m_shadowChickenFrame.codeBlock; |
| 286 | if (Optional<unsigned> bytecodeOffset = codeBlock->bytecodeOffsetFromCallSiteIndex(m_shadowChickenFrame.callSiteIndex)) { |
| 287 | return TextPosition(OrdinalNumber::fromOneBasedInt(codeBlock->lineNumberForBytecodeOffset(*bytecodeOffset)), |
| 288 | OrdinalNumber::fromOneBasedInt(codeBlock->columnNumberForBytecodeOffset(*bytecodeOffset))); |
| 289 | } |
| 290 | } |
| 291 | |
| 292 | return positionForCallFrame(m_validMachineFrame); |
| 293 | } |
| 294 | |
| 295 | TextPosition DebuggerCallFrame::positionForCallFrame(CallFrame* callFrame) |
| 296 | { |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 297 | LineAndColumnFunctor functor; |
| 298 | callFrame->iterate(functor); |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 299 | return TextPosition(OrdinalNumber::fromOneBasedInt(functor.line()), OrdinalNumber::fromOneBasedInt(functor.column())); |
| 300 | } |
| 301 | |
mark.lam@apple.com | 26c5340 | 2013-11-08 20:03:50 +0000 | [diff] [blame] | 302 | SourceID DebuggerCallFrame::sourceIDForCallFrame(CallFrame* callFrame) |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 303 | { |
| 304 | ASSERT(callFrame); |
| 305 | CodeBlock* codeBlock = callFrame->codeBlock(); |
| 306 | if (!codeBlock) |
mark.lam@apple.com | 26c5340 | 2013-11-08 20:03:50 +0000 | [diff] [blame] | 307 | return noSourceID; |
commit-queue@webkit.org | fa19663 | 2015-08-28 21:07:22 +0000 | [diff] [blame] | 308 | return codeBlock->ownerScriptExecutable()->sourceID(); |
mark.lam@apple.com | af032dd | 2013-10-05 00:51:31 +0000 | [diff] [blame] | 309 | } |
| 310 | |
cwzwarich@webkit.org | 3f782f6 | 2008-09-08 01:28:33 +0000 | [diff] [blame] | 311 | } // namespace JSC |