JitCpuContext.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using ARMeilleure.Memory;
  2. using ARMeilleure.Translation;
  3. namespace Ryujinx.Cpu.Jit
  4. {
  5. class JitCpuContext : ICpuContext
  6. {
  7. private readonly ITickSource _tickSource;
  8. private readonly Translator _translator;
  9. public JitCpuContext(ITickSource tickSource, IMemoryManager memory, bool for64Bit)
  10. {
  11. _tickSource = tickSource;
  12. _translator = new Translator(new JitMemoryAllocator(), memory, for64Bit);
  13. memory.UnmapEvent += UnmapHandler;
  14. }
  15. private void UnmapHandler(ulong address, ulong size)
  16. {
  17. _translator.InvalidateJitCacheRegion(address, size);
  18. }
  19. /// <inheritdoc/>
  20. public IExecutionContext CreateExecutionContext(ExceptionCallbacks exceptionCallbacks)
  21. {
  22. return new JitExecutionContext(new JitMemoryAllocator(), _tickSource, exceptionCallbacks);
  23. }
  24. /// <inheritdoc/>
  25. public void Execute(IExecutionContext context, ulong address)
  26. {
  27. _translator.Execute(((JitExecutionContext)context).Impl, address);
  28. }
  29. /// <inheritdoc/>
  30. public void InvalidateCacheRegion(ulong address, ulong size)
  31. {
  32. _translator.InvalidateJitCacheRegion(address, size);
  33. }
  34. }
  35. }