diff options
author | Konstantin Tokarev <annulen@yandex.ru> | 2016-08-25 19:20:41 +0300 |
---|---|---|
committer | Konstantin Tokarev <annulen@yandex.ru> | 2017-02-02 12:30:55 +0000 |
commit | 6882a04fb36642862b11efe514251d32070c3d65 (patch) | |
tree | b7959826000b061fd5ccc7512035c7478742f7b0 /Source/JavaScriptCore/interpreter/JSStack.h | |
parent | ab6df191029eeeb0b0f16f127d553265659f739e (diff) | |
download | qtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz |
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f
Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/JavaScriptCore/interpreter/JSStack.h')
-rw-r--r-- | Source/JavaScriptCore/interpreter/JSStack.h | 149 |
1 files changed, 71 insertions, 78 deletions
diff --git a/Source/JavaScriptCore/interpreter/JSStack.h b/Source/JavaScriptCore/interpreter/JSStack.h index fe4012d83..770db0920 100644 --- a/Source/JavaScriptCore/interpreter/JSStack.h +++ b/Source/JavaScriptCore/interpreter/JSStack.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2009, 2013, 2014 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 Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple 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. * @@ -35,124 +35,117 @@ #include <wtf/PageReservation.h> #include <wtf/VMTags.h> -#if !defined(NDEBUG) && !defined(ENABLE_DEBUG_JSSTACK) -#define ENABLE_DEBUG_JSSTACK 1 -#endif - namespace JSC { + class CodeBlockSet; class ConservativeRoots; - class DFGCodeBlocks; class ExecState; class JITStubRoutineSet; class VM; class LLIntOffsetsExtractor; + struct Instruction; + typedef ExecState CallFrame; + + struct CallerFrameAndPC { + CallFrame* callerFrame; + Instruction* pc; + }; + class JSStack { WTF_MAKE_NONCOPYABLE(JSStack); public: enum CallFrameHeaderEntry { - CallFrameHeaderSize = 6, - - ArgumentCount = -6, - CallerFrame = -5, - Callee = -4, - ScopeChain = -3, - ReturnPC = -2, // This is either an Instruction* or a pointer into JIT generated code stored as an Instruction*. - CodeBlock = -1, + CallerFrameAndPCSize = sizeof(CallerFrameAndPC) / sizeof(Register), + CodeBlock = CallerFrameAndPCSize, + Callee, + ArgumentCount, + CallFrameHeaderSize, + + // The following entries are not part of the CallFrameHeader but are provided here as a convenience: + ThisArgument = CallFrameHeaderSize, + FirstArgument, }; - static const size_t defaultCapacity = 512 * 1024; - static const size_t commitSize = 16 * 1024; // Allow 8k of excess registers before we start trying to reap the stack static const ptrdiff_t maxExcessCapacity = 8 * 1024; - JSStack(VM&, size_t capacity = defaultCapacity); - ~JSStack(); + JSStack(VM&); - void gatherConservativeRoots(ConservativeRoots&); - void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, DFGCodeBlocks&); - - Register* begin() const { return static_cast<Register*>(m_reservation.base()); } - Register* end() const { return m_end; } - size_t size() const { return end() - begin(); } + bool ensureCapacityFor(Register* newTopOfStack); - bool grow(Register*); - + bool containsAddress(Register* address) { return (lowAddress() <= address && address < highAddress()); } static size_t committedByteCount(); - static void initializeThreading(); - Register* const * addressOfEnd() const - { - return &m_end; - } +#if ENABLE(JIT) + void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&) { } + void sanitizeStack() { } +#else + ~JSStack(); - Register* getTopOfFrame(CallFrame*); - Register* getStartOfFrame(CallFrame*); - Register* getTopOfStack(); + void gatherConservativeRoots(ConservativeRoots&, JITStubRoutineSet&, CodeBlockSet&); + void sanitizeStack(); - CallFrame* pushFrame(CallFrame* callerFrame, class CodeBlock*, - JSScope*, int argsCount, JSObject* callee); + Register* baseOfStack() const + { + return highAddress() - 1; + } - void popFrame(CallFrame*); + size_t size() const { return highAddress() - lowAddress(); } - void enableErrorStackReserve(); - void disableErrorStackReserve(); + void setReservedZoneSize(size_t); -#if ENABLE(DEBUG_JSSTACK) - void installFence(CallFrame*, const char *function = "", int lineNo = 0); - void validateFence(CallFrame*, const char *function = "", int lineNo = 0); - static const int FenceSize = 4; -#else // !ENABLE(DEBUG_JSSTACK) - void installFence(CallFrame*, const char* = "", int = 0) { } - void validateFence(CallFrame*, const char* = "", int = 0) { } -#endif // !ENABLE(DEBUG_JSSTACK) + inline Register* topOfStack(); +#endif // ENABLE(JIT) private: - Register* reservationEnd() const + +#if !ENABLE(JIT) + Register* lowAddress() const { - char* base = static_cast<char*>(m_reservation.base()); - char* reservationEnd = base + m_reservation.size(); - return reinterpret_cast_ptr<Register*>(reservationEnd); + return m_end + 1; } -#if ENABLE(DEBUG_JSSTACK) - static JSValue generateFenceValue(size_t argIndex); - void installTrapsAfterFrame(CallFrame*); + Register* highAddress() const + { + return reinterpret_cast_ptr<Register*>(static_cast<char*>(m_reservation.base()) + m_reservation.size()); + } #else - void installTrapsAfterFrame(CallFrame*) { } -#endif + Register* lowAddress() const; + Register* highAddress() const; +#endif // !ENABLE(JIT) + +#if !ENABLE(JIT) + inline Register* topOfFrameFor(CallFrame*); + + Register* reservationTop() const + { + char* reservationTop = static_cast<char*>(m_reservation.base()); + return reinterpret_cast_ptr<Register*>(reservationTop); + } - bool growSlowCase(Register*); - void shrink(Register*); + bool grow(Register* newTopOfStack); + bool growSlowCase(Register* newTopOfStack); + void shrink(Register* newTopOfStack); void releaseExcessCapacity(); void addToCommittedByteCount(long); + void setStackLimit(Register* newTopOfStack); +#endif // !ENABLE(JIT) + + VM& m_vm; + CallFrame*& m_topCallFrame; +#if !ENABLE(JIT) Register* m_end; - Register* m_commitEnd; - Register* m_useableEnd; + Register* m_commitTop; PageReservation m_reservation; - CallFrame*& m_topCallFrame; + Register* m_lastStackTop; + ptrdiff_t m_reservedZoneSizeInRegisters; +#endif // !ENABLE(JIT) friend class LLIntOffsetsExtractor; }; - inline void JSStack::shrink(Register* newEnd) - { - if (newEnd >= m_end) - return; - m_end = newEnd; - if (m_end == m_reservation.base() && (m_commitEnd - begin()) >= maxExcessCapacity) - releaseExcessCapacity(); - } - - inline bool JSStack::grow(Register* newEnd) - { - if (newEnd <= m_end) - return true; - return growSlowCase(newEnd); - } - } // namespace JSC #endif // JSStack_h |