X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174..ed1e77d3adeb83d26fd1dfb16dd84cabdcefd250:/bytecode/StructureSet.h?ds=inline diff --git a/bytecode/StructureSet.h b/bytecode/StructureSet.h index bfc30fc..df19ec5 100644 --- a/bytecode/StructureSet.h +++ b/bytecode/StructureSet.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Apple Inc. All rights reserved. + * Copyright (C) 2011, 2013-2015 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,139 +26,61 @@ #ifndef StructureSet_h #define StructureSet_h -#include "PredictedType.h" +#include "ArrayProfile.h" +#include "DumpContext.h" +#include "SpeculatedType.h" #include "Structure.h" -#include -#include +#include namespace JSC { +class TrackedReferences; + namespace DFG { class StructureAbstractValue; +struct AbstractValue; } -class StructureSet { +class StructureSet : public TinyPtrSet { public: - StructureSet() { } - - StructureSet(Structure* structure) - { - m_structures.append(structure); - } - - void clear() - { - m_structures.clear(); - } + // I really want to do this: + // using TinyPtrSet::TinyPtrSet; + // + // But I can't because Windows. - void add(Structure* structure) + StructureSet() { - ASSERT(!contains(structure)); - m_structures.append(structure); } - bool addAll(const StructureSet& other) - { - bool changed = false; - for (size_t i = 0; i < other.size(); ++i) { - if (contains(other[i])) - continue; - add(other[i]); - changed = true; - } - return changed; - } - - void remove(Structure* structure) - { - for (size_t i = 0; i < m_structures.size(); ++i) { - if (m_structures[i] != structure) - continue; - - m_structures[i] = m_structures.last(); - m_structures.removeLast(); - return; - } - } - - bool contains(Structure* structure) const - { - for (size_t i = 0; i < m_structures.size(); ++i) { - if (m_structures[i] == structure) - return true; - } - return false; - } - - bool isSubsetOf(const StructureSet& other) const - { - for (size_t i = 0; i < m_structures.size(); ++i) { - if (!other.contains(m_structures[i])) - return false; - } - return true; - } - - bool isSupersetOf(const StructureSet& other) const + StructureSet(Structure* structure) + : TinyPtrSet(structure) { - return other.isSubsetOf(*this); } - size_t size() const { return m_structures.size(); } - - bool allAreUsingInlinePropertyStorage() const + ALWAYS_INLINE StructureSet(const StructureSet& other) + : TinyPtrSet(other) { - for (size_t i = 0; i < m_structures.size(); ++i) { - if (!m_structures[i]->isUsingInlineStorage()) - return false; - } - return true; } - Structure* at(size_t i) const { return m_structures.at(i); } - - Structure* operator[](size_t i) const { return at(i); } - - Structure* last() const { return m_structures.last(); } - - PredictedType predictionFromStructures() const + Structure* onlyStructure() const { - PredictedType result = PredictNone; - - for (size_t i = 0; i < m_structures.size(); ++i) - mergePrediction(result, predictionFromStructure(m_structures[i])); - - return result; + return onlyEntry(); } - bool operator==(const StructureSet& other) const - { - if (m_structures.size() != other.m_structures.size()) - return false; - - for (size_t i = 0; i < m_structures.size(); ++i) { - if (!other.contains(m_structures[i])) - return false; - } - - return true; - } +#if ENABLE(DFG_JIT) + void filter(const DFG::StructureAbstractValue&); + void filter(SpeculatedType); + void filterArrayModes(ArrayModes); + void filter(const DFG::AbstractValue&); +#endif // ENABLE(DFG_JIT) - void dump(FILE* out) - { - fprintf(out, "["); - for (size_t i = 0; i < m_structures.size(); ++i) { - if (i) - fprintf(out, ", "); - fprintf(out, "%p", m_structures[i]); - } - fprintf(out, "]"); - } + SpeculatedType speculationFromStructures() const; + ArrayModes arrayModesFromStructures() const; -private: - friend class DFG::StructureAbstractValue; + void dumpInContext(PrintStream&, DumpContext*) const; + void dump(PrintStream&) const; - Vector m_structures; + void validateReferences(const TrackedReferences&) const; }; } // namespace JSC