Exemplo n.º 1
0
        internal int AllocateILMarker()
        {
            Debug.Assert(this.RealizedIL.IsDefault, "Too late to allocate a new IL marker");
            if (_allocatedILMarkers == null)
            {
                _allocatedILMarkers = ArrayBuilder <ILMarker> .GetInstance();
            }

            BasicBlock curBlock = GetCurrentBlock();

            Debug.Assert(curBlock != null);

            int marker = _allocatedILMarkers.Count;

            curBlock.AddILMarker(marker);

            _allocatedILMarkers.Add(
                new ILMarker()
            {
                BlockOffset    = (int)curBlock.RegularInstructionsLength,
                AbsoluteOffset = -1
            }
                );

            return(marker);
        }
Exemplo n.º 2
0
        private void ReconcileTrailingMarkers()
        {
            //  there is a chance that 'lastCompleteBlock' may have an IL marker
            //  placed at the end of it such that block offset of the marker points
            //  to the next byte *after* the block is closed. In this case the marker 
            //  should be moved to the next block
            if (_lastCompleteBlock != null &&
                _lastCompleteBlock.BranchCode == ILOpCode.Nop &&
                _lastCompleteBlock.LastILMarker >= 0 &&
                _allocatedILMarkers[_lastCompleteBlock.LastILMarker].BlockOffset == _lastCompleteBlock.RegularInstructionsLength)
            {
                int startMarker = -1;
                int endMarker = -1;

                while (_lastCompleteBlock.LastILMarker >= 0 &&
                      _allocatedILMarkers[_lastCompleteBlock.LastILMarker].BlockOffset == _lastCompleteBlock.RegularInstructionsLength)
                {
                    Debug.Assert((startMarker < 0) || (startMarker == (_lastCompleteBlock.LastILMarker + 1)));
                    startMarker = _lastCompleteBlock.LastILMarker;
                    if (endMarker < 0)
                    {
                        endMarker = _lastCompleteBlock.LastILMarker;
                    }
                    _lastCompleteBlock.RemoveTailILMarker(_lastCompleteBlock.LastILMarker);
                }

                BasicBlock current = this.GetCurrentBlock();
                for (int marker = startMarker; marker <= endMarker; marker++)
                {
                    current.AddILMarker(marker);
                    _allocatedILMarkers[marker] = new ILMarker() { BlockOffset = (int)current.RegularInstructionsLength, AbsoluteOffset = -1 };
                }
            }
        }