# HG changeset patch # User brutisso # Date 1296794949 28800 # Node ID c798c277ddd1071be7dae36fa996adf91b300011 # Parent 176d0be302142e0eea9260562f6060c9a1b7e44e 7015169: GC Cause not always set Summary: Sometimes the gc cause was not always set. This caused JStat to print the wrong information. Reviewed-by: tonyp, ysr Contributed-by: suenaga.yasumasa@oss.ntt.co.jp diff -r 176d0be30214 -r c798c277ddd1 src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp --- a/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp Thu Feb 03 16:06:01 2011 -0500 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp Thu Feb 03 20:49:09 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -132,8 +132,7 @@ VM_GenCollectFullConcurrent(unsigned int gc_count_before, unsigned int full_gc_count_before, GCCause::Cause gc_cause) - : VM_GC_Operation(gc_count_before, full_gc_count_before, true /* full */) { - _gc_cause = gc_cause; + : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true /* full */) { assert(FullGCCount_lock != NULL, "Error"); assert(UseAsyncConcMarkSweepGC, "Else will hang caller"); } diff -r 176d0be30214 -r c798c277ddd1 src/share/vm/gc_implementation/g1/vm_operations_g1.hpp --- a/src/share/vm/gc_implementation/g1/vm_operations_g1.hpp Thu Feb 03 16:06:01 2011 -0500 +++ b/src/share/vm/gc_implementation/g1/vm_operations_g1.hpp Thu Feb 03 20:49:09 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ public: VM_G1OperationWithAllocRequest(unsigned int gc_count_before, size_t word_size) - : VM_GC_Operation(gc_count_before), + : VM_GC_Operation(gc_count_before, GCCause::_allocation_failure), _word_size(word_size), _result(NULL), _pause_succeeded(false) { } HeapWord* result() { return _result; } bool pause_succeeded() { return _pause_succeeded; } @@ -55,9 +55,7 @@ VM_G1CollectFull(unsigned int gc_count_before, unsigned int full_gc_count_before, GCCause::Cause cause) - : VM_GC_Operation(gc_count_before, full_gc_count_before) { - _gc_cause = cause; - } + : VM_GC_Operation(gc_count_before, cause, full_gc_count_before) { } virtual VMOp_Type type() const { return VMOp_G1CollectFull; } virtual void doit(); virtual const char* name() const { diff -r 176d0be30214 -r c798c277ddd1 src/share/vm/gc_implementation/parallelScavenge/vmPSOperations.cpp --- a/src/share/vm/gc_implementation/parallelScavenge/vmPSOperations.cpp Thu Feb 03 16:06:01 2011 -0500 +++ b/src/share/vm/gc_implementation/parallelScavenge/vmPSOperations.cpp Thu Feb 03 20:49:09 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ // The following methods are used by the parallel scavenge collector VM_ParallelGCFailedAllocation::VM_ParallelGCFailedAllocation(size_t size, bool is_tlab, unsigned int gc_count) : - VM_GC_Operation(gc_count), + VM_GC_Operation(gc_count, GCCause::_allocation_failure), _size(size), _is_tlab(is_tlab), _result(NULL) @@ -57,7 +57,7 @@ VM_ParallelGCFailedPermanentAllocation::VM_ParallelGCFailedPermanentAllocation(size_t size, unsigned int gc_count, unsigned int full_gc_count) : - VM_GC_Operation(gc_count, full_gc_count, true /* full */), + VM_GC_Operation(gc_count, GCCause::_allocation_failure, full_gc_count, true /* full */), _size(size), _result(NULL) { @@ -80,9 +80,8 @@ VM_ParallelGCSystemGC::VM_ParallelGCSystemGC(unsigned int gc_count, unsigned int full_gc_count, GCCause::Cause gc_cause) : - VM_GC_Operation(gc_count, full_gc_count, true /* full */) + VM_GC_Operation(gc_count, gc_cause, full_gc_count, true /* full */) { - _gc_cause = gc_cause; } void VM_ParallelGCSystemGC::doit() { diff -r 176d0be30214 -r c798c277ddd1 src/share/vm/gc_implementation/shared/vmGCOperations.cpp --- a/src/share/vm/gc_implementation/shared/vmGCOperations.cpp Thu Feb 03 16:06:01 2011 -0500 +++ b/src/share/vm/gc_implementation/shared/vmGCOperations.cpp Thu Feb 03 20:49:09 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,6 +87,8 @@ bool VM_GC_Operation::doit_prologue() { assert(Thread::current()->is_Java_thread(), "just checking"); + assert(((_gc_cause != GCCause::_no_gc) && + (_gc_cause != GCCause::_no_cause_specified)), "Illegal GCCause"); acquire_pending_list_lock(); // If the GC count has changed someone beat us to the collection diff -r 176d0be30214 -r c798c277ddd1 src/share/vm/gc_implementation/shared/vmGCOperations.hpp --- a/src/share/vm/gc_implementation/shared/vmGCOperations.hpp Thu Feb 03 16:06:01 2011 -0500 +++ b/src/share/vm/gc_implementation/shared/vmGCOperations.hpp Thu Feb 03 20:49:09 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,6 +85,7 @@ public: VM_GC_Operation(unsigned int gc_count_before, + GCCause::Cause _cause, unsigned int full_gc_count_before = 0, bool full = false) { _full = full; @@ -92,7 +93,7 @@ _gc_count_before = gc_count_before; // A subclass constructor will likely overwrite the following - _gc_cause = GCCause::_no_cause_specified; + _gc_cause = _cause; _gc_locked = false; @@ -136,6 +137,7 @@ VM_GC_HeapInspection(outputStream* out, bool request_full_gc, bool need_prologue) : VM_GC_Operation(0 /* total collections, dummy, ignored */, + GCCause::_heap_inspection /* GC Cause */, 0 /* total full collections, dummy, ignored */, request_full_gc) { _out = out; @@ -160,7 +162,7 @@ VM_GenCollectForAllocation(size_t size, bool tlab, unsigned int gc_count_before) - : VM_GC_Operation(gc_count_before), + : VM_GC_Operation(gc_count_before, GCCause::_allocation_failure), _size(size), _tlab(tlab) { _res = NULL; @@ -182,9 +184,8 @@ unsigned int full_gc_count_before, GCCause::Cause gc_cause, int max_level) - : VM_GC_Operation(gc_count_before, full_gc_count_before, true /* full */), - _max_level(max_level) - { _gc_cause = gc_cause; } + : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true /* full */), + _max_level(max_level) { } ~VM_GenCollectFull() {} virtual VMOp_Type type() const { return VMOp_GenCollectFull; } virtual void doit(); @@ -199,7 +200,7 @@ unsigned int gc_count_before, unsigned int full_gc_count_before, GCCause::Cause gc_cause) - : VM_GC_Operation(gc_count_before, full_gc_count_before, true), + : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true), _size(size) { _res = NULL; _gc_cause = gc_cause; diff -r 176d0be30214 -r c798c277ddd1 src/share/vm/gc_interface/gcCause.cpp --- a/src/share/vm/gc_interface/gcCause.cpp Thu Feb 03 16:06:01 2011 -0500 +++ b/src/share/vm/gc_interface/gcCause.cpp Thu Feb 03 20:49:09 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -92,28 +92,3 @@ } ShouldNotReachHere(); } - -#ifndef PRODUCT - -bool GCCause::is_for_full_collection(GCCause::Cause cause) { - bool result; - - // There are more GCCause::Cause types than listed here. - // For brevity, we list only those that cause full collections. - switch (cause) { - case _allocation_failure: - case _tenured_generation_full: - case _permanent_generation_full: - case _cms_generation_full: - case _last_ditch_collection: - result = true; - break; - - default: - result = false; - break; - } - return result; -} - -#endif // PRODUCT diff -r 176d0be30214 -r c798c277ddd1 src/share/vm/gc_interface/gcCause.hpp --- a/src/share/vm/gc_interface/gcCause.hpp Thu Feb 03 16:06:01 2011 -0500 +++ b/src/share/vm/gc_interface/gcCause.hpp Thu Feb 03 20:49:09 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,8 +85,6 @@ // Return a string describing the GCCause. static const char* to_string(GCCause::Cause cause); - // Return true if the GCCause is for a full collection. - static bool is_for_full_collection(GCCause::Cause cause) PRODUCT_RETURN0; }; #endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP diff -r 176d0be30214 -r c798c277ddd1 src/share/vm/services/heapDumper.cpp --- a/src/share/vm/services/heapDumper.cpp Thu Feb 03 16:06:01 2011 -0500 +++ b/src/share/vm/services/heapDumper.cpp Thu Feb 03 20:49:09 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1397,6 +1397,7 @@ public: VM_HeapDumper(DumpWriter* writer, bool gc_before_heap_dump, bool oome) : VM_GC_Operation(0 /* total collections, dummy, ignored */, + GCCause::_heap_dump /* GC Cause */, 0 /* total full collections, dummy, ignored */, gc_before_heap_dump) { _local_writer = writer;