Here's is a case for Escape Analysis. When a array of a primitive type is indexed by a variable, the allocation of the array is no longer optimized. A small test case is attached. There are two similar programs. The main difference is:

< s += b[i];
switch (i) {
case 0: s += b[0]; break;
case 1: s += b[1]; break;
case 2: s += b[2]; break;
case 3: s += b[3]; break;
case 4: s += b[4]; break;
case 5: s += b[5]; break;

For the second program the array allocation is eliminated. A log with more information and the Assembly output are included.
Can for the first program the array allocation be optimized as well ?


The information in this e-mail is intended only for the person or entity to which it is addressed.

It may contain confidential and /or privileged material. If someone other than the intended recipient should receive this e-mail, he / she shall not be entitled to read, disseminate, disclose or duplicate it.

If you receive this e-mail unintentionally, please inform us immediately by "reply" and then delete it from your system. Although this information has been compiled with great care, neither IMC Financial Markets & Asset Management nor any of its related entities shall accept any responsibility for any errors, omissions or other inaccuracies in this information or for the consequences thereof, nor shall it be bound in any way by the contents of this e-mail or its attachments. In the event of incomplete or incorrect transmission, please return the e-mail to the sender and permanently delete this message and any attachments.

Messages and attachments are scanned for all known viruses. Always scan attachments before opening them.
-------------- next part --------------
An HTML attachment was scrubbed...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: files.tar
Type: application/x-tar
Size: 71680 bytes
Desc: not available
Url :

Search Discussions

  • Paul Thio at Nov 27, 2010 at 6:34 am
    Please ignore my previous mail about Escape Analysis. I found the answer in the jdk 7 notes:

    "After escape analysis, the server compiler eliminates scalar replaceable object allocations and associated locks from heap. The server compiler also eliminates locks for all non-globally escaping objects. It does not replace a heap allocation with a stack allocation for non-globally escaping objects."

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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouphotspot-compiler-dev @
postedNov 27, '10 at 4:28a
activeNov 27, '10 at 6:34a

2 users in discussion

Paul Thio: 1 post P. Thio: 1 post



site design / logo © 2021 Grokbase