313 + OopClosure* scan_non_heap_weak_roots,
314 + G1GCPhaseTimes* phase_times,
315 + uint worker_i);
316
317 public:
318 G1RootProcessor(G1CollectedHeap* g1h);
319 diff --git a/test/gc/g1/TestGCLogMessages.java b/test/gc/g1/TestGCLogMessages.java
320 --- a/test/gc/g1/TestGCLogMessages.java
321 +++ b/test/gc/g1/TestGCLogMessages.java
322 @@ -1,5 +1,5 @@
323 /*
324 - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
325 + * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
326 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
327 *
328 * This code is free software; you can redistribute it and/or modify it
329 @@ -23,7 +23,7 @@
330
331 /*
332 * @test TestGCLogMessages
333 - * @bug 8035406 8027295 8035398 8019342 8027959 8048179
334 + * @bug 8035406 8027295 8035398 8019342 8027959 8048179 8027962
335 * @summary Ensure that the PrintGCDetails output for a minor GC with G1
336 * includes the expected necessary messages.
337 * @key gc
338 @@ -34,131 +34,159 @@
339 import com.oracle.java.testlibrary.OutputAnalyzer;
340
341 public class TestGCLogMessages {
342 - public static void main(String[] args) throws Exception {
343 - testNormalLogs();
344 - testWithToSpaceExhaustionLogs();
345 - }
346
347 - private static void testNormalLogs() throws Exception {
348 + private enum Level {
349 + OFF, FINER, FINEST;
350 + public boolean lessOrEqualTo(Level other) {
351 + return this.compareTo(other) < 0;
352 + }
353 + }
354
355 - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
356 - "-Xmx10M",
357 - GCTest.class.getName());
358 + private class LogMessageWithLevel {
359 + String message;
360 + Level level;
361
362 - OutputAnalyzer output = new OutputAnalyzer(pb.start());
363 + public LogMessageWithLevel(String message, Level level) {
364 + this.message = message;
365 + this.level = level;
366 + }
367 + };
368
369 - output.shouldNotContain("[Redirty Cards");
370 - output.shouldNotContain("[Parallel Redirty");
371 - output.shouldNotContain("[Redirtied Cards");
372 - output.shouldNotContain("[Code Root Purge");
373 - output.shouldNotContain("[String Dedup Fixup");
374 - output.shouldNotContain("[Young Free CSet");
375 - output.shouldNotContain("[Non-Young Free CSet");
376 - output.shouldNotContain("[Humongous Register");
377 - output.shouldNotContain("[Humongous Reclaim");
378 - output.shouldHaveExitValue(0);
379 + private LogMessageWithLevel allLogMessages[] = new LogMessageWithLevel[] {
380 + // Ext Root Scan
381 + new LogMessageWithLevel("Thread Roots (ms)", Level.FINEST),
382 + new LogMessageWithLevel("StringTable Roots (ms)", Level.FINEST),
383 + new LogMessageWithLevel("Universe Roots (ms)", Level.FINEST),
384 + new LogMessageWithLevel("JNI Handles Roots (ms)", Level.FINEST),
385 + new LogMessageWithLevel("ObjectSynchronizer Roots (ms)", Level.FINEST),
386 + new LogMessageWithLevel("FlatProfiler Roots", Level.FINEST),
387 + new LogMessageWithLevel("Management Roots", Level.FINEST),
388 + new LogMessageWithLevel("SystemDictionary Roots", Level.FINEST),
389 + new LogMessageWithLevel("CLDG Roots", Level.FINEST),
390 + new LogMessageWithLevel("JVMTI Roots", Level.FINEST),
391 + new LogMessageWithLevel("CodeCache Roots", Level.FINEST),
392 + new LogMessageWithLevel("SATB Filtering", Level.FINEST),
393 + new LogMessageWithLevel("CM RefProcessor Roots", Level.FINEST),
394 + new LogMessageWithLevel("Wait For Strong CLD", Level.FINEST),
395 + new LogMessageWithLevel("Weak CLD Roots", Level.FINEST),
396 + // Redirty Cards
397 + new LogMessageWithLevel("Redirty Cards", Level.FINER),
398 + new LogMessageWithLevel("Parallel Redirty", Level.FINEST),
399 + new LogMessageWithLevel("Redirtied Cards", Level.FINEST),
400 + // Misc Top-level
401 + new LogMessageWithLevel("Code Root Purge", Level.FINER),
402 + new LogMessageWithLevel("String Dedup Fixup", Level.FINER),
403 + // Free CSet
404 + new LogMessageWithLevel("Young Free CSet", Level.FINEST),
405 + new LogMessageWithLevel("Non-Young Free CSet", Level.FINEST),
406 + // Humongous Eager Reclaim
407 + new LogMessageWithLevel("Humongous Reclaim", Level.FINER),
408 + new LogMessageWithLevel("Humongous Register", Level.FINER),
409 + };
410
411 - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
412 - "-XX:+UseStringDeduplication",
413 - "-Xmx10M",
414 - "-XX:+PrintGCDetails",
415 - GCTest.class.getName());
416 + void checkMessagesAtLevel(OutputAnalyzer output, LogMessageWithLevel messages[], Level level) throws Exception {
417 + for (LogMessageWithLevel l : messages) {
418 + if (level.lessOrEqualTo(l.level)) {
419 + output.shouldNotContain(l.message);
420 + } else {
421 + output.shouldContain(l.message);
422 + }
423 + }
424 + }
425
426 - output = new OutputAnalyzer(pb.start());
427 + public static void main(String[] args) throws Exception {
428 + new TestGCLogMessages().testNormalLogs();
429 + new TestGCLogMessages().testWithToSpaceExhaustionLogs();
430 + }
431
432 - output.shouldContain("[Redirty Cards");
433 - output.shouldNotContain("[Parallel Redirty");
434 - output.shouldNotContain("[Redirtied Cards");
435 - output.shouldContain("[Code Root Purge");
436 - output.shouldContain("[String Dedup Fixup");
437 - output.shouldNotContain("[Young Free CSet");
438 - output.shouldNotContain("[Non-Young Free CSet");
439 - output.shouldContain("[Humongous Register");
440 - output.shouldNotContain("[Humongous Total");
441 - output.shouldNotContain("[Humongous Candidate");
442 - output.shouldContain("[Humongous Reclaim");
443 - output.shouldNotContain("[Humongous Reclaimed");
444 - output.shouldHaveExitValue(0);
445 + private void testNormalLogs() throws Exception {
446
447 - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
448 - "-XX:+UseStringDeduplication",
449 - "-Xmx10M",
450 - "-XX:+PrintGCDetails",
451 - "-XX:+UnlockExperimentalVMOptions",
452 - "-XX:G1LogLevel=finest",
453 - GCTest.class.getName());
454 + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
455 + "-Xmx10M",
456 + GCTest.class.getName());
457
458 - output = new OutputAnalyzer(pb.start());
459 + OutputAnalyzer output = new OutputAnalyzer(pb.start());
460 + checkMessagesAtLevel(output, allLogMessages, Level.OFF);
461 + output.shouldHaveExitValue(0);
462
463 - output.shouldContain("[Redirty Cards");
464 - output.shouldContain("[Parallel Redirty");
465 - output.shouldContain("[Redirtied Cards");
466 - output.shouldContain("[Code Root Purge");
467 - output.shouldContain("[String Dedup Fixup");
468 - output.shouldContain("[Young Free CSet");
469 - output.shouldContain("[Non-Young Free CSet");
470 - output.shouldContain("[Humongous Register");
471 - output.shouldContain("[Humongous Total");
472 - output.shouldContain("[Humongous Candidate");
473 - output.shouldContain("[Humongous Reclaim");
474 - output.shouldContain("[Humongous Reclaimed");
475 - output.shouldHaveExitValue(0);
476 - }
477 + pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
478 + "-XX:+UseStringDeduplication",
479 + "-Xmx10M",
480 + "-XX:+PrintGCDetails",
481 + GCTest.class.getName());
482
483 - private static void testWithToSpaceExhaustionLogs() throws Exception {
484 - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
485 - "-Xmx32M",
486 - "-Xmn16M",
487 - "-XX:+PrintGCDetails",
488 - GCTestWithToSpaceExhaustion.class.getName());
489 + output = new OutputAnalyzer(pb.start());
490 + checkMessagesAtLevel(output, allLogMessages, Level.FINER);
491
492 - OutputAnalyzer output = new OutputAnalyzer(pb.start());
493 - output.shouldContain("[Evacuation Failure");
494 - output.shouldNotContain("[Recalculate Used");
495 - output.shouldNotContain("[Remove Self Forwards");
496 - output.shouldNotContain("[Restore RemSet");
497 - output.shouldHaveExitValue(0);
498 + pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
499 + "-XX:+UseStringDeduplication",
500 + "-Xmx10M",
501 + "-XX:+PrintGCDetails",
502 + "-XX:+UnlockExperimentalVMOptions",
503 + "-XX:G1LogLevel=finest",
504 + GCTest.class.getName());
505
506 - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
507 - "-Xmx32M",
508 - "-Xmn16M",
509 - "-XX:+PrintGCDetails",
510 - "-XX:+UnlockExperimentalVMOptions",
511 - "-XX:G1LogLevel=finest",
512 - GCTestWithToSpaceExhaustion.class.getName());
513 + output = new OutputAnalyzer(pb.start());
514 + checkMessagesAtLevel(output, allLogMessages, Level.FINEST);
515 + output.shouldHaveExitValue(0);
516 + }
517
518 - output = new OutputAnalyzer(pb.start());
519 - output.shouldContain("[Evacuation Failure");
520 - output.shouldContain("[Recalculate Used");
521 - output.shouldContain("[Remove Self Forwards");
522 - output.shouldContain("[Restore RemSet");
523 - output.shouldHaveExitValue(0);
524 - }
525 + LogMessageWithLevel exhFailureMessages[] = new LogMessageWithLevel[] {
526 + new LogMessageWithLevel("Evacuation Failure", Level.FINER),
527 + new LogMessageWithLevel("Recalculate Used", Level.FINEST),
528 + new LogMessageWithLevel("Remove Self Forwards", Level.FINEST),
550 + output.shouldHaveExitValue(0);
551 +
552 + pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
553 + "-Xmx32M",
554 + "-Xmn16M",
555 + "-XX:+PrintGCDetails",
556 + "-XX:+UnlockExperimentalVMOptions",
557 + "-XX:G1LogLevel=finest",
558 + GCTestWithToSpaceExhaustion.class.getName());
559 +
560 + output = new OutputAnalyzer(pb.start());
561 + checkMessagesAtLevel(output, exhFailureMessages, Level.FINEST);
562 + output.shouldHaveExitValue(0);
563 }
564 - }
565
566 - static class GCTestWithToSpaceExhaustion {
567 - private static byte[] garbage;
568 - private static byte[] largeObject;
569 - public static void main(String [] args) {
570 - largeObject = new byte[16*1024*1024];
571 - System.out.println("Creating garbage");
572 - // create 128MB of garbage. This should result in at least one GC,
573 - // some of them with to-space exhaustion.
574 - for (int i = 0; i < 1024; i++) {
575 - garbage = new byte[128 * 1024];
576 - }
577 - System.out.println("Done");
578 + static class GCTest {
579 + private static byte[] garbage;
580 + public static void main(String [] args) {
581 + System.out.println("Creating garbage");
582 + // create 128MB of garbage. This should result in at least one GC
583 + for (int i = 0; i < 1024; i++) {
584 + garbage = new byte[128 * 1024];
585 + }
586 + System.out.println("Done");
587 + }
588 }
589 - }
590 +
|
313 + OopClosure* scan_non_heap_weak_roots,
314 + G1GCPhaseTimes* phase_times,
315 + uint worker_i);
316
317 public:
318 G1RootProcessor(G1CollectedHeap* g1h);
319 diff --git a/test/gc/g1/TestGCLogMessages.java b/test/gc/g1/TestGCLogMessages.java
320 --- a/test/gc/g1/TestGCLogMessages.java
321 +++ b/test/gc/g1/TestGCLogMessages.java
322 @@ -1,5 +1,5 @@
323 /*
324 - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
325 + * Copyright (c) 2014, 2015 Oracle and/or its affiliates. All rights reserved.
326 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
327 *
328 * This code is free software; you can redistribute it and/or modify it
329 @@ -23,7 +23,7 @@
330
331 /*
332 * @test TestGCLogMessages
333 - * @bug 8035406 8027295 8035398 8019342 8027959
334 + * @bug 8035406 8027295 8035398 8019342 8027959 8027962
335 * @summary Ensure that the PrintGCDetails output for a minor GC with G1
336 * includes the expected necessary messages.
337 * @key gc
338 @@ -34,128 +34,158 @@
339 import com.oracle.java.testlibrary.OutputAnalyzer;
340
341 public class TestGCLogMessages {
342 - public static void main(String[] args) throws Exception {
343 - testNormalLogs();
344 - testWithToSpaceExhaustionLogs();
345 - }
346
347 - private static void testNormalLogs() throws Exception {
348 + private enum Level {
349 + OFF, FINER, FINEST;
350 + public boolean lessOrEqualTo(Level other) {
351 + return this.compareTo(other) < 0;
352 + }
353 + }
354
355 - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
356 - "-Xmx10M",
357 - GCTest.class.getName());
358 + private class LogMessageWithLevel {
359 + String message;
360 + Level level;
361
362 - OutputAnalyzer output = new OutputAnalyzer(pb.start());
363 + public LogMessageWithLevel(String message, Level level) {
364 + this.message = message;
365 + this.level = level;
366 + }
367 + };
368
369 - output.shouldNotContain("[Redirty Cards");
370 - output.shouldNotContain("[Parallel Redirty");
371 - output.shouldNotContain("[Redirtied Cards");
372 - output.shouldNotContain("[Code Root Purge");
373 - output.shouldNotContain("[String Dedup Fixup");
374 - output.shouldNotContain("[Young Free CSet");
375 - output.shouldNotContain("[Non-Young Free CSet");
376 - output.shouldNotContain("[Humongous Reclaim");
377 - output.shouldHaveExitValue(0);
378 + private LogMessageWithLevel allLogMessages[] = new LogMessageWithLevel[] {
379 + // Ext Root Scan
380 + new LogMessageWithLevel("Thread Roots (ms)", Level.FINEST),
381 + new LogMessageWithLevel("StringTable Roots (ms)", Level.FINEST),
382 + new LogMessageWithLevel("Universe Roots (ms)", Level.FINEST),
383 + new LogMessageWithLevel("JNI Handles Roots (ms)", Level.FINEST),
384 + new LogMessageWithLevel("ObjectSynchronizer Roots (ms)", Level.FINEST),
385 + new LogMessageWithLevel("FlatProfiler Roots", Level.FINEST),
386 + new LogMessageWithLevel("Management Roots", Level.FINEST),
387 + new LogMessageWithLevel("SystemDictionary Roots", Level.FINEST),
388 + new LogMessageWithLevel("CLDG Roots", Level.FINEST),
389 + new LogMessageWithLevel("JVMTI Roots", Level.FINEST),
390 + new LogMessageWithLevel("CodeCache Roots", Level.FINEST),
391 + new LogMessageWithLevel("SATB Filtering", Level.FINEST),
392 + new LogMessageWithLevel("CM RefProcessor Roots", Level.FINEST),
393 + new LogMessageWithLevel("Wait For Strong CLD", Level.FINEST),
394 + new LogMessageWithLevel("Weak CLD Roots", Level.FINEST),
395 + // Redirty Cards
396 + new LogMessageWithLevel("Redirty Cards", Level.FINER),
397 + new LogMessageWithLevel("Parallel Redirty", Level.FINEST),
398 + new LogMessageWithLevel("Redirtied Cards", Level.FINEST),
399 + // Misc Top-level
400 + new LogMessageWithLevel("Code Root Purge", Level.FINER),
401 + new LogMessageWithLevel("String Dedup Fixup", Level.FINER),
402 + // Free CSet
403 + new LogMessageWithLevel("Young Free CSet", Level.FINEST),
404 + new LogMessageWithLevel("Non-Young Free CSet", Level.FINEST),
405 + // Humongous Eager Reclaim
406 + new LogMessageWithLevel("Humongous Reclaim", Level.FINER),
407 + };
408
409 - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
410 - "-XX:+UseStringDeduplication",
411 - "-Xmx10M",
412 - "-XX:+PrintGCDetails",
413 - GCTest.class.getName());
414 + void checkMessagesAtLevel(OutputAnalyzer output, LogMessageWithLevel messages[], Level level) throws Exception {
415 + for (LogMessageWithLevel l : messages) {
416 + if (level.lessOrEqualTo(l.level)) {
417 + output.shouldNotContain(l.message);
418 + } else {
419 + output.shouldContain(l.message);
420 + }
421 + }
422 + }
423
424 - output = new OutputAnalyzer(pb.start());
425 + public static void main(String[] args) throws Exception {
426 + new TestGCLogMessages().testNormalLogs();
427 + new TestGCLogMessages().testWithToSpaceExhaustionLogs();
428 + }
429
430 - output.shouldContain("[Redirty Cards");
431 - output.shouldNotContain("[Parallel Redirty");
432 - output.shouldNotContain("[Redirtied Cards");
433 - output.shouldContain("[Code Root Purge");
434 - output.shouldContain("[String Dedup Fixup");
435 - output.shouldNotContain("[Young Free CSet");
436 - output.shouldNotContain("[Non-Young Free CSet");
437 - output.shouldContain("[Humongous Reclaim");
438 - output.shouldNotContain("[Humongous Total");
439 - output.shouldNotContain("[Humongous Candidate");
440 - output.shouldNotContain("[Humongous Reclaimed");
441 - output.shouldHaveExitValue(0);
442 + private void testNormalLogs() throws Exception {
443
444 - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
445 - "-XX:+UseStringDeduplication",
446 - "-Xmx10M",
447 - "-XX:+PrintGCDetails",
448 - "-XX:+UnlockExperimentalVMOptions",
449 - "-XX:G1LogLevel=finest",
450 - GCTest.class.getName());
451 + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
452 + "-Xmx10M",
453 + GCTest.class.getName());
454
455 - output = new OutputAnalyzer(pb.start());
456 + OutputAnalyzer output = new OutputAnalyzer(pb.start());
457 + checkMessagesAtLevel(output, allLogMessages, Level.OFF);
458 + output.shouldHaveExitValue(0);
459
460 - output.shouldContain("[Redirty Cards");
461 - output.shouldContain("[Parallel Redirty");
462 - output.shouldContain("[Redirtied Cards");
463 - output.shouldContain("[Code Root Purge");
464 - output.shouldContain("[String Dedup Fixup");
465 - output.shouldContain("[Young Free CSet");
466 - output.shouldContain("[Non-Young Free CSet");
467 - output.shouldContain("[Humongous Reclaim");
468 - output.shouldContain("[Humongous Total");
469 - output.shouldContain("[Humongous Candidate");
470 - output.shouldContain("[Humongous Reclaimed");
471 - output.shouldHaveExitValue(0);
472 - }
473 + pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
474 + "-XX:+UseStringDeduplication",
475 + "-Xmx10M",
476 + "-XX:+PrintGCDetails",
477 + GCTest.class.getName());
478
479 - private static void testWithToSpaceExhaustionLogs() throws Exception {
480 - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
481 - "-Xmx10M",
482 - "-Xmn5M",
483 - "-XX:+PrintGCDetails",
484 - GCTestWithToSpaceExhaustion.class.getName());
485 + output = new OutputAnalyzer(pb.start());
486 + checkMessagesAtLevel(output, allLogMessages, Level.FINER);
487
488 - OutputAnalyzer output = new OutputAnalyzer(pb.start());
489 - output.shouldContain("[Evacuation Failure");
490 - output.shouldNotContain("[Recalculate Used");
491 - output.shouldNotContain("[Remove Self Forwards");
492 - output.shouldNotContain("[Restore RemSet");
493 - output.shouldHaveExitValue(0);
494 + pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
495 + "-XX:+UseStringDeduplication",
496 + "-Xmx10M",
497 + "-XX:+PrintGCDetails",
498 + "-XX:+UnlockExperimentalVMOptions",
499 + "-XX:G1LogLevel=finest",
500 + GCTest.class.getName());
501
502 - pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
503 - "-Xmx10M",
504 - "-Xmn5M",
505 - "-XX:+PrintGCDetails",
506 - "-XX:+UnlockExperimentalVMOptions",
507 - "-XX:G1LogLevel=finest",
508 - GCTestWithToSpaceExhaustion.class.getName());
509 + output = new OutputAnalyzer(pb.start());
510 + checkMessagesAtLevel(output, allLogMessages, Level.FINEST);
511 + output.shouldHaveExitValue(0);
512 + }
513
514 - output = new OutputAnalyzer(pb.start());
515 - output.shouldContain("[Evacuation Failure");
516 - output.shouldContain("[Recalculate Used");
517 - output.shouldContain("[Remove Self Forwards");
518 - output.shouldContain("[Restore RemSet");
519 - output.shouldHaveExitValue(0);
520 - }
521 + LogMessageWithLevel exhFailureMessages[] = new LogMessageWithLevel[] {
522 + new LogMessageWithLevel("Evacuation Failure", Level.FINER),
523 + new LogMessageWithLevel("Recalculate Used", Level.FINEST),
524 + new LogMessageWithLevel("Remove Self Forwards", Level.FINEST),
546 + output.shouldHaveExitValue(0);
547 +
548 + pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
549 + "-Xmx32M",
550 + "-Xmn16M",
551 + "-XX:+PrintGCDetails",
552 + "-XX:+UnlockExperimentalVMOptions",
553 + "-XX:G1LogLevel=finest",
554 + GCTestWithToSpaceExhaustion.class.getName());
555 +
556 + output = new OutputAnalyzer(pb.start());
557 + checkMessagesAtLevel(output, exhFailureMessages, Level.FINEST);
558 + output.shouldHaveExitValue(0);
559 }
560 - }
561
562 - static class GCTestWithToSpaceExhaustion {
563 - private static byte[] garbage;
564 - private static byte[] largeObject;
565 - public static void main(String [] args) {
566 - largeObject = new byte[5*1024*1024];
567 - System.out.println("Creating garbage");
568 - // create 128MB of garbage. This should result in at least one GC,
569 - // some of them with to-space exhaustion.
570 - for (int i = 0; i < 1024; i++) {
571 - garbage = new byte[128 * 1024];
572 - }
573 - System.out.println("Done");
574 + static class GCTest {
575 + private static byte[] garbage;
576 + public static void main(String [] args) {
577 + System.out.println("Creating garbage");
578 + // create 128MB of garbage. This should result in at least one GC
579 + for (int i = 0; i < 1024; i++) {
580 + garbage = new byte[128 * 1024];
581 + }
582 + System.out.println("Done");
583 + }
584 }
585 - }
586 +
|