1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/asPSYoungGen.cpp Wed Apr 27 01:25:04 2016 +0800 1.3 @@ -0,0 +1,548 @@ 1.4 +/* 1.5 + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#include "precompiled.hpp" 1.29 +#include "gc_implementation/parallelScavenge/asPSYoungGen.hpp" 1.30 +#include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" 1.31 +#include "gc_implementation/parallelScavenge/psMarkSweepDecorator.hpp" 1.32 +#include "gc_implementation/parallelScavenge/psScavenge.hpp" 1.33 +#include "gc_implementation/parallelScavenge/psYoungGen.hpp" 1.34 +#include "gc_implementation/shared/gcUtil.hpp" 1.35 +#include "gc_implementation/shared/spaceDecorator.hpp" 1.36 +#include "oops/oop.inline.hpp" 1.37 +#include "runtime/java.hpp" 1.38 + 1.39 +ASPSYoungGen::ASPSYoungGen(size_t init_byte_size, 1.40 + size_t minimum_byte_size, 1.41 + size_t byte_size_limit) : 1.42 + PSYoungGen(init_byte_size, minimum_byte_size, byte_size_limit), 1.43 + _gen_size_limit(byte_size_limit) { 1.44 +} 1.45 + 1.46 + 1.47 +ASPSYoungGen::ASPSYoungGen(PSVirtualSpace* vs, 1.48 + size_t init_byte_size, 1.49 + size_t minimum_byte_size, 1.50 + size_t byte_size_limit) : 1.51 + //PSYoungGen(init_byte_size, minimum_byte_size, byte_size_limit), 1.52 + PSYoungGen(vs->committed_size(), minimum_byte_size, byte_size_limit), 1.53 + _gen_size_limit(byte_size_limit) { 1.54 + 1.55 + assert(vs->committed_size() == init_byte_size, "Cannot replace with"); 1.56 + 1.57 + _virtual_space = vs; 1.58 +} 1.59 + 1.60 +void ASPSYoungGen::initialize_virtual_space(ReservedSpace rs, 1.61 + size_t alignment) { 1.62 + assert(_init_gen_size != 0, "Should have a finite size"); 1.63 + _virtual_space = new PSVirtualSpaceHighToLow(rs, alignment); 1.64 + if (!_virtual_space->expand_by(_init_gen_size)) { 1.65 + vm_exit_during_initialization("Could not reserve enough space for " 1.66 + "object heap"); 1.67 + } 1.68 +} 1.69 + 1.70 +void ASPSYoungGen::initialize(ReservedSpace rs, size_t alignment) { 1.71 + initialize_virtual_space(rs, alignment); 1.72 + initialize_work(); 1.73 +} 1.74 + 1.75 +size_t ASPSYoungGen::available_for_expansion() { 1.76 + size_t current_committed_size = virtual_space()->committed_size(); 1.77 + assert((gen_size_limit() >= current_committed_size), 1.78 + "generation size limit is wrong"); 1.79 + ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 1.80 + size_t result = gen_size_limit() - current_committed_size; 1.81 + size_t result_aligned = align_size_down(result, heap->generation_alignment()); 1.82 + return result_aligned; 1.83 +} 1.84 + 1.85 +// Return the number of bytes the young gen is willing give up. 1.86 +// 1.87 +// Future implementations could check the survivors and if to_space is in the 1.88 +// right place (below from_space), take a chunk from to_space. 1.89 +size_t ASPSYoungGen::available_for_contraction() { 1.90 + size_t uncommitted_bytes = virtual_space()->uncommitted_size(); 1.91 + if (uncommitted_bytes != 0) { 1.92 + return uncommitted_bytes; 1.93 + } 1.94 + 1.95 + if (eden_space()->is_empty()) { 1.96 + // Respect the minimum size for eden and for the young gen as a whole. 1.97 + ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 1.98 + const size_t eden_alignment = heap->space_alignment(); 1.99 + const size_t gen_alignment = heap->generation_alignment(); 1.100 + 1.101 + assert(eden_space()->capacity_in_bytes() >= eden_alignment, 1.102 + "Alignment is wrong"); 1.103 + size_t eden_avail = eden_space()->capacity_in_bytes() - eden_alignment; 1.104 + eden_avail = align_size_down(eden_avail, gen_alignment); 1.105 + 1.106 + assert(virtual_space()->committed_size() >= min_gen_size(), 1.107 + "minimum gen size is wrong"); 1.108 + size_t gen_avail = virtual_space()->committed_size() - min_gen_size(); 1.109 + assert(virtual_space()->is_aligned(gen_avail), "not aligned"); 1.110 + 1.111 + const size_t max_contraction = MIN2(eden_avail, gen_avail); 1.112 + // See comment for ASPSOldGen::available_for_contraction() 1.113 + // for reasons the "increment" fraction is used. 1.114 + PSAdaptiveSizePolicy* policy = heap->size_policy(); 1.115 + size_t result = policy->eden_increment_aligned_down(max_contraction); 1.116 + size_t result_aligned = align_size_down(result, gen_alignment); 1.117 + if (PrintAdaptiveSizePolicy && Verbose) { 1.118 + gclog_or_tty->print_cr("ASPSYoungGen::available_for_contraction: " SIZE_FORMAT " K", 1.119 + result_aligned/K); 1.120 + gclog_or_tty->print_cr(" max_contraction " SIZE_FORMAT " K", max_contraction/K); 1.121 + gclog_or_tty->print_cr(" eden_avail " SIZE_FORMAT " K", eden_avail/K); 1.122 + gclog_or_tty->print_cr(" gen_avail " SIZE_FORMAT " K", gen_avail/K); 1.123 + } 1.124 + return result_aligned; 1.125 + } 1.126 + 1.127 + return 0; 1.128 +} 1.129 + 1.130 +// The current implementation only considers to the end of eden. 1.131 +// If to_space is below from_space, to_space is not considered. 1.132 +// to_space can be. 1.133 +size_t ASPSYoungGen::available_to_live() { 1.134 + ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 1.135 + const size_t alignment = heap->space_alignment(); 1.136 + 1.137 + // Include any space that is committed but is not in eden. 1.138 + size_t available = pointer_delta(eden_space()->bottom(), 1.139 + virtual_space()->low(), 1.140 + sizeof(char)); 1.141 + 1.142 + const size_t eden_capacity = eden_space()->capacity_in_bytes(); 1.143 + if (eden_space()->is_empty() && eden_capacity > alignment) { 1.144 + available += eden_capacity - alignment; 1.145 + } 1.146 + return available; 1.147 +} 1.148 + 1.149 +// Similar to PSYoungGen::resize_generation() but 1.150 +// allows sum of eden_size and 2 * survivor_size to exceed _max_gen_size 1.151 +// expands at the low end of the virtual space 1.152 +// moves the boundary between the generations in order to expand 1.153 +// some additional diagnostics 1.154 +// If no additional changes are required, this can be deleted 1.155 +// and the changes factored back into PSYoungGen::resize_generation(). 1.156 +bool ASPSYoungGen::resize_generation(size_t eden_size, size_t survivor_size) { 1.157 + const size_t alignment = virtual_space()->alignment(); 1.158 + size_t orig_size = virtual_space()->committed_size(); 1.159 + bool size_changed = false; 1.160 + 1.161 + // There used to be a guarantee here that 1.162 + // (eden_size + 2*survivor_size) <= _max_gen_size 1.163 + // This requirement is enforced by the calculation of desired_size 1.164 + // below. It may not be true on entry since the size of the 1.165 + // eden_size is no bounded by the generation size. 1.166 + 1.167 + assert(max_size() == reserved().byte_size(), "max gen size problem?"); 1.168 + assert(min_gen_size() <= orig_size && orig_size <= max_size(), 1.169 + "just checking"); 1.170 + 1.171 + // Adjust new generation size 1.172 + const size_t eden_plus_survivors = 1.173 + align_size_up(eden_size + 2 * survivor_size, alignment); 1.174 + size_t desired_size = MAX2(MIN2(eden_plus_survivors, gen_size_limit()), 1.175 + min_gen_size()); 1.176 + assert(desired_size <= gen_size_limit(), "just checking"); 1.177 + 1.178 + if (desired_size > orig_size) { 1.179 + // Grow the generation 1.180 + size_t change = desired_size - orig_size; 1.181 + HeapWord* prev_low = (HeapWord*) virtual_space()->low(); 1.182 + if (!virtual_space()->expand_by(change)) { 1.183 + return false; 1.184 + } 1.185 + if (ZapUnusedHeapArea) { 1.186 + // Mangle newly committed space immediately because it 1.187 + // can be done here more simply that after the new 1.188 + // spaces have been computed. 1.189 + HeapWord* new_low = (HeapWord*) virtual_space()->low(); 1.190 + assert(new_low < prev_low, "Did not grow"); 1.191 + 1.192 + MemRegion mangle_region(new_low, prev_low); 1.193 + SpaceMangler::mangle_region(mangle_region); 1.194 + } 1.195 + size_changed = true; 1.196 + } else if (desired_size < orig_size) { 1.197 + size_t desired_change = orig_size - desired_size; 1.198 + 1.199 + // How much is available for shrinking. 1.200 + size_t available_bytes = limit_gen_shrink(desired_change); 1.201 + size_t change = MIN2(desired_change, available_bytes); 1.202 + virtual_space()->shrink_by(change); 1.203 + size_changed = true; 1.204 + } else { 1.205 + if (Verbose && PrintGC) { 1.206 + if (orig_size == gen_size_limit()) { 1.207 + gclog_or_tty->print_cr("ASPSYoung generation size at maximum: " 1.208 + SIZE_FORMAT "K", orig_size/K); 1.209 + } else if (orig_size == min_gen_size()) { 1.210 + gclog_or_tty->print_cr("ASPSYoung generation size at minium: " 1.211 + SIZE_FORMAT "K", orig_size/K); 1.212 + } 1.213 + } 1.214 + } 1.215 + 1.216 + if (size_changed) { 1.217 + reset_after_change(); 1.218 + if (Verbose && PrintGC) { 1.219 + size_t current_size = virtual_space()->committed_size(); 1.220 + gclog_or_tty->print_cr("ASPSYoung generation size changed: " 1.221 + SIZE_FORMAT "K->" SIZE_FORMAT "K", 1.222 + orig_size/K, current_size/K); 1.223 + } 1.224 + } 1.225 + 1.226 + guarantee(eden_plus_survivors <= virtual_space()->committed_size() || 1.227 + virtual_space()->committed_size() == max_size(), "Sanity"); 1.228 + 1.229 + return true; 1.230 +} 1.231 + 1.232 +// Similar to PSYoungGen::resize_spaces() but 1.233 +// eden always starts at the low end of the committed virtual space 1.234 +// current implementation does not allow holes between the spaces 1.235 +// _young_generation_boundary has to be reset because it changes. 1.236 +// so additional verification 1.237 + 1.238 +void ASPSYoungGen::resize_spaces(size_t requested_eden_size, 1.239 + size_t requested_survivor_size) { 1.240 + assert(UseAdaptiveSizePolicy, "sanity check"); 1.241 + assert(requested_eden_size > 0 && requested_survivor_size > 0, 1.242 + "just checking"); 1.243 + 1.244 + space_invariants(); 1.245 + 1.246 + // We require eden and to space to be empty 1.247 + if ((!eden_space()->is_empty()) || (!to_space()->is_empty())) { 1.248 + return; 1.249 + } 1.250 + 1.251 + if (PrintAdaptiveSizePolicy && Verbose) { 1.252 + gclog_or_tty->print_cr("PSYoungGen::resize_spaces(requested_eden_size: " 1.253 + SIZE_FORMAT 1.254 + ", requested_survivor_size: " SIZE_FORMAT ")", 1.255 + requested_eden_size, requested_survivor_size); 1.256 + gclog_or_tty->print_cr(" eden: [" PTR_FORMAT ".." PTR_FORMAT ") " 1.257 + SIZE_FORMAT, 1.258 + p2i(eden_space()->bottom()), 1.259 + p2i(eden_space()->end()), 1.260 + pointer_delta(eden_space()->end(), 1.261 + eden_space()->bottom(), 1.262 + sizeof(char))); 1.263 + gclog_or_tty->print_cr(" from: [" PTR_FORMAT ".." PTR_FORMAT ") " 1.264 + SIZE_FORMAT, 1.265 + p2i(from_space()->bottom()), 1.266 + p2i(from_space()->end()), 1.267 + pointer_delta(from_space()->end(), 1.268 + from_space()->bottom(), 1.269 + sizeof(char))); 1.270 + gclog_or_tty->print_cr(" to: [" PTR_FORMAT ".." PTR_FORMAT ") " 1.271 + SIZE_FORMAT, 1.272 + p2i(to_space()->bottom()), 1.273 + p2i(to_space()->end()), 1.274 + pointer_delta( to_space()->end(), 1.275 + to_space()->bottom(), 1.276 + sizeof(char))); 1.277 + } 1.278 + 1.279 + // There's nothing to do if the new sizes are the same as the current 1.280 + if (requested_survivor_size == to_space()->capacity_in_bytes() && 1.281 + requested_survivor_size == from_space()->capacity_in_bytes() && 1.282 + requested_eden_size == eden_space()->capacity_in_bytes()) { 1.283 + if (PrintAdaptiveSizePolicy && Verbose) { 1.284 + gclog_or_tty->print_cr(" capacities are the right sizes, returning"); 1.285 + } 1.286 + return; 1.287 + } 1.288 + 1.289 + char* eden_start = (char*)virtual_space()->low(); 1.290 + char* eden_end = (char*)eden_space()->end(); 1.291 + char* from_start = (char*)from_space()->bottom(); 1.292 + char* from_end = (char*)from_space()->end(); 1.293 + char* to_start = (char*)to_space()->bottom(); 1.294 + char* to_end = (char*)to_space()->end(); 1.295 + 1.296 + assert(eden_start < from_start, "Cannot push into from_space"); 1.297 + 1.298 + ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 1.299 + const size_t alignment = heap->space_alignment(); 1.300 + const bool maintain_minimum = 1.301 + (requested_eden_size + 2 * requested_survivor_size) <= min_gen_size(); 1.302 + 1.303 + bool eden_from_to_order = from_start < to_start; 1.304 + // Check whether from space is below to space 1.305 + if (eden_from_to_order) { 1.306 + // Eden, from, to 1.307 + 1.308 + if (PrintAdaptiveSizePolicy && Verbose) { 1.309 + gclog_or_tty->print_cr(" Eden, from, to:"); 1.310 + } 1.311 + 1.312 + // Set eden 1.313 + // "requested_eden_size" is a goal for the size of eden 1.314 + // and may not be attainable. "eden_size" below is 1.315 + // calculated based on the location of from-space and 1.316 + // the goal for the size of eden. from-space is 1.317 + // fixed in place because it contains live data. 1.318 + // The calculation is done this way to avoid 32bit 1.319 + // overflow (i.e., eden_start + requested_eden_size 1.320 + // may too large for representation in 32bits). 1.321 + size_t eden_size; 1.322 + if (maintain_minimum) { 1.323 + // Only make eden larger than the requested size if 1.324 + // the minimum size of the generation has to be maintained. 1.325 + // This could be done in general but policy at a higher 1.326 + // level is determining a requested size for eden and that 1.327 + // should be honored unless there is a fundamental reason. 1.328 + eden_size = pointer_delta(from_start, 1.329 + eden_start, 1.330 + sizeof(char)); 1.331 + } else { 1.332 + eden_size = MIN2(requested_eden_size, 1.333 + pointer_delta(from_start, eden_start, sizeof(char))); 1.334 + } 1.335 + 1.336 + eden_end = eden_start + eden_size; 1.337 + assert(eden_end >= eden_start, "addition overflowed"); 1.338 + 1.339 + // To may resize into from space as long as it is clear of live data. 1.340 + // From space must remain page aligned, though, so we need to do some 1.341 + // extra calculations. 1.342 + 1.343 + // First calculate an optimal to-space 1.344 + to_end = (char*)virtual_space()->high(); 1.345 + to_start = (char*)pointer_delta(to_end, 1.346 + (char*)requested_survivor_size, 1.347 + sizeof(char)); 1.348 + 1.349 + // Does the optimal to-space overlap from-space? 1.350 + if (to_start < (char*)from_space()->end()) { 1.351 + assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); 1.352 + 1.353 + // Calculate the minimum offset possible for from_end 1.354 + size_t from_size = 1.355 + pointer_delta(from_space()->top(), from_start, sizeof(char)); 1.356 + 1.357 + // Should we be in this method if from_space is empty? Why not the set_space method? FIX ME! 1.358 + if (from_size == 0) { 1.359 + from_size = alignment; 1.360 + } else { 1.361 + from_size = align_size_up(from_size, alignment); 1.362 + } 1.363 + 1.364 + from_end = from_start + from_size; 1.365 + assert(from_end > from_start, "addition overflow or from_size problem"); 1.366 + 1.367 + guarantee(from_end <= (char*)from_space()->end(), 1.368 + "from_end moved to the right"); 1.369 + 1.370 + // Now update to_start with the new from_end 1.371 + to_start = MAX2(from_end, to_start); 1.372 + } 1.373 + 1.374 + guarantee(to_start != to_end, "to space is zero sized"); 1.375 + 1.376 + if (PrintAdaptiveSizePolicy && Verbose) { 1.377 + gclog_or_tty->print_cr(" [eden_start .. eden_end): " 1.378 + "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, 1.379 + p2i(eden_start), 1.380 + p2i(eden_end), 1.381 + pointer_delta(eden_end, eden_start, sizeof(char))); 1.382 + gclog_or_tty->print_cr(" [from_start .. from_end): " 1.383 + "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, 1.384 + p2i(from_start), 1.385 + p2i(from_end), 1.386 + pointer_delta(from_end, from_start, sizeof(char))); 1.387 + gclog_or_tty->print_cr(" [ to_start .. to_end): " 1.388 + "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, 1.389 + p2i(to_start), 1.390 + p2i(to_end), 1.391 + pointer_delta( to_end, to_start, sizeof(char))); 1.392 + } 1.393 + } else { 1.394 + // Eden, to, from 1.395 + if (PrintAdaptiveSizePolicy && Verbose) { 1.396 + gclog_or_tty->print_cr(" Eden, to, from:"); 1.397 + } 1.398 + 1.399 + // To space gets priority over eden resizing. Note that we position 1.400 + // to space as if we were able to resize from space, even though from 1.401 + // space is not modified. 1.402 + // Giving eden priority was tried and gave poorer performance. 1.403 + to_end = (char*)pointer_delta(virtual_space()->high(), 1.404 + (char*)requested_survivor_size, 1.405 + sizeof(char)); 1.406 + to_end = MIN2(to_end, from_start); 1.407 + to_start = (char*)pointer_delta(to_end, (char*)requested_survivor_size, 1.408 + sizeof(char)); 1.409 + // if the space sizes are to be increased by several times then 1.410 + // 'to_start' will point beyond the young generation. In this case 1.411 + // 'to_start' should be adjusted. 1.412 + to_start = MAX2(to_start, eden_start + alignment); 1.413 + 1.414 + // Compute how big eden can be, then adjust end. 1.415 + // See comments above on calculating eden_end. 1.416 + size_t eden_size; 1.417 + if (maintain_minimum) { 1.418 + eden_size = pointer_delta(to_start, eden_start, sizeof(char)); 1.419 + } else { 1.420 + eden_size = MIN2(requested_eden_size, 1.421 + pointer_delta(to_start, eden_start, sizeof(char))); 1.422 + } 1.423 + eden_end = eden_start + eden_size; 1.424 + assert(eden_end >= eden_start, "addition overflowed"); 1.425 + 1.426 + // Don't let eden shrink down to 0 or less. 1.427 + eden_end = MAX2(eden_end, eden_start + alignment); 1.428 + to_start = MAX2(to_start, eden_end); 1.429 + 1.430 + if (PrintAdaptiveSizePolicy && Verbose) { 1.431 + gclog_or_tty->print_cr(" [eden_start .. eden_end): " 1.432 + "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, 1.433 + p2i(eden_start), 1.434 + p2i(eden_end), 1.435 + pointer_delta(eden_end, eden_start, sizeof(char))); 1.436 + gclog_or_tty->print_cr(" [ to_start .. to_end): " 1.437 + "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, 1.438 + p2i(to_start), 1.439 + p2i(to_end), 1.440 + pointer_delta( to_end, to_start, sizeof(char))); 1.441 + gclog_or_tty->print_cr(" [from_start .. from_end): " 1.442 + "[" PTR_FORMAT " .. " PTR_FORMAT ") " SIZE_FORMAT, 1.443 + p2i(from_start), 1.444 + p2i(from_end), 1.445 + pointer_delta(from_end, from_start, sizeof(char))); 1.446 + } 1.447 + } 1.448 + 1.449 + 1.450 + guarantee((HeapWord*)from_start <= from_space()->bottom(), 1.451 + "from start moved to the right"); 1.452 + guarantee((HeapWord*)from_end >= from_space()->top(), 1.453 + "from end moved into live data"); 1.454 + assert(is_object_aligned((intptr_t)eden_start), "checking alignment"); 1.455 + assert(is_object_aligned((intptr_t)from_start), "checking alignment"); 1.456 + assert(is_object_aligned((intptr_t)to_start), "checking alignment"); 1.457 + 1.458 + MemRegion edenMR((HeapWord*)eden_start, (HeapWord*)eden_end); 1.459 + MemRegion toMR ((HeapWord*)to_start, (HeapWord*)to_end); 1.460 + MemRegion fromMR((HeapWord*)from_start, (HeapWord*)from_end); 1.461 + 1.462 + // Let's make sure the call to initialize doesn't reset "top"! 1.463 + DEBUG_ONLY(HeapWord* old_from_top = from_space()->top();) 1.464 + 1.465 + // For PrintAdaptiveSizePolicy block below 1.466 + size_t old_from = from_space()->capacity_in_bytes(); 1.467 + size_t old_to = to_space()->capacity_in_bytes(); 1.468 + 1.469 + if (ZapUnusedHeapArea) { 1.470 + // NUMA is a special case because a numa space is not mangled 1.471 + // in order to not prematurely bind its address to memory to 1.472 + // the wrong memory (i.e., don't want the GC thread to first 1.473 + // touch the memory). The survivor spaces are not numa 1.474 + // spaces and are mangled. 1.475 + if (UseNUMA) { 1.476 + if (eden_from_to_order) { 1.477 + mangle_survivors(from_space(), fromMR, to_space(), toMR); 1.478 + } else { 1.479 + mangle_survivors(to_space(), toMR, from_space(), fromMR); 1.480 + } 1.481 + } 1.482 + 1.483 + // If not mangling the spaces, do some checking to verify that 1.484 + // the spaces are already mangled. 1.485 + // The spaces should be correctly mangled at this point so 1.486 + // do some checking here. Note that they are not being mangled 1.487 + // in the calls to initialize(). 1.488 + // Must check mangling before the spaces are reshaped. Otherwise, 1.489 + // the bottom or end of one space may have moved into an area 1.490 + // covered by another space and a failure of the check may 1.491 + // not correctly indicate which space is not properly mangled. 1.492 + 1.493 + HeapWord* limit = (HeapWord*) virtual_space()->high(); 1.494 + eden_space()->check_mangled_unused_area(limit); 1.495 + from_space()->check_mangled_unused_area(limit); 1.496 + to_space()->check_mangled_unused_area(limit); 1.497 + } 1.498 + // When an existing space is being initialized, it is not 1.499 + // mangled because the space has been previously mangled. 1.500 + eden_space()->initialize(edenMR, 1.501 + SpaceDecorator::Clear, 1.502 + SpaceDecorator::DontMangle); 1.503 + to_space()->initialize(toMR, 1.504 + SpaceDecorator::Clear, 1.505 + SpaceDecorator::DontMangle); 1.506 + from_space()->initialize(fromMR, 1.507 + SpaceDecorator::DontClear, 1.508 + SpaceDecorator::DontMangle); 1.509 + 1.510 + PSScavenge::set_young_generation_boundary(eden_space()->bottom()); 1.511 + 1.512 + assert(from_space()->top() == old_from_top, "from top changed!"); 1.513 + 1.514 + if (PrintAdaptiveSizePolicy) { 1.515 + ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 1.516 + assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); 1.517 + 1.518 + gclog_or_tty->print("AdaptiveSizePolicy::survivor space sizes: " 1.519 + "collection: %d " 1.520 + "(" SIZE_FORMAT ", " SIZE_FORMAT ") -> " 1.521 + "(" SIZE_FORMAT ", " SIZE_FORMAT ") ", 1.522 + heap->total_collections(), 1.523 + old_from, old_to, 1.524 + from_space()->capacity_in_bytes(), 1.525 + to_space()->capacity_in_bytes()); 1.526 + gclog_or_tty->cr(); 1.527 + } 1.528 + space_invariants(); 1.529 +} 1.530 +void ASPSYoungGen::reset_after_change() { 1.531 + assert_locked_or_safepoint(Heap_lock); 1.532 + 1.533 + _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(), 1.534 + (HeapWord*)virtual_space()->high_boundary()); 1.535 + PSScavenge::reference_processor()->set_span(_reserved); 1.536 + 1.537 + HeapWord* new_eden_bottom = (HeapWord*)virtual_space()->low(); 1.538 + HeapWord* eden_bottom = eden_space()->bottom(); 1.539 + if (new_eden_bottom != eden_bottom) { 1.540 + MemRegion eden_mr(new_eden_bottom, eden_space()->end()); 1.541 + eden_space()->initialize(eden_mr, 1.542 + SpaceDecorator::Clear, 1.543 + SpaceDecorator::Mangle); 1.544 + PSScavenge::set_young_generation_boundary(eden_space()->bottom()); 1.545 + } 1.546 + MemRegion cmr((HeapWord*)virtual_space()->low(), 1.547 + (HeapWord*)virtual_space()->high()); 1.548 + Universe::heap()->barrier_set()->resize_covered_region(cmr); 1.549 + 1.550 + space_invariants(); 1.551 +}