Exemplo n.º 1
0
        private void weakUpdate(List <VirtualReference> references, MemoryEntry update)
        {
            foreach (var reference in references)
            {
                var entry = getEntry(reference);
                ReportMemoryEntryMerge();
                var updated = MemoryEntry.Merge(entry, update);

                setEntry(reference, updated);
            }
        }
Exemplo n.º 2
0
        internal void ExtendBy(DataContainer dataContainer, bool directExtend)
        {
            foreach (var dataPair in dataContainer._data)
            {
                var reference = dataPair.Key;

                MemoryEntry oldEntry;

                REPORT(Statistic.SimpleHashSearches);
                if (_data.TryGetValue(dataPair.Key, out oldEntry))
                {
                    REPORT(Statistic.MemoryEntryComparisons);
                    if (!dataPair.Value.Equals(oldEntry))
                    {
                        if (directExtend)
                        {
                            REPORT(Statistic.SimpleHashAssigns);
                            _data[dataPair.Key] = dataPair.Value;
                        }
                        else
                        {
                            //merge two memory entries
                            REPORT(Statistic.MemoryEntryMerges);
                            _data[dataPair.Key] = MemoryEntry.Merge(oldEntry, dataPair.Value);
                        }
                    }
                }
                else
                {
                    //data are missed in some branch - needs to be filled with undefined value

                    MemoryEntry merged;

                    //only references valid in current context can be merged with undefined
                    var sameContext = reference.ContextStamp == _owner.CurrentContextStamp;

                    if (directExtend | !sameContext | reference.Kind == VariableKind.Meta)
                    {
                        merged = dataPair.Value;
                    }
                    else
                    {
                        REPORT(Statistic.MemoryEntryCreation);
                        REPORT(Statistic.MemoryEntryMerges);
                        merged = MemoryEntry.Merge(dataPair.Value, new MemoryEntry(_owner.UndefinedValue));
                    }

                    REPORT(Statistic.SimpleHashAssigns);
                    _data[dataPair.Key] = merged;
                }
            }
        }
Exemplo n.º 3
0
        /// <inheritdoc />
        protected override MemoryEntry readMemory(SnapshotBase context)
        {
            var target = C(context);

            switch (Storages.Length)
            {
            case 0:
                return(new MemoryEntry(target.UndefinedValue));

            case 1:
                return(target.ReadValue(Storages[0]));

            default:
                var entries = new List <MemoryEntry>();
                foreach (var storage in Storages)
                {
                    entries.Add(target.ReadValue(storage));
                }
                return(MemoryEntry.Merge(entries));
            }
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        protected override void flowThrough()
        {
            if (TrueAssume.Assumed && FalseAssume.Assumed)
            {
                //merge result from both branches
                var trueVal  = TrueOperand.Values;
                var falseVal = FalseOperand.Values;

                var merged = MemoryEntry.Merge(trueVal, falseVal);
                Value = OutSnapshot.CreateSnapshotEntry(merged);
            }
            else if (TrueAssume.Assumed)
            {
                //only true value is used
                Value = TrueOperand.Value;
            }
            else
            {
                //only false value is used
                Value = FalseOperand.Value;
            }
        }