Skip to end of metadata
Go to start of metadata

A compiler intrinsic will usually generate a specific code sequence. The code sequence will usually be inlined and optimized as part of compilation phase of the optimizing compiler.

Magic

All the methods in Magic are compiler intrinsics. Because these methods access raw memory or other machine state, perform unsafe casts, or are operating system calls, they cannot be implemented in Java code.

A Jikes™ RVM implementor must be extremely careful when writing code that uses Magic to circumvent the Java type system. The use of Magic.objectAsAddress to perform various forms of pointer arithmetic is especially hazardous, since it can result in pointers being "lost" during garbage collection. All such uses of magic must either occur in uninterruptible methods or be guarded by calls to VM.disableGC and VM.enableGC. The optimizing compiler performs aggressive inlining and code motion, so not explicitly marking such dangerous regions in one of these two manners will lead to disaster.

Since magic is inexpressible in the Java programming language , it is unsurprising that the bodies of Magic methods are undefined. Instead, for each of these methods, the Java instructions to generate the code is stored in GenerateMagic and GenerateMachineSpecificMagic (to generate HIR) and BaselineCompilerImpl (to generate assembly code) (Note: The optimizing compiler always uses the set of instructions that generate HIR; the instructions that generate assembly code are only invoked by the baseline compiler.). Whenever the compiler encounters a call to one of these magic methods, it inlines appropriate code for the magic method into the caller method.

  • No labels