Esempio n. 1
0
        public static void Initialize(IJitMemoryAllocator allocator)
        {
            if (_initialized)
            {
                return;
            }

            lock (_lock)
            {
                if (_initialized)
                {
                    return;
                }

                _jitRegion = new ReservedRegion(allocator, CacheSize);

                _cacheAllocator = new CacheMemoryAllocator(CacheSize);

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    JitUnwindWindows.InstallFunctionTableHandler(_jitRegion.Pointer, CacheSize, _jitRegion.Pointer + Allocate(PageSize));
                }

                _initialized = true;
            }
        }
Esempio n. 2
0
        public static void Initialize(IJitMemoryAllocator allocator)
        {
            if (_initialized)
            {
                return;
            }

            lock (_lock)
            {
                if (_initialized)
                {
                    return;
                }

                _jitRegion = new ReservedRegion(allocator, CacheSize);

                _cacheAllocator = new CacheMemoryAllocator(CacheSize);

                if (OperatingSystem.IsWindows())
                {
                    JitUnwindWindows.InstallFunctionTableHandler(_jitRegion.Pointer, CacheSize, _jitRegion.Pointer + Allocate(PageSize));
                }

                _initialized = true;
            }
        }
Esempio n. 3
0
        public ExecutionContext(IJitMemoryAllocator allocator)
        {
            _nativeContext = new NativeContext(allocator);

            Running = true;

            _nativeContext.SetCounter(MinCountForCheck);
        }
Esempio n. 4
0
        public JumpTable(IJitMemoryAllocator allocator)
        {
            _jumpRegion    = new ReservedRegion(allocator, JumpTableByteSize);
            _dynamicRegion = new ReservedRegion(allocator, DynamicTableByteSize);

            _targets    = new ConcurrentDictionary <ulong, TranslatedFunction>();
            _dependants = new ConcurrentDictionary <ulong, LinkedList <int> >();

            Symbols.Add((ulong)_jumpRegion.Pointer.ToInt64(), JumpTableByteSize, JumpTableStride, "JMP_TABLE");
            Symbols.Add((ulong)_dynamicRegion.Pointer.ToInt64(), DynamicTableByteSize, DynamicTableStride, "DYN_TABLE");
        }
Esempio n. 5
0
        public ReservedRegion(IJitMemoryAllocator allocator, ulong maxSize, ulong granularity = 0)
        {
            if (granularity == 0)
            {
                granularity = DefaultGranularity;
            }

            Block            = allocator.Reserve(maxSize);
            _maxSize         = maxSize;
            _sizeGranularity = granularity;
            _currentSize     = 0;
        }
Esempio n. 6
0
        public Translator(IJitMemoryAllocator allocator, IMemoryManager memory)
        {
            _memory = memory;

            _funcs = new ConcurrentDictionary <ulong, TranslatedFunction>();

            _jumpTable = new JumpTable(allocator);

            _backgroundQueue = new PriorityQueue <RejitRequest>(2);

            _backgroundTranslatorEvent = new AutoResetEvent(false);

            JitCache.Initialize(allocator);
            DirectCallStubs.InitializeStubs();
        }
Esempio n. 7
0
        public Translator(IJitMemoryAllocator allocator, IMemoryManager memory)
        {
            _allocator = allocator;
            _memory    = memory;

            _funcs    = new ConcurrentDictionary <ulong, TranslatedFunction>();
            _oldFuncs = new ConcurrentQueue <KeyValuePair <ulong, IntPtr> >();

            _backgroundStack           = new ConcurrentStack <RejitRequest>();
            _backgroundTranslatorEvent = new AutoResetEvent(false);
            _backgroundTranslatorLock  = new ReaderWriterLock();

            JitCache.Initialize(allocator);

            DirectCallStubs.InitializeStubs();
        }
Esempio n. 8
0
        public static void Initialize(IJitMemoryAllocator allocator)
        {
            if (_initialized) return;
            lock (_lock)
            {
                if (_initialized) return;
                _jitRegion = new ReservedRegion(allocator, CacheSize);

                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    _jitRegion.ExpandIfNeeded(PageSize);
                    JitUnwindWindows.InstallFunctionTableHandler(_jitRegion.Pointer, CacheSize);

                    // The first page is used for the table based SEH structs.
                    _offset = PageSize;
                }
                _initialized = true;
            }
        }
Esempio n. 9
0
        public Translator(IJitMemoryAllocator allocator, IMemoryManager memory)
        {
            _memory = memory;

            _funcs = new ConcurrentDictionary <ulong, TranslatedFunction>();

            _backgroundStack = new ConcurrentStack <RejitRequest>();

            _backgroundTranslatorEvent = new AutoResetEvent(false);

            _jumpTable = new JumpTable(allocator);

            JitCache.Initialize(allocator);

            DirectCallStubs.InitializeStubs();

            if (Ptc.State == PtcState.Enabled)
            {
                Ptc.LoadTranslations(_funcs, memory.PageTablePointer, _jumpTable);
            }
        }
Esempio n. 10
0
        public NativeContext(IJitMemoryAllocator allocator)
        {
            _block = allocator.Allocate((ulong)Unsafe.SizeOf <NativeCtxStorage>());

            GetStorage().ExclusiveAddress = ulong.MaxValue;
        }
Esempio n. 11
0
 public NativeContext(IJitMemoryAllocator allocator)
 {
     _block = allocator.Allocate(TotalSize);
 }
Esempio n. 12
0
 public NativeContext(IJitMemoryAllocator allocator)
 {
     _block = allocator.Allocate((ulong)Unsafe.SizeOf <NativeCtxStorage>());
 }