Re: [rvm-research] Procedure to add new code in the system

Erik Brangs <[email protected]>
Newsgroups gmane.comp.java.jikes.rvm.devel
Message-ID <[email protected]>
Hi,

On 30.04.2015 22:26, Luis Pedro Costa wrote:
> We found this open issue that we think we could implement, at least some part of it:
> 
> https://xtenlang.atlassian.net/browse/RVM-564
> 
> It's about the Array Bounds Check. I already browse in the mercurial for the commits related to this and I have found that the initial prototype was removed in the 2.2.1 release. What I was hoping I could do is, basing on the code from the 2.2.0 relase, incorporate the bounds check prototype in the most recent release.
I'm not familiar with the old ABCD code but it seems that the old array bound check implementation depended on SSA form. The SSA form in Jikes RVM was disabled years ago because of bugs and never re-enabled. I don't think that you can just port the old code to the current version of Jikes RVM. It is probably easier to start fresh with a new implementation of another algorithm.

> To do this, we looked around in Jira for some open issues. We were interested in performing some optimization, in the Optimizing Compiler component.
Just for the record, we are also missing other optimizations that are not mentioned in the bug tracker. If you're going to implement something new, you can also choose some other optimization that you think is interesting.

> I have no clue what's the procedure to incorporate new code in a system so big as Jikes. As you can imagine, i only have experience in academic programming.
> 
> I already searched the user guide in the section "Modifying the RVM". Unfortunately, as I have seen so far, this only points out what is the conventions that the new code must have. What I was hoping is that, I would get some help on what's the general procedure to implement new code in the system. What are the basics steps?  Can i just add the new classes in a package that I create in the src folder? 
When modifying the optimizing compiler, you can just add new classes for the VM in the rvm/src folder in an appropriate package.

You can also try to write unit tests and put those in rvm/test-src package. Unit tests need annotations so that JUnit can determine if a test can be run either on the boostrap VM (the VM that is used to build Jikes RVM), on Jikes RVM or both. There should be some unit tests that you can look at in the rvm/test-src folder if you're using the latest version from the repository.

> In general, Is there a procedure one must follow when adding new code to the system?
Start small and proceed in small steps. For example, when adding a new compiler phase, add the phase to the OptimizationPlanner and make sure that it is actually called before doing further work. As a next step, you could check that the phase can actually find all the places that you're interested in (e.g. all the instructions that are bound checks).

When adding new optimizations, I would recommend to disable them by default and enable them using an option. This has the advantage that the new optimization pass won't be used when building a development or production image, so you can be reasonably sure that the built bootimage is no more buggy than a standard Jikes RVM boot image. The options for the Jikes RVM are generated during the build from the files in rvm/src-generated/options .

Note that you must have some kind of automated testing approach when doing opt compiler work because the Jikes RVM will use the baseline compiler by default unless the method is hot enough or the VM has been configured otherwise. You will probably want to have a combination of unit tests and other tests (e.g. using test runs) to make sure that the optimization pass works correctly. There isn't any good infrastructure right now that's specifically built to test single compiler phases. You will have to write something yourself or try to modify one of the existing mechanisms (e.g. OptTestHarness, unit tests) if you need something more fine-grained than normal test runs.

> Also, in a different subject, let's say I modify the source code of the system, adding just some println's in the methods. I would do this as a way to understand what's going on in the system. Now, to test the newly added printlns in the code, do I have to do a complete clean of the system and then compile entirely it again? 
> Obviously this takes quite some time because it is creating the boot image and it takes a while for the complete system to build in my machine. Is there a more simpler way to do this? Maybe re-build the components i have changed? Is that possible?
Unfortunately, you will have to build a new bootimage when modifiying most parts of the Jikes RVM. One normally deals with this by using a configuration that builds quickly (prototype-opt in your case) and only switching to a faster configuration (development in your case) when it's benefical (e.g. long running tests, tests using benchmarks or applications). If you want to do performance evaluation, use the production configuration.

Cleaning shouldn't be necessary in most cases. 

Be careful with print outs in the compilers. The compilers are used to build the bootimage, so you should consider limiting printouts to the interesting cases. For example, if you were only interested in code compiled after the bootimage was built, you would guard your printouts with "if (VM.runningVM)" . If you have too much printouts in the compilers, the bootimage writer log will get too big. This might cause increases in build times or even cause the Ant build to fail with an OutOfMemoryError directly after the bootimage has been built (the build parses the bootimage writer log to look for uninteruptible violations and fails if they occur).


Kind regards,

Erik Brangs

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.