diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/JavaScriptCore/interpreter/Interpreter.h | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/JavaScriptCore/interpreter/Interpreter.h')
-rw-r--r-- | Source/JavaScriptCore/interpreter/Interpreter.h | 154 |
1 files changed, 73 insertions, 81 deletions
diff --git a/Source/JavaScriptCore/interpreter/Interpreter.h b/Source/JavaScriptCore/interpreter/Interpreter.h index aba745f17..cfc721b38 100644 --- a/Source/JavaScriptCore/interpreter/Interpreter.h +++ b/Source/JavaScriptCore/interpreter/Interpreter.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2013, 2015 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2013 Apple Inc. All rights reserved. * Copyright (C) 2012 Research In Motion Limited. All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -11,7 +11,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. * @@ -33,12 +33,12 @@ #include "ArgList.h" #include "JSCJSValue.h" #include "JSCell.h" +#include "JSFunction.h" #include "JSObject.h" #include "JSStack.h" #include "LLIntData.h" #include "Opcode.h" #include "SourceProvider.h" -#include "StackAlignment.h" #include <wtf/HashMap.h> #include <wtf/text/StringBuilder.h> @@ -50,13 +50,9 @@ namespace JSC { class ExecutableBase; class FunctionExecutable; class VM; - class JSFunction; class JSGlobalObject; - class JSModuleEnvironment; - class JSModuleRecord; class LLIntOffsetsExtractor; class ProgramExecutable; - class ModuleProgramExecutable; class Register; class JSScope; class SamplingTool; @@ -65,8 +61,6 @@ namespace JSC { struct Instruction; struct ProtoCallFrame; - enum UnwindStart { UnwindFromCurrentFrame, UnwindFromCallerFrame }; - enum DebugHookID { WillExecuteProgram, DidExecuteProgram, @@ -79,7 +73,6 @@ namespace JSC { enum StackFrameCodeType { StackFrameGlobalCode, StackFrameEvalCode, - StackFrameModuleCode, StackFrameFunctionCode, StackFrameNativeCode }; @@ -87,7 +80,7 @@ namespace JSC { struct StackFrame { Strong<JSObject> callee; StackFrameCodeType codeType; - Strong<ScriptExecutable> executable; + Strong<ExecutableBase> executable; Strong<UnlinkedCodeBlock> codeBlock; RefPtr<SourceProvider> code; int lineOffset; @@ -96,28 +89,65 @@ namespace JSC { unsigned bytecodeOffset; String sourceURL; JS_EXPORT_PRIVATE String toString(CallFrame*); - String friendlySourceURL() const; - String friendlyFunctionName(CallFrame*) const; + String friendlySourceURL() const + { + String traceLine; + + switch (codeType) { + case StackFrameEvalCode: + case StackFrameFunctionCode: + case StackFrameGlobalCode: + if (!sourceURL.isEmpty()) + traceLine = sourceURL.impl(); + break; + case StackFrameNativeCode: + traceLine = "[native code]"; + break; + } + return traceLine.isNull() ? emptyString() : traceLine; + } + String friendlyFunctionName(CallFrame* callFrame) const + { + String traceLine; + JSObject* stackFrameCallee = callee.get(); + + switch (codeType) { + case StackFrameEvalCode: + traceLine = "eval code"; + break; + case StackFrameNativeCode: + if (callee) + traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl(); + break; + case StackFrameFunctionCode: + traceLine = getCalculatedDisplayName(callFrame, stackFrameCallee).impl(); + break; + case StackFrameGlobalCode: + traceLine = "global code"; + break; + } + return traceLine.isNull() ? emptyString() : traceLine; + } JS_EXPORT_PRIVATE void computeLineAndColumn(unsigned& line, unsigned& column); private: void expressionInfo(int& divot, int& startOffset, int& endOffset, unsigned& line, unsigned& column); }; - class SuspendExceptionScope { + class ClearExceptionScope { public: - SuspendExceptionScope(VM* vm) - : m_vm(vm) + ClearExceptionScope(VM* vm): m_vm(vm) { - oldException = vm->exception(); + vm->getExceptionInfo(oldException, oldExceptionStack); vm->clearException(); } - ~SuspendExceptionScope() + ~ClearExceptionScope() { - m_vm->restorePreviousException(oldException); + m_vm->setExceptionInfo(oldException, oldExceptionStack); } private: - Exception* oldException; + JSC::JSValue oldException; + RefCountedArray<JSC::StackFrame> oldExceptionStack; VM* m_vm; }; @@ -127,11 +157,13 @@ namespace JSC { : vm(currentVM) , oldCallFrame(currentVM.topCallFrame) { + ASSERT(!callFrame->isVMEntrySentinel()); currentVM.topCallFrame = callFrame; } ~TopCallFrameSetter() { + ASSERT(!oldCallFrame->isVMEntrySentinel()); vm.topCallFrame = oldCallFrame; } private: @@ -145,36 +177,11 @@ namespace JSC { { ASSERT(vm); ASSERT(callFrame); - ASSERT(callFrame < vm->topVMEntryFrame); + ASSERT(!callFrame->isVMEntrySentinel()); vm->topCallFrame = callFrame; } }; - class NativeCallFrameTracerWithRestore { - public: - ALWAYS_INLINE NativeCallFrameTracerWithRestore(VM* vm, VMEntryFrame* vmEntryFrame, CallFrame* callFrame) - : m_vm(vm) - { - ASSERT(vm); - ASSERT(callFrame); - m_savedTopVMEntryFrame = vm->topVMEntryFrame; - m_savedTopCallFrame = vm->topCallFrame; - vm->topVMEntryFrame = vmEntryFrame; - vm->topCallFrame = callFrame; - } - - ALWAYS_INLINE ~NativeCallFrameTracerWithRestore() - { - m_vm->topVMEntryFrame = m_savedTopVMEntryFrame; - m_vm->topCallFrame = m_savedTopCallFrame; - } - - private: - VM* m_vm; - VMEntryFrame* m_savedTopVMEntryFrame; - CallFrame* m_savedTopCallFrame; - }; - class Interpreter { WTF_MAKE_FAST_ALLOCATED; friend class CachedCall; @@ -183,10 +190,18 @@ namespace JSC { friend class VM; public: + class ErrorHandlingMode { + public: + JS_EXPORT_PRIVATE ErrorHandlingMode(ExecState*); + JS_EXPORT_PRIVATE ~ErrorHandlingMode(); + private: + Interpreter& m_interpreter; + }; + Interpreter(VM &); ~Interpreter(); - void initialize(); + void initialize(bool canUseJIT); JSStack& stack() { return m_stack; } @@ -203,7 +218,7 @@ namespace JSC { OpcodeID getOpcodeID(Opcode opcode) { ASSERT(m_initialized); -#if ENABLE(COMPUTED_GOTO_OPCODES) +#if ENABLE(COMPUTED_GOTO_OPCODES) && ENABLE(LLINT) ASSERT(isOpcode(opcode)); return m_opcodeIDTable.get(opcode); #else @@ -215,16 +230,16 @@ namespace JSC { JSValue execute(ProgramExecutable*, CallFrame*, JSObject* thisObj); JSValue executeCall(CallFrame*, JSObject* function, CallType, const CallData&, JSValue thisValue, const ArgList&); - JSObject* executeConstruct(CallFrame*, JSObject* function, ConstructType, const ConstructData&, const ArgList&, JSValue newTarget); + JSObject* executeConstruct(CallFrame*, JSObject* function, ConstructType, const ConstructData&, const ArgList&); JSValue execute(EvalExecutable*, CallFrame*, JSValue thisValue, JSScope*); - JSValue execute(ModuleProgramExecutable*, CallFrame*, JSModuleEnvironment*); void getArgumentsData(CallFrame*, JSFunction*&, ptrdiff_t& firstParameterIndex, Register*& argv, int& argc); SamplingTool* sampler() { return m_sampler.get(); } - NEVER_INLINE HandlerInfo* unwind(VM&, CallFrame*&, Exception*, UnwindStart); - void notifyDebuggerOfExceptionToBeThrown(CallFrame*, Exception*); + bool isInErrorHandlingMode() { return m_errorHandlingModeReentry; } + + NEVER_INLINE HandlerInfo* unwind(CallFrame*&, JSValue&); NEVER_INLINE void debug(CallFrame*, DebugHookID); JSString* stackTraceAsString(ExecState*, Vector<StackFrame>); @@ -239,8 +254,6 @@ namespace JSC { JS_EXPORT_PRIVATE void dumpCallFrame(CallFrame*); - void getStackTrace(Vector<StackFrame>& results, size_t maxStackSize = std::numeric_limits<size_t>::max()); - private: enum ExecutionFlag { Normal, InitializeAndReturn }; @@ -248,21 +261,21 @@ namespace JSC { JSValue execute(CallFrameClosure&); - + void getStackTrace(Vector<StackFrame>& results, size_t maxStackSize = std::numeric_limits<size_t>::max()); void dumpRegisters(CallFrame*); - bool isCallBytecode(Opcode opcode) { return opcode == getOpcode(op_call) || opcode == getOpcode(op_construct) || opcode == getOpcode(op_call_eval) || opcode == getOpcode(op_tail_call); } + bool isCallBytecode(Opcode opcode) { return opcode == getOpcode(op_call) || opcode == getOpcode(op_construct) || opcode == getOpcode(op_call_eval); } void enableSampler(); int m_sampleEntryDepth; - std::unique_ptr<SamplingTool> m_sampler; + OwnPtr<SamplingTool> m_sampler; VM& m_vm; JSStack m_stack; int m_errorHandlingModeReentry; -#if ENABLE(COMPUTED_GOTO_OPCODES) +#if ENABLE(COMPUTED_GOTO_OPCODES) && ENABLE(LLINT) Opcode* m_opcodeTable; // Maps OpcodeID => Opcode for compiling HashMap<Opcode, OpcodeID> m_opcodeIDTable; // Maps Opcode => OpcodeID for decompiling #endif @@ -273,29 +286,8 @@ namespace JSC { }; JSValue eval(CallFrame*); - - inline CallFrame* calleeFrameForVarargs(CallFrame* callFrame, unsigned numUsedStackSlots, unsigned argumentCountIncludingThis) - { - // We want the new frame to be allocated on a stack aligned offset with a stack - // aligned size. Align the size here. - argumentCountIncludingThis = WTF::roundUpToMultipleOf( - stackAlignmentRegisters(), - argumentCountIncludingThis + JSStack::CallFrameHeaderSize) - JSStack::CallFrameHeaderSize; - - // Align the frame offset here. - unsigned paddedCalleeFrameOffset = WTF::roundUpToMultipleOf( - stackAlignmentRegisters(), - numUsedStackSlots + argumentCountIncludingThis + JSStack::CallFrameHeaderSize); - return CallFrame::create(callFrame->registers() - paddedCalleeFrameOffset); - } - - unsigned sizeOfVarargs(CallFrame* exec, JSValue arguments, uint32_t firstVarArgOffset); - static const unsigned maxArguments = 0x10000; - unsigned sizeFrameForVarargs(CallFrame* exec, JSStack*, JSValue arguments, unsigned numUsedStackSlots, uint32_t firstVarArgOffset); - void loadVarargs(CallFrame* execCaller, VirtualRegister firstElementDest, JSValue source, uint32_t offset, uint32_t length); - void setupVarargsFrame(CallFrame* execCaller, CallFrame* execCallee, JSValue arguments, uint32_t firstVarArgOffset, uint32_t length); - void setupVarargsFrameAndSetThis(CallFrame* execCaller, CallFrame* execCallee, JSValue thisValue, JSValue arguments, uint32_t firstVarArgOffset, uint32_t length); - + CallFrame* sizeAndAllocFrameForVarargs(CallFrame*, JSStack*, JSValue, int); + void loadVarargs(CallFrame*, CallFrame*, JSValue, JSValue); } // namespace JSC #endif // Interpreter_h |