36 import jdk.test.whitebox.WhiteBox;
37
38 /**
39 * @test
40 * @summary Test that when an object is allocated outside a TLAB an event will be triggered.
41 * @requires vm.flagless
42 * @requires vm.hasJFR
43 * @library /test/lib
44 * @build jdk.test.whitebox.WhiteBox
45 *
46 * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
47 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
48 * -XX:+UseTLAB -XX:TLABSize=2k -XX:-ResizeTLAB
49 * jdk.jfr.event.allocation.TestObjectAllocationSampleEventThrottling
50 */
51
52 public class TestObjectAllocationSampleEventThrottling {
53 private static final String EVENT_NAME = EventNames.ObjectAllocationSample;
54
55 private static final Boolean COMPRESSED_CLASS_PTRS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedClassPointers");
56
57 private static final int BYTE_ARRAY_OVERHEAD = (Platform.is64bit() && !COMPRESSED_CLASS_PTRS) ? 24 : 16;
58 private static final int OBJECT_SIZE = 128 * 1024;
59
60 private static final int OBJECTS_TO_ALLOCATE = 100;
61 private static final String BYTE_ARRAY_CLASS_NAME = new byte[0].getClass().getName();
62 private static int eventCount;
63
64 // Make sure allocation isn't dead code eliminated.
65 public static byte[] tmp;
66
67 public static void main(String[] args) throws Exception {
68 testZeroPerSecond();
69 testThrottleSettings();
70 }
71
72 private static void testZeroPerSecond() throws Exception {
73 Recording r1 = new Recording();
74 setThrottle(r1, "0/s");
75 r1.start();
76 allocate();
77 r1.stop();
|
36 import jdk.test.whitebox.WhiteBox;
37
38 /**
39 * @test
40 * @summary Test that when an object is allocated outside a TLAB an event will be triggered.
41 * @requires vm.flagless
42 * @requires vm.hasJFR
43 * @library /test/lib
44 * @build jdk.test.whitebox.WhiteBox
45 *
46 * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
47 * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
48 * -XX:+UseTLAB -XX:TLABSize=2k -XX:-ResizeTLAB
49 * jdk.jfr.event.allocation.TestObjectAllocationSampleEventThrottling
50 */
51
52 public class TestObjectAllocationSampleEventThrottling {
53 private static final String EVENT_NAME = EventNames.ObjectAllocationSample;
54
55 private static final Boolean COMPRESSED_CLASS_PTRS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedClassPointers");
56 private static final Boolean COMPACT_HEADERS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompactObjectHeaders");
57
58 private static final int BYTE_ARRAY_OVERHEAD = COMPACT_HEADERS ? 12 : ((Platform.is64bit() && !COMPRESSED_CLASS_PTRS) ? 24 : 16);
59 private static final int OBJECT_SIZE = 128 * 1024;
60
61 private static final int OBJECTS_TO_ALLOCATE = 100;
62 private static final String BYTE_ARRAY_CLASS_NAME = new byte[0].getClass().getName();
63 private static int eventCount;
64
65 // Make sure allocation isn't dead code eliminated.
66 public static byte[] tmp;
67
68 public static void main(String[] args) throws Exception {
69 testZeroPerSecond();
70 testThrottleSettings();
71 }
72
73 private static void testZeroPerSecond() throws Exception {
74 Recording r1 = new Recording();
75 setThrottle(r1, "0/s");
76 r1.start();
77 allocate();
78 r1.stop();
|