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> /// Initializes a new instance of the <see cref="FieldLocationVisitor"/> class. /// </summary> /// <param name="fieldSegment">The field segment.</param> /// <param name="assistant">The assistant.</param> /// <param name="mustLocationProcess">The must location process.</param> /// <param name="mayLocationProcess">The may location process.</param> public FieldLocationVisitor(FieldPathSegment fieldSegment, MemoryAssistantBase assistant, HashSet <ValueLocation> mustLocationProcess, HashSet <ValueLocation> mayLocationProcess) : base(assistant) { this.fieldSegment = fieldSegment; this.mustLocationProcess = mustLocationProcess; this.mayLocationProcess = mayLocationProcess; }
/// <summary> /// Initializes a new instance of the <see cref="IndexLocationVisitor"/> class. /// </summary> /// <param name="indexSegment">The index segment.</param> /// <param name="assistant">The assistant.</param> /// <param name="mustLocationProcess">The must location process.</param> /// <param name="mayLocationProcess">The may location process.</param> public IndexLocationVisitor(IndexPathSegment indexSegment, MemoryAssistantBase assistant, HashSet <ValueLocation> mustLocationProcess, HashSet <ValueLocation> mayLocationProcess) : base(assistant) { this.indexSegment = indexSegment; this.mustLocationProcess = mustLocationProcess; this.mayLocationProcess = mayLocationProcess; }
/// <summary> /// Compares this structure object with given copy of old data and applies widening operation on memory entry which differs. /// </summary> /// <param name="oldValue">The old value.</param> /// <param name="simplifyLimit">The simplify limit.</param> /// <param name="assistant">The assistant.</param> /// <returns><c>true</c> if the data are same; otherwise, <c>false</c>.</returns> public bool WidenNotEqual(SnapshotStructure oldValue, int simplifyLimit, MemoryAssistantBase assistant) { lockedTest(); bool funcCount = this.FunctionDecl.Count == oldValue.FunctionDecl.Count; bool classCount = this.ClassDecl.Count == oldValue.ClassDecl.Count; if (!widenNotEqualData(oldValue, simplifyLimit, assistant)) { return(false); } return(compareDeclarations(oldValue)); }
/// <summary> /// Initializes a new instance of the <see cref="CopyCommitWorker"/> class. /// </summary> /// <param name="factories">The factories.</param> /// <param name="snapshot">The snapshot.</param> /// <param name="simplifyLimit">The simplify limit.</param> /// <param name="newStructure">The new structure.</param> /// <param name="oldStructure">The old structure.</param> /// <param name="newData">The new data.</param> /// <param name="oldData">The old data.</param> public CopyCommitWorker(ModularMemoryModelFactories factories, Snapshot snapshot, int simplifyLimit, ISnapshotStructureProxy newStructure, ISnapshotStructureProxy oldStructure, ISnapshotDataProxy newData, ISnapshotDataProxy oldData) { Factories = factories; this.snapshot = snapshot; this.simplifyLimit = simplifyLimit; this.assistant = snapshot.MemoryAssistant; this.newStructure = newStructure; this.oldStructure = oldStructure; this.newData = newData; this.oldData = oldData; }
/// <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))); } }
/// <summary> /// Simplifies memory entries which is bigget than simplify limit and compares data of this data collection object with the given one. /// </summary> /// <param name="oldData">The old data.</param> /// <param name="simplifyLimit">The simplify limit.</param> /// <param name="assistant">The assistant.</param> /// <returns>True whether compared data are the same.</returns> public bool DataEqualsAndSimplify(SnapshotData oldData, int simplifyLimit, MemoryAssistantBase assistant) { bool areEquals = true; HashSet <MemoryIndex> indexes = new HashSet <MemoryIndex>(); HashSetTools.AddAll(indexes, this.IndexData.Keys); HashSetTools.AddAll(indexes, oldData.IndexData.Keys); foreach (MemoryIndex index in indexes) { if (!DataEqualsAndSimplify(oldData, index, simplifyLimit, assistant)) { areEquals = false; } } return(areEquals); }
/// <summary> /// Read values from location using specified memory assistant. /// </summary> /// <param name="assistant">The assistant.</param> /// <returns>Result of reading received from assistant.</returns> public abstract IEnumerable <Value> ReadValues(MemoryAssistantBase assistant);
/// <summary> /// Read values from location using specified memory assistant. /// </summary> /// <param name="assistant">The assistant.</param> /// <returns> /// Result of reading received from assistant. /// </returns> public override IEnumerable <Value> ReadValues(MemoryAssistantBase assistant) { return(values); }
/// <summary> /// Read values to location using specified memory assistant. /// </summary> /// <param name="assistant">The assistant.</param> /// <param name="entry">The entry.</param> /// <returns> /// Result of writing received from assistant. /// </returns> public override IEnumerable <Value> WriteValues(MemoryAssistantBase assistant, MemoryEntry entry) { return(values); }
public IndexReadExecutor(MemoryAssistantBase assistant, MemberIdentifier index) { _assistant = assistant; _index = index; }
/// <summary> /// Initializes a new instance of the <see cref="ProcessValueAsLocationVisitor"/> class. /// </summary> /// <param name="assistant">The assistant.</param> public ProcessValueAsLocationVisitor(MemoryAssistantBase assistant) { this.assistant = assistant; }
/// <summary> /// Compares this structure object with given copy of old data and applies simplify limit when new memory entry is bigger than given simplify limit. /// </summary> /// <param name="oldValue">The old value.</param> /// <param name="simplifyLimit">The simplify limit.</param> /// <param name="assistant">The assistant.</param> /// <returns><c>true</c> if the data are same; otherwise, <c>false</c>.</returns> private bool compareDataAndSimplify(SnapshotStructure oldValue, int simplifyLimit, MemoryAssistantBase assistant) { HashSet <MemoryIndex> usedIndexes = new HashSet <MemoryIndex>(); HashSetTools.AddAll(usedIndexes, this.IndexData.Keys); HashSetTools.AddAll(usedIndexes, oldValue.IndexData.Keys); IndexData emptyStructure = new CopyMemoryModel.IndexData(null, null, null); bool areEqual = true; foreach (MemoryIndex index in usedIndexes) { if (index is TemporaryIndex) { continue; } IndexData newStructure = getDataOrUndefined(index, this, emptyStructure); IndexData oldStructure = getDataOrUndefined(index, oldValue, emptyStructure); if (!newStructure.DataEquals(oldStructure)) { areEqual = false; } if (!Data.DataEqualsAndSimplify(oldValue.Data, index, simplifyLimit, assistant)) { areEqual = false; } } return(areEqual); }
/// <summary> /// Compares this structure object with given copy of old data and applies simplify limit when new memory entry is bigger than given simplify limit. /// </summary> /// <param name="oldValue">The old value.</param> /// <param name="simplifyLimit">The simplify limit.</param> /// <param name="assistant">The assistant.</param> /// <returns> /// <c>true</c> if the data are same; otherwise, <c>false</c>. /// </returns> public bool DataEqualsAndSimplify(SnapshotStructure oldValue, int simplifyLimit, MemoryAssistantBase assistant) { if (!compareDataAndSimplify(oldValue, simplifyLimit, assistant)) { return(false); } return(compareDeclarations(oldValue)); }
/// <summary> /// Read values from location using specified memory assistant. /// </summary> /// <param name="assistant">The assistant.</param> /// <returns> /// Result of reading received from assistant. /// </returns> public override IEnumerable <Value> ReadValues(MemoryAssistantBase assistant) { return(assistant.ReadAnyValueIndex(value, index).PossibleValues); }
/// <summary> /// Read values to location using specified memory assistant. /// </summary> /// <param name="assistant">The assistant.</param> /// <param name="entry">The entry.</param> /// <returns>Result of writing received from assistant.</returns> public abstract IEnumerable <Value> WriteValues(MemoryAssistantBase assistant, MemoryEntry entry);
/// <summary> /// Compares this structure object with given copy of old data and applies widening operation on memory entry which differs. /// </summary> /// <param name="oldValue">The old value.</param> /// <param name="simplifyLimit">The simplify limit.</param> /// <param name="assistant">The assistant.</param> /// <returns><c>true</c> if the data are same; otherwise, <c>false</c>.</returns> private bool widenNotEqualData(SnapshotStructure oldValue, int simplifyLimit, MemoryAssistantBase assistant) { HashSet <MemoryIndex> indexes = new HashSet <MemoryIndex>(); HashSetTools.AddAll(indexes, this.IndexData.Keys); HashSetTools.AddAll(indexes, oldValue.IndexData.Keys); IndexData emptyData = new CopyMemoryModel.IndexData(null, null, null); bool areEqual = true; foreach (MemoryIndex index in indexes) { if (index is TemporaryIndex) { continue; } IndexData newData = getDataOrUndefined(index, this, emptyData); IndexData oldData = getDataOrUndefined(index, oldValue, emptyData); Data.DataWiden(oldValue.Data, index, assistant); if (!Data.DataEqualsAndSimplify(oldValue.Data, index, simplifyLimit, assistant)) { areEqual = false; } } return(areEqual); }
/// <summary> /// Read values from location using specified memory assistant. /// </summary> /// <param name="assistant">The assistant.</param> /// <returns> /// Result of reading received from assistant. /// </returns> public override IEnumerable <Value> ReadValues(MemoryAssistantBase assistant) { return(assistant.ReadStringIndex(value, index)); }
/// <summary> /// Simplify data of single memory index if exceeds given simplify limit and compares it with the data inside given data container. /// </summary> /// <param name="oldData">The old data.</param> /// <param name="index">The index.</param> /// <param name="simplifyLimit">The simplify limit.</param> /// <param name="assistant">The assistant.</param> /// <returns>True whether compared data are the same.</returns> public bool DataEqualsAndSimplify(SnapshotData oldData, MemoryIndex index, int simplifyLimit, 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; } if (oldEntry.Equals(newEntry)) { return(true); } else if (newEntry.Count > simplifyLimit) { MemoryIndex testIndex = ControlIndex.Create(".return", 6); if (testIndex.Equals(index)) { } MemoryEntry simplifiedEntry = assistant.Simplify(newEntry); SetMemoryEntry(index, simplifiedEntry); return(oldEntry.Equals(simplifiedEntry)); } else { return(false); } }
/// <summary> /// Read values to location using specified memory assistant. /// </summary> /// <param name="assistant">The assistant.</param> /// <param name="entry">The entry.</param> /// <returns> /// Result of writing received from assistant. /// </returns> public override IEnumerable <Value> WriteValues(MemoryAssistantBase assistant, MemoryEntry entry) { return(assistant.WriteValueIndex(value, index, entry)); }
public IndexWriteExecutor(MemoryAssistantBase assistant, MemberIdentifier index, MemoryEntry writtenValue) { _assistant = assistant; _index = index; _writtenValue = writtenValue; }