<?xml version="1.0"?>
<rss version="2.0.">
  <channel>
    <title>Advogato blog for gary</title>
    <link>http://www.advogato.org/person/gary/</link>
    <description>Advogato blog for gary</description>
    <language>en-us</language>
    <generator>mod_virgule</generator>
    <pubDate>Thu, 24 Jul 2008 22:20:07 GMT</pubDate>
    <item>
      <pubDate>Thu, 24 Jul 2008 10:19:07 GMT</pubDate>
      <title>Synchronization</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=214</link>
      <guid>http://gbenson.net/?p=89</guid>
      <description>&lt;p&gt;I figured out the deal with getting the number of monitors from typeflow.  I was confused because it only tells you the number of monitors at the start of each block, but what I didn&amp;#8217;t realise is that it inserts block boundaries after every &lt;code&gt;monitorenter&lt;/code&gt; and &lt;code&gt;monitorexit&lt;/code&gt;, so the number of monitors remains constant for entire block. A quick scan through a method&amp;#8217;s blocks will find the one with the most monitors, and that&amp;#8217;s the maximum number of monitors you need for your method. I wrote the code to allocate them yesterday; today I write the code to actually lock and unlock things with them.&lt;/p&gt;
&lt;p&gt;As an aside, I&amp;#8217;ve seen a few people refer to zero as a VM in its own right, a replacement for HotSpot, but this isn&amp;#8217;t the case at all: zero is a &lt;em&gt;port&lt;/em&gt; of HotSpot.  HotSpot is a largely generic VM with a small number of CPU- and OS-specific files, and when people refer to a port of HotSpot to some processor or operating system, they&amp;#8217;re talking about these files. If you look inside an OpenJDK tarball, you&amp;#8217;ll find the HotSpot sources in something like these directories:&lt;/p&gt;
&lt;pre&gt;openjdk/hotspot/src/share
openjdk/hotspot/src/cpu/x86
openjdk/hotspot/src/cpu/sparc
openjdk/hotspot/src/os/linux
openjdk/hotspot/src/os/solaris
openjdk/hotspot/src/os/win32
openjdk/hotspot/src/os_cpu/linux_x86
openjdk/hotspot/src/os_cpu/linux_sparc
openjdk/hotspot/src/os_cpu/solaris_x86
openjdk/hotspot/src/os_cpu/solaris_sparc
openjdk/hotspot/src/os_cpu/win32_x86&lt;/pre&gt;
&lt;p&gt;Zero adds the following directories to that list:&lt;/p&gt;
&lt;pre&gt;openjdk/hotspot/src/cpu/zero
openjdk/hotspot/src/os_cpu/linux_zero&lt;/pre&gt;
&lt;p&gt;So when you build HotSpot with zero, you&amp;#8217;re using the following code:&lt;/p&gt;
&lt;pre&gt;openjdk/hotspot/src/share              444,621 lines
openjdk/hotspot/src/cpu/zero             5,300 lines
openjdk/hotspot/src/os/linux             7,865 lines
openjdk/hotspot/src/os_cpu/linux_zero    1,085 lines&lt;/pre&gt;
&lt;p&gt;That&amp;#8217;s 98.6% pure, unadulterated HotSpot.&lt;/p&gt;
&lt;p&gt;(Shark isn&amp;#8217;t a VM either: it&amp;#8217;s a optional JIT compiler for the zero port of HotSpot.)&lt;/p&gt;
</description>
    </item>
    <item>
      <pubDate>Thu, 24 Jul 2008 09:05:59 GMT</pubDate>
      <title>IcedTea is served on ARM</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=213</link>
      <guid>http://gbenson.net/?p=88</guid>
      <description>&lt;p&gt;Matthias Klose got the first ever &amp;#8220;IcedTea is served&amp;#8221; on ARM today.&lt;/p&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 23 Jul 2008 10:17:29 GMT</pubDate>
      <title>Shark&#x2019;s framewalker interface</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=212</link>
      <guid>http://gbenson.net/?p=87</guid>
      <description>&lt;p&gt;Yesterday I finished my &lt;a href="http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=170" &gt;zero&lt;/a&gt; &lt;a href="http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=167" &gt;bugs&lt;/a&gt;, so now I&amp;#8217;m back on Shark.  Until a couple of weeks ago I&amp;#8217;d been implementing bytecodes one by one as they came up, but during some team meetings I had the idea to cause unimplemented bytecodes to abort only that particular compilation.  Previously this would abort the entire VM, but now that I have a fair few of the most common ones implemented already this change would mean Shark was usable even in it&#x2019;s unfinished state, both for general use and for a little bit of benchmarking.  Getting day-to-day grind of implementing bytecodes out of the way means I now need to figure out some of the bigger design issues, however.&lt;/p&gt;
&lt;p&gt;One that&amp;#8217;s been lurking in the background since pretty much day one is the framewalker stuff.  There are all kinds of different types of stack frames in HotSpot, but the relevant ones here are &lt;em&gt;interpreted frames&lt;/em&gt; and &lt;em&gt;native frames&lt;/em&gt;.  Each method in the stack will have one or the other of these*, and it&amp;#8217;s one of the cpu-specific code&amp;#8217;s jobs to provide accessors into the ABI stack frames so that HotSpot can poke around in them.  In the very first days of Shark I tried to make Shark frames appear as native frames, but doing that required all kinds of things I couldn&amp;#8217;t provide: PCs and such like. I put in some pretty nasty hacks to make Shark frames look like interpreter frames and got on with the rest of it.&lt;/p&gt;
&lt;p&gt;Fast forward a couple of months and this approach is showing the strain.  I&amp;#8217;m at a bit where the garbage collector is interrogating frames, and the GC needs a lot more than just a method pointer and a BCI.  I&amp;#8217;m faced with the decision of either trying to store everything into the Shark frames that the C++ interpreter stores (in which case I may as well make them identical, and do away with the distinction) or have another go at implementing Shark frames as native frames.&lt;/p&gt;
&lt;p&gt;My gut feeling is to have another go with native frames.  Making them interpreter frames is hacky enough, and trying to mimic the C++ interpreter perfectly feels too horrible to contemplate.  What I may do first, however, is implement synchronization.  It &lt;em&gt;should&lt;/em&gt; be possible to handle it without having to resize frames, but it&amp;#8217;s not obvious how to extract the number of monitors from the typeflow information so I&amp;#8217;ve been avoiding thinking about it.  Once I have that done, everything that Shark needs to store will be stored, and I can add the extra stuff to mimic HotSpot&amp;#8217;s interpreter/native frames at my leisure.&lt;/p&gt;
&lt;div style="font-size: 0.8em; color: #333;"&gt;* This is a simplification, but it&amp;#8217;s certainly true of zero as it stands today.&lt;/div&gt;
</description>
    </item>
    <item>
      <pubDate>Mon, 21 Jul 2008 16:08:16 GMT</pubDate>
      <title>General update</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=211</link>
      <guid>http://gbenson.net/?p=85</guid>
      <description>&lt;p&gt;It&amp;#8217;s been a while.  I&amp;#8217;ve been doing loads of little things lately, and that tends to stop me blogging.  If I&amp;#8217;m working on only one big thing then I tend to write about it as a break, often at the end of the day when I don&amp;#8217;t want to start anything else, but hopping from task to task means there&amp;#8217;s not one obvious thing to either a)&amp;nbsp;write about or b)&amp;nbsp;take breaks from.  Ah well&amp;#8230;&lt;/p&gt;
&lt;p&gt;Probably the single biggest thing is that I &lt;a href="http://mail.openjdk.java.net/pipermail/porters-dev/2008-July/000160.html" &gt;started&lt;/a&gt; the process of getting an official OpenJDK porters project for zero.  Zero&amp;#8217;s been pretty much stable since the end of March so it&amp;#8217;s high time I did this, but I&amp;#8217;ve been procrastinating about it because I&amp;#8217;m not sure how I&amp;#8217;ll be able to develop in that environment.  I want my local tree to be as close as possible to whatever upstream I&amp;#8217;m using, which is currently the ecj-bootstrap side of IcedTea, but I won&amp;#8217;t be able to use ecj to build straight from a project repository without either applying and committing the icedtea-ecj.patch (bad) or applying it locally and having a non-buildable repository (also bad).  I may have to bite the bullet and use IcedTea to build it, which isn&amp;#8217;t as bad as it initially seems since the target I use for rebuilds contains no Java.  The initial build will be painful but I&amp;#8217;ll just have to do it and be more careful not to blow away my tree!&lt;/p&gt;
&lt;p&gt;Of course, the increasing interest in zero means I&amp;#8217;m getting more bug reports.  A few people have mentioned builds failing with &lt;code&gt;java.lang.IllegalArgumentException: disparate values&lt;/code&gt;.  I assumed they were all the same, so I investigated (and fixed) it on ia64, but that particular issue was little-endian specific and so doesn&amp;#8217;t explain that people have been seeing it on ppc EPEL.  It seems that this is the first place in the build where floating point values are used &lt;em&gt;and checked&lt;/em&gt;, so this message is not one specific error but a catch-all for generic floating point bugs.  Anyway, if you&amp;#8217;re seeing this error then please let me know.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;ve been thinking about TCK runs too.  I didn&amp;#8217;t fancy the idea of setting up an entire TCK environment on ppc, so I filed it in my head under &amp;ldquo;Future work&amp;rdquo;, but it occurred to me that zero works (or should do) on amd64 too, so it shouldn&amp;#8217;t be too difficult to drop it into our nightly tester.  I&amp;#8217;ve not done more than thinking about this as yet since there&amp;#8217;s not much point in doing it without copious free time to fix the thousands of bugs it&amp;#8217;ll doubtless find &amp;#8212; which I don&amp;#8217;t have!&lt;/p&gt;
&lt;p&gt;All this zero stuff has left Shark on the back-burner for a bit, but work there is progressing too.  Lately I&amp;#8217;ve been working on making unimplemented stuff abort only that compilation (not the entire VM) so that a)&amp;nbsp; people can use it in it&amp;#8217;s unfinished state, and b)&amp;nbsp;I can run some benchmarks and get some idea of the progress I&amp;#8217;m making.&lt;/p&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 24 Jun 2008 09:12:37 GMT</pubDate>
      <title>Shark 0.01 released</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=210</link>
      <guid>http://gbenson.net/?p=83</guid>
      <description>&lt;p&gt;I just committed what I have of Shark to &lt;a href="http://icedtea.classpath.org/hg/icedtea6" &gt;icedtea6 hg&lt;/a&gt;. Its version number should be taken as an indication of its level of completeness. To build it you need to use &lt;code&gt;./configure&amp;nbsp;--enable-shark&lt;/code&gt; with a very recent LLVM installed on your system.  I&amp;#8217;m using 52487&amp;#8230;&lt;/p&gt;
</description>
    </item>
    <item>
      <pubDate>Fri, 20 Jun 2008 09:14:26 GMT</pubDate>
      <title>20 Jun 2008</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=209</link>
      <guid>http://gbenson.net/?p=82</guid>
      <description>&lt;p&gt;I spent quite a lot of time tracking down a &lt;a href="http://llvm.org/bugs/show_bug.cgi?id=2464" &gt;miscompilation&lt;/a&gt; in LLVM lately but I&amp;#8217;m pretty much back on track now.  One fun thing is that I figured out how to add diagnostic options to OpenJDK, so when I eventually release Shark you&amp;#8217;ll be able to debug it with the following exciting options:&lt;/p&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;code&gt;-XX:SharkStartAt=&lt;em&gt;N&lt;/em&gt;&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Start compiling only after &lt;em&gt;N&lt;/em&gt; compilation requests. (Use in conjunction with &lt;code&gt;-XX:+PrintCompilation&lt;/code&gt;.)&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;-XX:SharkStopAfter=&lt;em&gt;N&lt;/em&gt;&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Stop compiling after &lt;em&gt;N&lt;/em&gt; compilation requests.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;-XX:SharkDumpModuleAfter=&lt;em&gt;N&lt;/em&gt;&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Dump all generated LLVM bitcode (to &lt;code&gt;hotspot.bc&lt;/code&gt;) after &lt;em&gt;N&lt;/em&gt; compilation requests.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;-XX:SharkPrintTypeflowAfter=&lt;em&gt;N&lt;/em&gt;&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Print the results of the typeflow pass of the &lt;em&gt;N&lt;/em&gt;th compilation request.&lt;/dd&gt;
&lt;dt&gt;&lt;code&gt;-XX:+SharkTraceBytecodes&lt;/code&gt;&lt;/dt&gt;
&lt;dd&gt;Print the name and bci of each bytecode compiled (Handy for crashes).&lt;/dd&gt;
&lt;/dl&gt;
&lt;p&gt;I tend to use them in pairs, eg &lt;code&gt;-XX:Shark{StartAt,DumpModuleAfter}=17&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This list will probably get real old real quick, but they&amp;#8217;ll all be listed in &lt;code&gt;ports/hotspot/src/share/vm/shark/shark_globals.hpp&lt;/code&gt;.&lt;/p&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 3 Jun 2008 16:14:33 GMT</pubDate>
      <title>3 Jun 2008</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=208</link>
      <guid>http://gbenson.net/?p=81</guid>
      <description>&lt;p&gt;Keeping the (Java) stack and locals in registers is all very well, but it makes method calls and safepoints tricky as previously everything was on the (Zero) stack where it needed to be, and now it isn&amp;#8217;t.&lt;/p&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 28 May 2008 12:27:08 GMT</pubDate>
      <title>28 May 2008</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=207</link>
      <guid>http://gbenson.net/?p=80</guid>
      <description>&lt;p&gt;So here it is, the &lt;a href="http://gbenson.net/?page_id=78" &gt;first method&lt;/a&gt; from the all new Shark, &lt;code&gt;String.hashCode()&lt;/code&gt;.  And the &lt;a href="http://gbenson.net/?page_id=79" &gt;same method from old Shark&lt;/a&gt; for comparison. Some highlights:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The inner loop for the actual calculation is 18 instructions (down from 53)&lt;/li&gt;
&lt;li&gt;A complete pass through the method when fetching a cached hashcode is 39 instructions (down from 66)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All in all I&amp;#8217;m pretty pleased with myself.&lt;/p&gt;
</description>
    </item>
    <item>
      <pubDate>Tue, 27 May 2008 10:24:36 GMT</pubDate>
      <title>27 May 2008</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=206</link>
      <guid>http://gbenson.net/?p=77</guid>
      <description>&lt;p&gt;I nearly have &lt;code&gt;String.hashCode()&lt;/code&gt; compiling with Shark II and the code is so short it&amp;#8217;s unbelievable!&lt;/p&gt;
</description>
    </item>
    <item>
      <pubDate>Wed, 21 May 2008 23:16:49 GMT</pubDate>
      <title>21 May 2008</title>
      <link>http://www.advogato.org/person/gary/diary.html?start=205</link>
      <guid>http://gbenson.net/?p=76</guid>
      <description>&lt;p&gt;I started tearing Shark apart yesterday.  I had a chat with &lt;a href="http://www.tromey.com/blog/" &gt;Tom Tromey&lt;/a&gt; on Saturday and he mentioned some properties of Java bytecode of which I was unaware &amp;#8212; like, you can compile it without using a stack pointer.  I was trying to figure out how to modify my first pass to generate some of this stuff when a &lt;a href="http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2008-May/000170.html" &gt;reply&lt;/a&gt; to a &lt;a href="http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/2008-May/000168.html" &gt;seemingly unrelated question&lt;/a&gt; made me realise that not only does the server JIT have a pass that does all this and more, but it&amp;#8217;s been abstracted out for easy reuse!  So stay tuned for the Shark that keeps its stack and locals in registers :)&lt;/p&gt;
</description>
    </item>
  </channel>
</rss>
