Path: blob/master/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.cpp
40957 views
/*1* Copyright (c) 2013, 2019, Red Hat, Inc. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "gc/shared/space.inline.hpp"26#include "gc/shared/tlab_globals.hpp"27#include "gc/shenandoah/shenandoahHeapRegionSet.inline.hpp"28#include "gc/shenandoah/shenandoahHeap.inline.hpp"29#include "gc/shenandoah/shenandoahHeapRegion.hpp"30#include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"31#include "jfr/jfrEvents.hpp"32#include "memory/allocation.hpp"33#include "memory/iterator.inline.hpp"34#include "memory/resourceArea.hpp"35#include "memory/universe.hpp"36#include "oops/oop.inline.hpp"37#include "runtime/atomic.hpp"38#include "runtime/globals_extension.hpp"39#include "runtime/java.hpp"40#include "runtime/mutexLocker.hpp"41#include "runtime/os.hpp"42#include "runtime/safepoint.hpp"43#include "utilities/powerOfTwo.hpp"4445size_t ShenandoahHeapRegion::RegionCount = 0;46size_t ShenandoahHeapRegion::RegionSizeBytes = 0;47size_t ShenandoahHeapRegion::RegionSizeWords = 0;48size_t ShenandoahHeapRegion::RegionSizeBytesShift = 0;49size_t ShenandoahHeapRegion::RegionSizeWordsShift = 0;50size_t ShenandoahHeapRegion::RegionSizeBytesMask = 0;51size_t ShenandoahHeapRegion::RegionSizeWordsMask = 0;52size_t ShenandoahHeapRegion::HumongousThresholdBytes = 0;53size_t ShenandoahHeapRegion::HumongousThresholdWords = 0;54size_t ShenandoahHeapRegion::MaxTLABSizeBytes = 0;55size_t ShenandoahHeapRegion::MaxTLABSizeWords = 0;5657ShenandoahHeapRegion::ShenandoahHeapRegion(HeapWord* start, size_t index, bool committed) :58_index(index),59_bottom(start),60_end(start + RegionSizeWords),61_new_top(NULL),62_empty_time(os::elapsedTime()),63_state(committed ? _empty_committed : _empty_uncommitted),64_top(start),65_tlab_allocs(0),66_gclab_allocs(0),67_live_data(0),68_critical_pins(0),69_update_watermark(start) {7071assert(Universe::on_page_boundary(_bottom) && Universe::on_page_boundary(_end),72"invalid space boundaries");73if (ZapUnusedHeapArea && committed) {74SpaceMangler::mangle_region(MemRegion(_bottom, _end));75}76}7778void ShenandoahHeapRegion::report_illegal_transition(const char *method) {79ResourceMark rm;80stringStream ss;81ss.print("Illegal region state transition from \"%s\", at %s\n ", region_state_to_string(_state), method);82print_on(&ss);83fatal("%s", ss.as_string());84}8586void ShenandoahHeapRegion::make_regular_allocation() {87shenandoah_assert_heaplocked();8889switch (_state) {90case _empty_uncommitted:91do_commit();92case _empty_committed:93set_state(_regular);94case _regular:95case _pinned:96return;97default:98report_illegal_transition("regular allocation");99}100}101102void ShenandoahHeapRegion::make_regular_bypass() {103shenandoah_assert_heaplocked();104assert (ShenandoahHeap::heap()->is_full_gc_in_progress() || ShenandoahHeap::heap()->is_degenerated_gc_in_progress(),105"only for full or degen GC");106107switch (_state) {108case _empty_uncommitted:109do_commit();110case _empty_committed:111case _cset:112case _humongous_start:113case _humongous_cont:114set_state(_regular);115return;116case _pinned_cset:117set_state(_pinned);118return;119case _regular:120case _pinned:121return;122default:123report_illegal_transition("regular bypass");124}125}126127void ShenandoahHeapRegion::make_humongous_start() {128shenandoah_assert_heaplocked();129switch (_state) {130case _empty_uncommitted:131do_commit();132case _empty_committed:133set_state(_humongous_start);134return;135default:136report_illegal_transition("humongous start allocation");137}138}139140void ShenandoahHeapRegion::make_humongous_start_bypass() {141shenandoah_assert_heaplocked();142assert (ShenandoahHeap::heap()->is_full_gc_in_progress(), "only for full GC");143144switch (_state) {145case _empty_committed:146case _regular:147case _humongous_start:148case _humongous_cont:149set_state(_humongous_start);150return;151default:152report_illegal_transition("humongous start bypass");153}154}155156void ShenandoahHeapRegion::make_humongous_cont() {157shenandoah_assert_heaplocked();158switch (_state) {159case _empty_uncommitted:160do_commit();161case _empty_committed:162set_state(_humongous_cont);163return;164default:165report_illegal_transition("humongous continuation allocation");166}167}168169void ShenandoahHeapRegion::make_humongous_cont_bypass() {170shenandoah_assert_heaplocked();171assert (ShenandoahHeap::heap()->is_full_gc_in_progress(), "only for full GC");172173switch (_state) {174case _empty_committed:175case _regular:176case _humongous_start:177case _humongous_cont:178set_state(_humongous_cont);179return;180default:181report_illegal_transition("humongous continuation bypass");182}183}184185void ShenandoahHeapRegion::make_pinned() {186shenandoah_assert_heaplocked();187assert(pin_count() > 0, "Should have pins: " SIZE_FORMAT, pin_count());188189switch (_state) {190case _regular:191set_state(_pinned);192case _pinned_cset:193case _pinned:194return;195case _humongous_start:196set_state(_pinned_humongous_start);197case _pinned_humongous_start:198return;199case _cset:200_state = _pinned_cset;201return;202default:203report_illegal_transition("pinning");204}205}206207void ShenandoahHeapRegion::make_unpinned() {208shenandoah_assert_heaplocked();209assert(pin_count() == 0, "Should not have pins: " SIZE_FORMAT, pin_count());210211switch (_state) {212case _pinned:213set_state(_regular);214return;215case _regular:216case _humongous_start:217return;218case _pinned_cset:219set_state(_cset);220return;221case _pinned_humongous_start:222set_state(_humongous_start);223return;224default:225report_illegal_transition("unpinning");226}227}228229void ShenandoahHeapRegion::make_cset() {230shenandoah_assert_heaplocked();231switch (_state) {232case _regular:233set_state(_cset);234case _cset:235return;236default:237report_illegal_transition("cset");238}239}240241void ShenandoahHeapRegion::make_trash() {242shenandoah_assert_heaplocked();243switch (_state) {244case _cset:245// Reclaiming cset regions246case _humongous_start:247case _humongous_cont:248// Reclaiming humongous regions249case _regular:250// Immediate region reclaim251set_state(_trash);252return;253default:254report_illegal_transition("trashing");255}256}257258void ShenandoahHeapRegion::make_trash_immediate() {259make_trash();260261// On this path, we know there are no marked objects in the region,262// tell marking context about it to bypass bitmap resets.263ShenandoahHeap::heap()->complete_marking_context()->reset_top_bitmap(this);264}265266void ShenandoahHeapRegion::make_empty() {267shenandoah_assert_heaplocked();268switch (_state) {269case _trash:270set_state(_empty_committed);271_empty_time = os::elapsedTime();272return;273default:274report_illegal_transition("emptying");275}276}277278void ShenandoahHeapRegion::make_uncommitted() {279shenandoah_assert_heaplocked();280switch (_state) {281case _empty_committed:282do_uncommit();283set_state(_empty_uncommitted);284return;285default:286report_illegal_transition("uncommiting");287}288}289290void ShenandoahHeapRegion::make_committed_bypass() {291shenandoah_assert_heaplocked();292assert (ShenandoahHeap::heap()->is_full_gc_in_progress(), "only for full GC");293294switch (_state) {295case _empty_uncommitted:296do_commit();297set_state(_empty_committed);298return;299default:300report_illegal_transition("commit bypass");301}302}303304void ShenandoahHeapRegion::reset_alloc_metadata() {305_tlab_allocs = 0;306_gclab_allocs = 0;307}308309size_t ShenandoahHeapRegion::get_shared_allocs() const {310return used() - (_tlab_allocs + _gclab_allocs) * HeapWordSize;311}312313size_t ShenandoahHeapRegion::get_tlab_allocs() const {314return _tlab_allocs * HeapWordSize;315}316317size_t ShenandoahHeapRegion::get_gclab_allocs() const {318return _gclab_allocs * HeapWordSize;319}320321void ShenandoahHeapRegion::set_live_data(size_t s) {322assert(Thread::current()->is_VM_thread(), "by VM thread");323_live_data = (s >> LogHeapWordSize);324}325326void ShenandoahHeapRegion::print_on(outputStream* st) const {327st->print("|");328st->print(SIZE_FORMAT_W(5), this->_index);329330switch (_state) {331case _empty_uncommitted:332st->print("|EU ");333break;334case _empty_committed:335st->print("|EC ");336break;337case _regular:338st->print("|R ");339break;340case _humongous_start:341st->print("|H ");342break;343case _pinned_humongous_start:344st->print("|HP ");345break;346case _humongous_cont:347st->print("|HC ");348break;349case _cset:350st->print("|CS ");351break;352case _trash:353st->print("|T ");354break;355case _pinned:356st->print("|P ");357break;358case _pinned_cset:359st->print("|CSP");360break;361default:362ShouldNotReachHere();363}364st->print("|BTE " INTPTR_FORMAT_W(12) ", " INTPTR_FORMAT_W(12) ", " INTPTR_FORMAT_W(12),365p2i(bottom()), p2i(top()), p2i(end()));366st->print("|TAMS " INTPTR_FORMAT_W(12),367p2i(ShenandoahHeap::heap()->marking_context()->top_at_mark_start(const_cast<ShenandoahHeapRegion*>(this))));368st->print("|UWM " INTPTR_FORMAT_W(12),369p2i(_update_watermark));370st->print("|U " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(used()), proper_unit_for_byte_size(used()));371st->print("|T " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_tlab_allocs()), proper_unit_for_byte_size(get_tlab_allocs()));372st->print("|G " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_gclab_allocs()), proper_unit_for_byte_size(get_gclab_allocs()));373st->print("|S " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_shared_allocs()), proper_unit_for_byte_size(get_shared_allocs()));374st->print("|L " SIZE_FORMAT_W(5) "%1s", byte_size_in_proper_unit(get_live_data_bytes()), proper_unit_for_byte_size(get_live_data_bytes()));375st->print("|CP " SIZE_FORMAT_W(3), pin_count());376st->cr();377}378379void ShenandoahHeapRegion::oop_iterate(OopIterateClosure* blk) {380if (!is_active()) return;381if (is_humongous()) {382oop_iterate_humongous(blk);383} else {384oop_iterate_objects(blk);385}386}387388void ShenandoahHeapRegion::oop_iterate_objects(OopIterateClosure* blk) {389assert(! is_humongous(), "no humongous region here");390HeapWord* obj_addr = bottom();391HeapWord* t = top();392// Could call objects iterate, but this is easier.393while (obj_addr < t) {394oop obj = cast_to_oop(obj_addr);395obj_addr += obj->oop_iterate_size(blk);396}397}398399void ShenandoahHeapRegion::oop_iterate_humongous(OopIterateClosure* blk) {400assert(is_humongous(), "only humongous region here");401// Find head.402ShenandoahHeapRegion* r = humongous_start_region();403assert(r->is_humongous_start(), "need humongous head here");404oop obj = cast_to_oop(r->bottom());405obj->oop_iterate(blk, MemRegion(bottom(), top()));406}407408ShenandoahHeapRegion* ShenandoahHeapRegion::humongous_start_region() const {409ShenandoahHeap* heap = ShenandoahHeap::heap();410assert(is_humongous(), "Must be a part of the humongous region");411size_t i = index();412ShenandoahHeapRegion* r = const_cast<ShenandoahHeapRegion*>(this);413while (!r->is_humongous_start()) {414assert(i > 0, "Sanity");415i--;416r = heap->get_region(i);417assert(r->is_humongous(), "Must be a part of the humongous region");418}419assert(r->is_humongous_start(), "Must be");420return r;421}422423void ShenandoahHeapRegion::recycle() {424set_top(bottom());425clear_live_data();426427reset_alloc_metadata();428429ShenandoahHeap::heap()->marking_context()->reset_top_at_mark_start(this);430set_update_watermark(bottom());431432make_empty();433434if (ZapUnusedHeapArea) {435SpaceMangler::mangle_region(MemRegion(bottom(), end()));436}437}438439HeapWord* ShenandoahHeapRegion::block_start(const void* p) const {440assert(MemRegion(bottom(), end()).contains(p),441"p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")",442p2i(p), p2i(bottom()), p2i(end()));443if (p >= top()) {444return top();445} else {446HeapWord* last = bottom();447HeapWord* cur = last;448while (cur <= p) {449last = cur;450cur += cast_to_oop(cur)->size();451}452shenandoah_assert_correct(NULL, cast_to_oop(last));453return last;454}455}456457size_t ShenandoahHeapRegion::block_size(const HeapWord* p) const {458assert(MemRegion(bottom(), end()).contains(p),459"p (" PTR_FORMAT ") not in space [" PTR_FORMAT ", " PTR_FORMAT ")",460p2i(p), p2i(bottom()), p2i(end()));461if (p < top()) {462return cast_to_oop(p)->size();463} else {464assert(p == top(), "just checking");465return pointer_delta(end(), (HeapWord*) p);466}467}468469void ShenandoahHeapRegion::setup_sizes(size_t max_heap_size) {470// Absolute minimums we should not ever break.471static const size_t MIN_REGION_SIZE = 256*K;472473if (FLAG_IS_DEFAULT(ShenandoahMinRegionSize)) {474FLAG_SET_DEFAULT(ShenandoahMinRegionSize, MIN_REGION_SIZE);475}476477size_t region_size;478if (FLAG_IS_DEFAULT(ShenandoahRegionSize)) {479if (ShenandoahMinRegionSize > max_heap_size / MIN_NUM_REGIONS) {480err_msg message("Max heap size (" SIZE_FORMAT "%s) is too low to afford the minimum number "481"of regions (" SIZE_FORMAT ") of minimum region size (" SIZE_FORMAT "%s).",482byte_size_in_proper_unit(max_heap_size), proper_unit_for_byte_size(max_heap_size),483MIN_NUM_REGIONS,484byte_size_in_proper_unit(ShenandoahMinRegionSize), proper_unit_for_byte_size(ShenandoahMinRegionSize));485vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize option", message);486}487if (ShenandoahMinRegionSize < MIN_REGION_SIZE) {488err_msg message("" SIZE_FORMAT "%s should not be lower than minimum region size (" SIZE_FORMAT "%s).",489byte_size_in_proper_unit(ShenandoahMinRegionSize), proper_unit_for_byte_size(ShenandoahMinRegionSize),490byte_size_in_proper_unit(MIN_REGION_SIZE), proper_unit_for_byte_size(MIN_REGION_SIZE));491vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize option", message);492}493if (ShenandoahMinRegionSize < MinTLABSize) {494err_msg message("" SIZE_FORMAT "%s should not be lower than TLAB size size (" SIZE_FORMAT "%s).",495byte_size_in_proper_unit(ShenandoahMinRegionSize), proper_unit_for_byte_size(ShenandoahMinRegionSize),496byte_size_in_proper_unit(MinTLABSize), proper_unit_for_byte_size(MinTLABSize));497vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize option", message);498}499if (ShenandoahMaxRegionSize < MIN_REGION_SIZE) {500err_msg message("" SIZE_FORMAT "%s should not be lower than min region size (" SIZE_FORMAT "%s).",501byte_size_in_proper_unit(ShenandoahMaxRegionSize), proper_unit_for_byte_size(ShenandoahMaxRegionSize),502byte_size_in_proper_unit(MIN_REGION_SIZE), proper_unit_for_byte_size(MIN_REGION_SIZE));503vm_exit_during_initialization("Invalid -XX:ShenandoahMaxRegionSize option", message);504}505if (ShenandoahMinRegionSize > ShenandoahMaxRegionSize) {506err_msg message("Minimum (" SIZE_FORMAT "%s) should be larger than maximum (" SIZE_FORMAT "%s).",507byte_size_in_proper_unit(ShenandoahMinRegionSize), proper_unit_for_byte_size(ShenandoahMinRegionSize),508byte_size_in_proper_unit(ShenandoahMaxRegionSize), proper_unit_for_byte_size(ShenandoahMaxRegionSize));509vm_exit_during_initialization("Invalid -XX:ShenandoahMinRegionSize or -XX:ShenandoahMaxRegionSize", message);510}511512// We rapidly expand to max_heap_size in most scenarios, so that is the measure513// for usual heap sizes. Do not depend on initial_heap_size here.514region_size = max_heap_size / ShenandoahTargetNumRegions;515516// Now make sure that we don't go over or under our limits.517region_size = MAX2(ShenandoahMinRegionSize, region_size);518region_size = MIN2(ShenandoahMaxRegionSize, region_size);519520} else {521if (ShenandoahRegionSize > max_heap_size / MIN_NUM_REGIONS) {522err_msg message("Max heap size (" SIZE_FORMAT "%s) is too low to afford the minimum number "523"of regions (" SIZE_FORMAT ") of requested size (" SIZE_FORMAT "%s).",524byte_size_in_proper_unit(max_heap_size), proper_unit_for_byte_size(max_heap_size),525MIN_NUM_REGIONS,526byte_size_in_proper_unit(ShenandoahRegionSize), proper_unit_for_byte_size(ShenandoahRegionSize));527vm_exit_during_initialization("Invalid -XX:ShenandoahRegionSize option", message);528}529if (ShenandoahRegionSize < ShenandoahMinRegionSize) {530err_msg message("Heap region size (" SIZE_FORMAT "%s) should be larger than min region size (" SIZE_FORMAT "%s).",531byte_size_in_proper_unit(ShenandoahRegionSize), proper_unit_for_byte_size(ShenandoahRegionSize),532byte_size_in_proper_unit(ShenandoahMinRegionSize), proper_unit_for_byte_size(ShenandoahMinRegionSize));533vm_exit_during_initialization("Invalid -XX:ShenandoahRegionSize option", message);534}535if (ShenandoahRegionSize > ShenandoahMaxRegionSize) {536err_msg message("Heap region size (" SIZE_FORMAT "%s) should be lower than max region size (" SIZE_FORMAT "%s).",537byte_size_in_proper_unit(ShenandoahRegionSize), proper_unit_for_byte_size(ShenandoahRegionSize),538byte_size_in_proper_unit(ShenandoahMaxRegionSize), proper_unit_for_byte_size(ShenandoahMaxRegionSize));539vm_exit_during_initialization("Invalid -XX:ShenandoahRegionSize option", message);540}541region_size = ShenandoahRegionSize;542}543544// Make sure region size is at least one large page, if enabled.545// The heap sizes would be rounded by heap initialization code by546// page size, so we need to round up the region size too, to cover547// the heap exactly.548if (UseLargePages) {549region_size = MAX2(region_size, os::large_page_size());550}551552int region_size_log = log2i(region_size);553// Recalculate the region size to make sure it's a power of554// 2. This means that region_size is the largest power of 2 that's555// <= what we've calculated so far.556region_size = size_t(1) << region_size_log;557558// Now, set up the globals.559guarantee(RegionSizeBytesShift == 0, "we should only set it once");560RegionSizeBytesShift = (size_t)region_size_log;561562guarantee(RegionSizeWordsShift == 0, "we should only set it once");563RegionSizeWordsShift = RegionSizeBytesShift - LogHeapWordSize;564565guarantee(RegionSizeBytes == 0, "we should only set it once");566RegionSizeBytes = region_size;567RegionSizeWords = RegionSizeBytes >> LogHeapWordSize;568assert (RegionSizeWords*HeapWordSize == RegionSizeBytes, "sanity");569570guarantee(RegionSizeWordsMask == 0, "we should only set it once");571RegionSizeWordsMask = RegionSizeWords - 1;572573guarantee(RegionSizeBytesMask == 0, "we should only set it once");574RegionSizeBytesMask = RegionSizeBytes - 1;575576guarantee(RegionCount == 0, "we should only set it once");577RegionCount = align_up(max_heap_size, RegionSizeBytes) / RegionSizeBytes;578guarantee(RegionCount >= MIN_NUM_REGIONS, "Should have at least minimum regions");579580guarantee(HumongousThresholdWords == 0, "we should only set it once");581HumongousThresholdWords = RegionSizeWords * ShenandoahHumongousThreshold / 100;582HumongousThresholdWords = align_down(HumongousThresholdWords, MinObjAlignment);583assert (HumongousThresholdWords <= RegionSizeWords, "sanity");584585guarantee(HumongousThresholdBytes == 0, "we should only set it once");586HumongousThresholdBytes = HumongousThresholdWords * HeapWordSize;587assert (HumongousThresholdBytes <= RegionSizeBytes, "sanity");588589// The rationale for trimming the TLAB sizes has to do with the raciness in590// TLAB allocation machinery. It may happen that TLAB sizing policy polls Shenandoah591// about next free size, gets the answer for region #N, goes away for a while, then592// tries to allocate in region #N, and fail because some other thread have claimed part593// of the region #N, and then the freeset allocation code has to retire the region #N,594// before moving the allocation to region #N+1.595//596// The worst case realizes when "answer" is "region size", which means it could597// prematurely retire an entire region. Having smaller TLABs does not fix that598// completely, but reduces the probability of too wasteful region retirement.599// With current divisor, we will waste no more than 1/8 of region size in the worst600// case. This also has a secondary effect on collection set selection: even under601// the race, the regions would be at least 7/8 used, which allows relying on602// "used" - "live" for cset selection. Otherwise, we can get the fragmented region603// below the garbage threshold that would never be considered for collection.604//605// The whole thing is mitigated if Elastic TLABs are enabled.606//607guarantee(MaxTLABSizeWords == 0, "we should only set it once");608MaxTLABSizeWords = MIN2(ShenandoahElasticTLAB ? RegionSizeWords : (RegionSizeWords / 8), HumongousThresholdWords);609MaxTLABSizeWords = align_down(MaxTLABSizeWords, MinObjAlignment);610611guarantee(MaxTLABSizeBytes == 0, "we should only set it once");612MaxTLABSizeBytes = MaxTLABSizeWords * HeapWordSize;613assert (MaxTLABSizeBytes > MinTLABSize, "should be larger");614}615616void ShenandoahHeapRegion::do_commit() {617ShenandoahHeap* heap = ShenandoahHeap::heap();618if (!heap->is_heap_region_special() && !os::commit_memory((char *) bottom(), RegionSizeBytes, false)) {619report_java_out_of_memory("Unable to commit region");620}621if (!heap->commit_bitmap_slice(this)) {622report_java_out_of_memory("Unable to commit bitmaps for region");623}624if (AlwaysPreTouch) {625os::pretouch_memory(bottom(), end(), heap->pretouch_heap_page_size());626}627heap->increase_committed(ShenandoahHeapRegion::region_size_bytes());628}629630void ShenandoahHeapRegion::do_uncommit() {631ShenandoahHeap* heap = ShenandoahHeap::heap();632if (!heap->is_heap_region_special() && !os::uncommit_memory((char *) bottom(), RegionSizeBytes)) {633report_java_out_of_memory("Unable to uncommit region");634}635if (!heap->uncommit_bitmap_slice(this)) {636report_java_out_of_memory("Unable to uncommit bitmaps for region");637}638heap->decrease_committed(ShenandoahHeapRegion::region_size_bytes());639}640641void ShenandoahHeapRegion::set_state(RegionState to) {642EventShenandoahHeapRegionStateChange evt;643if (evt.should_commit()){644evt.set_index((unsigned) index());645evt.set_start((uintptr_t)bottom());646evt.set_used(used());647evt.set_from(_state);648evt.set_to(to);649evt.commit();650}651_state = to;652}653654void ShenandoahHeapRegion::record_pin() {655Atomic::add(&_critical_pins, (size_t)1);656}657658void ShenandoahHeapRegion::record_unpin() {659assert(pin_count() > 0, "Region " SIZE_FORMAT " should have non-zero pins", index());660Atomic::sub(&_critical_pins, (size_t)1);661}662663size_t ShenandoahHeapRegion::pin_count() const {664return Atomic::load(&_critical_pins);665}666667668