any impact on performance from javac's debug option ?

John Rose John.Rose at Sun.COM
Mon Aug 4 13:56:57 PDT 2008

On Aug 4, 2008, at 1:26 PM, Charles Oliver Nutter wrote:

> I asked because I've seen that too...LogCompilation messages about  
> a method being too big when that method consisted almost entirely  
> of an assertion line. Guess I'll have to be more careful about not  
> putting assertions in the hottest, smallest methods like field  
> accessors, eh?

The most common cliff to step off of is MaxInlineSize, the size (in  
bytecodes) beyond which a method is not inlined unless there is  
strong evidence to the contrary, such as a hot profile.  The number  
is currently 35.  Adding an assert to a field accessor method should  
not kick you over that limit, unless the assert has a complex structure.

Here's a rule of thumb, which should remain valid across a wide range  
of JVMs:  If a hot method contains cold paths, factor the code on  
those paths out into a (private) subroutine.  Assert expressions are  
cold paths, because they are not taken when asserts are disabled.

-- John

Not so good:
     String getName() {
         assert(name.indexOf('/') == name.lastIndexOf('/'));
         return name;
     String getName2() {
         if (name.length() > 15)  throw new RuntimeException("length  
of name is "+name.length());
         return name;

     String getName() {
         return name;
     private boolean nameHasTwoSlashes() {
         return name.indexOf('/') != name.lastIndexOf('/');
     String getName2() {
         if (name.length() > 15)  throw nameTooLongException();
         return name;
     private RuntimeException nameTooLongException() {
         return new RuntimeException("length of name is "+name.length 

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the hotspot-dev mailing list