SourceForge has been redesigned. Learn more.
Close

[97a262]: / userguide / html / RVM / Compiler Intrinsics.html  Maximize  Restore  History

Download this file

45 lines (37 with data), 3.2 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>RVM : Compiler Intrinsics</title>
<link rel="stylesheet" href="styles/site.css" type="text/css" />
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<table class="pagecontent" border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#ffffff">
<tr>
<td valign="top" class="pagebody">
<div class="pageheader">
<span class="pagetitle">
RVM : Compiler Intrinsics
</span>
</div>
<div class="pagesubheading">
This page last changed on Jul 03, 2008 by <font color="#0050B2">dgrove</font>.
</div>
<p>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.</p>
<h2><a name="CompilerIntrinsics-Magic"></a>Magic</h2>
<p>All the methods in <tt>Magic</tt> 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.</p>
<p>A Jikes��� RVM implementor must be <em>extremely careful</em> when writing code that uses <tt>Magic</tt> to circumvent the Java type system. The use of <tt>Magic.objectAsAddress</tt> 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 <tt>VM.disableGC</tt> and <tt>VM.enableGC</tt>. 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.</p>
<p>Since magic is inexpressible in the Java programming language , it is unsurprising that the bodies of <tt>Magic</tt> methods are undefined. Instead, for each of these methods, the Java instructions to generate the code is stored in <tt>GenerateMagic</tt> and <tt>GenerateMachineSpecificMagic</tt> (to generate HIR) and <tt>BaselineCompilerImpl</tt> (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.</p>
</td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td height="12" background="http://docs.codehaus.org/images/border/border_bottom.gif"><img src="images/border/spacer.gif" width="1" height="1" border="0"/></td>
</tr>
<tr>
<td align="center"><font color="grey">Document generated by Confluence on Jul 04, 2010 19:57</font></td>
</tr>
</table>
</body>
</html>