internal void WidenWith(MemoryAssistantBase assistant) { foreach (var oldData in _oldData) { MemoryEntry widenedEntry = null; MemoryEntry currEntry; REPORT(Statistic.SimpleHashSearches); if (_data.TryGetValue(oldData.Key, out currEntry)) { REPORT(Statistic.MemoryEntryComparisons); if (!currEntry.Equals(oldData.Value)) { //differ in stored data widenedEntry = assistant.Widen(oldData.Value, currEntry); } } else { //differ in presence of some reference REPORT(Statistic.MemoryEntryCreation); widenedEntry = assistant.Widen(new MemoryEntry(_owner.UndefinedValue), currEntry); } if (widenedEntry == null) { //there is no widening continue; } //apply widening _data[oldData.Key] = widenedEntry; } }
/// <summary> /// Widens the data of given memory index in this data container. /// </summary> /// <param name="oldData">The old data.</param> /// <param name="index">The index.</param> /// <param name="assistant">The assistant.</param> public void DataWiden(SnapshotData oldData, MemoryIndex index, MemoryAssistantBase assistant) { MemoryEntry newEntry = null; if (!this.IndexData.TryGetValue(index, out newEntry)) { newEntry = EmptyEntry; } MemoryEntry oldEntry = null; if (!oldData.IndexData.TryGetValue(index, out oldEntry)) { oldEntry = EmptyEntry; } MemoryIndex testIndex = ControlIndex.Create(".return", 6); if (testIndex.Equals(index)) { } if (!oldEntry.Equals(newEntry)) { MemoryEntry widenedEntry = assistant.Widen(oldEntry, newEntry); CollectComposedValuesVisitor newVisitor = new CollectComposedValuesVisitor(); newVisitor.VisitMemoryEntry(newEntry); CollectComposedValuesVisitor widenedVisitor = new CollectComposedValuesVisitor(); widenedVisitor.VisitMemoryEntry(widenedEntry); if (newVisitor.Arrays.Count != widenedVisitor.Arrays.Count) { snapshot.DestroyArray(index); } if (newVisitor.Objects.Count != widenedVisitor.Objects.Count) { snapshot.Structure.SetObjects(index, null); } SetMemoryEntry(index, assistant.Widen(oldEntry, new MemoryEntry(widenedVisitor.Values))); } }
private void widenData(MemoryIndex index) { MemoryEntry newEntry = null; if (!newData.Readonly.TryGetMemoryEntry(index, out newEntry)) { newEntry = snapshot.EmptyEntry; } MemoryEntry oldEntry = null; if (!oldData.Readonly.TryGetMemoryEntry(index, out oldEntry)) { oldEntry = snapshot.EmptyEntry; } MemoryEntry widenedEntry = assistant.Widen(oldEntry, newEntry); MemoryEntry entry = setNewMemoryEntry(index, newEntry, widenedEntry); }
private void widenAndSimplifyData() { List <MemoryIndex> indexes = new List <MemoryIndex>(); CollectionMemoryUtils.AddAll(indexes, newData.Readonly.ReadonlyChangeTracker.IndexChanges); var previousTracker = newData.Readonly.ReadonlyChangeTracker.PreviousTracker; var currentTracker = newData.Writeable.WriteableChangeTracker; foreach (MemoryIndex index in indexes) { MemoryEntry newEntry = getMemoryEntryOrEmpty(index, newData.Readonly); MemoryEntry accEntryValue = newEntry; if (newEntry != null && newEntry.Count > simplifyLimit) { MemoryEntry simplifiedEntry = assistant.Simplify(newEntry); accEntryValue = simplifiedEntry; } MemoryEntry oldEntry = getMemoryEntryOrEmpty(index, oldData.Readonly); if (!ValueUtils.CompareMemoryEntries(newEntry, oldEntry)) { MemoryEntry widenedEntry = assistant.Widen(oldEntry, newEntry); accEntryValue = widenedEntry; } if (previousTracker != null) { MemoryEntry previousEntry = getMemoryEntryOrEmpty(index, previousTracker.Container); if (ValueUtils.CompareMemoryEntries(previousEntry, accEntryValue)) { currentTracker.RemoveIndexChange(index); } } if (accEntryValue != newEntry && newEntry != null) { setNewMemoryEntry(index, newEntry, accEntryValue); } } }