Skip to content

Add x64 intrinsics to .NET through the use of ungodly hacks

License

Notifications You must be signed in to change notification settings

damageboy/ReJit

Repository files navigation

HackJit

What

HackJit aims to add useful x64 (only for now, no x86 since I'm lazy). The method is based on a hack shown by @JeroenFrijters of IKVM.NET fame: How to Hack Your Own JIT Intrinsic

The intrinsincs are exposed through a class called JIT where each intrinsics is implemented as a "method".

The reason I refer to these implementations as methods with quotation marks is that they are not normal methods in the common sense.

When the method is first executed, it patches the caller's code to use the x64 assembly instead of calling the method. So in reality the first call to the "method" from each call site actually triggers a code path that modifies the code into using said intrinsics.

Supported Initrinsics

The supported intrinsics currently are:

  • BSWAP32 (signed/unsigned)
  • BSWAP64 (signed/unsigned) Note: Not currently working
  • BSR32 (signed/unsigned)
  • BSF32 (signed/unsigned)
  • BSR64 (signed/unsigned)
  • BSF64 (signed/unsigned)
  • RDTSC (with memory barrier)
  • RDTSCP
  • CPUID

Todo

  • AES*
  • MFENCE
  • SFENCE
  • WBINVD
  • CLFLUSH
  • BTS
  • BTR
  • BT
  • BTC
  • INVD
  • RDRAND
  • PREFETCH0/1/2/NTA
  • POPCNT
  • PAUSE
  • CMPXCHNG8B/CMPXCHNG16B

About

Add x64 intrinsics to .NET through the use of ungodly hacks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published