*** MOVED ***

NOTE: I have merged the contents of this blog with my web-site. I will not be updating this blog any more.


A Tinkertoy Computer That Plays Tic-Tac-Toe

I came across this reproduction of an article by A. K. Dewdney in his "Computer Recreations" series in Scientific American. I am not exaggerating when I say that this was the series that fundamentally altered the way I looked at computers and programming. I long to read such articles now... ~sigh~
Of course, I already own copies of "Armchair Universe" and "The Computational Beauty of Nature", but a regular series like this would be quite welcome.

(Originally posted on Advogato.)


Making Room for Linux

Without ntfsresize to help us out, we could not have made room for a Linux installation on an unfortunate PC that had a complete Windows 2000 infestation on its entire hard disc. All hail Free software!

(Originally posted on Advogato.)


Hosting Zero

For some reason, the guys at Hosting Zero suddenly offered to host my site for free! So I moved my web site there. They seem to have far more facilities than Tripod where I used to host my site and have no irritating advertisements and popup windows.

Let us see how this works out. A big thanks to the guys at Hosting Zero - do check them out.

(Originally posted on Advogato.)



As a standards-based slide presentation framework for browsers, S5 is quite impressive!

(Originally posted on Advogato.)

The Great GCJ Binary Compatibility Merge

Tom merged in the GCJ Binary Compatibility branch. Time to explore this with the help of the paper by Tom and Andrew.

(Originally posted on Advogato.)


Running Kernel's Image

Can anyone tell me of a reliable way of finding out the actual image (program file) that was used to launch the currently running Linux kernel?

(Originally posted on Advogato.)

Reality Bytes

While trying to help a friend's Mom with sending emails, I realised how much we programmers assume of the ordinary user's ability to think of computers the way we do and how unhelpful computers really are even today. It also provided me with a couple of amusing exchanges that I thought I'd share.

I asked her if she uses Netscape to check her mail. She said: "No, I use VSNL to check mails!" (VSNL is the ISP she uses and the corresponding Dial-up connection icon has the same name.)

She said: "Who is this 'SMTP' and why is he bothering me?" After a while, I figured out that she was saying this because her mail client used to show an error message like "smtp.vsnl.net responded: Please enter your correct username/password". For someone who only knows about "The Internet" and nothing of mail protocols or server hostnames, I think her indignation was somewhat justified. ;-)

(Originally posted on Advogato.)


Linux Kernel Headers

Hey, I didn't know that you were no longer supposed to maintain a "/usr/src/linux" symlink for the kernel headers!

(Originally posted on Advogato.)


New GCC C Parser

Lesser mortals take significantly longer than the mere week that Joseph Myers took to write a new recursive-descent C parser for GCC that accepts the same C language plus GNU extensions (a.k.a. "GNU C") as the existing one that uses Bison. :-/

(Originally posted on Advogato.)


Jacks Migrated

Jacks has migrated to its new home within Mauve! Thank you Tom and Mark.

(Originally posted on Advogato.)

QEMU Rocks!

At work, we needed to test out our project on as many machines as possible, but we could not get access to enough machines that we could maul as and when we pleased. VMWare would have helped, but we didn't have enough licenses. Bochs was good but was too slow for practical purposes. Fortunately for us, we found QEMU and it fit the bill quite well. It has been written primarily by Fabrice Bellard and is quite fast and works surprisingly well - we could get an entire installation of Red Hat Enterprise Linux 3 Advanced Server running under QEMU without any problems!

For the adventurous, quite a few QEMU-ready images can be found at FreeOSZoo. QEMU also comes with a utility to convert VMWare disc images to the raw disc images used by both QEMU and Bochs. Very cool stuff and highly recommended! Thanks Fabrice!

(Originally posted on Advogato.)



Tom thinks that Jacks should be forked since development on it has stalled and no one seems to respond to any mails. Anyone checking out the Jacks CVS repository regularly or taking a look at the Jacks mailing list archives would also come to the same conclusion. Jacks is a fantastic testsuite but sadly has not kept up with the language constructs introduced in JDK 1.5 (or "Java 2 Version 5" or "Java 5" or whatever) and patches to fix this have been mostly ignored for some reason.

In fact, there seems to be a proposal to merge Jacks with Mauve. That would be really neat. I hope it is kept as a separate module within the Mauve CVS repository though, as compiler and runtime testsuites ought to be kept separate, in my opinion.

As an aside, I found that GCJX gives different results (as is to be expected) when run against Jacks and different values for the --source option. For example, the construct Object foo = 1; now seems to be valid due to automatic boxing. Perhaps Jacks should be modified to tailor the status of testcase executions based on the language level targetted by the compiler being tested. Or perhaps it can just target the latest language specification.

Talking of GCJX, a simple clarification I asked for on the GCC mailing list resulted in a big thread - thankfully, the patch I suggested to work around the issue was approved, so that the part of GCC used by GCJX can now be compiled by a C++ compiler once again.

(Originally posted on Advogato.)


Corrupt RAM Modules

Once again, I have been bitten by bad RAM modules, this time in the Dell Optiplex GX270 machine I use at work. Memtest-86 was able to diagnose the problem after I spent almost a month wondering why programs randomly crashed on me and trying out all sorts of software updates.

(Originally posted on Advogato.)


Tom has been having great sucesses with GCJX lately. He announced his intentions to start a branch on gcc.gnu.org to continue with its development. He also wanted to take suggestions for an alternative name for this project. The straightforward one in the grand hacker tradition of recursive acronyms would perhaps be "GING" for "GING Is Not GCJ" or maybe "GRAG" for "GCJ Rewritten As GRAG". Or perhaps "JAC4J" for "Just Another Compiler For Java", though that one almost looks like it has come from a marketroid.

(Originally posted on Advogato.)


Doom 3 on Windows 98

The load at work has finally eased a bit and I can now actually get home in time! ~phew~
So I decide to try out a few game demos ("Doom 3", "Far Cry" and "Prince of Persia: Sands of Time") and finish the full version of "Uru" that had been abandoned when the mad rush to finish the project at work started.

While Far Cry and PoPSoT are gorgeous games, Doom 3 just refused to run on the Windows 98 that I have. Specifically, it needed "GlobalMemoryStatusEx" from kernel32.dll, which is available only in Windows 2000 and XP. Now I am not going to buy Windows 2000 or XP just to play the demo of a game.

Of course others have also faced the same issue but alarmingly people have just been editing the doom3.exe binary to zero out the "Ex" of "GlobalMemorysStatusEx" in the import table to match another function that is available on Windows 98. It seems to work for them, but is wrong because the former method returns a BOOL while the latter does not and the former takes in a struct of a different size altogether!

So using MinGW I wrote a simple dummy DLL named "mykrnl32.dll" which provided an implementation of GlobalMemoryStatusEx using GlobalMemoryStatus from the real kernel32.dll and forwarded all other calls to the real kernel32.dll. The forwarding bit was done by using "export forwarding" support in Windows Portable Executable files. (Interestingly, export forwarding is supported by MinGW's dllwrap tool but not by its "gcc -shared".) I then changed "kernel32.dll" in the import table of the doom3.exe binary to "mykrnl32.dll".

This got me past that particular failure, but I had to do a couple of more tweaks (none related to Windows 98 per se) to get it running. Suffice it to say that I did manage to get it running well enough in the end! So Doom 3 can run on Windows 98 (and perhaps 95 and ME), but doesn't because of some sloppy coding on iD's part - hey even libiberty in GCC knows how to do it right!

However, the game itself was a terrible letdown - it is so dark throughout the game and while the characters look detailed, their klunky contours are quite distracting! Far Cry is much better looks wise (but with terrible controls) as well as for playability (those enemies with their A.I.!) and PoPSoT is far more polished than either of these.

In any case, I enjoyed this little bit of hacking.

(Originally posted on Advogato.)


GCC 4.0

So the next version of GCC will be numbered "4.0.0" after all! I was hoping this would happen and could never quite understand why some people were so against bumping the major version number.

(Originally posted on Advogato.)


GCC and Stack Slot Coalescing

RTH does it again - GCC now has stack slot coalescing! This feature is especially important for the kernel developers.

(Originally posted on Advogato.)



The pressure at work to meet the project deadline is not letting me spend any time on GCC hacking. :-(
A quick perusal of the lists show that some very exciting things are happening with GCC and with GCJ. GCC will soon be entering Stage 3 and a lot of people are working hard to get their stuff in before that. Jan Hubicka seems to be on a mission to reduce the memory taken up by GCC after the tree-ssa merge. Sebastian Pop has actually implemented loop interchanging for code that ought to have been written properly in the first place - I am happy that GCC is becoming smarter but sad that this would let sloppy code go unpunished.

Tom and Andrew are back at hacking furiously at the BC-ABI for GCJ while Michael has finally liberated GCJ from the clutches of a hacked automake. Bryce seems have taken on the role of the GCJ PR man while triaging (and fixing) a lot of GCJ bugs.

I can't wait to get back...

(Originally posted on Advogato.)



GDB 6.2 is out finally and so is Linux Kernel 2.4.27.

(Originally posted on Advogato.)

UPS Woes

My UPS by APC was out of action and at a service centre this weekend - it switched off while I was working on my computer and then started emitting these highly irritating beeps that I couldn't quite do much about (it being 11PM in the night). To add insult to injury, the service centre guys apparently kept it under observation for two days and did not find any problems with it whatsoever!

(Originally posted on Advogato.)

"Effective C++"

I read this book by Scott Meyers this weekend and grew even less fond of C++! I mean, it's almost as if this language goes out of its way to ensure that you end up with several "gotchas" to worry about in addition to what you set out to code in the first place!

(Originally posted on Advogato.)


"Keeping Programming Fun"

I came across an Ask Slashdot question that touches upon something that has really been bothering me lately - as a professional programmer, how can you keep programming fun enough to dabble in your favourite Free or Open-Source or personal project after work at home?

Many a time, I am just too mentally tired to do any useful programming work at home on weekdays and I would like to keep the weekends free for other non-programming activities (reading books, socialising with friends, watching movies, etc.). So where is the time for a poor hacker to work on his favourite projects?

Some of the possibilities:
  • Work for a company that will actually pay you for your work on your favourite project. Not everyone can be so lucky and sometimes there are other factors (location preference, desired minimum salary, etc.) which make this impossible. In addition, I have this weird problem where a thing becomes totally uninteresting to me and a chore the moment I am asked or expected to work on it by someone else. :-(

  • Work for a company where the day job is not so taxing (usually) on your creative juices, yet pays you well enough to bring food to your table and to pay for your loans (mortgages). In Bangalore, this is a possibility. ;-)

  • Switch professions - get a job that does not involve programming. The problem with this, apart from the need to be educationally qualified to do such a job, is the danger of the job getting too boring or too interesting - the former can be disastrous while the latter saps into your creative juices just the way a programming job does.

  • Forget about personal projects for a while, concentrate on your job, wait for the Peter Principle to take effect and get promoted into management - you will then have more money as well as a job that does not involve coding. Personally, this will profoundly depress me, killing all the enthusiasm I have.

The comments in the Slashdot article linked above provide some more options, but there is nothing that really helped me.

How do you cope up with it?

(Originally posted on Advogato.)



After almost a decade of "abstinence", I am finally attending a training course on learing SQL and PL/SQL. Two of the big products that I have been involved with at work (at my current as well as previous employer) have had almost all of the core business logic in PL/SQL, so saying "I'm a Java programmer - I won't look at that!" doesn't quite work that well when it comes to understanding these systems.

My fears and reluctance in learning these earlier were mostly unfounded - these are not that bad to learn and to use, though it seems that elegance is something that their designers didn't particularly have high on their minds.

(Originally posted on Advogato.)

No News is Bad GNUs

What's up people? There haven't been regular updates on Planet Classpath from a lot of you for a long time... Get off your Glutius Maximii and tell us what you have been up to recently!

(Originally posted on Advogato.)



I am playing with Tom's GCJX now whenever I get some time, trying to understand it and see if I can contribute a little to add in some of the missing pieces. Last weekend I contributed JAR/ZIP reading. It turns out that this is a bit slower than reading from expanded folders containing the compiled classes.

By the way, GCJX is most definitely much easier to understand and tweak than the current GCJ front end. It also uses standard STL containers instead of the ubiquitous GCC trees or hash tables.

A disturbing thing that I discovered was that GCJX compiled with debugging information is around 48.5MB(!) on my machine and when stripped, comes down to somewhat reasonable 1.5MB. Could it be that we need to exorcise the Template Instantiation demon?

(Originally posted on Advogato.)



I started tinkering with Tom's
project this weekend. On a cursory perusal, it definitely seems
more accessible to ordinary mortals than the current GCJ front end. It
is written in C++, a language that I am not too comfortable with, but
that should not be an insurmountable problem.

I built and ran GCJX against the current GCC mainline. I normally do
not actually install a newly built mainline GCC snapshot after the GCC
build process is complete, so using this compiler is a bit
different than normal - I used the following script to build GCJX using
such a GCC:


# Build GCJX


BLT_CXX="$GCC_BLD_DIR/gcc/g++ -B$GCC_BLD_DIR/gcc/ \
-I$GCC_BLD_DIR/$GCC_BLD_TGT/libstdc++-v3/include \
-I$GCC_BLD_DIR/$GCC_BLD_TGT/libstdc++-v3/include/$GCC_BLD_TGT \
-I$GCC_SRC_DIR/libstdc++-v3/libsupc++ \

make CXX="$BLT_CXX" typedefs.hh.gch

make CXX="$BLT_CXX" want_pch=yes

Compiling C++ programs that use STL with GCC can be quite slow, so I
am glad that newer GCC versions have pre-compiled header (PCH) support.
The script above uses PCH to build GCJX - on my little machine, the total
build time is reduced from 12m 2s to 6m 32s and an additional 11s to
build the PCH itself. That's quite an improvement!

Since GCJX does not come with its own class libraries, I used GNU
Classpath 0.10 sources appropriately updated
(create "gnu/classpath/Configuration.java" and copy over classes
under "vm/reference/" into the top folder) for use with GCJX.
After this, I could compile simple programs as:

lextest /path/to/classpath-0.10 . -- HelloWorld.java

This parses the given file and all files from the Java runtime
(quite a lot) needed for a complete closure and writes out class
files (and CNI header files) to "/tmp/gcjx-out" (which I had
to create beforehand). Note that I had to update LD_LIBRARY_PATH
to point to the folder containing the libstdc++.so file from the GCC
build folder as "lextest" depends on this library.

Compiling so many of the Java runtime classes over and over again every
time I want to compile a source file is a little wasteful, not to
mention quite slow, so I started giving the path to the libgcj build
folder from the GCC build folder and this speeded things up considerably.

My next task was to check GCJX against the Jacks testsuite. I had
to create an appropriate Jacks "gcjx_setup" file. Mine looks
like this:

set JAVAC /extra/src/gcjx/lextest
set JAVA /extra/src/gcc/build/i686-pc-linux-gnu/libjava/gij
set JAVA_FLAGS "-mx=64m"
set JAVAC_FLAGS {/extra/src/gcc/build/i686-pc-linux-gnu/libjava . -- -jacks}
set JAVAC_DEPRECATION_FLAG "-deprecated"
set tcltest::testConstraints(assert) 1

"-jacks" is a temporary flag that causes GCJX to suppress most
of its pedantic warnings and causes it to write out classes to the current
folder (instead of "/tmp/gcjx-out").

I got 4302 PASS-es, 541 FAILs and 76 UNTESTED out of a total of 4919 Jacks
testcases. This is not as good as what Tom reports, so I have to see what
has gone wrong - but in any case, it is much better than what the
current GCJ front end gives.

Great work Tom!

I want to see if I can add JAR/ZIP reading support to GCJX. This looks
doable and Tom already has most of the framework ready.

(Originally posted on Advogato.)



My understanding of the bootstrapping process.

(Originally posted on Advogato.)

Bytecode Verification

I was able to track down and fix PR 5537 with a simple patch, but fixing it exposed other problems in the front end bytecode verifier that cause failures in the libjava testsuite and in the Mauve verifier testsuite.

So now I need to go after these bugs before I can submit a patch.
(Why do such things always happen to me?)

I found an interesting presentation (PDF) by Gilad Bracha (a "Computational Theologist" in Sun) on bytecode verification. I found it interesting because he says that Sun went with load-time bytecode verification to reduce run-time verification overheads and had to introduce strict definite (un)assignment as a mandatory feature of the language to be able to carry out proper type inference during verification! The other interesting bit was that they went with type inference (instead of type checking) to reduce the space used by class files at the cost of increased complexity, memory usage and speed - they later found out that type checking would have meant faster and simpler code at the cost of only a little extra space (5-10%)!

"Premature optimisation is the root of all evil!"

By the way, JDK 1.5 will have class data sharing to reduce startup times. So should libgcj use prelinking?

(Originally posted on Advogato.)


GCC and C++

The GCC Steering Committee published its decision (and that of RMS) on Nathan Sidwell's proposal to rewrite GCC in a useful subset of C++. In short, they have turned it down though they are open to the idea of making GCC sources compile correctly with a C++ compiler. What I didn't quite get was this:

In addition, RMS stated that the use of C++ was unacceptable for the GNU Project, at least for programs that are presently written in C.

This is quite weird and without more of the context in which this was uttered or clarifications, I don't understand this at all. In particular, this doesn't bode well for Tom's rewrite of the GCJ front end in C++, which by the way, is coming along pretty well for a one man project.

RMS also considers GCJ's capabilities to compile Java bytecode bad, considering it a way for malicious vendors to bypass GCC's GPL to use it as a compiler backend!


(Originally posted on Advogato.)

Emaciated, yet Emancipated

Linux Weekly News (LWN) is an online resource of superb quality - dare I say it is The Economist of the Free Software journalism world - well researched and mostly thorough articles, quite up to date and fairly balanced content and a simple yet effective layout. I have enjoyed it for quite some time now and would highly recommend it to anyone who cares to listen.

For some time now however, the "crown jewel" of LWN, "The LWN.net Weekly Edition" has been immediately available only to subscribers (though it is made freely accessible to everyone else after a week) as even the LWN guys need to feed themselves, just like everyone else. So I decided to subscribe to it, if nothing to show my support for these wonderful guys, but found out that except for the "starving hacker" level of subscription, everything else would be a bit of an indulgence for me when the fact that a US Dollar is around 45 Indian Rupees is considered. So that is what I opted for and now I get all the LWN stuff as soon as it is published. Cool!

(Originally posted on Advogato.)


Contributing to GCC

Roger Sayle sums it up nicely. I agree with him 100%. Even though I am a fringe and quite erratic contributor to GCJ (much less the core GCC), it has helped me immensely as a software developer. To paraphrase Calvin's Dad, "It helps build character".

(Originally posted on Advogato.)



Nathan Sidwell is on the laudable mission of introducing statically typed trees to GCC replacing the much abused and overloaded "tree" structure. Some people were of the opinion that it might be much better to just write a front end in C++ or at least a reduced subset of C++ ("C with classes"?). Some though were a bit apprehensive of the idea, saying that once you let in a bit of C++, there will really be nothing stopping developers from bringing in all of C++ and then you'd find yourself in a nightmare of trying to support all those C++ compilers on all supported platforms that differ sometimes subtly, sometimes not quite so in their interpretation of the language standards.

Tom has rewritten the GCJ front end in C++ and has done awesomely well and quite a lot in such a short period of time.

Looks like there's no escaping it now...


I have never been able to bring myself to like this language. There is no one thing that I can point to nor can I write detailed and knowledgeable analyses like this or this, though I do agree completely with a lot of points raised in these.

Perhaps it is because of the boring and overly complex book on the language by Stroustrup that happened to be my first introduction to C++ (in a sharp contrast to that masterpiece of brevity, accessibility and utility that was written by Kernighan and Ritchie). Perhaps it is because of the mind-scarring error messages spewed by the versions of the IBM xlC compiler on AIX containing literally two to three lines of mangled names of instantiations of templates. Perhaps it is because of the fact that GCC is so slow compiling programs using the STL. Perhaps it is because I found that as a programmer I had to know so many things about the nuances of the language just to be able to program anything with a semblence of confidence.

I really like object-oriented programming, but I find Java to be way better and much simpler in expressing myself than C++. I would not at all mind if GCC were to be rewritten in Java, though I'm not at all a Java fanboy.

I just want a natively compiled, simple programming language without many "gotchas", that lets me easily express decent object-oriented designs and that comes with a standard and fairly comprehensive runtime library. Perhaps I should take a dekko at Objective C.

(See? This is what happens when Advogato comes back up online after a long time.)

(Originally posted on Advogato.)

"Things a Computer Scientist Rarely Talks About"

My friend Ananth has just gifted me a copy of "Things a Computer Scientist Rarely Talks About", a very different book by Donald Knuth. Having admired and being in awe of most of Knuth's work and being an atheist, this book should make some interesting reading for me.

Other recently acquired books on my "reading pending" list (besides almost the whole of my library) include "The Art of Unix Programming" by Eric Raymond and "Five Point Someone" by Chetan Bhagat, a novel about life in an IIT.

(Originally posted on Advogato.)


Advogato Is Back!


My inane ramblings can now resume.


(Originally posted on Advogato.)


Small World

Niraj Kumar, who contributed the support for FreeBSD's UFS2 filesystems to the 2.6 series Linux kernel is also from Bangalore!

Not only that - he works for Oracle India as well and in fact sits in the same building as I do!

I am yet to meet him though. :-/

(Originally posted on Advogato.)


GCJ and Definite [Un]Assignments

I spent most of my free time this weekend trying to resolve some of the issues with definite [un]assignment in GCJ as specified by the JLS.

I just wanted to be able to see zero new FAILs with Jacks, but that goal proved to be quite elusive - I fix one bug and that uncovers problems elsewhere, I fix some of those bugs and they uncover some more, ad nauseam - I had to give up after a certain point and just came up with something that is the least disruptive.

All this effort on something that I do not even agree completely with! I mean, this part of the JLS must be one of the shadiest - Sun has just converted into a specification whatever they felt they could reasonably implement in their own compiler, never mind if someone else can come up with a more thorough code flow analysis and give out less stoopid warnings. Sheesh!

(Originally posted on Advogato.)



"How to Write Shared Libraries" (PDF) is a paper by Ulrich Drepper that should be mandatory reading for every serious UNIX programmer. If nothing else, it lets one throw terms around like GOT and PLTs at newbies! ;-)

(Originally posted on Advogato.)

GCC Gets Tree-SSA

After almost 4 years of development, the tree-ssa project has finally been merged into the GCC mainline!

The Static Single Assignment (SSA) form enables all sorts of funky optimisations to be implemented in GCC, making it possible for it to compete effectively with commercial optimising compilers.

Thanks in large part to Jeff Sturm and Andrew Haley, GCJ starts off as a first class citizen in this new avatar of GCC, that too with no libjava testsuite regressions. In fact, the Jacks testsuite now shows 30 unexpected successes (XPASSes) with GCJ and only 5 new failures (FAILs)!

The GCC bootstrap time seems to have regressed by around 20% percent, but one should not forget that quite a bit of new code has been added, not to mention the increased number of Trees that are created and the now redundant RTL optimisers.

And oh, by the way, say "Hello!" to Tree Browser!

(Originally posted on Advogato.)

www.advogato.org server woes

Even the Advogato server has been having problems lately! The result is that I've not been able to post diary entries for around a week now. (Not that I have anything insanely useful or profoundly interesting to say, but still...)

The following is what I intended to post around a week ago:

(Originally posted on Advogato.)



Gmail is a real pleasure to use - thanks to Yumpee Saar, I've had a Gmail account for a while now. It still lacks a couple of things and is not as customisable as one would have liked it to be, but it is still so much better than any other web-based email service I have seen. Like so many great innovations, it has so many neat and simple features that make you think "Why hadn't anyone thought of this before?". Nice.

I have since had four opportunities to invite others and my wife, my sister, Kingshuk and Srikanth were promptly doled out these invitations.

(Originally posted on Advogato.)

Package-Private Accesses in GCJ

My patches for PR 15073 and 9685 are finally in.

(Originally posted on Advogato.)

gcc.gnu.org Server Woes

The server that hosts gcc.gnu.org as well as sources.redhat.com had to be moved out of its colo facility at a very short notice. Its IP address was therefore changed and the RAM was also upgraded to 4GB. However the corresponding DNS entry's TTL was one whole day, so the IP address change did not quite propagate as soon as one would have liked it to. So we couldn't access the server for that period. However, worse was yet to follow.

The increased bandwidth and RAM somehow caused a RAID driver bug that results in hard lock-ups to show up much more frequently than ever before, with the result that the server is only intermittently up for useful work. (It responds to "ping", but CVS, SSH, etc. seem to be down.)

As of this writing, the server is down again - I really hope this issue gets resolved as soon as possible.

By the way, what I do not understand is why the "overseers" mailing list that is used to coordinate the activities of the maintainers of this important server for free software seems to be hosted on the server itself!

(Originally posted on Advogato.)


GCJ Front End Hacking

A couple of remarkable things happened while I was working on the above. First, my wife got curious about what I was trying to fix and how I planned to fix it and pretty soon I found myself walking my wife through the parsing bits of the GCJ front end, including the Java grammar!

She and my sister then left for a movie that I was not at all keen to watch, so I spent that time at home hacking on GCJ - that resulted in four and half hours of continuous hacking that was masochistically exhilarating, helped of course by the fact that I was actually able to find a satisfactory solution at the end of it.

Such hacking binges are sadly so rare now, but used to be so frequent during my undergraduate days. ~sigh~ :-(
Anyway, I found out that the GCJ front-end is not such a mess after all - there's a method to the madness, as they say, but it requires a bit of patience and perseverance to understand. Of course, to use another cliche, I have just seen the tip of the iceberg - who knows what horrors lurk as I try to delve deeper into the front end?

Anyone wishing to understand the front end should definitely try out Alexandre Oliva's debugx to step through the code using a debugger like GDB to see how it works. Inside a debugger, GCC's cool debug_tree() function can be used to examine a TREE node. The GNU coding standards make it very easy to search for the implementation of a function in a file (ESC/^foobar in vi, for example). The function java_parse_file() in the file "java/jcf-parse.c" provides the "big picture" for the front end.

(Originally posted on Advogato.)

Package-Private Class Access in GCJ

This weekend I thought I would try my luck at nailing down another instance of illegal package-private access that GCJ lets through (PR java/15073). As luck would have it, I was able to come up with a patch that fixes that problem. The great thing about this patch is that it also simplifies my fix to the other package-private access problem, by removing a nagging kludge that was needed for that fix to work properly. (If you must know, not_accessible_p() in "java/parse.y" was being called even for classes and not just members as it was supposed to be - the kludge was needed to account for such rogue TYPE_DECLs.) Cool!

(Originally posted on Advogato.)


CVS Updates Over SSH

The slow CVS updates from the GCC repository that I was facing were mostly due to filesystem corruption on the machine hosting gcc.gnu.org and sources.redhat.com. Now that these problems have been fixed, my CVS updates over SSH are acceptably fast over my dial-up link at home.

(Originally posted on Advogato.)

GCC 3.4.0 Released

GCC 3.4.0 is out with tonnes of improvements! Notable among these are cool optimiser improvements (profile feedback based optimisation and unit-at-a-time compilation), a rewritten C++ parser that brings g++ much closer to standards conformance, much better GCJ and a Java interpreter that can actually run Eclipse 2.x(!), etc.

(Originally posted on Advogato.)

Illegal Package-Private Accesses Checking

...in the current GCJ is just plain broken. I have had a simple patch for fixing this for accesses to package-private members for a long
time now, but the bug had let in a few instances of wrong code to creep into libgcj that were sometimes trivial, sometimes not so trivial, to fix. Yesterday, Michael Koch committed the fix for the last of these problems and therefore I promptly submitted a revised version of my patch for review.

Unfortunately, this still does not fix illegal access to package-private classes though.

Sadder still is that GCJ still has a bunch of problems related to access control. :-(

(Originally posted on Advogato.)


Awed by GRUB/Linux

I had heard of the "loop" capabilities of mount and the Linux kernel, but I experienced its full utility only yesterday - very, very cool!

We needed to install SuSE Linux apart from the existing Red Hat installation on our machine at the office, but neither was the floppy drive enabled nor was it possible to get a bootable CD burned from the corresponding ISO image from SuSE due to the existing "IT policies". (Yes, big corporations are like this some times.)

So we first reformatted our swap partition as a regular ext3 filesystem, "loop" mounted the ISO image and copied over all the files into the newly created filesystem. Then we used the cool edit-boot-parameters-before-booting feature of GRUB to temporarily boot using this filesystem and proceeded to the actual installation. No floppy or CD required!

SuSE Linux 9.0 has a lot more eye candy than a default installation of Red Hat Enterprise Linux 9.0 and also has a couple of cool extra features. I look forward to exploring this variant of my favourite OS.

But I still love Slackware and yearn for its simple methods.

(Originally posted on Advogato.)

NV40 a.k.a. NVIDIA GeForce6


(Originally posted on Advogato.)

TrueType Fonts Under FreeType2

If you are in a country where software patents do not (yet) apply - or if you just do not believe in them - you should always compile FreeType2 with TT_CONFIG_OPTION_BYTECODE_INTERPRETER defined in the file "include/freetype/config/ftoption.h". This improves the display of TrueType fonts. However, "Times New Roman" and "Courier New" still do not render nicely enough under Mozilla for me. :-(
(Yes, I do have the Xft/Gtk2/Pango enabled build of Mozilla.)

(Originally posted on Advogato.)



Please do not say or write "Mr Foo Bar" on first mention - just say "Foo Bar" the first time you refer to a person - after that, you can call him "Mr Bar".
The Economist's Style Guide spells it out nicely. In fact, the "Mr Foo Bar" form is not proper at all, but is sadly used almost universally by (at least) English speaking Indians - just use the surnames with "Mr/Mrs/Miss" as in "Mr Bar".

This is not to say that I speak/write perfect English (I
strive to, but mostly fail), but there are some things that irritate me more than others and this is one of them.

(Originally posted on Advogato.)

Garbage Collection

Tom quotes Stephan T. Lavavej:"Garbage collection is a morally bankrupt idea".

In my opinion, most developers seem to naively think that Garbage Collection is bad and expensive. They assert that nothing can beat malloc( )/free( ) based explicit (or implicit, via destructors invoked on leaving a scope) resource management. In fact, unless it is a good implementation of malloc( )/free( ), how can you even be sure that these functions will return in a "reasonable" amount of time, every time? You can have sudden stalls under heavy conditions even with these, just as with a garbage collector.

Many nice articles and eye-openers on Garbage Collection can be found at Hans Boehm's site. This article is particularly relevant.

(Originally posted on Advogato.)

CVS over SSH

Sean Middleditch points out that I should ask SSH to compress the transmitted data by using the "-C" flag. The SSH manual says that I can also set the variables "Compression" and "CompressionLevel" to achieve the same effect. Thanks a lot Sean!

(Originally posted on Advogato.)



Baby's first GCC CVS commit.

"cvs update" over SSH is so slow! Why? Is there anything I can do to help matters?

(Originally posted on Advogato.)

GDB 6.1

GDB 6.1 has
finally been released. This is the only version that works
properly with the current GCC CVS without crashing out on the DWARF-2 location lists generated by GCC (that can be disabled by using "-fno-var-tracking").

(Originally posted on Advogato.)



In one of those now rare moods that used to be so common when I was new to Linux, I spent most of my week simply updating almost every package on my system to the latest stable release by compiling from source, including glibc! Much of it was a breeze (yes, even glibc), but Qt and KDE gave me the most grief - for some reason, uic from Qt simply omits the KDE headers required to access custom KDE widgets from KDE applications, causing the builds to irritatingly break every now and then. I think it is the fault of the ".ui" files in the KDE distribution, but wouldn't they have built and tested the distribution before release? I am confused, but I haven't found any answers via Google yet. >:-(
GCC keeps regressing in compile speed, especially for C++ code, with the result that Qt/KDE took an enormous amount of time to build with GCC 3.3.3 - I felt like going with Gtk+/GNOME just for this reason! But for some strange, possibly idiotic, reason, I persisted and the result is I must say quite pretty - KDE 3.2.1 feels much faster and is so gorgeous to look at! (For some reason, my display wallpaper change does not take effect at all, though Konqueror is able to display all these wallpapers just fine - does anyone have an idea why?)

An awesome side-effect is that everything is now rendered in TrueType fonts, albeit with so much weird anti-aliasing that it becomes difficult to read text for long. (A few years ago, I wouldn't have believed that this is going to be my primary complaint with my Linux desktop. :-) Who says we haven't made progress here?)

(Originally posted on Advogato.)


Since there is no way my hopelessly unreliable dial-up link at home is going to let me synchronise with the GCC CVS repository (which is around 234MB of checked out files), I checked it out elsewhere(?), archived it and brought it home - from that point, checking out differential updates became possible even on my otherwise useless link. Now I finally have a CVS checkout of GCC that can be kept as updated as I wish.

What took me so long to implement this was the time taken to figure out a way of using TCP/IP over HTTP behind a proxy server so that CVS could be used, a way of carrying large amounts of data back home and the time taken to move my glutius maximus.

So I applied for, and got, write access to the GCC CVS this week, albeit not without problems (why do I always run into such things?).

(Originally posted on Advogato.)

Hear Ye, Hear Ye!

Planet Classpath has started collecting entries from my diary!

(Originally posted on Advogato.)



A cool, though shy, Andrew Haley.

(Originally posted on Advogato.)

History of GCJ

Some time back, I stumbled upon "Cygnus Foundry Java Edition - Architecture and Design Manual". This document is somewhat dated and describes the plans more than what really has been implemented in GCJ, but it is still a good read and I would highly recommend it to anyone trying to understand GCJ.

I had my "Aaaahhhh!!" moments of comprehension reading this document, especially with the "Stack Slot Compilation", "Class Metadata", "Debugging Interpreted Java", "C/C++ and Compiled Java", etc sections.

Mark Wielaard (mjw) has created "Planet Classpath", a wonderful consolidation of weblogs maintained by GNU Classpath hackers. Kudos to him.

This weekend I spent time reading "The Java Virtual Machine Specification", something that I should have a done a very long time ago. I didn't finish it and I didn't understand everything, but a lot of things have become much clearer, including the meaning of (ID[Ljava/lang/String;)Ljava/lang/Thread;. ;-)
I also played around with Jasmin, an assembler for the JVM.

In 1995-96, when I was in the final year of my undergraduate studies at IIT-K and Java was this new and cool language for creating web animations, most of us learnt this language and played around with it. "HS" was a guy who went beyond the language and used to play with the class file format and raw JVM instructions - he was promptly labelled a "weirdo" and people used to make fun of him behind his back, but were still in awe of him.

I am such a weirdo myself now. :-)
But seriously, the JVM architecture is quite simple and the instruction set is quite high-level and simple - no decent Java programmer will have much difficulty in understanding it. It is worth a dekko.

(Originally posted on Advogato.)



tromey continues to blog albeit elsewhere!

He seems to be working on a new frontend for GCJ.

Now why don't I get to know of such cool things
earlier? :-(
BTW, I finally get to see what he looks like!

(Originally posted on Advogato.)




is being merged into the GCC mainline! This project brings in an
optimisation framework for GCC Trees based on the Static
Single Assignment (SSA) form. GCC uses Trees as one of its
Intermediate Representations (IRs) - the Register Transfer
Language (RTL) being the other IR.

Trees are being cleaned
up (simplified and made language independent) into the new
"GENERIC" representation, which will then be
simplified further into the "GIMPLE" representation.
More details can be found in the
of the 2003 Annual GCC Summit.
(See the papers "Tree SSA - A New Optimization Infrastructure for GCC" by Diego Novillo and
"GENERIC and GIMPLE: A new tree representation for entire functions" by Jason Merrill.)

The current mainline now has "Variable Tracking",
that allows GCC to more accurately track and describe
variables in the generated debug information
even after optimisation - even with -fomit-frame-pointer! As a result,
-fomit-frame-pointer will become the default
for the x86 backend, freeing up a much-needed register
on this starved architecture. You will however
minimally need GDB 6.1 to be able to correctly debug
with the generated location lists. This version has
not yet been released though.

(Originally posted on Advogato.)