summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/bytecode/StructureSet.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/bytecode/StructureSet.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/JavaScriptCore/bytecode/StructureSet.h')
-rw-r--r--Source/JavaScriptCore/bytecode/StructureSet.h157
1 files changed, 19 insertions, 138 deletions
diff --git a/Source/JavaScriptCore/bytecode/StructureSet.h b/Source/JavaScriptCore/bytecode/StructureSet.h
index 4cdcd01cb..8654ca500 100644
--- a/Source/JavaScriptCore/bytecode/StructureSet.h
+++ b/Source/JavaScriptCore/bytecode/StructureSet.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011, 2013 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
@@ -23,165 +23,46 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef StructureSet_h
-#define StructureSet_h
+#pragma once
#include "ArrayProfile.h"
+#include "DumpContext.h"
#include "SpeculatedType.h"
#include "Structure.h"
-#include "DumpContext.h"
-#include <wtf/CommaPrinter.h>
-#include <wtf/Vector.h>
+#include <wtf/TinyPtrSet.h>
namespace JSC {
-namespace DFG {
-class StructureAbstractValue;
-}
+class TrackedReferences;
-class StructureSet {
+class StructureSet : public TinyPtrSet<Structure*> {
public:
- StructureSet() { }
-
- StructureSet(Structure* structure)
- {
- m_structures.append(structure);
- }
-
- void clear()
- {
- m_structures.clear();
- }
-
- void add(Structure* structure)
- {
- 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;
- }
+ // I really want to do this:
+ // using TinyPtrSet::TinyPtrSet;
+ //
+ // But I can't because Windows.
- void remove(Structure* structure)
+ StructureSet()
{
- 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 containsOnly(Structure* structure) const
- {
- if (size() != 1)
- return false;
- return singletonStructure() == structure;
- }
-
- 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
- {
- return other.isSubsetOf(*this);
- }
-
- size_t size() const { return m_structures.size(); }
-
- // Call this if you know that the structure set must consist of exactly
- // one structure.
- Structure* singletonStructure() const
- {
- ASSERT(m_structures.size() == 1);
- return m_structures[0];
- }
-
- 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(); }
-
- SpeculatedType speculationFromStructures() const
- {
- SpeculatedType result = SpecNone;
-
- for (size_t i = 0; i < m_structures.size(); ++i)
- mergeSpeculation(result, speculationFromStructure(m_structures[i]));
-
- return result;
- }
-
- ArrayModes arrayModesFromStructures() const
- {
- ArrayModes result = 0;
-
- for (size_t i = 0; i < m_structures.size(); ++i)
- mergeArrayModes(result, asArrayModes(m_structures[i]->indexingType()));
-
- return result;
- }
-
- bool operator==(const StructureSet& other) const
+ StructureSet(Structure* structure)
+ : TinyPtrSet(structure)
{
- 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;
}
- void dumpInContext(PrintStream& out, DumpContext* context) const
+ ALWAYS_INLINE StructureSet(const StructureSet& other)
+ : TinyPtrSet(other)
{
- CommaPrinter comma;
- out.print("[");
- for (size_t i = 0; i < m_structures.size(); ++i)
- out.print(comma, inContext(*m_structures[i], context));
- out.print("]");
}
- void dump(PrintStream& out) const
+ Structure* onlyStructure() const
{
- dumpInContext(out, 0);
+ return onlyEntry();
}
-private:
- friend class DFG::StructureAbstractValue;
-
- Vector<Structure*, 2> m_structures;
+ void dumpInContext(PrintStream&, DumpContext*) const;
+ void dump(PrintStream&) const;
};
} // namespace JSC
-
-#endif // StructureSet_h