hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.cpp
HeapWord* G1AllocRegion::new_alloc_region_and_allocate(size_t word_size,
bool force) {
{- -------------------------------------------
(1) (assert)
---------------------------------------- -}
assert(_alloc_region == _dummy_region, ar_ext_msg(this, "pre-condition"));
assert(_used_bytes_before == 0, ar_ext_msg(this, "pre-condition"));
{- -------------------------------------------
(1) (トレース出力)
---------------------------------------- -}
trace("attempting region allocation");
{- -------------------------------------------
(1) MutatorAllocRegion::allocate_new_region() で
G1AllocRegion 用の新しい HeapRegion の確保を試みる.
---------------------------------------- -}
HeapRegion* new_alloc_region = allocate_new_region(word_size, force);
{- -------------------------------------------
(1) もし確保に成功していれば, ...#TODO
---------------------------------------- -}
if (new_alloc_region != NULL) {
{- -------------------------------------------
(1.1) ?? #TODO
---------------------------------------- -}
new_alloc_region->reset_pre_dummy_top();
// Need to do this before the allocation
_used_bytes_before = new_alloc_region->used();
{- -------------------------------------------
(1.1) G1AllocRegion::allocate() で, 新しく確保した HeapRegion 内からオブジェクトの確保を試みる.
---------------------------------------- -}
HeapWord* result = allocate(new_alloc_region, word_size, _bot_updates);
assert(result != NULL, ar_ext_msg(this, "the allocation should succeeded"));
{- -------------------------------------------
(1.1) G1AllocRegion::_alloc_region フィールド (G1AllocRegion が確保に使用する HeapRegion を示すフィールド) を
新しく確保した HeapRegion に置き換える.
(なお, OrderAccess::storestore() を張っているので, この書き換えが
これ以前の変更 (G1AllocRegion::allocate() 等での変更) を追い抜くのは禁止.)
---------------------------------------- -}
OrderAccess::storestore();
// Note that we first perform the allocation and then we store the
// region in _alloc_region. This is the reason why an active region
// can never be empty.
_alloc_region = new_alloc_region;
{- -------------------------------------------
(1.1) (トレース出力)
---------------------------------------- -}
trace("region allocation successful");
{- -------------------------------------------
(1.1) 確保した領域へのポインタをリターン
---------------------------------------- -}
return result;
{- -------------------------------------------
(1) もし確保に失敗していた場合は NULL をリターン.
及び(トレース出力)
---------------------------------------- -}
} else {
trace("region allocation failed");
return NULL;
}
{- -------------------------------------------
(1) (以下は決して到達しないパス)
---------------------------------------- -}
ShouldNotReachHere();
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.