本文整理汇总了C++中ParallelScavengeHeap::intra_heap_alignment方法的典型用法代码示例。如果您正苦于以下问题:C++ ParallelScavengeHeap::intra_heap_alignment方法的具体用法?C++ ParallelScavengeHeap::intra_heap_alignment怎么用?C++ ParallelScavengeHeap::intra_heap_alignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParallelScavengeHeap
的用法示例。
在下文中一共展示了ParallelScavengeHeap::intra_heap_alignment方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compute_initial_space_boundaries
void PSYoungGen::compute_initial_space_boundaries() {
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity");
// Compute sizes
size_t alignment = heap->intra_heap_alignment();
size_t size = virtual_space()->committed_size();
size_t survivor_size = size / InitialSurvivorRatio;
survivor_size = align_size_down(survivor_size, alignment);
// ... but never less than an alignment
survivor_size = MAX2(survivor_size, alignment);
// Young generation is eden + 2 survivor spaces
size_t eden_size = size - (2 * survivor_size);
// Now go ahead and set 'em.
set_space_boundaries(eden_size, survivor_size);
space_invariants();
if (UsePerfData) {
_eden_counters->update_capacity();
_from_counters->update_capacity();
_to_counters->update_capacity();
}
}
示例2: available_to_live
// This method assumes that from-space has live data and that
// any shrinkage of the young gen is limited by location of
// from-space.
size_t PSYoungGen::available_to_live() {
size_t delta_in_survivor = 0;
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
const size_t space_alignment = heap->intra_heap_alignment();
const size_t gen_alignment = heap->young_gen_alignment();
MutableSpace* space_shrinking = NULL;
if (from_space()->end() > to_space()->end()) {
space_shrinking = from_space();
} else {
space_shrinking = to_space();
}
// Include any space that is committed but not included in
// the survivor spaces.
assert(((HeapWord*)virtual_space()->high()) >= space_shrinking->end(),
"Survivor space beyond high end");
size_t unused_committed = pointer_delta(virtual_space()->high(),
space_shrinking->end(), sizeof(char));
if (space_shrinking->is_empty()) {
// Don't let the space shrink to 0
assert(space_shrinking->capacity_in_bytes() >= space_alignment,
"Space is too small");
delta_in_survivor = space_shrinking->capacity_in_bytes() - space_alignment;
} else {
delta_in_survivor = pointer_delta(space_shrinking->end(),
space_shrinking->top(),
sizeof(char));
}
size_t delta_in_bytes = unused_committed + delta_in_survivor;
delta_in_bytes = align_size_down(delta_in_bytes, gen_alignment);
return delta_in_bytes;
}
示例3: space_invariants
void PSYoungGen::space_invariants() {
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
const size_t alignment = heap->intra_heap_alignment();
// Currently, our eden size cannot shrink to zero
guarantee(eden_space()->capacity_in_bytes() >= alignment, "eden too small");
guarantee(from_space()->capacity_in_bytes() >= alignment, "from too small");
guarantee(to_space()->capacity_in_bytes() >= alignment, "to too small");
// Relationship of spaces to each other
char* eden_start = (char*)eden_space()->bottom();
char* eden_end = (char*)eden_space()->end();
char* from_start = (char*)from_space()->bottom();
char* from_end = (char*)from_space()->end();
char* to_start = (char*)to_space()->bottom();
char* to_end = (char*)to_space()->end();
guarantee(eden_start >= virtual_space()->low(), "eden bottom");
guarantee(eden_start < eden_end, "eden space consistency");
guarantee(from_start < from_end, "from space consistency");
guarantee(to_start < to_end, "to space consistency");
// Check whether from space is below to space
if (from_start < to_start) {
// Eden, from, to
guarantee(eden_end <= from_start, "eden/from boundary");
guarantee(from_end <= to_start, "from/to boundary");
guarantee(to_end <= virtual_space()->high(), "to end");
} else {
// Eden, to, from
guarantee(eden_end <= to_start, "eden/to boundary");
guarantee(to_end <= from_start, "to/from boundary");
guarantee(from_end <= virtual_space()->high(), "from end");
}
// More checks that the virtual space is consistent with the spaces
assert(virtual_space()->committed_size() >=
(eden_space()->capacity_in_bytes() +
to_space()->capacity_in_bytes() +
from_space()->capacity_in_bytes()), "Committed size is inconsistent");
assert(virtual_space()->committed_size() <= virtual_space()->reserved_size(),
"Space invariant");
char* eden_top = (char*)eden_space()->top();
char* from_top = (char*)from_space()->top();
char* to_top = (char*)to_space()->top();
assert(eden_top <= virtual_space()->high(), "eden top");
assert(from_top <= virtual_space()->high(), "from top");
assert(to_top <= virtual_space()->high(), "to top");
virtual_space()->verify();
}
示例4: available_to_live
// This method assumes that from-space has live data and that
// any shrinkage of the young gen is limited by location of
// from-space.
size_t ASParNewGeneration::available_to_live() const {
#undef SHRINKS_AT_END_OF_EDEN
#ifdef SHRINKS_AT_END_OF_EDEN
size_t delta_in_survivor = 0;
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
const size_t space_alignment = heap->intra_heap_alignment();
const size_t gen_alignment = heap->object_heap_alignment();
MutableSpace* space_shrinking = NULL;
if (from_space()->end() > to_space()->end()) {
space_shrinking = from_space();
} else {
space_shrinking = to_space();
}
// Include any space that is committed but not included in
// the survivor spaces.
assert(((HeapWord*)virtual_space()->high()) >= space_shrinking->end(),
"Survivor space beyond high end");
size_t unused_committed = pointer_delta(virtual_space()->high(),
space_shrinking->end(), sizeof(char));
if (space_shrinking->is_empty()) {
// Don't let the space shrink to 0
assert(space_shrinking->capacity_in_bytes() >= space_alignment,
"Space is too small");
delta_in_survivor = space_shrinking->capacity_in_bytes() - space_alignment;
} else {
delta_in_survivor = pointer_delta(space_shrinking->end(),
space_shrinking->top(),
sizeof(char));
}
size_t delta_in_bytes = unused_committed + delta_in_survivor;
delta_in_bytes = align_size_down(delta_in_bytes, gen_alignment);
return delta_in_bytes;
#else
// The only space available for shrinking is in to-space if it
// is above from-space.
if (to()->bottom() > from()->bottom()) {
const size_t alignment = os::vm_page_size();
if (to()->capacity() < alignment) {
return 0;
} else {
return to()->capacity() - alignment;
}
} else {
return 0;
}
#endif
}
示例5: available_to_live
// The current implementation only considers to the end of eden.
// If to_space is below from_space, to_space is not considered.
// to_space can be.
size_t ASPSYoungGen::available_to_live() {
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
const size_t alignment = heap->intra_heap_alignment();
// Include any space that is committed but is not in eden.
size_t available = pointer_delta(eden_space()->bottom(),
virtual_space()->low(),
sizeof(char));
const size_t eden_capacity = eden_space()->capacity_in_bytes();
if (eden_space()->is_empty() && eden_capacity > alignment) {
available += eden_capacity - alignment;
}
return available;
}
示例6: available_for_contraction
// Return the number of bytes the young gen is willing give up.
//
// Future implementations could check the survivors and if to_space is in the
// right place (below from_space), take a chunk from to_space.
size_t ASPSYoungGen::available_for_contraction() {
size_t uncommitted_bytes = virtual_space()->uncommitted_size();
if (uncommitted_bytes != 0) {
return uncommitted_bytes;
}
if (eden_space()->is_empty()) {
// Respect the minimum size for eden and for the young gen as a whole.
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
const size_t eden_alignment = heap->intra_heap_alignment();
const size_t gen_alignment = heap->young_gen_alignment();
assert(eden_space()->capacity_in_bytes() >= eden_alignment,
"Alignment is wrong");
size_t eden_avail = eden_space()->capacity_in_bytes() - eden_alignment;
eden_avail = align_size_down(eden_avail, gen_alignment);
assert(virtual_space()->committed_size() >= min_gen_size(),
"minimum gen size is wrong");
size_t gen_avail = virtual_space()->committed_size() - min_gen_size();
assert(virtual_space()->is_aligned(gen_avail), "not aligned");
const size_t max_contraction = MIN2(eden_avail, gen_avail);
// See comment for ASPSOldGen::available_for_contraction()
// for reasons the "increment" fraction is used.
PSAdaptiveSizePolicy* policy = heap->size_policy();
size_t result = policy->eden_increment_aligned_down(max_contraction);
size_t result_aligned = align_size_down(result, gen_alignment);
if (PrintAdaptiveSizePolicy && Verbose) {
gclog_or_tty->print_cr("ASPSYoungGen::available_for_contraction: %d K",
result_aligned/K);
gclog_or_tty->print_cr(" max_contraction %d K", max_contraction/K);
gclog_or_tty->print_cr(" eden_avail %d K", eden_avail/K);
gclog_or_tty->print_cr(" gen_avail %d K", gen_avail/K);
}
return result_aligned;
}
return 0;
}
示例7: initialize_work
void PSYoungGen::initialize_work() {
_reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(),
(HeapWord*)virtual_space()->high_boundary());
MemRegion cmr((HeapWord*)virtual_space()->low(),
(HeapWord*)virtual_space()->high());
Universe::heap()->barrier_set()->resize_covered_region(cmr);
if (ZapUnusedHeapArea) {
// Mangle newly committed space immediately because it
// can be done here more simply that after the new
// spaces have been computed.
SpaceMangler::mangle_region(cmr);
}
if (UseNUMA) {
_eden_space = new MutableNUMASpace(virtual_space()->alignment());
} else {
_eden_space = new MutableSpace(virtual_space()->alignment());
}
_from_space = new MutableSpace(virtual_space()->alignment());
_to_space = new MutableSpace(virtual_space()->alignment());
if (_eden_space == NULL || _from_space == NULL || _to_space == NULL) {
vm_exit_during_initialization("Could not allocate a young gen space");
}
// Allocate the mark sweep views of spaces
_eden_mark_sweep =
new PSMarkSweepDecorator(_eden_space, NULL, MarkSweepDeadRatio);
_from_mark_sweep =
new PSMarkSweepDecorator(_from_space, NULL, MarkSweepDeadRatio);
_to_mark_sweep =
new PSMarkSweepDecorator(_to_space, NULL, MarkSweepDeadRatio);
if (_eden_mark_sweep == NULL ||
_from_mark_sweep == NULL ||
_to_mark_sweep == NULL) {
vm_exit_during_initialization("Could not complete allocation"
" of the young generation");
}
// Generation Counters - generation 0, 3 subspaces
_gen_counters = new PSGenerationCounters("new", 0, 3, _virtual_space);
// Compute maximum space sizes for performance counters
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
size_t alignment = heap->intra_heap_alignment();
size_t size = virtual_space()->reserved_size();
size_t max_survivor_size;
size_t max_eden_size;
if (UseAdaptiveSizePolicy) {
max_survivor_size = size / MinSurvivorRatio;
// round the survivor space size down to the nearest alignment
// and make sure its size is greater than 0.
max_survivor_size = align_size_down(max_survivor_size, alignment);
max_survivor_size = MAX2(max_survivor_size, alignment);
// set the maximum size of eden to be the size of the young gen
// less two times the minimum survivor size. The minimum survivor
// size for UseAdaptiveSizePolicy is one alignment.
max_eden_size = size - 2 * alignment;
} else {
max_survivor_size = size / InitialSurvivorRatio;
// round the survivor space size down to the nearest alignment
// and make sure its size is greater than 0.
max_survivor_size = align_size_down(max_survivor_size, alignment);
max_survivor_size = MAX2(max_survivor_size, alignment);
// set the maximum size of eden to be the size of the young gen
// less two times the survivor size when the generation is 100%
// committed. The minimum survivor size for -UseAdaptiveSizePolicy
// is dependent on the committed portion (current capacity) of the
// generation - the less space committed, the smaller the survivor
// space, possibly as small as an alignment. However, we are interested
// in the case where the young generation is 100% committed, as this
// is the point where eden reachs its maximum size. At this point,
// the size of a survivor space is max_survivor_size.
max_eden_size = size - 2 * max_survivor_size;
}
_eden_counters = new SpaceCounters("eden", 0, max_eden_size, _eden_space,
_gen_counters);
_from_counters = new SpaceCounters("s0", 1, max_survivor_size, _from_space,
_gen_counters);
_to_counters = new SpaceCounters("s1", 2, max_survivor_size, _to_space,
_gen_counters);
compute_initial_space_boundaries();
}
示例8: resize_spaces
void PSYoungGen::resize_spaces(size_t requested_eden_size,
size_t requested_survivor_size) {
assert(UseAdaptiveSizePolicy, "sanity check");
assert(requested_eden_size > 0 && requested_survivor_size > 0,
"just checking");
// We require eden and to space to be empty
if ((!eden_space()->is_empty()) || (!to_space()->is_empty())) {
return;
}
if (PrintAdaptiveSizePolicy && Verbose) {
gclog_or_tty->print_cr("PSYoungGen::resize_spaces(requested_eden_size: "
SIZE_FORMAT
", requested_survivor_size: " SIZE_FORMAT ")",
requested_eden_size, requested_survivor_size);
gclog_or_tty->print_cr(" eden: [" PTR_FORMAT ".." PTR_FORMAT ") "
SIZE_FORMAT,
eden_space()->bottom(),
eden_space()->end(),
pointer_delta(eden_space()->end(),
eden_space()->bottom(),
sizeof(char)));
gclog_or_tty->print_cr(" from: [" PTR_FORMAT ".." PTR_FORMAT ") "
SIZE_FORMAT,
from_space()->bottom(),
from_space()->end(),
pointer_delta(from_space()->end(),
from_space()->bottom(),
sizeof(char)));
gclog_or_tty->print_cr(" to: [" PTR_FORMAT ".." PTR_FORMAT ") "
SIZE_FORMAT,
to_space()->bottom(),
to_space()->end(),
pointer_delta( to_space()->end(),
to_space()->bottom(),
sizeof(char)));
}
// There's nothing to do if the new sizes are the same as the current
if (requested_survivor_size == to_space()->capacity_in_bytes() &&
requested_survivor_size == from_space()->capacity_in_bytes() &&
requested_eden_size == eden_space()->capacity_in_bytes()) {
if (PrintAdaptiveSizePolicy && Verbose) {
gclog_or_tty->print_cr(" capacities are the right sizes, returning");
}
return;
}
char* eden_start = (char*)eden_space()->bottom();
char* eden_end = (char*)eden_space()->end();
char* from_start = (char*)from_space()->bottom();
char* from_end = (char*)from_space()->end();
char* to_start = (char*)to_space()->bottom();
char* to_end = (char*)to_space()->end();
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
const size_t alignment = heap->intra_heap_alignment();
const bool maintain_minimum =
(requested_eden_size + 2 * requested_survivor_size) <= min_gen_size();
bool eden_from_to_order = from_start < to_start;
// Check whether from space is below to space
if (eden_from_to_order) {
// Eden, from, to
eden_from_to_order = true;
if (PrintAdaptiveSizePolicy && Verbose) {
gclog_or_tty->print_cr(" Eden, from, to:");
}
// Set eden
// "requested_eden_size" is a goal for the size of eden
// and may not be attainable. "eden_size" below is
// calculated based on the location of from-space and
// the goal for the size of eden. from-space is
// fixed in place because it contains live data.
// The calculation is done this way to avoid 32bit
// overflow (i.e., eden_start + requested_eden_size
// may too large for representation in 32bits).
size_t eden_size;
if (maintain_minimum) {
// Only make eden larger than the requested size if
// the minimum size of the generation has to be maintained.
// This could be done in general but policy at a higher
// level is determining a requested size for eden and that
// should be honored unless there is a fundamental reason.
eden_size = pointer_delta(from_start,
eden_start,
sizeof(char));
} else {
eden_size = MIN2(requested_eden_size,
pointer_delta(from_start, eden_start, sizeof(char)));
}
eden_end = eden_start + eden_size;
assert(eden_end >= eden_start, "addition overflowed");
// To may resize into from space as long as it is clear of live data.
// From space must remain page aligned, though, so we need to do some
// extra calculations.
//.........这里部分代码省略.........
示例9: resize_spaces
void ASPSYoungGen::resize_spaces(size_t requested_eden_size,
size_t requested_survivor_size) {
assert(UseAdaptiveSizePolicy, "sanity check");
assert(requested_eden_size > 0 && requested_survivor_size > 0,
"just checking");
space_invariants();
// We require eden and to space to be empty
if ((!eden_space()->is_empty()) || (!to_space()->is_empty())) {
return;
}
if (PrintAdaptiveSizePolicy && Verbose) {
gclog_or_tty->print_cr("PSYoungGen::resize_spaces(requested_eden_size: "
SIZE_FORMAT
", requested_survivor_size: " SIZE_FORMAT ")",
requested_eden_size, requested_survivor_size);
gclog_or_tty->print_cr(" eden: [" PTR_FORMAT ".." PTR_FORMAT ") "
SIZE_FORMAT,
eden_space()->bottom(),
eden_space()->end(),
pointer_delta(eden_space()->end(),
eden_space()->bottom(),
sizeof(char)));
gclog_or_tty->print_cr(" from: [" PTR_FORMAT ".." PTR_FORMAT ") "
SIZE_FORMAT,
from_space()->bottom(),
from_space()->end(),
pointer_delta(from_space()->end(),
from_space()->bottom(),
sizeof(char)));
gclog_or_tty->print_cr(" to: [" PTR_FORMAT ".." PTR_FORMAT ") "
SIZE_FORMAT,
to_space()->bottom(),
to_space()->end(),
pointer_delta( to_space()->end(),
to_space()->bottom(),
sizeof(char)));
}
// There's nothing to do if the new sizes are the same as the current
if (requested_survivor_size == to_space()->capacity_in_bytes() &&
requested_survivor_size == from_space()->capacity_in_bytes() &&
requested_eden_size == eden_space()->capacity_in_bytes()) {
if (PrintAdaptiveSizePolicy && Verbose) {
gclog_or_tty->print_cr(" capacities are the right sizes, returning");
}
return;
}
char* eden_start = (char*)virtual_space()->low();
char* eden_end = (char*)eden_space()->end();
char* from_start = (char*)from_space()->bottom();
char* from_end = (char*)from_space()->end();
char* to_start = (char*)to_space()->bottom();
char* to_end = (char*)to_space()->end();
assert(eden_start < from_start, "Cannot push into from_space");
ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
const size_t alignment = heap->intra_heap_alignment();
const bool maintain_minimum =
(requested_eden_size + 2 * requested_survivor_size) <= min_gen_size();
bool eden_from_to_order = from_start < to_start;
// Check whether from space is below to space
if (eden_from_to_order) {
// Eden, from, to
if (PrintAdaptiveSizePolicy && Verbose) {
gclog_or_tty->print_cr(" Eden, from, to:");
}
// Set eden
// "requested_eden_size" is a goal for the size of eden
// and may not be attainable. "eden_size" below is
// calculated based on the location of from-space and
// the goal for the size of eden. from-space is
// fixed in place because it contains live data.
// The calculation is done this way to avoid 32bit
// overflow (i.e., eden_start + requested_eden_size
// may too large for representation in 32bits).
size_t eden_size;
if (maintain_minimum) {
// Only make eden larger than the requested size if
// the minimum size of the generation has to be maintained.
// This could be done in general but policy at a higher
// level is determining a requested size for eden and that
// should be honored unless there is a fundamental reason.
eden_size = pointer_delta(from_start,
eden_start,
sizeof(char));
} else {
eden_size = MIN2(requested_eden_size,
pointer_delta(from_start, eden_start, sizeof(char)));
}
eden_end = eden_start + eden_size;
assert(eden_end >= eden_start, "addition overflowed")
//.........这里部分代码省略.........