bool StructureSet::merge(const StructureSet& other) { if (other.isThin()) { if (other.singleStructure()) return add(other.singleStructure()); return false; } OutOfLineList* list = other.structureList(); if (list->m_length >= 2) { if (isThin()) { OutOfLineList* myNewList = OutOfLineList::create( list->m_length + !!singleStructure()); if (singleStructure()) { myNewList->m_length = 1; myNewList->list()[0] = singleStructure(); } set(myNewList); } bool changed = false; for (unsigned i = 0; i < list->m_length; ++i) changed |= addOutOfLine(list->list()[i]); return changed; } ASSERT(list->m_length); return add(list->list()[0]); }
bool StructureSet::isSubsetOf(const StructureSet& other) const { if (isThin()) { if (!singleStructure()) return true; return other.contains(singleStructure()); } if (other.isThin()) { if (!other.singleStructure()) return false; OutOfLineList* list = structureList(); if (list->m_length >= 2) return false; if (list->list()[0] == other.singleStructure()) return true; return false; } OutOfLineList* list = structureList(); for (unsigned i = 0; i < list->m_length; ++i) { if (!other.containsOutOfLine(list->list()[i])) return false; } return true; }
bool StructureSet::contains(Structure* structure) const { if (isThin()) return singleStructure() == structure; return containsOutOfLine(structure); }
void StructureSet::exclude(const StructureSet& other) { if (other.isThin()) { if (other.singleStructure()) remove(other.singleStructure()); return; } if (isThin()) { if (!singleStructure()) return; if (other.contains(singleStructure())) clear(); return; } OutOfLineList* list = structureList(); for (unsigned i = 0; i < list->m_length; ++i) { if (!other.containsOutOfLine(list->list()[i])) continue; list->list()[i--] = list->list()[--list->m_length]; } if (!list->m_length) clear(); }
WatchpointSet* InlineWatchpointSet::inflateSlow() { ASSERT(isThin()); ASSERT(!isCompilationThread()); WatchpointSet* fat = adoptRef(new WatchpointSet(decodeState(m_data))).leakRef(); WTF::storeStoreFence(); m_data = bitwise_cast<uintptr_t>(fat); return fat; }
WatchpointSet* InlineWatchpointSet::inflateSlow() { ASSERT(isThin()); ASSERT(!isCompilationThread()); WatchpointSet* fat = adoptRef(new WatchpointSet(InitializedBlind)).leakRef(); if (m_data & IsInvalidatedFlag) fat->m_isInvalidated = true; if (m_data & IsWatchedFlag) fat->m_isWatched = true; WTF::storeStoreFence(); m_data = bitwise_cast<uintptr_t>(fat); return fat; }
ArrayModes StructureSet::arrayModesFromStructures() const { if (isThin()) { if (!singleStructure()) return 0; return asArrayModes(singleStructure()->indexingType()); } ArrayModes result = 0; OutOfLineList* list = structureList(); for (unsigned i = 0; i < list->m_length; ++i) mergeArrayModes(result, asArrayModes(list->list()[i]->indexingType())); return result; }
SpeculatedType StructureSet::speculationFromStructures() const { if (isThin()) { if (!singleStructure()) return SpecNone; return speculationFromStructure(singleStructure()); } SpeculatedType result = SpecNone; OutOfLineList* list = structureList(); for (unsigned i = 0; i < list->m_length; ++i) mergeSpeculation(result, speculationFromStructure(list->list()[i])); return result; }
bool StructureSet::add(Structure* structure) { ASSERT(structure); if (isThin()) { if (singleStructure() == structure) return false; if (!singleStructure()) { set(structure); return true; } OutOfLineList* list = OutOfLineList::create(defaultStartingSize); list->m_length = 2; list->list()[0] = singleStructure(); list->list()[1] = structure; set(list); return true; } return addOutOfLine(structure); }
bool StructureSet::remove(Structure* structure) { if (isThin()) { if (singleStructure() == structure) { setEmpty(); return true; } return false; } OutOfLineList* list = structureList(); for (unsigned i = 0; i < list->m_length; ++i) { if (list->list()[i] != structure) continue; list->list()[i] = list->list()[--list->m_length]; if (!list->m_length) { OutOfLineList::destroy(list); setEmpty(); } return true; } return false; }