ysr@777: /* mlarsson@7686: * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. ysr@777: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ysr@777: * ysr@777: * This code is free software; you can redistribute it and/or modify it ysr@777: * under the terms of the GNU General Public License version 2 only, as ysr@777: * published by the Free Software Foundation. ysr@777: * ysr@777: * This code is distributed in the hope that it will be useful, but WITHOUT ysr@777: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ysr@777: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ysr@777: * version 2 for more details (a copy is included in the LICENSE file that ysr@777: * accompanied this code). ysr@777: * ysr@777: * You should have received a copy of the GNU General Public License version ysr@777: * 2 along with this work; if not, write to the Free Software Foundation, ysr@777: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ysr@777: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. ysr@777: * ysr@777: */ ysr@777: stefank@2314: #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_VM_OPERATIONS_G1_HPP stefank@2314: #define SHARE_VM_GC_IMPLEMENTATION_G1_VM_OPERATIONS_G1_HPP stefank@2314: sjohanss@7118: #include "gc_implementation/g1/g1AllocationContext.hpp" stefank@2314: #include "gc_implementation/shared/vmGCOperations.hpp" stefank@2314: ysr@777: // VM_operations for the G1 collector. ysr@777: // VM_GC_Operation: ysr@777: // - VM_CGC_Operation ysr@777: // - VM_G1CollectFull tonyp@2315: // - VM_G1OperationWithAllocRequest tonyp@2315: // - VM_G1CollectForAllocation tonyp@2315: // - VM_G1IncCollectionPause tonyp@2315: tonyp@2315: class VM_G1OperationWithAllocRequest: public VM_GC_Operation { tonyp@2315: protected: tonyp@2315: size_t _word_size; tonyp@2315: HeapWord* _result; tonyp@2315: bool _pause_succeeded; sjohanss@7118: AllocationContext_t _allocation_context; tonyp@2315: tonyp@2315: public: mlarsson@7686: VM_G1OperationWithAllocRequest(uint gc_count_before, mlarsson@7686: size_t word_size, johnc@3666: GCCause::Cause gc_cause) johnc@3666: : VM_GC_Operation(gc_count_before, gc_cause), tonyp@2315: _word_size(word_size), _result(NULL), _pause_succeeded(false) { } tonyp@2315: HeapWord* result() { return _result; } tonyp@2315: bool pause_succeeded() { return _pause_succeeded; } sjohanss@7118: void set_allocation_context(AllocationContext_t context) { _allocation_context = context; } sjohanss@7118: AllocationContext_t allocation_context() { return _allocation_context; } tonyp@2315: }; ysr@777: ysr@777: class VM_G1CollectFull: public VM_GC_Operation { tonyp@2315: public: mlarsson@7686: VM_G1CollectFull(uint gc_count_before, mlarsson@7686: uint full_gc_count_before, tonyp@2011: GCCause::Cause cause) sjohanss@7285: : VM_GC_Operation(gc_count_before, cause, full_gc_count_before, true) { } ysr@777: virtual VMOp_Type type() const { return VMOp_G1CollectFull; } ysr@777: virtual void doit(); ysr@777: virtual const char* name() const { ysr@777: return "full garbage-first collection"; ysr@777: } ysr@777: }; ysr@777: tonyp@2315: class VM_G1CollectForAllocation: public VM_G1OperationWithAllocRequest { tonyp@2315: public: mlarsson@7686: VM_G1CollectForAllocation(uint gc_count_before, tonyp@2315: size_t word_size); ysr@777: virtual VMOp_Type type() const { return VMOp_G1CollectForAllocation; } ysr@777: virtual void doit(); ysr@777: virtual const char* name() const { ysr@777: return "garbage-first collection to satisfy allocation"; ysr@777: } ysr@777: }; ysr@777: tonyp@2315: class VM_G1IncCollectionPause: public VM_G1OperationWithAllocRequest { tonyp@2011: private: tonyp@2315: bool _should_initiate_conc_mark; johnc@3666: bool _should_retry_gc; tonyp@2315: double _target_pause_time_ms; mlarsson@7686: uint _old_marking_cycles_completed_before; tonyp@2011: public: mlarsson@7686: VM_G1IncCollectionPause(uint gc_count_before, tonyp@2315: size_t word_size, tonyp@2011: bool should_initiate_conc_mark, tonyp@2011: double target_pause_time_ms, tonyp@2315: GCCause::Cause gc_cause); ysr@777: virtual VMOp_Type type() const { return VMOp_G1IncCollectionPause; } johnc@3666: virtual bool doit_prologue(); ysr@777: virtual void doit(); tonyp@2011: virtual void doit_epilogue(); ysr@777: virtual const char* name() const { ysr@777: return "garbage-first incremental collection pause"; ysr@777: } johnc@3666: bool should_retry_gc() const { return _should_retry_gc; } ysr@777: }; ysr@777: johnc@3218: // Concurrent GC stop-the-world operations such as remark and cleanup; ysr@777: // consider sharing these with CMS's counterparts. ysr@777: class VM_CGC_Operation: public VM_Operation { ysr@777: VoidClosure* _cl; ysr@777: const char* _printGCMessage; johnc@3666: bool _needs_pll; johnc@3218: johnc@3218: protected: johnc@3218: // java.lang.ref.Reference support johnc@3218: void acquire_pending_list_lock(); johnc@3218: void release_and_notify_pending_list_lock(); johnc@3218: tonyp@2315: public: johnc@3666: VM_CGC_Operation(VoidClosure* cl, const char *printGCMsg, bool needs_pll) johnc@3666: : _cl(cl), _printGCMessage(printGCMsg), _needs_pll(needs_pll) { } ysr@777: virtual VMOp_Type type() const { return VMOp_CGC_Operation; } ysr@777: virtual void doit(); ysr@777: virtual bool doit_prologue(); ysr@777: virtual void doit_epilogue(); ysr@777: virtual const char* name() const { ysr@777: return "concurrent gc"; ysr@777: } ysr@777: }; stefank@2314: stefank@2314: #endif // SHARE_VM_GC_IMPLEMENTATION_G1_VM_OPERATIONS_G1_HPP