0N/A/*
1879N/A * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#include "precompiled.hpp"
1879N/A#include "gc_implementation/parallelScavenge/parallelScavengeHeap.inline.hpp"
1879N/A#include "gc_implementation/parallelScavenge/psMarkSweep.hpp"
1879N/A#include "gc_implementation/parallelScavenge/psScavenge.hpp"
1879N/A#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp"
0N/A#include "gc_implementation/parallelScavenge/vmPSOperations.hpp"
0N/A#include "memory/gcLocker.inline.hpp"
0N/A#include "utilities/dtrace.hpp"
0N/A
0N/A// The following methods are used by the parallel scavenge collector
0N/AVM_ParallelGCFailedAllocation::VM_ParallelGCFailedAllocation(size_t size,
0N/A unsigned int gc_count) :
0N/A VM_GC_Operation(gc_count, GCCause::_allocation_failure),
0N/A _size(size),
0N/A _result(NULL)
0N/A{
0N/A}
1350N/A
0N/Avoid VM_ParallelGCFailedAllocation::doit() {
0N/A SvcGCMarker sgcm(SvcGCMarker::MINOR);
0N/A
0N/A ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
0N/A assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "must be a ParallelScavengeHeap");
0N/A
0N/A GCCauseSetter gccs(heap, _gc_cause);
0N/A _result = heap->failed_mem_allocate(_size);
0N/A
0N/A if (_result == NULL && GC_locker::is_active_and_needs_gc()) {
0N/A set_gc_locked();
0N/A }
0N/A}
0N/A
0N/AVM_ParallelGCFailedPermanentAllocation::VM_ParallelGCFailedPermanentAllocation(size_t size,
0N/A unsigned int gc_count, unsigned int full_gc_count) :
0N/A VM_GC_Operation(gc_count, GCCause::_allocation_failure, full_gc_count, true /* full */),
0N/A _size(size),
0N/A _result(NULL)
0N/A{
0N/A}
0N/A
0N/Avoid VM_ParallelGCFailedPermanentAllocation::doit() {
0N/A SvcGCMarker sgcm(SvcGCMarker::FULL);
0N/A
0N/A ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "must be a ParallelScavengeHeap");
GCCauseSetter gccs(heap, _gc_cause);
_result = heap->failed_permanent_mem_allocate(_size);
if (_result == NULL && GC_locker::is_active_and_needs_gc()) {
set_gc_locked();
}
}
// Only used for System.gc() calls
VM_ParallelGCSystemGC::VM_ParallelGCSystemGC(unsigned int gc_count,
unsigned int full_gc_count,
GCCause::Cause gc_cause) :
VM_GC_Operation(gc_count, gc_cause, full_gc_count, true /* full */)
{
}
void VM_ParallelGCSystemGC::doit() {
SvcGCMarker sgcm(SvcGCMarker::FULL);
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
assert(heap->kind() == CollectedHeap::ParallelScavengeHeap,
"must be a ParallelScavengeHeap");
GCCauseSetter gccs(heap, _gc_cause);
if (_gc_cause == GCCause::_gc_locker
DEBUG_ONLY(|| _gc_cause == GCCause::_scavenge_alot)) {
// If (and only if) the scavenge fails, this will invoke a full gc.
heap->invoke_scavenge();
} else {
heap->invoke_full_gc(false);
}
}