JDK-4411596 : C1 does not inline sun.misc.Unsafe operations
  • Type: Bug
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 1.4.0
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2001-02-04
  • Updated: 2001-02-13
  • Resolved: 2001-02-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 betaFixed
Related Reports
Relates :  
Description
Running the following program prints:

    % /usr/local/java/jdk1.4/linux-i386/bin/java -client InlineBug
    heap 1146
    direct 3366
    % /usr/local/java/jdk1.4/linux-i386/bin/java -server InlineBug 
    heap 694
    direct 687
    % 

(This is on Linux, using build 50; I get similar numbers on Solaris.)  These
numbers, plus the profile shown below, suggest that C1 is not yet inlining the
sun.misc.Unsafe intrinsics.  Doing so is critical to the performance of the
java.nio subsystem.

---- InlineBug.java

import java.nio.*;


public class InlineBug {

    static int time(String name, ByteBuffer bb) {
	int n = bb.capacity();
	bb.limit(bb.capacity());
	int a = 0;
	long start = System.currentTimeMillis();
	for (int i = 0; i < 4096; i++) {
	    bb.rewind();
	    for (int j = 0; j < n; j++)
		a += bb.get(j);
	}
	System.out.println(name + " " + (System.currentTimeMillis() - start));
	return a;
    }

    public static void main(String[] args) {
	int n = 4096;
	String key = "hd";
	if (args.length == 1)
	    key = args[0];
	int a = 0;
	if (key.indexOf('h') >= 0)
	    a += time("heap", ByteBuffer.allocate(n));
	if (key.indexOf('d') >= 0)
	    a += time("direct", ByteBuffer.allocateDirect(n));
	System.exit(a);
    }

}

---- -Xprof output

% /usr/local/java/jdk1.4/linux-i386/bin/java -client -showversion -Xprof InlineBug d
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b50)
Java HotSpot(TM) Client VM (build 1.4beta-B50, mixed mode)

direct 5000

Flat profile of 5.27 secs (87 total ticks): main

  Interpreted + native   Method                        
  1.1%     0  +     1    java.lang.String.intern
  1.1%     1  +     0    java.lang.StringCoding$StringEncoder.<init>
  1.1%     0  +     1    java.nio.ByteBuffer.allocateDirect
  1.1%     0  +     1    java.lang.StringBuffer.expandCapacity
  4.6%     1  +     3    Total interpreted

     Compiled + native   Method                        
 21.8%    19  +     0    java.nio.DirectByteBuffer.get
 12.6%    11  +     0    InlineBug.time
  4.6%     4  +     0    java.nio.Buffer.checkIndex
 39.1%    34  +     0    Total compiled

         Stub + native   Method                        
 44.8%    15  +    24    sun.misc.Unsafe.getByte
 44.8%    15  +    24    Total stub

  Thread-local ticks:
 11.5%    10             Unknown: thread_state


Global summary of 5.27 seconds:
100.0%    87             Received ticks
 11.5%    10             Unknown code
% 

-- mr@eng 2001/2/4

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta FIXED IN: merlin-beta INTEGRATED IN: merlin-beta
14-06-2004

EVALUATION c1 now supports this feature with the old backend. Awaiting build 51 for running jck and putback. mohammad.gharahgouzloo@Eng 2001-02-07
07-02-2001