Bug 68833 - Ditch codegen "inline finally blocks"
Summary: Ditch codegen "inline finally blocks"
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Linux-GTK
: P3 normal (vote)
Target Milestone: 3.0   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-29 04:26 EDT by Johan Walles CLA
Modified: 2004-10-27 06:50 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johan Walles CLA 2004-06-29 04:26:49 EDT
In Eclipse 3.0GA:
Go to Window -> Preferences -> Java -> Compiler -> Compliance & Class Files.

On this page there's a checkbox for having the Java compiler inlining finally
blocks.  I fail to see the point of this feature.  I can see two cases:

1. The finally block is on a hot path once the code runs.  The JVM sees this and
inlines the finally block, at least for the hot catch blocks.  Having it inlined
in the cold catch blocks as well (which this feature does) is a waste of space
and may pollute the CPU's code cache with junk.

2. The finally block in not on a hot path.  Inlining it (which this feature
does) is a waste of space and may pollute the CPU's code cache with junk.

Is there a third option that I'm missing?  The description of the option says
that it leads to "larger class files" (correct) and "improved performance". 
Under what conditions have the inlined finally blocks actually lead to "improved
performance"?

If this (premature AFAICT) optimization actually yields a performance gain, a
bug should be raised with the JVM vendor.
Comment 1 Philipe Mulet CLA 2004-06-29 06:00:57 EDT
JSR202 describes this evolution. Basically, from 1.5 on, compilers are no 
longer supposed to generate bytecode instruction 'jsr' (jump subroutine) which 
is used for finally blocks. This instruction is giving headaches to VM 
implementors, so the VM specs are being evolved to deprecate this instruction 
(sadly for compilers which have to generate longer bytecode sequence due to 
inlining).

I fully agree with your claim, but we have to comply. Note that space is 
bigger, but the file will load faster, since the verification process will be 
much faster...

In preparation for this evolution, we added an option to our compiler for 
enabling this behavior so as for clients to measure its impact.
Comment 2 Philipe Mulet CLA 2004-06-29 06:01:44 EDT
My previous should have said: "from target 1.5 on".
Comment 3 Johan Walles CLA 2004-06-29 06:17:30 EDT
Cool.  Thanks for the explanation.