duke@435: /* mlarsson@7686: * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * 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. duke@435: * duke@435: */ duke@435: stefank@2314: #include "precompiled.hpp" stefank@2314: #include "gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp" stefank@2314: #include "gc_implementation/parallelScavenge/psMarkSweep.hpp" stefank@2314: #include "gc_implementation/parallelScavenge/psScavenge.hpp" stefank@2314: #include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" stefank@2314: #include "gc_implementation/parallelScavenge/vmPSOperations.hpp" stefank@2314: #include "memory/gcLocker.inline.hpp" stefank@2314: #include "utilities/dtrace.hpp" duke@435: duke@435: // The following methods are used by the parallel scavenge collector mlarsson@7687: VM_ParallelGCFailedAllocation::VM_ParallelGCFailedAllocation(size_t word_size, mlarsson@7686: uint gc_count) : mlarsson@7687: VM_CollectForAllocation(word_size, gc_count, GCCause::_allocation_failure) { mlarsson@7687: assert(word_size != 0, "An allocation should always be requested with this operation."); duke@435: } duke@435: duke@435: void VM_ParallelGCFailedAllocation::doit() { kamg@2445: SvcGCMarker sgcm(SvcGCMarker::MINOR); duke@435: duke@435: ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); duke@435: assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "must be a ParallelScavengeHeap"); duke@435: duke@435: GCCauseSetter gccs(heap, _gc_cause); mlarsson@7687: _result = heap->failed_mem_allocate(_word_size); duke@435: duke@435: if (_result == NULL && GC_locker::is_active_and_needs_gc()) { duke@435: set_gc_locked(); duke@435: } duke@435: } duke@435: kbarrett@9787: static bool is_cause_full(GCCause::Cause cause) { kbarrett@9787: return (cause != GCCause::_gc_locker) && (cause != GCCause::_wb_young_gc) kbarrett@9787: DEBUG_ONLY(&& (cause != GCCause::_scavenge_alot)); kbarrett@9787: } kbarrett@9787: duke@435: // Only used for System.gc() calls mlarsson@7686: VM_ParallelGCSystemGC::VM_ParallelGCSystemGC(uint gc_count, mlarsson@7686: uint full_gc_count, duke@435: GCCause::Cause gc_cause) : kbarrett@9787: VM_GC_Operation(gc_count, gc_cause, full_gc_count, is_cause_full(gc_cause)) duke@435: { duke@435: } duke@435: duke@435: void VM_ParallelGCSystemGC::doit() { kamg@2445: SvcGCMarker sgcm(SvcGCMarker::FULL); duke@435: duke@435: ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); duke@435: assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, duke@435: "must be a ParallelScavengeHeap"); duke@435: duke@435: GCCauseSetter gccs(heap, _gc_cause); kbarrett@9787: if (!_full) { duke@435: // If (and only if) the scavenge fails, this will invoke a full gc. duke@435: heap->invoke_scavenge(); duke@435: } else { coleenp@4037: heap->do_full_collection(false); duke@435: } duke@435: }