|
30 | 30 | import jdk.test.lib.jfr.EventNames; |
31 | 31 | import jdk.test.lib.jfr.Events; |
32 | 32 | import jdk.test.lib.Asserts; |
| 33 | +import jdk.test.lib.Platform; |
| 34 | +import sun.hotspot.WhiteBox; |
33 | 35 |
|
34 | 36 | /** |
35 | 37 | * @test |
36 | 38 | * @summary Test that event is triggered when an object is allocated in a new TLAB. |
37 | 39 | * @key jfr |
38 | 40 | * @requires vm.hasJFR |
39 | 41 | * @library /test/lib |
40 | | - * @run main/othervm -XX:+UseTLAB -XX:TLABSize=100k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=1 jdk.jfr.event.allocation.TestObjectAllocationInNewTLABEvent |
41 | | - * @run main/othervm -XX:+UseTLAB -XX:TLABSize=100k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=1 -Xint jdk.jfr.event.allocation.TestObjectAllocationInNewTLABEvent |
| 42 | + * @build sun.hotspot.WhiteBox |
| 43 | + * |
| 44 | + * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox |
| 45 | + * @run main/othervm -XX:+WhiteBoxAPI -Xbootclasspath/a:. |
| 46 | + * -XX:+UseTLAB -XX:TLABSize=100k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=1 |
| 47 | + * jdk.jfr.event.allocation.TestObjectAllocationInNewTLABEvent |
| 48 | + * @run main/othervm -XX:+WhiteBoxAPI -Xbootclasspath/a:. |
| 49 | + * -XX:+UseTLAB -XX:TLABSize=100k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=1 |
| 50 | + * -Xint |
| 51 | + * jdk.jfr.event.allocation.TestObjectAllocationInNewTLABEvent |
42 | 52 | */ |
43 | 53 |
|
44 | 54 | /** |
45 | 55 | * Test that when an object is allocated in a new Thread Local Allocation Buffer (TLAB) |
46 | 56 | * an event will be triggered. The test is done for default and interpreted mode (-Xint). |
47 | 57 | * |
48 | 58 | * To force objects to be allocated in a new TLAB: |
49 | | - * the size of TLAB is set to 100k (-XX:TLABSize=100k); |
50 | | - * the size of allocated objects is set to 100k minus 16 bytes overhead; |
| 59 | + * the initial size of TLAB is set to 100k (-XX:TLABSize=100k); |
| 60 | + * the size of allocated objects is set to 128k; |
51 | 61 | * max TLAB waste at refill is set to minimum (-XX:TLABRefillWasteFraction=1), |
52 | 62 | * to provoke a new TLAB creation. |
53 | 63 | */ |
54 | 64 | public class TestObjectAllocationInNewTLABEvent { |
55 | 65 | private final static String EVENT_NAME = EventNames.ObjectAllocationInNewTLAB; |
56 | 66 |
|
57 | | - private static final int BYTE_ARRAY_OVERHEAD = 16; // Extra bytes used by a byte array. |
58 | | - private static final int OBJECT_SIZE = 100 * 1024; |
59 | | - private static final int OBJECT_SIZE_ALT = OBJECT_SIZE + 8; // Object size in case of disabled CompressedOops. |
| 67 | + private static final Boolean COMPRESSED_CLASS_PTRS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedClassPointers"); |
| 68 | + |
| 69 | + private static final int BYTE_ARRAY_OVERHEAD = (Platform.is64bit() && !COMPRESSED_CLASS_PTRS) ? 24 : 16; |
| 70 | + private static final int OBJECT_SIZE = 128 * 1024; |
| 71 | + |
60 | 72 | private static final int OBJECTS_TO_ALLOCATE = 100; |
61 | 73 | private static final String BYTE_ARRAY_CLASS_NAME = new byte[0].getClass().getName(); |
62 | 74 | private static final int INITIAL_TLAB_SIZE = 100 * 1024; |
@@ -112,9 +124,9 @@ private static void verify(RecordedEvent event) { |
112 | 124 | long allocationSize = Events.assertField(event, "allocationSize").atLeast(1L).getValue(); |
113 | 125 | long tlabSize = Events.assertField(event, "tlabSize").atLeast(allocationSize).getValue(); |
114 | 126 | String className = Events.assertField(event, "objectClass.name").notEmpty().getValue(); |
115 | | - if (className.equals(BYTE_ARRAY_CLASS_NAME) && (allocationSize == OBJECT_SIZE || allocationSize == OBJECT_SIZE_ALT)) { |
| 127 | + if (className.equals(BYTE_ARRAY_CLASS_NAME) && (allocationSize == OBJECT_SIZE)) { |
116 | 128 | countAllTlabs++; |
117 | | - if (tlabSize == INITIAL_TLAB_SIZE + OBJECT_SIZE || tlabSize == INITIAL_TLAB_SIZE + OBJECT_SIZE_ALT) { |
| 129 | + if (tlabSize == INITIAL_TLAB_SIZE + OBJECT_SIZE) { |
118 | 130 | countFullTlabs++; |
119 | 131 | } |
120 | 132 | } |
|
0 commit comments