Example #1
0
        public ulong ExecuteSingle(State.ExecutionContext context, ulong address)
        {
            TranslatedFunction func = GetOrTranslate(address, context.ExecutionMode);

            Statistics.StartTimer();

            ulong nextAddr = func.Execute(context);

            Statistics.StopTimer(address);

            return(nextAddr);
        }
Example #2
0
        private void TranslateQueuedSubs()
        {
            while (_threadCount != 0)
            {
                if (_backgroundQueue.TryDequeue(out RejitRequest request))
                {
                    TranslatedFunction func = Translate(request.Address, request.Mode, highCq: true);

                    _funcs.AddOrUpdate(request.Address, func, (key, oldFunc) => func);
                }
                else
                {
                    _backgroundTranslatorEvent.WaitOne();
                }
            }
        }
Example #3
0
        private void TranslateQueuedSubs()
        {
            while (_threadCount != 0)
            {
                if (_backgroundQueue.TryDequeue(out ulong address))
                {
                    TranslatedFunction func = Translate(address, ExecutionMode.Aarch64, highCq: true);

                    _funcs.AddOrUpdate(address, func, (key, oldFunc) => func);
                }
                else
                {
                    _backgroundTranslatorEvent.WaitOne();
                }
            }
        }
Example #4
0
        private void TranslateQueuedSubs()
        {
            while (_threadCount != 0)
            {
                if (_backgroundQueue.TryDequeue(out RejitRequest request))
                {
                    TranslatedFunction func = Translate(request.Address, request.Mode, highCq: true);

                    _funcs.AddOrUpdate(request.Address, func, (key, oldFunc) => func);
                    _jumpTable.RegisterFunction(request.Address, func);
                }
                else
                {
                    _backgroundTranslatorEvent.WaitOne();
                }
            }
            _backgroundTranslatorEvent.Set(); // Wake up any other background translator threads, to encourage them to exit.
        }
Example #5
0
        public void RegisterFunction(ulong address, TranslatedFunction func)
        {
            address &= ~3UL;
            _targets.AddOrUpdate(address, func, (key, oldFunc) => func);
            long funcPtr = func.GetPointer().ToInt64();

            // Update all jump table entries that target this address.
            if (_dependants.TryGetValue(address, out LinkedList <int> myDependants))
            {
                lock (myDependants)
                {
                    foreach (var entry in myDependants)
                    {
                        IntPtr addr = _jumpRegion.Pointer + entry * JumpTableStride;
                        Marshal.WriteInt64(addr, 8, funcPtr);
                    }
                }
            }
        }
Example #6
0
        public void RegisterFunction(ulong address, TranslatedFunction func)
        {
            address &= ~3UL;
            Targets.AddOrUpdate(address, func, (key, oldFunc) => func);
            long funcPtr = func.FuncPtr.ToInt64();

            // Update all jump table entries that target this address.
            if (Dependants.TryGetValue(address, out LinkedList <int> myDependants))
            {
                lock (myDependants)
                {
                    foreach (int entry in myDependants)
                    {
                        IntPtr addr = GetEntryAddressJumpTable(entry);

                        Marshal.WriteInt64(addr, 8, funcPtr);
                    }
                }
            }
        }
Example #7
0
 private void EnqueueForDeletion(ulong guestAddress, TranslatedFunction func)
 {
     _oldFuncs.Enqueue(new KeyValuePair <ulong, IntPtr>(guestAddress, func.FuncPtr));
 }