Function name scope is only created on the function instance that triggered parsing...
[WebKit-https.git] / Source / JavaScriptCore / interpreter / Interpreter.cpp
1 /*
2  * Copyright (C) 2008, 2009, 2010, 2012-2015 Apple Inc. All rights reserved.
3  * Copyright (C) 2008 Cameron Zwarich <cwzwarich@uwaterloo.ca>
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1.  Redistributions of source code must retain the above copyright
10  *     notice, this list of conditions and the following disclaimer.
11  * 2.  Redistributions in binary form must reproduce the above copyright
12  *     notice, this list of conditions and the following disclaimer in the
13  *     documentation and/or other materials provided with the distribution.
14  * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
15  *     its contributors may be used to endorse or promote products derived
16  *     from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29
30 #include "config.h"
31 #include "Interpreter.h"
32
33 #include "Arguments.h"
34 #include "BatchedTransitionOptimizer.h"
35 #include "CallFrameClosure.h"
36 #include "CallFrameInlines.h"
37 #include "CodeBlock.h"
38 #include "Heap.h"
39 #include "Debugger.h"
40 #include "DebuggerCallFrame.h"
41 #include "ErrorInstance.h"
42 #include "EvalCodeCache.h"
43 #include "ExceptionHelpers.h"
44 #include "GetterSetter.h"
45 #include "JSArray.h"
46 #include "JSBoundFunction.h"
47 #include "JSLexicalEnvironment.h"
48 #include "JSNameScope.h"
49 #include "JSNotAnObject.h"
50 #include "JSStackInlines.h"
51 #include "JSString.h"
52 #include "JSWithScope.h"
53 #include "LLIntCLoop.h"
54 #include "LLIntThunks.h"
55 #include "LegacyProfiler.h"
56 #include "LiteralParser.h"
57 #include "ObjectPrototype.h"
58 #include "JSCInlines.h"
59 #include "Parser.h"
60 #include "ProtoCallFrame.h"
61 #include "RegExpObject.h"
62 #include "RegExpPrototype.h"
63 #include "Register.h"
64 #include "SamplingTool.h"
65 #include "StackAlignment.h"
66 #include "StackVisitor.h"
67 #include "StrictEvalActivation.h"
68 #include "StrongInlines.h"
69 #include "Symbol.h"
70 #include "VMEntryScope.h"
71 #include "VirtualRegister.h"
72
73 #include <limits.h>
74 #include <stdio.h>
75 #include <wtf/StackStats.h>
76 #include <wtf/StdLibExtras.h>
77 #include <wtf/StringPrintStream.h>
78 #include <wtf/Threading.h>
79 #include <wtf/WTFThreadData.h>
80 #include <wtf/text/StringBuilder.h>
81
82 #if ENABLE(JIT)
83 #include "JIT.h"
84 #endif
85
86 using namespace std;
87
88 namespace JSC {
89
90 JSValue eval(CallFrame* callFrame)
91 {
92     if (!callFrame->argumentCount())
93         return jsUndefined();
94
95     JSValue program = callFrame->argument(0);
96     if (!program.isString())
97         return program;
98     
99     TopCallFrameSetter topCallFrame(callFrame->vm(), callFrame);
100     String programSource = asString(program)->value(callFrame);
101     if (callFrame->hadException())
102         return JSValue();
103     
104     CallFrame* callerFrame = callFrame->callerFrame();
105     CodeBlock* callerCodeBlock = callerFrame->codeBlock();
106     JSScope* callerScopeChain = callerFrame->uncheckedR(callerCodeBlock->scopeRegister().offset()).Register::scope();
107     EvalExecutable* eval = callerCodeBlock->evalCodeCache().tryGet(callerCodeBlock->isStrictMode(), programSource, callerScopeChain);
108
109     if (!eval) {
110         if (!callerCodeBlock->isStrictMode()) {
111             // FIXME: We can use the preparser in strict mode, we just need additional logic
112             // to prevent duplicates.
113             if (programSource.is8Bit()) {
114                 LiteralParser<LChar> preparser(callFrame, programSource.characters8(), programSource.length(), NonStrictJSON);
115                 if (JSValue parsedObject = preparser.tryLiteralParse())
116                     return parsedObject;
117             } else {
118                 LiteralParser<UChar> preparser(callFrame, programSource.characters16(), programSource.length(), NonStrictJSON);
119                 if (JSValue parsedObject = preparser.tryLiteralParse())
120                     return parsedObject;                
121             }
122         }
123         
124         // If the literal parser bailed, it should not have thrown exceptions.
125         ASSERT(!callFrame->vm().exception());
126
127         eval = callerCodeBlock->evalCodeCache().getSlow(callFrame, callerCodeBlock->ownerExecutable(), callerCodeBlock->isStrictMode(), programSource, callerScopeChain);
128         if (!eval)
129             return jsUndefined();
130     }
131
132     JSValue thisValue = callerFrame->thisValue();
133     Interpreter* interpreter = callFrame->vm().interpreter;
134     return interpreter->execute(eval, callFrame, thisValue, callerScopeChain);
135 }
136
137 unsigned sizeOfVarargs(CallFrame* callFrame, JSValue arguments, uint32_t firstVarArgOffset)
138 {
139     unsigned length;
140     if (!arguments)
141         length = callFrame->argumentCount();
142     else if (arguments.isUndefinedOrNull())
143         length = 0;
144     else if (!arguments.isObject()) {
145         callFrame->vm().throwException(callFrame, createInvalidParameterError(callFrame, "Function.prototype.apply", arguments));
146         return 0;
147     } else if (asObject(arguments)->classInfo() == Arguments::info())
148         length = asArguments(arguments)->length(callFrame);
149     else if (isJSArray(arguments))
150         length = asArray(arguments)->length();
151     else
152         length = asObject(arguments)->get(callFrame, callFrame->propertyNames().length).toUInt32(callFrame);
153     
154     if (length >= firstVarArgOffset)
155         length -= firstVarArgOffset;
156     else
157         length = 0;
158     
159     return length;
160 }
161
162 unsigned sizeFrameForVarargs(CallFrame* callFrame, JSStack* stack, JSValue arguments, unsigned numUsedStackSlots, uint32_t firstVarArgOffset)
163 {
164     unsigned length = sizeOfVarargs(callFrame, arguments, firstVarArgOffset);
165     
166     CallFrame* calleeFrame = calleeFrameForVarargs(callFrame, numUsedStackSlots, length + 1);
167     if (length > Arguments::MaxArguments || !stack->ensureCapacityFor(calleeFrame->registers())) {
168         throwStackOverflowError(callFrame);
169         return 0;
170     }
171     
172     return length;
173 }
174
175 void loadVarargs(CallFrame* callFrame, VirtualRegister firstElementDest, JSValue arguments, uint32_t offset, uint32_t length)
176 {
177     if (!arguments) { // f.apply(x, arguments), with arguments unmodified.
178         for (size_t i = 0; i < length; ++i)
179             callFrame->r(firstElementDest + i) = callFrame->argumentAfterCapture(i + offset);
180         return;
181     }
182     
183     if (arguments.isUndefinedOrNull())
184         return;
185     
186     if (asObject(arguments)->classInfo() == Arguments::info()) {
187         asArguments(arguments)->copyToArguments(callFrame, firstElementDest, offset, length);
188         return;
189     }
190     
191     if (isJSArray(arguments)) {
192         asArray(arguments)->copyToArguments(callFrame, firstElementDest, offset, length);
193         return;
194     }
195     
196     for (unsigned i = 0; i < length; ++i) {
197         callFrame->r(firstElementDest + i) = asObject(arguments)->get(callFrame, i + offset);
198         if (UNLIKELY(callFrame->vm().exception()))
199             return;
200     }
201 }
202
203 void setupVarargsFrame(CallFrame* callFrame, CallFrame* newCallFrame, JSValue arguments, uint32_t offset, uint32_t length)
204 {
205     VirtualRegister calleeFrameOffset(newCallFrame - callFrame);
206     
207     loadVarargs(
208         callFrame,
209         calleeFrameOffset + CallFrame::argumentOffset(0),
210         arguments, offset, length);
211     
212     newCallFrame->setArgumentCountIncludingThis(length + 1);
213 }
214
215 void setupVarargsFrameAndSetThis(CallFrame* callFrame, CallFrame* newCallFrame, JSValue thisValue, JSValue arguments, uint32_t firstVarArgOffset, uint32_t length)
216 {
217     setupVarargsFrame(callFrame, newCallFrame, arguments, firstVarArgOffset, length);
218     newCallFrame->setThisValue(thisValue);
219 }
220
221 Interpreter::Interpreter(VM& vm)
222     : m_sampleEntryDepth(0)
223     , m_vm(vm)
224     , m_stack(vm)
225     , m_errorHandlingModeReentry(0)
226 #if !ASSERT_DISABLED
227     , m_initialized(false)
228 #endif
229 {
230 }
231
232 Interpreter::~Interpreter()
233 {
234 }
235
236 void Interpreter::initialize(bool canUseJIT)
237 {
238     UNUSED_PARAM(canUseJIT);
239
240 #if ENABLE(COMPUTED_GOTO_OPCODES)
241     m_opcodeTable = LLInt::opcodeMap();
242     for (int i = 0; i < numOpcodeIDs; ++i)
243         m_opcodeIDTable.add(m_opcodeTable[i], static_cast<OpcodeID>(i));
244 #endif
245
246 #if !ASSERT_DISABLED
247     m_initialized = true;
248 #endif
249
250 #if ENABLE(OPCODE_SAMPLING)
251     enableSampler();
252 #endif
253 }
254
255 #ifdef NDEBUG
256
257 void Interpreter::dumpCallFrame(CallFrame*)
258 {
259 }
260
261 #else
262
263 void Interpreter::dumpCallFrame(CallFrame* callFrame)
264 {
265     callFrame->codeBlock()->dumpBytecode();
266     dumpRegisters(callFrame);
267 }
268
269 class DumpRegisterFunctor {
270 public:
271     DumpRegisterFunctor(const Register*& it)
272         : m_hasSkippedFirstFrame(false)
273         , m_it(it)
274     {
275     }
276
277     StackVisitor::Status operator()(StackVisitor& visitor)
278     {
279         if (!m_hasSkippedFirstFrame) {
280             m_hasSkippedFirstFrame = true;
281             return StackVisitor::Continue;
282         }
283
284         unsigned line = 0;
285         unsigned unusedColumn = 0;
286         visitor->computeLineAndColumn(line, unusedColumn);
287         dataLogF("[ReturnVPC]                | %10p | %d (line %d)\n", m_it, visitor->bytecodeOffset(), line);
288         --m_it;
289         return StackVisitor::Done;
290     }
291
292 private:
293     bool m_hasSkippedFirstFrame;
294     const Register*& m_it;
295 };
296
297 void Interpreter::dumpRegisters(CallFrame* callFrame)
298 {
299     dataLogF("Register frame: \n\n");
300     dataLogF("-----------------------------------------------------------------------------\n");
301     dataLogF("            use            |   address  |                value               \n");
302     dataLogF("-----------------------------------------------------------------------------\n");
303
304     CodeBlock* codeBlock = callFrame->codeBlock();
305     const Register* it;
306     const Register* end;
307
308     it = callFrame->registers() + JSStack::ThisArgument + callFrame->argumentCount();
309     end = callFrame->registers() + JSStack::ThisArgument - 1;
310     while (it > end) {
311         JSValue v = it->jsValue();
312         int registerNumber = it - callFrame->registers();
313         String name = codeBlock->nameForRegister(VirtualRegister(registerNumber));
314         dataLogF("[r% 3d %14s]      | %10p | %-16s 0x%lld \n", registerNumber, name.ascii().data(), it, toCString(v).data(), (long long)JSValue::encode(v));
315         --it;
316     }
317     
318     dataLogF("-----------------------------------------------------------------------------\n");
319     dataLogF("[ArgumentCount]            | %10p | %lu \n", it, (unsigned long) callFrame->argumentCount());
320     --it;
321     dataLogF("[CallerFrame]              | %10p | %p \n", it, callFrame->callerFrame());
322     --it;
323     dataLogF("[Callee]                   | %10p | %p \n", it, callFrame->callee());
324     --it;
325     // FIXME: Remove the next decrement when the ScopeChain slot is removed from the call header
326     --it;
327 #if ENABLE(JIT)
328     AbstractPC pc = callFrame->abstractReturnPC(callFrame->vm());
329     if (pc.hasJITReturnAddress())
330         dataLogF("[ReturnJITPC]              | %10p | %p \n", it, pc.jitReturnAddress().value());
331 #endif
332
333     DumpRegisterFunctor functor(it);
334     callFrame->iterate(functor);
335
336     dataLogF("[CodeBlock]                | %10p | %p \n", it, callFrame->codeBlock());
337     --it;
338     dataLogF("-----------------------------------------------------------------------------\n");
339
340     end = it - codeBlock->m_numVars;
341     if (it != end) {
342         do {
343             JSValue v = it->jsValue();
344             int registerNumber = it - callFrame->registers();
345             String name = codeBlock->nameForRegister(VirtualRegister(registerNumber));
346             dataLogF("[r% 3d %14s]      | %10p | %-16s 0x%lld \n", registerNumber, name.ascii().data(), it, toCString(v).data(), (long long)JSValue::encode(v));
347             --it;
348         } while (it != end);
349     }
350     dataLogF("-----------------------------------------------------------------------------\n");
351
352     end = it - codeBlock->m_numCalleeRegisters + codeBlock->m_numVars;
353     if (it != end) {
354         do {
355             JSValue v = (*it).jsValue();
356             int registerNumber = it - callFrame->registers();
357             dataLogF("[r% 3d]                     | %10p | %-16s 0x%lld \n", registerNumber, it, toCString(v).data(), (long long)JSValue::encode(v));
358             --it;
359         } while (it != end);
360     }
361     dataLogF("-----------------------------------------------------------------------------\n");
362 }
363
364 #endif
365
366 bool Interpreter::isOpcode(Opcode opcode)
367 {
368 #if ENABLE(COMPUTED_GOTO_OPCODES)
369     return opcode != HashTraits<Opcode>::emptyValue()
370         && !HashTraits<Opcode>::isDeletedValue(opcode)
371         && m_opcodeIDTable.contains(opcode);
372 #else
373     return opcode >= 0 && opcode <= op_end;
374 #endif
375 }
376
377 static bool unwindCallFrame(StackVisitor& visitor)
378 {
379     CallFrame* callFrame = visitor->callFrame();
380     if (Debugger* debugger = callFrame->vmEntryGlobalObject()->debugger()) {
381         ClearExceptionScope scope(&callFrame->vm());
382         if (jsDynamicCast<JSFunction*>(callFrame->callee()))
383             debugger->returnEvent(callFrame);
384         else
385             debugger->didExecuteProgram(callFrame);
386         ASSERT(!callFrame->hadException());
387     }
388
389     if (CodeBlock* codeBlock = visitor->codeBlock()) {
390         if (codeBlock->codeType() == FunctionCode && codeBlock->needsActivation()) {
391 #if ENABLE(DFG_JIT)
392             RELEASE_ASSERT(!visitor->isInlinedFrame());
393 #endif
394         }
395
396         if (codeBlock->codeType() == FunctionCode && codeBlock->usesArguments()) {
397             if (Arguments* arguments = visitor->existingArguments()) {
398 #if ENABLE(DFG_JIT)
399                 if (visitor->isInlinedFrame())
400                     arguments->tearOff(callFrame, visitor->inlineCallFrame());
401                 else
402 #endif
403                     arguments->tearOff(callFrame);
404             }
405         }
406     }
407
408     return !visitor->callerIsVMEntryFrame();
409 }
410
411 static StackFrameCodeType getStackFrameCodeType(StackVisitor& visitor)
412 {
413     switch (visitor->codeType()) {
414     case StackVisitor::Frame::Eval:
415         return StackFrameEvalCode;
416     case StackVisitor::Frame::Function:
417         return StackFrameFunctionCode;
418     case StackVisitor::Frame::Global:
419         return StackFrameGlobalCode;
420     case StackVisitor::Frame::Native:
421         ASSERT_NOT_REACHED();
422         return StackFrameNativeCode;
423     }
424     RELEASE_ASSERT_NOT_REACHED();
425     return StackFrameGlobalCode;
426 }
427
428 void StackFrame::computeLineAndColumn(unsigned& line, unsigned& column)
429 {
430     if (!codeBlock) {
431         line = 0;
432         column = 0;
433         return;
434     }
435
436     int divot = 0;
437     int unusedStartOffset = 0;
438     int unusedEndOffset = 0;
439     unsigned divotLine = 0;
440     unsigned divotColumn = 0;
441     expressionInfo(divot, unusedStartOffset, unusedEndOffset, divotLine, divotColumn);
442
443     line = divotLine + lineOffset;
444     column = divotColumn + (divotLine ? 1 : firstLineColumnOffset);
445 }
446
447 void StackFrame::expressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column)
448 {
449     codeBlock->expressionRangeForBytecodeOffset(bytecodeOffset, divot, startOffset, endOffset, line, column);
450     divot += characterOffset;
451 }
452
453 String StackFrame::toString(CallFrame* callFrame)
454 {
455     StringBuilder traceBuild;
456     String functionName = friendlyFunctionName(callFrame);
457     String sourceURL = friendlySourceURL();
458     traceBuild.append(functionName);
459     if (!sourceURL.isEmpty()) {
460         if (!functionName.isEmpty())
461             traceBuild.append('@');
462         traceBuild.append(sourceURL);
463         if (codeType != StackFrameNativeCode) {
464             unsigned line;
465             unsigned column;
466             computeLineAndColumn(line, column);
467
468             traceBuild.append(':');
469             traceBuild.appendNumber(line);
470             traceBuild.append(':');
471             traceBuild.appendNumber(column);
472         }
473     }
474     return traceBuild.toString().impl();
475 }
476
477 class GetStackTraceFunctor {
478 public:
479     GetStackTraceFunctor(VM& vm, Vector<StackFrame>& results, size_t remainingCapacity)
480         : m_vm(vm)
481         , m_results(results)
482         , m_remainingCapacityForFrameCapture(remainingCapacity)
483     {
484     }
485
486     StackVisitor::Status operator()(StackVisitor& visitor)
487     {
488         VM& vm = m_vm;
489         if (m_remainingCapacityForFrameCapture) {
490             if (visitor->isJSFrame() && !visitor->codeBlock()->unlinkedCodeBlock()->isBuiltinFunction()) {
491                 CodeBlock* codeBlock = visitor->codeBlock();
492                 StackFrame s = {
493                     Strong<JSObject>(vm, visitor->callee()),
494                     getStackFrameCodeType(visitor),
495                     Strong<ExecutableBase>(vm, codeBlock->ownerExecutable()),
496                     Strong<UnlinkedCodeBlock>(vm, codeBlock->unlinkedCodeBlock()),
497                     codeBlock->source(),
498                     codeBlock->ownerExecutable()->lineNo(),
499                     codeBlock->firstLineColumnOffset(),
500                     codeBlock->sourceOffset(),
501                     visitor->bytecodeOffset(),
502                     visitor->sourceURL()
503                 };
504                 m_results.append(s);
505             } else {
506                 StackFrame s = { Strong<JSObject>(vm, visitor->callee()), StackFrameNativeCode, Strong<ExecutableBase>(), Strong<UnlinkedCodeBlock>(), 0, 0, 0, 0, 0, String()};
507                 m_results.append(s);
508             }
509     
510             m_remainingCapacityForFrameCapture--;
511             return StackVisitor::Continue;
512         }
513         return StackVisitor::Done;
514     }
515
516 private:
517     VM& m_vm;
518     Vector<StackFrame>& m_results;
519     size_t m_remainingCapacityForFrameCapture;
520 };
521
522 void Interpreter::getStackTrace(Vector<StackFrame>& results, size_t maxStackSize)
523 {
524     VM& vm = m_vm;
525     CallFrame* callFrame = vm.topCallFrame;
526     if (!callFrame)
527         return;
528
529     GetStackTraceFunctor functor(vm, results, maxStackSize);
530     callFrame->iterate(functor);
531 }
532
533 JSString* Interpreter::stackTraceAsString(ExecState* exec, Vector<StackFrame> stackTrace)
534 {
535     // FIXME: JSStringJoiner could be more efficient than StringBuilder here.
536     StringBuilder builder;
537     for (unsigned i = 0; i < stackTrace.size(); i++) {
538         builder.append(String(stackTrace[i].toString(exec)));
539         if (i != stackTrace.size() - 1)
540             builder.append('\n');
541     }
542     return jsString(&exec->vm(), builder.toString());
543 }
544
545 class GetExceptionHandlerFunctor {
546 public:
547     GetExceptionHandlerFunctor()
548         : m_handler(0)
549     {
550     }
551
552     HandlerInfo* handler() { return m_handler; }
553
554     StackVisitor::Status operator()(StackVisitor& visitor)
555     {
556         CodeBlock* codeBlock = visitor->codeBlock();
557         if (!codeBlock)
558             return StackVisitor::Continue;
559
560         unsigned bytecodeOffset = visitor->bytecodeOffset();
561         m_handler = codeBlock->handlerForBytecodeOffset(bytecodeOffset);
562         if (m_handler)
563             return StackVisitor::Done;
564
565         return StackVisitor::Continue;
566     }
567
568 private:
569     HandlerInfo* m_handler;
570 };
571
572 class UnwindFunctor {
573 public:
574     UnwindFunctor(VMEntryFrame*& vmEntryFrame, CallFrame*& callFrame, bool isTermination, CodeBlock*& codeBlock, HandlerInfo*& handler)
575         : m_vmEntryFrame(vmEntryFrame)
576         , m_callFrame(callFrame)
577         , m_isTermination(isTermination)
578         , m_codeBlock(codeBlock)
579         , m_handler(handler)
580     {
581     }
582
583     StackVisitor::Status operator()(StackVisitor& visitor)
584     {
585         VM& vm = m_callFrame->vm();
586         m_vmEntryFrame = visitor->vmEntryFrame();
587         m_callFrame = visitor->callFrame();
588         m_codeBlock = visitor->codeBlock();
589         unsigned bytecodeOffset = visitor->bytecodeOffset();
590
591         if (m_isTermination || !(m_handler = m_codeBlock ? m_codeBlock->handlerForBytecodeOffset(bytecodeOffset) : nullptr)) {
592             if (!unwindCallFrame(visitor)) {
593                 if (LegacyProfiler* profiler = vm.enabledProfiler())
594                     profiler->exceptionUnwind(m_callFrame);
595                 return StackVisitor::Done;
596             }
597         } else
598             return StackVisitor::Done;
599
600         return StackVisitor::Continue;
601     }
602
603 private:
604     VMEntryFrame*& m_vmEntryFrame;
605     CallFrame*& m_callFrame;
606     bool m_isTermination;
607     CodeBlock*& m_codeBlock;
608     HandlerInfo*& m_handler;
609 };
610
611 NEVER_INLINE HandlerInfo* Interpreter::unwind(VMEntryFrame*& vmEntryFrame, CallFrame*& callFrame, JSValue& exceptionValue)
612 {
613     CodeBlock* codeBlock = callFrame->codeBlock();
614     bool isTermination = false;
615
616     ASSERT(!exceptionValue.isEmpty());
617     ASSERT(!exceptionValue.isCell() || exceptionValue.asCell());
618     // This shouldn't be possible (hence the assertions), but we're already in the slowest of
619     // slow cases, so let's harden against it anyway to be safe.
620     if (exceptionValue.isEmpty() || (exceptionValue.isCell() && !exceptionValue.asCell()))
621         exceptionValue = jsNull();
622
623     if (exceptionValue.isObject())
624         isTermination = isTerminatedExecutionException(asObject(exceptionValue));
625
626     ASSERT(callFrame->vm().exceptionStack().size());
627
628     Debugger* debugger = callFrame->vmEntryGlobalObject()->debugger();
629     if (debugger && debugger->needsExceptionCallbacks()) {
630         // We need to clear the exception and the exception stack here in order to see if a new exception happens.
631         // Afterwards, the values are put back to continue processing this error.
632         ClearExceptionScope scope(&callFrame->vm());
633         // This code assumes that if the debugger is enabled then there is no inlining.
634         // If that assumption turns out to be false then we'll ignore the inlined call
635         // frames.
636         // https://bugs.webkit.org/show_bug.cgi?id=121754
637
638         bool hasHandler;
639         if (isTermination)
640             hasHandler = false;
641         else {
642             GetExceptionHandlerFunctor functor;
643             callFrame->iterate(functor);
644             hasHandler = !!functor.handler();
645         }
646
647         debugger->exception(callFrame, exceptionValue, hasHandler);
648         ASSERT(!callFrame->hadException());
649     }
650
651     // Calculate an exception handler vPC, unwinding call frames as necessary.
652     HandlerInfo* handler = 0;
653     VM& vm = callFrame->vm();
654     ASSERT(callFrame == vm.topCallFrame);
655     UnwindFunctor functor(vmEntryFrame, callFrame, isTermination, codeBlock, handler);
656     callFrame->iterate(functor);
657     if (!handler)
658         return 0;
659
660     if (LegacyProfiler* profiler = vm.enabledProfiler())
661         profiler->exceptionUnwind(callFrame);
662
663     // Unwind the scope chain within the exception handler's call frame.
664     int targetScopeDepth = handler->scopeDepth;
665     if (codeBlock->needsActivation() && callFrame->hasActivation())
666         ++targetScopeDepth;
667
668     int scopeRegisterOffset = codeBlock->scopeRegister().offset();
669     JSScope* scope = callFrame->scope(scopeRegisterOffset);
670     int scopeDelta = scope->depth() - targetScopeDepth;
671     RELEASE_ASSERT(scopeDelta >= 0);
672
673     while (scopeDelta--)
674         scope = scope->next();
675
676     callFrame->setScope(scopeRegisterOffset, scope);
677
678     return handler;
679 }
680
681 static inline JSValue checkedReturn(JSValue returnValue)
682 {
683     ASSERT(returnValue);
684     return returnValue;
685 }
686
687 static inline JSObject* checkedReturn(JSObject* returnValue)
688 {
689     ASSERT(returnValue);
690     return returnValue;
691 }
692
693 class SamplingScope {
694 public:
695     SamplingScope(Interpreter* interpreter)
696         : m_interpreter(interpreter)
697     {
698         interpreter->startSampling();
699     }
700     ~SamplingScope()
701     {
702         m_interpreter->stopSampling();
703     }
704 private:
705     Interpreter* m_interpreter;
706 };
707
708 JSValue Interpreter::execute(ProgramExecutable* program, CallFrame* callFrame, JSObject* thisObj)
709 {
710     SamplingScope samplingScope(this);
711
712     JSScope* scope = thisObj->globalObject();
713     VM& vm = *scope->vm();
714
715     ASSERT(!vm.exception());
716     ASSERT(!vm.isCollectorBusy());
717     RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
718     if (vm.isCollectorBusy())
719         return jsNull();
720
721     if (!vm.isSafeToRecurse())
722         return checkedReturn(throwStackOverflowError(callFrame));
723
724     // First check if the "program" is actually just a JSON object. If so,
725     // we'll handle the JSON object here. Else, we'll handle real JS code
726     // below at failedJSONP.
727
728     Vector<JSONPData> JSONPData;
729     bool parseResult;
730     const String programSource = program->source().toString();
731     if (programSource.isNull())
732         return jsUndefined();
733     if (programSource.is8Bit()) {
734         LiteralParser<LChar> literalParser(callFrame, programSource.characters8(), programSource.length(), JSONP);
735         parseResult = literalParser.tryJSONPParse(JSONPData, scope->globalObject()->globalObjectMethodTable()->supportsRichSourceInfo(scope->globalObject()));
736     } else {
737         LiteralParser<UChar> literalParser(callFrame, programSource.characters16(), programSource.length(), JSONP);
738         parseResult = literalParser.tryJSONPParse(JSONPData, scope->globalObject()->globalObjectMethodTable()->supportsRichSourceInfo(scope->globalObject()));
739     }
740
741     if (parseResult) {
742         JSGlobalObject* globalObject = scope->globalObject();
743         JSValue result;
744         for (unsigned entry = 0; entry < JSONPData.size(); entry++) {
745             Vector<JSONPPathEntry> JSONPPath;
746             JSONPPath.swap(JSONPData[entry].m_path);
747             JSValue JSONPValue = JSONPData[entry].m_value.get();
748             if (JSONPPath.size() == 1 && JSONPPath[0].m_type == JSONPPathEntryTypeDeclare) {
749                 globalObject->addVar(callFrame, JSONPPath[0].m_pathEntryName);
750                 PutPropertySlot slot(globalObject);
751                 globalObject->methodTable()->put(globalObject, callFrame, JSONPPath[0].m_pathEntryName, JSONPValue, slot);
752                 result = jsUndefined();
753                 continue;
754             }
755             JSValue baseObject(globalObject);
756             for (unsigned i = 0; i < JSONPPath.size() - 1; i++) {
757                 ASSERT(JSONPPath[i].m_type != JSONPPathEntryTypeDeclare);
758                 switch (JSONPPath[i].m_type) {
759                 case JSONPPathEntryTypeDot: {
760                     if (i == 0) {
761                         PropertySlot slot(globalObject);
762                         if (!globalObject->getPropertySlot(callFrame, JSONPPath[i].m_pathEntryName, slot)) {
763                             if (entry)
764                                 return callFrame->vm().throwException(callFrame, createUndefinedVariableError(globalObject->globalExec(), JSONPPath[i].m_pathEntryName));
765                             goto failedJSONP;
766                         }
767                         baseObject = slot.getValue(callFrame, JSONPPath[i].m_pathEntryName);
768                     } else
769                         baseObject = baseObject.get(callFrame, JSONPPath[i].m_pathEntryName);
770                     if (callFrame->hadException())
771                         return jsUndefined();
772                     continue;
773                 }
774                 case JSONPPathEntryTypeLookup: {
775                     baseObject = baseObject.get(callFrame, JSONPPath[i].m_pathIndex);
776                     if (callFrame->hadException())
777                         return jsUndefined();
778                     continue;
779                 }
780                 default:
781                     RELEASE_ASSERT_NOT_REACHED();
782                     return jsUndefined();
783                 }
784             }
785             PutPropertySlot slot(baseObject);
786             switch (JSONPPath.last().m_type) {
787             case JSONPPathEntryTypeCall: {
788                 JSValue function = baseObject.get(callFrame, JSONPPath.last().m_pathEntryName);
789                 if (callFrame->hadException())
790                     return jsUndefined();
791                 CallData callData;
792                 CallType callType = getCallData(function, callData);
793                 if (callType == CallTypeNone)
794                     return callFrame->vm().throwException(callFrame, createNotAFunctionError(callFrame, function));
795                 MarkedArgumentBuffer jsonArg;
796                 jsonArg.append(JSONPValue);
797                 JSValue thisValue = JSONPPath.size() == 1 ? jsUndefined(): baseObject;
798                 JSONPValue = JSC::call(callFrame, function, callType, callData, thisValue, jsonArg);
799                 if (callFrame->hadException())
800                     return jsUndefined();
801                 break;
802             }
803             case JSONPPathEntryTypeDot: {
804                 baseObject.put(callFrame, JSONPPath.last().m_pathEntryName, JSONPValue, slot);
805                 if (callFrame->hadException())
806                     return jsUndefined();
807                 break;
808             }
809             case JSONPPathEntryTypeLookup: {
810                 baseObject.putByIndex(callFrame, JSONPPath.last().m_pathIndex, JSONPValue, slot.isStrictMode());
811                 if (callFrame->hadException())
812                     return jsUndefined();
813                 break;
814             }
815             default:
816                 RELEASE_ASSERT_NOT_REACHED();
817                     return jsUndefined();
818             }
819             result = JSONPValue;
820         }
821         return result;
822     }
823 failedJSONP:
824     // If we get here, then we have already proven that the script is not a JSON
825     // object.
826
827     VMEntryScope entryScope(vm, scope->globalObject());
828
829     // Compile source to bytecode if necessary:
830     if (JSObject* error = program->initializeGlobalProperties(vm, callFrame, scope))
831         return checkedReturn(callFrame->vm().throwException(callFrame, error));
832
833     if (JSObject* error = program->prepareForExecution(callFrame, nullptr, scope, CodeForCall))
834         return checkedReturn(callFrame->vm().throwException(callFrame, error));
835
836     ProgramCodeBlock* codeBlock = program->codeBlock();
837
838     if (UNLIKELY(vm.watchdog && vm.watchdog->didFire(callFrame)))
839         return throwTerminatedExecutionException(callFrame);
840
841     ASSERT(codeBlock->numParameters() == 1); // 1 parameter for 'this'.
842
843     ProtoCallFrame protoCallFrame;
844     protoCallFrame.init(codeBlock, JSCallee::create(vm, scope->globalObject(), scope), thisObj, 1);
845
846     if (LegacyProfiler* profiler = vm.enabledProfiler())
847         profiler->willExecute(callFrame, program->sourceURL(), program->lineNo(), program->startColumn());
848
849     // Execute the code:
850     JSValue result;
851     {
852         SamplingTool::CallRecord callRecord(m_sampler.get());
853         Watchdog::Scope watchdogScope(vm.watchdog.get());
854
855         result = program->generatedJITCode()->execute(&vm, &protoCallFrame);
856     }
857
858     if (LegacyProfiler* profiler = vm.enabledProfiler())
859         profiler->didExecute(callFrame, program->sourceURL(), program->lineNo(), program->startColumn());
860
861     return checkedReturn(result);
862 }
863
864 JSValue Interpreter::executeCall(CallFrame* callFrame, JSObject* function, CallType callType, const CallData& callData, JSValue thisValue, const ArgList& args)
865 {
866     VM& vm = callFrame->vm();
867     ASSERT(!callFrame->hadException());
868     ASSERT(!vm.isCollectorBusy());
869     if (vm.isCollectorBusy())
870         return jsNull();
871
872     bool isJSCall = (callType == CallTypeJS);
873     JSScope* scope = nullptr;
874     CodeBlock* newCodeBlock;
875     size_t argsCount = 1 + args.size(); // implicit "this" parameter
876
877     JSGlobalObject* globalObject;
878
879     if (isJSCall) {
880         scope = callData.js.scope;
881         globalObject = scope->globalObject();
882     } else {
883         ASSERT(callType == CallTypeHost);
884         globalObject = function->globalObject();
885     }
886
887     VMEntryScope entryScope(vm, globalObject);
888     if (!vm.isSafeToRecurse())
889         return checkedReturn(throwStackOverflowError(callFrame));
890
891     if (isJSCall) {
892         // Compile the callee:
893         JSObject* compileError = callData.js.functionExecutable->prepareForExecution(callFrame, jsCast<JSFunction*>(function), scope, CodeForCall);
894         if (UNLIKELY(!!compileError)) {
895             return checkedReturn(callFrame->vm().throwException(callFrame, compileError));
896         }
897         newCodeBlock = callData.js.functionExecutable->codeBlockForCall();
898         ASSERT(!!newCodeBlock);
899         newCodeBlock->m_shouldAlwaysBeInlined = false;
900     } else
901         newCodeBlock = 0;
902
903     if (UNLIKELY(vm.watchdog && vm.watchdog->didFire(callFrame)))
904         return throwTerminatedExecutionException(callFrame);
905
906     ProtoCallFrame protoCallFrame;
907     protoCallFrame.init(newCodeBlock, function, thisValue, argsCount, args.data());
908
909     if (LegacyProfiler* profiler = vm.enabledProfiler())
910         profiler->willExecute(callFrame, function);
911
912     JSValue result;
913     {
914         SamplingTool::CallRecord callRecord(m_sampler.get(), !isJSCall);
915         Watchdog::Scope watchdogScope(vm.watchdog.get());
916
917         // Execute the code:
918         if (isJSCall)
919             result = callData.js.functionExecutable->generatedJITCodeForCall()->execute(&vm, &protoCallFrame);
920         else {
921             result = JSValue::decode(vmEntryToNative(reinterpret_cast<void*>(callData.native.function), &vm, &protoCallFrame));
922             if (callFrame->hadException())
923                 result = jsNull();
924         }
925     }
926
927     if (LegacyProfiler* profiler = vm.enabledProfiler())
928         profiler->didExecute(callFrame, function);
929
930     return checkedReturn(result);
931 }
932
933 JSObject* Interpreter::executeConstruct(CallFrame* callFrame, JSObject* constructor, ConstructType constructType, const ConstructData& constructData, const ArgList& args)
934 {
935     VM& vm = callFrame->vm();
936     ASSERT(!callFrame->hadException());
937     ASSERT(!vm.isCollectorBusy());
938     // We throw in this case because we have to return something "valid" but we're
939     // already in an invalid state.
940     if (vm.isCollectorBusy())
941         return checkedReturn(throwStackOverflowError(callFrame));
942
943     bool isJSConstruct = (constructType == ConstructTypeJS);
944     JSScope* scope = nullptr;
945     CodeBlock* newCodeBlock;
946     size_t argsCount = 1 + args.size(); // implicit "this" parameter
947
948     JSGlobalObject* globalObject;
949
950     if (isJSConstruct) {
951         scope = constructData.js.scope;
952         globalObject = scope->globalObject();
953     } else {
954         ASSERT(constructType == ConstructTypeHost);
955         globalObject = constructor->globalObject();
956     }
957
958     VMEntryScope entryScope(vm, globalObject);
959     if (!vm.isSafeToRecurse())
960         return checkedReturn(throwStackOverflowError(callFrame));
961
962     if (isJSConstruct) {
963         // Compile the callee:
964         JSObject* compileError = constructData.js.functionExecutable->prepareForExecution(callFrame, jsCast<JSFunction*>(constructor), scope, CodeForConstruct);
965         if (UNLIKELY(!!compileError)) {
966             return checkedReturn(callFrame->vm().throwException(callFrame, compileError));
967         }
968         newCodeBlock = constructData.js.functionExecutable->codeBlockForConstruct();
969         ASSERT(!!newCodeBlock);
970         newCodeBlock->m_shouldAlwaysBeInlined = false;
971     } else
972         newCodeBlock = 0;
973
974     if (UNLIKELY(vm.watchdog && vm.watchdog->didFire(callFrame)))
975         return throwTerminatedExecutionException(callFrame);
976
977     ProtoCallFrame protoCallFrame;
978     protoCallFrame.init(newCodeBlock, constructor, jsUndefined(), argsCount, args.data());
979
980     if (LegacyProfiler* profiler = vm.enabledProfiler())
981         profiler->willExecute(callFrame, constructor);
982
983     JSValue result;
984     {
985         SamplingTool::CallRecord callRecord(m_sampler.get(), !isJSConstruct);
986         Watchdog::Scope watchdogScope(vm.watchdog.get());
987
988         // Execute the code.
989         if (isJSConstruct)
990             result = constructData.js.functionExecutable->generatedJITCodeForConstruct()->execute(&vm, &protoCallFrame);
991         else {
992             result = JSValue::decode(vmEntryToNative(reinterpret_cast<void*>(constructData.native.function), &vm, &protoCallFrame));
993
994             if (!callFrame->hadException())
995                 RELEASE_ASSERT(result.isObject());
996         }
997     }
998
999     if (LegacyProfiler* profiler = vm.enabledProfiler())
1000         profiler->didExecute(callFrame, constructor);
1001
1002     if (callFrame->hadException())
1003         return 0;
1004     ASSERT(result.isObject());
1005     return checkedReturn(asObject(result));
1006 }
1007
1008 CallFrameClosure Interpreter::prepareForRepeatCall(FunctionExecutable* functionExecutable, CallFrame* callFrame, ProtoCallFrame* protoCallFrame, JSFunction* function, int argumentCountIncludingThis, JSScope* scope, JSValue* args)
1009 {
1010     VM& vm = *scope->vm();
1011     ASSERT(!vm.exception());
1012     
1013     if (vm.isCollectorBusy())
1014         return CallFrameClosure();
1015
1016     // Compile the callee:
1017     JSObject* error = functionExecutable->prepareForExecution(callFrame, function, scope, CodeForCall);
1018     if (error) {
1019         callFrame->vm().throwException(callFrame, error);
1020         return CallFrameClosure();
1021     }
1022     CodeBlock* newCodeBlock = functionExecutable->codeBlockForCall();
1023     newCodeBlock->m_shouldAlwaysBeInlined = false;
1024
1025     size_t argsCount = argumentCountIncludingThis;
1026
1027     protoCallFrame->init(newCodeBlock, function, jsUndefined(), argsCount, args);
1028     // Return the successful closure:
1029     CallFrameClosure result = { callFrame, protoCallFrame, function, functionExecutable, &vm, scope, newCodeBlock->numParameters(), argumentCountIncludingThis };
1030     return result;
1031 }
1032
1033 JSValue Interpreter::execute(CallFrameClosure& closure) 
1034 {
1035     VM& vm = *closure.vm;
1036     SamplingScope samplingScope(this);
1037     
1038     ASSERT(!vm.isCollectorBusy());
1039     RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
1040     if (vm.isCollectorBusy())
1041         return jsNull();
1042
1043     StackStats::CheckPoint stackCheckPoint;
1044
1045     if (LegacyProfiler* profiler = vm.enabledProfiler())
1046         profiler->willExecute(closure.oldCallFrame, closure.function);
1047
1048     if (UNLIKELY(vm.watchdog && vm.watchdog->didFire(closure.oldCallFrame)))
1049         return throwTerminatedExecutionException(closure.oldCallFrame);
1050
1051     // Execute the code:
1052     JSValue result;
1053     {
1054         SamplingTool::CallRecord callRecord(m_sampler.get());
1055         Watchdog::Scope watchdogScope(vm.watchdog.get());
1056
1057         result = closure.functionExecutable->generatedJITCodeForCall()->execute(&vm, closure.protoCallFrame);
1058     }
1059
1060     if (LegacyProfiler* profiler = vm.enabledProfiler())
1061         profiler->didExecute(closure.oldCallFrame, closure.function);
1062
1063     return checkedReturn(result);
1064 }
1065
1066 JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSValue thisValue, JSScope* scope)
1067 {
1068     VM& vm = *scope->vm();
1069     SamplingScope samplingScope(this);
1070     
1071     ASSERT(scope->vm() == &callFrame->vm());
1072     ASSERT(!vm.exception());
1073     ASSERT(!vm.isCollectorBusy());
1074     RELEASE_ASSERT(vm.currentThreadIsHoldingAPILock());
1075     if (vm.isCollectorBusy())
1076         return jsNull();
1077
1078     VMEntryScope entryScope(vm, scope->globalObject());
1079     if (!vm.isSafeToRecurse())
1080         return checkedReturn(throwStackOverflowError(callFrame));        
1081
1082     unsigned numVariables = eval->numVariables();
1083     int numFunctions = eval->numberOfFunctionDecls();
1084
1085     JSScope* variableObject;
1086     if ((numVariables || numFunctions) && eval->isStrictMode()) {
1087         scope = StrictEvalActivation::create(callFrame, scope);
1088         variableObject = scope;
1089     } else {
1090         for (JSScope* node = scope; ; node = node->next()) {
1091             RELEASE_ASSERT(node);
1092             if (node->isVariableObject()) {
1093                 ASSERT(!node->isNameScopeObject());
1094                 variableObject = node;
1095                 break;
1096             }
1097         }
1098     }
1099
1100     JSObject* compileError = eval->prepareForExecution(callFrame, nullptr, scope, CodeForCall);
1101     if (UNLIKELY(!!compileError))
1102         return checkedReturn(callFrame->vm().throwException(callFrame, compileError));
1103     EvalCodeBlock* codeBlock = eval->codeBlock();
1104
1105     if (numVariables || numFunctions) {
1106         BatchedTransitionOptimizer optimizer(vm, variableObject);
1107         if (variableObject->next())
1108             variableObject->globalObject()->varInjectionWatchpoint()->fireAll("Executed eval, fired VarInjection watchpoint");
1109
1110         for (unsigned i = 0; i < numVariables; ++i) {
1111             const Identifier& ident = codeBlock->variable(i);
1112             if (!variableObject->hasProperty(callFrame, ident)) {
1113                 PutPropertySlot slot(variableObject);
1114                 variableObject->methodTable()->put(variableObject, callFrame, ident, jsUndefined(), slot);
1115             }
1116         }
1117
1118         for (int i = 0; i < numFunctions; ++i) {
1119             FunctionExecutable* function = codeBlock->functionDecl(i);
1120             PutPropertySlot slot(variableObject);
1121             variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot);
1122         }
1123     }
1124
1125     if (UNLIKELY(vm.watchdog && vm.watchdog->didFire(callFrame)))
1126         return throwTerminatedExecutionException(callFrame);
1127
1128     ASSERT(codeBlock->numParameters() == 1); // 1 parameter for 'this'.
1129
1130     ProtoCallFrame protoCallFrame;
1131     protoCallFrame.init(codeBlock, JSCallee::create(vm, scope->globalObject(), scope), thisValue, 1);
1132
1133     if (LegacyProfiler* profiler = vm.enabledProfiler())
1134         profiler->willExecute(callFrame, eval->sourceURL(), eval->lineNo(), eval->startColumn());
1135
1136     // Execute the code:
1137     JSValue result;
1138     {
1139         SamplingTool::CallRecord callRecord(m_sampler.get());
1140         Watchdog::Scope watchdogScope(vm.watchdog.get());
1141
1142         result = eval->generatedJITCode()->execute(&vm, &protoCallFrame);
1143     }
1144
1145     if (LegacyProfiler* profiler = vm.enabledProfiler())
1146         profiler->didExecute(callFrame, eval->sourceURL(), eval->lineNo(), eval->startColumn());
1147
1148     return checkedReturn(result);
1149 }
1150
1151 NEVER_INLINE void Interpreter::debug(CallFrame* callFrame, DebugHookID debugHookID)
1152 {
1153     Debugger* debugger = callFrame->vmEntryGlobalObject()->debugger();
1154     if (!debugger)
1155         return;
1156
1157     ASSERT(callFrame->codeBlock()->hasDebuggerRequests());
1158     ASSERT(!callFrame->hadException());
1159
1160     switch (debugHookID) {
1161         case DidEnterCallFrame:
1162             debugger->callEvent(callFrame);
1163             break;
1164         case WillLeaveCallFrame:
1165             debugger->returnEvent(callFrame);
1166             break;
1167         case WillExecuteStatement:
1168             debugger->atStatement(callFrame);
1169             break;
1170         case WillExecuteProgram:
1171             debugger->willExecuteProgram(callFrame);
1172             break;
1173         case DidExecuteProgram:
1174             debugger->didExecuteProgram(callFrame);
1175             break;
1176         case DidReachBreakpoint:
1177             debugger->didReachBreakpoint(callFrame);
1178             break;
1179     }
1180     ASSERT(!callFrame->hadException());
1181 }    
1182
1183 void Interpreter::enableSampler()
1184 {
1185 #if ENABLE(OPCODE_SAMPLING)
1186     if (!m_sampler) {
1187         m_sampler = std::make_unique<SamplingTool>(this);
1188         m_sampler->setup();
1189     }
1190 #endif
1191 }
1192 void Interpreter::dumpSampleData(ExecState* exec)
1193 {
1194 #if ENABLE(OPCODE_SAMPLING)
1195     if (m_sampler)
1196         m_sampler->dump(exec);
1197 #else
1198     UNUSED_PARAM(exec);
1199 #endif
1200 }
1201 void Interpreter::startSampling()
1202 {
1203 #if ENABLE(SAMPLING_THREAD)
1204     if (!m_sampleEntryDepth)
1205         SamplingThread::start();
1206
1207     m_sampleEntryDepth++;
1208 #endif
1209 }
1210 void Interpreter::stopSampling()
1211 {
1212 #if ENABLE(SAMPLING_THREAD)
1213     m_sampleEntryDepth--;
1214     if (!m_sampleEntryDepth)
1215         SamplingThread::stop();
1216 #endif
1217 }
1218
1219 } // namespace JSC