8146736: Move sun.misc performance counters to jdk.internal.perf

Reviewed-by: alanb, mchung, rriggs
This commit is contained in:
Chris Hegarty 2016-01-13 14:32:42 +00:00
parent 9884b80330
commit ed581c190a
11 changed files with 51 additions and 38 deletions

View File

@ -50,6 +50,8 @@ import java.util.Vector;
import java.util.Hashtable;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
import jdk.internal.perf.PerfCounter;
import sun.misc.Resource;
import sun.misc.URLClassPath;
import sun.reflect.CallerSensitive;
@ -423,9 +425,9 @@ public abstract class ClassLoader {
c = findClass(name);
// this is the defining class loader; record the stats
sun.misc.PerfCounter.getParentDelegationTime().addTime(t1 - t0);
sun.misc.PerfCounter.getFindClassTime().addElapsedTimeFrom(t1);
sun.misc.PerfCounter.getFindClasses().increment();
PerfCounter.getParentDelegationTime().addTime(t1 - t0);
PerfCounter.getFindClassTime().addElapsedTimeFrom(t1);
PerfCounter.getFindClasses().increment();
}
}
if (resolve) {

View File

@ -52,6 +52,7 @@ import java.util.jar.Manifest;
import jdk.internal.misc.JavaNetAccess;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.perf.PerfCounter;
import sun.misc.Resource;
import sun.misc.URLClassPath;
import sun.net.www.ParseUtil;
@ -459,14 +460,14 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
// Use (direct) ByteBuffer:
CodeSigner[] signers = res.getCodeSigners();
CodeSource cs = new CodeSource(url, signers);
sun.misc.PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0);
PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0);
return defineClass(name, bb, cs);
} else {
byte[] b = res.getBytes();
// must read certificates AFTER reading bytes.
CodeSigner[] signers = res.getCodeSigners();
CodeSource cs = new CodeSource(url, signers);
sun.misc.PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0);
PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0);
return defineClass(name, b, 0, b.length, cs);
}
}

View File

@ -54,6 +54,7 @@ import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import jdk.internal.misc.JavaUtilZipFileAccess;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.perf.PerfCounter;
import static java.util.zip.ZipConstants.*;
import static java.util.zip.ZipConstants64.*;
@ -210,8 +211,8 @@ class ZipFile implements ZipConstants, Closeable {
this.name = name;
long t0 = System.nanoTime();
this.zsrc = Source.get(file, (mode & OPEN_DELETE) != 0);
sun.misc.PerfCounter.getZipFileOpenTime().addElapsedTimeFrom(t0);
sun.misc.PerfCounter.getZipFileCount().increment();
PerfCounter.getZipFileOpenTime().addElapsedTimeFrom(t0);
PerfCounter.getZipFileCount().increment();
}
/**

View File

@ -22,13 +22,14 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.misc;
package jdk.internal.perf;
import java.nio.ByteBuffer;
import java.security.Permission;
import java.security.PrivilegedAction;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import jdk.internal.ref.CleanerFactory;
/**
* The Perf class provides the ability to attach to an instrumentation
@ -46,7 +47,7 @@ import java.io.UnsupportedEncodingException;
* @author Brian Doherty
* @since 1.4.2
* @see #getPerf
* @see sun.misc.Perf$GetPerfAction
* @see jdk.internal.perf.Perf.GetPerfAction
* @see java.nio.ByteBuffer
*/
public final class Perf {
@ -123,10 +124,10 @@ public final class Perf {
* Please note that the <em>"sun.misc.Perf.getPerf"</em> permission
* is not a JDK specified permission.
*
* @return A reference to the singleton Perf instance.
* @throws AccessControlException if a security manager exists and
* its <code>checkPermission</code> method doesn't allow
* access to the <em>"sun.misc.Perf.getPerf"</em> target.
* @return A reference to the singleton Perf instance.
* @throws SecurityException if a security manager exists and its
* <code>checkPermission</code> method doesn't allow access
* to the <em>"jdk.internal.perf.Perf.getPerf""</em> target.
* @see java.lang.RuntimePermission
* @see #attach
*/
@ -134,7 +135,7 @@ public final class Perf {
{
SecurityManager security = System.getSecurityManager();
if (security != null) {
Permission perm = new RuntimePermission("sun.misc.Perf.getPerf");
Permission perm = new RuntimePermission("jdk.internal.perf.Perf.getPerf");
security.checkPermission(perm);
}
@ -277,27 +278,35 @@ public final class Perf {
// This is an instrumentation buffer for another Java virtual
// machine with native resources that need to be managed. We
// create a duplicate of the native ByteBuffer and manage it
// with a Cleaner object (PhantomReference). When the duplicate
// becomes only phantomly reachable, the native resources will
// be released.
// with a Cleaner. When the duplicate becomes phantom reachable,
// the native resources will be released.
final ByteBuffer dup = b.duplicate();
Cleaner.create(dup, new Runnable() {
public void run() {
try {
instance.detach(b);
}
catch (Throwable th) {
// avoid crashing the reference handler thread,
// but provide for some diagnosability
assert false : th.toString();
}
}
});
CleanerFactory.cleaner()
.register(dup, new CleanerAction(instance, b));
return dup;
}
}
private static class CleanerAction implements Runnable {
private final ByteBuffer bb;
private final Perf perf;
CleanerAction(Perf perf, ByteBuffer bb) {
this.perf = perf;
this.bb = bb;
}
public void run() {
try {
perf.detach(bb);
} catch (Throwable th) {
// avoid crashing the reference handler thread,
// but provide for some diagnosability
assert false : th.toString();
}
}
}
/**
* Native method to perform the implementation specific attach mechanism.
* <p>
@ -341,7 +350,7 @@ public final class Perf {
* machine running this method (lvmid=0, for example), then the detach
* request is silently ignored.
*
* @param ByteBuffer A direct allocated byte buffer created by the
* @param bb A direct allocated byte buffer created by the
* <code>attach</code> method.
* @see java.nio.ByteBuffer
* @see #attach

View File

@ -23,7 +23,7 @@
* questions.
*/
package sun.misc;
package jdk.internal.perf;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;

View File

@ -38,6 +38,7 @@ import java.awt.event.WindowListener;
import java.awt.peer.WindowPeer;
import java.util.ArrayList;
import jdk.internal.perf.PerfCounter;
import sun.awt.AWTAccessor;
import sun.awt.AWTAccessor.ComponentAccessor;
import sun.awt.Win32GraphicsDevice;
@ -69,9 +70,9 @@ public class D3DGraphicsDevice extends Win32GraphicsDevice {
if (d3dAvailable) {
// we don't use pixel formats for the d3d pipeline
pfDisabled = true;
sun.misc.PerfCounter.getD3DAvailable().set(1);
PerfCounter.getD3DAvailable().set(1);
} else {
sun.misc.PerfCounter.getD3DAvailable().set(0);
PerfCounter.getD3DAvailable().set(0);
}
}

View File

@ -34,7 +34,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import sun.misc.Perf;
import jdk.internal.perf.Perf;
import sun.management.counter.Units;
import sun.management.counter.Counter;
import sun.management.counter.perf.PerfInstrumentation;

View File

@ -25,7 +25,7 @@
package sun.management;
import sun.misc.Perf;
import jdk.internal.perf.Perf;
import sun.management.counter.*;
import sun.management.counter.perf.*;
import java.nio.ByteBuffer;

View File

@ -95,7 +95,7 @@ public abstract class AbstractMonitoredVm implements BufferedMonitoredVm {
public void detach() {
/*
* no default action required because the detach operation for the
* native byte buffer is managed by the sun.misc.Perf class.
* native byte buffer is managed by the Perf class.
*/
}

View File

@ -25,7 +25,6 @@
package sun.jvmstat.perfdata.monitor;
import sun.misc.Perf;
import sun.jvmstat.monitor.*;
import java.util.*;
import java.io.*;

View File

@ -25,7 +25,7 @@
package sun.jvmstat.perfdata.monitor.protocol.local;
import sun.misc.Perf;
import jdk.internal.perf.Perf;
import sun.jvmstat.monitor.*;
import sun.jvmstat.perfdata.monitor.*;
import java.util.*;