X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/6fe7ccc865dc7d7541b93c5bcaf6368d2c98a174..2656c66b5b30d5597e842a751c7f19ad6c2fe31a:/bytecode/StructureSet.h?ds=sidebyside diff --git a/bytecode/StructureSet.h b/bytecode/StructureSet.h index bfc30fc..d7087b9 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 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,9 +26,11 @@ #ifndef StructureSet_h #define StructureSet_h -#include "PredictedType.h" +#include "ArrayProfile.h" +#include "SpeculatedType.h" #include "Structure.h" -#include +#include "DumpContext.h" +#include #include namespace JSC { @@ -43,6 +45,7 @@ public: StructureSet(Structure* structure) { + ASSERT(structure); m_structures.append(structure); } @@ -53,6 +56,7 @@ public: void add(Structure* structure) { + ASSERT(structure); ASSERT(!contains(structure)); m_structures.append(structure); } @@ -90,6 +94,13 @@ public: 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) { @@ -104,15 +115,23 @@ public: return other.isSubsetOf(*this); } - size_t size() const { return m_structures.size(); } - - bool allAreUsingInlinePropertyStorage() const + bool overlaps(const StructureSet& other) const { for (size_t i = 0; i < m_structures.size(); ++i) { - if (!m_structures[i]->isUsingInlineStorage()) - return false; + if (other.contains(m_structures[i])) + return true; } - return true; + return false; + } + + 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); } @@ -121,12 +140,22 @@ public: Structure* last() const { return m_structures.last(); } - PredictedType predictionFromStructures() const + 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 { - PredictedType result = PredictNone; + ArrayModes result = 0; for (size_t i = 0; i < m_structures.size(); ++i) - mergePrediction(result, predictionFromStructure(m_structures[i])); + mergeArrayModes(result, asArrayModes(m_structures[i]->indexingType())); return result; } @@ -144,15 +173,18 @@ public: return true; } - void dump(FILE* out) + void dumpInContext(PrintStream& out, DumpContext* context) const { - fprintf(out, "["); - for (size_t i = 0; i < m_structures.size(); ++i) { - if (i) - fprintf(out, ", "); - fprintf(out, "%p", m_structures[i]); - } - fprintf(out, "]"); + 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 + { + dumpInContext(out, 0); } private: