/// <inheritdoc /> public void AssignAlias(Snapshot snapshot, Memory.MemoryPath targetPath, Memory.MemoryPath sourcePath) { //Collect alias indexes AssignCollector sourceCollector = new AssignCollector(snapshot); sourceCollector.ProcessPath(sourcePath); //Memory locations where to get data from ReadCollector valueCollector = new ReadCollector(snapshot); valueCollector.ProcessPath(sourcePath); //Get data from locations ReadWorker worker = new ReadWorker(snapshot); MemoryEntry value = worker.ReadValue(valueCollector); //Makes deep copy of data to prevent changes after assign alias TemporaryIndex temporaryIndex = snapshot.CreateTemporary(); MergeWithinSnapshotWorker mergeWorker = new MergeWithinSnapshotWorker(snapshot); mergeWorker.MergeMemoryEntry(temporaryIndex, value); //Memory locations to store data into AssignCollector targetCollector = new AssignCollector(snapshot); targetCollector.AliasesProcessing = AliasesProcessing.BeforeCollecting; targetCollector.ProcessPath(targetPath); AssignAliasWorker assignWorker = new AssignAliasWorker(snapshot); assignWorker.AssignAlias(sourceCollector, targetCollector, temporaryIndex); snapshot.ReleaseTemporary(temporaryIndex); }
/// <summary> /// Gets the snapshot entry of temporary index associated with this memory entry. /// </summary> /// <param name="context">The context.</param> private SnapshotEntry getTemporary(SnapshotBase context) { Snapshot snapshot = SnapshotEntry.ToSnapshot(context); if (temporaryLocation == null) { temporaryIndex = snapshot.CreateTemporary(); temporaryLocation = new SnapshotEntry(MemoryPath.MakePathTemporary(temporaryIndex)); snapshot.Factories.Benchmark.StartAlgorithm(snapshot, AlgorithmType.MERGE_TO_TEMPORARY); snapshot.Algorithms.MergeAlgorithm.MergeMemoryEntry(snapshot, temporaryIndex, dataEntry); snapshot.Factories.Benchmark.FinishAlgorithm(snapshot, AlgorithmType.MERGE_TO_TEMPORARY); } return(temporaryLocation); }
public void VisitTemporaryIndex(TemporaryIndex index) { MemoryIndexCollectorNode node; if (!rootNode.TemporaryNodes.TryGetValue(index.RootIndex, out node)) { MemoryIndexCollectorNode newNode = new MemoryIndexCollectorNode(index.RootIndex); newNode.IsMust = isMust; rootNode.TemporaryNodes.Add(index.RootIndex, newNode); currentNode = newNode; } else { currentNode = node; } processIndexPath(index); if (!processAlias(index)) { if (isMust) { rootNode.TemporaryNodes.Remove(index.RootIndex); MemoryIndexCollectorNode newNode = new MemoryIndexCollectorNode(index.RootIndex); newNode.IsMust = isMust; rootNode.TemporaryNodes.Add(index.RootIndex, newNode); } else { MemoryIndexCollectorNode childNode = rootNode.TemporaryNodes[index.RootIndex]; collector.AddNode(childNode); childNode.TargetIndex = index; childNode.SourceIndex = index; childNode.IsMust = false; } } }
/// <inheritdoc /> public void Assign(Snapshot snapshot, Memory.MemoryPath path, AnalysisFramework.Memory.MemoryEntry value, bool forceStrongWrite) { TemporaryIndex temporaryIndex = snapshot.CreateTemporary(); MergeWithinSnapshotWorker mergeWorker = new MergeWithinSnapshotWorker(snapshot); mergeWorker.MergeMemoryEntry(temporaryIndex, value); AssignCollector collector = new AssignCollector(snapshot); collector.ProcessPath(path); if (forceStrongWrite) { collector.SetAllToMust(); } AssignWorker worker = new AssignWorker(snapshot); worker.Assign(collector, temporaryIndex); snapshot.ReleaseTemporary(temporaryIndex); }
/// <inheritdoc /> public void VisitTemporaryIndex(TemporaryIndex index) { MemoryIndexTreeStackContext stackContext = getStackLevel(index); addToRoot(index, stackContext.TemporaryTreeRoot); }
/// <inheritdoc /> public void MergeMemoryEntry(Snapshot snapshot, TemporaryIndex temporaryIndex, MemoryEntry dataEntry) { MergeWithinSnapshotWorker mergeWorker = new MergeWithinSnapshotWorker(snapshot); mergeWorker.MergeMemoryEntry(temporaryIndex, dataEntry); }
/// <summary> /// Initializes a new instance of the <see cref="TemporaryPathSegment"/> class. /// </summary> /// <param name="temporaryIndex">Index of the temporary.</param> public TemporaryPathSegment(TemporaryIndex temporaryIndex) : base(true) { this.TemporaryIndex = temporaryIndex; }
/// <summary> /// Makes the path to temporary memory location. /// </summary> /// <param name="temporaryIndex">Index of the temporary.</param> /// <returns>New path to temporary memory location</returns> public static MemoryPath MakePathTemporary(TemporaryIndex temporaryIndex) { return(new MemoryPath(new TemporaryPathSegment(temporaryIndex), GlobalContext.LocalOnly, temporaryIndex.CallLevel)); }