hotspot/src/share/vm/memory/defNewGeneration.cpp
// The last collection bailed out, we are running out of heap space,
// so we try to allocate the from-space, too.
HeapWord* DefNewGeneration::allocate_from_space(size_t size) {
{- -------------------------------------------
(1) (変数宣言など)
---------------------------------------- -}
HeapWord* result = NULL;
{- -------------------------------------------
(1) (トレース出力)
---------------------------------------- -}
if (Verbose && PrintGCDetails) {
gclog_or_tty->print("DefNewGeneration::allocate_from_space(%u):"
" will_fail: %s"
" heap_lock: %s"
" free: " SIZE_FORMAT,
size,
GenCollectedHeap::heap()->incremental_collection_will_fail(false /* don't consult_young */) ?
"true" : "false",
Heap_lock->is_locked() ? "locked" : "unlocked",
from()->free());
}
{- -------------------------------------------
(1) ...#TODO であれば, ContiguousSpace::allocate() を呼んで From 領域からメモリを確保する.
---------------------------------------- -}
if (should_allocate_from_space() || GC_locker::is_active_and_needs_gc()) {
if (Heap_lock->owned_by_self() ||
(SafepointSynchronize::is_at_safepoint() &&
Thread::current()->is_VM_thread())) {
// If the Heap_lock is not locked by this thread, this will be called
// again later with the Heap_lock held.
result = from()->allocate(size);
} else if (PrintGC && Verbose) {
gclog_or_tty->print_cr(" Heap_lock is not owned by self");
}
} else if (PrintGC && Verbose) {
gclog_or_tty->print_cr(" should_allocate_from_space: NOT");
}
{- -------------------------------------------
(1) (トレース出力)
---------------------------------------- -}
if (PrintGC && Verbose) {
gclog_or_tty->print_cr(" returns %s", result == NULL ? "NULL" : "object");
}
{- -------------------------------------------
(1) 結果をリターン
---------------------------------------- -}
return result;
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.