< prev index next >

test/jdk/jdk/jfr/event/allocation/TestObjectAllocationOutsideTLABEvent.java

Print this page

 48  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
 49  *                   -XX:+UseTLAB -XX:TLABSize=90k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=256
 50  *                   -Xint
 51  *                   jdk.jfr.event.allocation.TestObjectAllocationOutsideTLABEvent
 52  */
 53 
 54 /**
 55  * Test that an event is triggered when an object is allocated outside a
 56  * Thread Local Allocation Buffer (TLAB). The test is done for default interpreted mode (-Xint).
 57  *
 58  * To force objects to be allocated outside TLAB:
 59  *      the initial size of TLAB is set to 90k (-XX:TLABSize=90k);
 60  *      the size of allocated objects is set to 128k;
 61  *      max TLAB waste at refill is set to 256 (-XX:TLABRefillWasteFraction=256),
 62  *          to prevent a new TLAB creation.
 63 */
 64 public class TestObjectAllocationOutsideTLABEvent {
 65     private static final String EVENT_NAME = EventNames.ObjectAllocationOutsideTLAB;
 66 
 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 
 72     private static final int OBJECTS_TO_ALLOCATE = 100;
 73     private static final String BYTE_ARRAY_CLASS_NAME = new byte[0].getClass().getName();
 74     private static int eventCount;
 75 
 76     // Make sure allocation isn't dead code eliminated.
 77     public static byte[] tmp;
 78 
 79     public static void main(String[] args) throws Exception {
 80         Recording recording = new Recording();
 81         recording.enable(EVENT_NAME);
 82         recording.start();
 83         allocate();
 84         recording.stop();
 85         verifyRecording(recording);
 86         int minCount = (int) floor(OBJECTS_TO_ALLOCATE * 0.80);
 87         Asserts.assertGreaterThanOrEqual(eventCount, minCount, "Too few objects allocated");
 88         Asserts.assertLessThanOrEqual(eventCount, OBJECTS_TO_ALLOCATE, "Too many objects allocated");
 89     }

 48  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:.
 49  *                   -XX:+UseTLAB -XX:TLABSize=90k -XX:-ResizeTLAB -XX:TLABRefillWasteFraction=256
 50  *                   -Xint
 51  *                   jdk.jfr.event.allocation.TestObjectAllocationOutsideTLABEvent
 52  */
 53 
 54 /**
 55  * Test that an event is triggered when an object is allocated outside a
 56  * Thread Local Allocation Buffer (TLAB). The test is done for default interpreted mode (-Xint).
 57  *
 58  * To force objects to be allocated outside TLAB:
 59  *      the initial size of TLAB is set to 90k (-XX:TLABSize=90k);
 60  *      the size of allocated objects is set to 128k;
 61  *      max TLAB waste at refill is set to 256 (-XX:TLABRefillWasteFraction=256),
 62  *          to prevent a new TLAB creation.
 63 */
 64 public class TestObjectAllocationOutsideTLABEvent {
 65     private static final String EVENT_NAME = EventNames.ObjectAllocationOutsideTLAB;
 66 
 67     private static final Boolean COMPRESSED_CLASS_PTRS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompressedClassPointers");
 68     private static final Boolean COMPACT_HEADERS = WhiteBox.getWhiteBox().getBooleanVMFlag("UseCompactObjectHeaders");
 69 
 70     private static final int BYTE_ARRAY_OVERHEAD = COMPACT_HEADERS ? 12 : ((Platform.is64bit() && !COMPRESSED_CLASS_PTRS) ? 24 : 16);
 71     private static final int OBJECT_SIZE = 128 * 1024;
 72 
 73     private static final int OBJECTS_TO_ALLOCATE = 100;
 74     private static final String BYTE_ARRAY_CLASS_NAME = new byte[0].getClass().getName();
 75     private static int eventCount;
 76 
 77     // Make sure allocation isn't dead code eliminated.
 78     public static byte[] tmp;
 79 
 80     public static void main(String[] args) throws Exception {
 81         Recording recording = new Recording();
 82         recording.enable(EVENT_NAME);
 83         recording.start();
 84         allocate();
 85         recording.stop();
 86         verifyRecording(recording);
 87         int minCount = (int) floor(OBJECTS_TO_ALLOCATE * 0.80);
 88         Asserts.assertGreaterThanOrEqual(eventCount, minCount, "Too few objects allocated");
 89         Asserts.assertLessThanOrEqual(eventCount, OBJECTS_TO_ALLOCATE, "Too many objects allocated");
 90     }
< prev index next >