598 middle_alignment(), _executable);)
599 return false;
600 }
601 _middle_high += middle_needs;
602 }
603 if (upper_needs > 0) {
604 assert(middle_high_boundary() <= upper_high() &&
605 upper_high() + upper_needs <= upper_high_boundary(),
606 "must not expand beyond region");
607 if (!os::commit_memory(upper_high(), upper_needs, _executable)) {
608 debug_only(warning("INFO: os::commit_memory(" PTR_FORMAT
609 ", upper_needs=" SIZE_FORMAT ", %d) failed",
610 upper_high(), upper_needs, _executable);)
611 return false;
612 } else {
613 _upper_high += upper_needs;
614 }
615 }
616
617 if (pre_touch || AlwaysPreTouch) {
618 int vm_ps = os::vm_page_size();
619 for (char* curr = previous_high;
620 curr < unaligned_new_high;
621 curr += vm_ps) {
622 // Note the use of a write here; originally we tried just a read, but
623 // since the value read was unused, the optimizer removed the read.
624 // If we ever have a concurrent touchahead thread, we'll want to use
625 // a read, to avoid the potential of overwriting data (if a mutator
626 // thread beats the touchahead thread to a page). There are various
627 // ways of making sure this read is not optimized away: for example,
628 // generating the code for a read procedure at runtime.
629 *curr = 0;
630 }
631 }
632
633 _high += bytes;
634 return true;
635 }
636
637 // A page is uncommitted if the contents of the entire page is deemed unusable.
638 // Continue to decrement the high() pointer until it reaches a page boundary
639 // in which case that particular page can now be uncommitted.
640 void VirtualSpace::shrink_by(size_t size) {
641 if (committed_size() < size)
642 fatal("Cannot shrink virtual space to negative size");
643
644 if (special()) {
645 // don't uncommit if the entire space is pinned in memory
646 _high -= size;
647 return;
648 }
649
650 char* unaligned_new_high = high() - size;
|
598 middle_alignment(), _executable);)
599 return false;
600 }
601 _middle_high += middle_needs;
602 }
603 if (upper_needs > 0) {
604 assert(middle_high_boundary() <= upper_high() &&
605 upper_high() + upper_needs <= upper_high_boundary(),
606 "must not expand beyond region");
607 if (!os::commit_memory(upper_high(), upper_needs, _executable)) {
608 debug_only(warning("INFO: os::commit_memory(" PTR_FORMAT
609 ", upper_needs=" SIZE_FORMAT ", %d) failed",
610 upper_high(), upper_needs, _executable);)
611 return false;
612 } else {
613 _upper_high += upper_needs;
614 }
615 }
616
617 if (pre_touch || AlwaysPreTouch) {
618 os::pretouch_memory(previous_high, unaligned_new_high);
619 }
620
621 _high += bytes;
622 return true;
623 }
624
625 // A page is uncommitted if the contents of the entire page is deemed unusable.
626 // Continue to decrement the high() pointer until it reaches a page boundary
627 // in which case that particular page can now be uncommitted.
628 void VirtualSpace::shrink_by(size_t size) {
629 if (committed_size() < size)
630 fatal("Cannot shrink virtual space to negative size");
631
632 if (special()) {
633 // don't uncommit if the entire space is pinned in memory
634 _high -= size;
635 return;
636 }
637
638 char* unaligned_new_high = high() - size;
|