diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/ftl/FTLAbstractHeap.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/ftl/FTLAbstractHeap.h')
-rw-r--r-- | Source/JavaScriptCore/ftl/FTLAbstractHeap.h | 144 |
1 files changed, 63 insertions, 81 deletions
diff --git a/Source/JavaScriptCore/ftl/FTLAbstractHeap.h b/Source/JavaScriptCore/ftl/FTLAbstractHeap.h index e92a2fc2c..ae883a620 100644 --- a/Source/JavaScriptCore/ftl/FTLAbstractHeap.h +++ b/Source/JavaScriptCore/ftl/FTLAbstractHeap.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Apple Inc. All rights reserved. + * Copyright (C) 2013, 2015-2016 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -23,29 +23,22 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef FTLAbstractHeap_h -#define FTLAbstractHeap_h - -#include <wtf/Platform.h> +#pragma once #if ENABLE(FTL_JIT) -#include "FTLAbbreviations.h" +#include "B3HeapRange.h" +#include "FTLAbbreviatedTypes.h" #include "JSCJSValue.h" #include <array> #include <wtf/FastMalloc.h> #include <wtf/HashMap.h> #include <wtf/Noncopyable.h> -#include <wtf/OwnPtr.h> #include <wtf/Vector.h> #include <wtf/text/CString.h> namespace JSC { namespace FTL { -// The FTL JIT tries to aid LLVM's TBAA. The FTL's notion of how this -// happens is the AbstractHeap. AbstractHeaps are a simple type system -// with sub-typing. - class AbstractHeapRepository; class Output; class TypedPointer; @@ -54,132 +47,120 @@ class AbstractHeap { WTF_MAKE_NONCOPYABLE(AbstractHeap); WTF_MAKE_FAST_ALLOCATED; public: AbstractHeap() - : m_parent(0) - , m_heapName(0) - , m_tbaaMetadata(0) - { - } - - AbstractHeap(AbstractHeap* parent, const char* heapName) - : m_parent(parent) - , m_heapName(heapName) - , m_tbaaMetadata(0) { } + AbstractHeap(AbstractHeap* parent, const char* heapName, ptrdiff_t offset = 0); + bool isInitialized() const { return !!m_heapName; } - void initialize(AbstractHeap* parent, const char* heapName) + void initialize(AbstractHeap* parent, const char* heapName, ptrdiff_t offset = 0) { - m_parent = parent; + changeParent(parent); m_heapName = heapName; + m_offset = offset; } + + void changeParent(AbstractHeap* parent); AbstractHeap* parent() const { ASSERT(isInitialized()); return m_parent; } + + const Vector<AbstractHeap*>& children() const; const char* heapName() const { ASSERT(isInitialized()); return m_heapName; } - - LValue tbaaMetadata(const AbstractHeapRepository& repository) const - { - ASSERT(isInitialized()); - if (LIKELY(!!m_tbaaMetadata)) - return m_tbaaMetadata; - return tbaaMetadataSlow(repository); - } - - void decorateInstruction(LValue instruction, const AbstractHeapRepository&) const; -private: - friend class AbstractHeapRepository; - - LValue tbaaMetadataSlow(const AbstractHeapRepository&) const; - - AbstractHeap* m_parent; - const char* m_heapName; - mutable LValue m_tbaaMetadata; -}; - -// Think of "AbstractField" as being an "AbstractHeapWithOffset". I would have named -// it the latter except that I don't like typing that much. -class AbstractField : public AbstractHeap { -public: - AbstractField() - { - } - - AbstractField(AbstractHeap* parent, const char* heapName, ptrdiff_t offset) - : AbstractHeap(parent, heapName) - , m_offset(offset) - { - } - - void initialize(AbstractHeap* parent, const char* heapName, ptrdiff_t offset) + B3::HeapRange range() const { - AbstractHeap::initialize(parent, heapName); - m_offset = offset; + // This will not have a valid value until after all lowering is done. Do associate an + // AbstractHeap with a B3::Value*, use AbstractHeapRepository::decorateXXX(). + if (!m_range) + badRangeError(); + + return m_range; } - + + // WARNING: Not all abstract heaps have a meaningful offset. ptrdiff_t offset() const { ASSERT(isInitialized()); return m_offset; } - + + void compute(unsigned begin = 0); + + // Print information about just this heap. + void shallowDump(PrintStream&) const; + + // Print information about this heap and its ancestors. This is the default. + void dump(PrintStream&) const; + + // Print information about this heap and its descendents. This is a multi-line dump. + void deepDump(PrintStream&, unsigned indent = 0) const; + private: - ptrdiff_t m_offset; + friend class AbstractHeapRepository; + + NO_RETURN_DUE_TO_CRASH void badRangeError() const; + + AbstractHeap* m_parent { nullptr }; + Vector<AbstractHeap*> m_children; + intptr_t m_offset { 0 }; + B3::HeapRange m_range; + const char* m_heapName { nullptr }; }; class IndexedAbstractHeap { public: - IndexedAbstractHeap(LContext, AbstractHeap* parent, const char* heapName, size_t elementSize); + IndexedAbstractHeap(AbstractHeap* parent, const char* heapName, ptrdiff_t offset, size_t elementSize); ~IndexedAbstractHeap(); const AbstractHeap& atAnyIndex() const { return m_heapForAnyIndex; } - const AbstractField& at(ptrdiff_t index) + const AbstractHeap& at(ptrdiff_t index) { if (static_cast<size_t>(index) < m_smallIndices.size()) return returnInitialized(m_smallIndices[index], index); return atSlow(index); } - const AbstractField& operator[](ptrdiff_t index) { return at(index); } + const AbstractHeap& operator[](ptrdiff_t index) { return at(index); } TypedPointer baseIndex(Output& out, LValue base, LValue index, JSValue indexAsConstant = JSValue(), ptrdiff_t offset = 0); + void dump(PrintStream&) const; + private: - const AbstractField& returnInitialized(AbstractField& field, ptrdiff_t index) + const AbstractHeap& returnInitialized(AbstractHeap& field, ptrdiff_t index) { if (UNLIKELY(!field.isInitialized())) initialize(field, index); return field; } - const AbstractField& atSlow(ptrdiff_t index); - void initialize(AbstractField& field, ptrdiff_t index); + const AbstractHeap& atSlow(ptrdiff_t index); + void initialize(AbstractHeap& field, ptrdiff_t index); AbstractHeap m_heapForAnyIndex; size_t m_heapNameLength; + ptrdiff_t m_offset; size_t m_elementSize; - LValue m_scaleTerm; - bool m_canShift; - std::array<AbstractField, 16> m_smallIndices; + std::array<AbstractHeap, 16> m_smallIndices; struct WithoutZeroOrOneHashTraits : WTF::GenericHashTraits<ptrdiff_t> { static void constructDeletedValue(ptrdiff_t& slot) { slot = 1; } static bool isDeletedValue(ptrdiff_t value) { return value == 1; } }; - typedef HashMap<ptrdiff_t, std::unique_ptr<AbstractField>, WTF::IntHash<ptrdiff_t>, WithoutZeroOrOneHashTraits> MapType; + typedef HashMap<ptrdiff_t, std::unique_ptr<AbstractHeap>, WTF::IntHash<ptrdiff_t>, WithoutZeroOrOneHashTraits> MapType; - OwnPtr<MapType> m_largeIndices; + std::unique_ptr<MapType> m_largeIndices; Vector<CString, 16> m_largeIndexNames; }; @@ -190,7 +171,7 @@ private: class NumberedAbstractHeap { public: - NumberedAbstractHeap(LContext, AbstractHeap* parent, const char* heapName); + NumberedAbstractHeap(AbstractHeap* parent, const char* heapName); ~NumberedAbstractHeap(); const AbstractHeap& atAnyNumber() const { return m_indexedHeap.atAnyIndex(); } @@ -198,6 +179,8 @@ public: const AbstractHeap& at(unsigned number) { return m_indexedHeap.at(number); } const AbstractHeap& operator[](unsigned number) { return at(number); } + void dump(PrintStream&) const; + private: // We use the fact that the indexed heap already has a superset of the @@ -207,17 +190,19 @@ private: class AbsoluteAbstractHeap { public: - AbsoluteAbstractHeap(LContext, AbstractHeap* parent, const char* heapName); + AbsoluteAbstractHeap(AbstractHeap* parent, const char* heapName); ~AbsoluteAbstractHeap(); const AbstractHeap& atAnyAddress() const { return m_indexedHeap.atAnyIndex(); } - const AbstractHeap& at(void* address) + const AbstractHeap& at(const void* address) { return m_indexedHeap.at(bitwise_cast<ptrdiff_t>(address)); } - const AbstractHeap& operator[](void* address) { return at(address); } + const AbstractHeap& operator[](const void* address) { return at(address); } + + void dump(PrintStream&) const; private: // The trick here is that the indexed heap is "indexed" by a pointer-width @@ -229,6 +214,3 @@ private: } } // namespace JSC::FTL #endif // ENABLE(FTL_JIT) - -#endif // FTLAbstractHeap_h - |