516 pointer_delta(aligned_upper_new_high, upper_high(), sizeof(char)); 517 } 518 519 // Check contiguity. 520 assert(low_boundary() <= lower_high() && 521 lower_high() <= lower_high_boundary(), 522 "high address must be contained within the region"); 523 assert(lower_high_boundary() <= middle_high() && 524 middle_high() <= middle_high_boundary(), 525 "high address must be contained within the region"); 526 assert(middle_high_boundary() <= upper_high() && 527 upper_high() <= upper_high_boundary(), 528 "high address must be contained within the region"); 529 530 // Commit regions 531 if (lower_needs > 0) { 532 assert(low_boundary() <= lower_high() && 533 lower_high() + lower_needs <= lower_high_boundary(), 534 "must not expand beyond region"); 535 if (!os::commit_memory(lower_high(), lower_needs, _executable)) { 536 debug_only(warning("os::commit_memory failed")); 537 return false; 538 } else { 539 _lower_high += lower_needs; 540 } 541 } 542 if (middle_needs > 0) { 543 assert(lower_high_boundary() <= middle_high() && 544 middle_high() + middle_needs <= middle_high_boundary(), 545 "must not expand beyond region"); 546 if (!os::commit_memory(middle_high(), middle_needs, middle_alignment(), 547 _executable)) { 548 debug_only(warning("os::commit_memory failed")); 549 return false; 550 } 551 _middle_high += middle_needs; 552 } 553 if (upper_needs > 0) { 554 assert(middle_high_boundary() <= upper_high() && 555 upper_high() + upper_needs <= upper_high_boundary(), 556 "must not expand beyond region"); 557 if (!os::commit_memory(upper_high(), upper_needs, _executable)) { 558 debug_only(warning("os::commit_memory failed")); 559 return false; 560 } else { 561 _upper_high += upper_needs; 562 } 563 } 564 565 if (pre_touch || AlwaysPreTouch) { 566 int vm_ps = os::vm_page_size(); 567 for (char* curr = previous_high; 568 curr < unaligned_new_high; 569 curr += vm_ps) { 570 // Note the use of a write here; originally we tried just a read, but 571 // since the value read was unused, the optimizer removed the read. 572 // If we ever have a concurrent touchahead thread, we'll want to use 573 // a read, to avoid the potential of overwriting data (if a mutator 574 // thread beats the touchahead thread to a page). There are various 575 // ways of making sure this read is not optimized away: for example, 576 // generating the code for a read procedure at runtime. 577 *curr = 0; 578 } | 516 pointer_delta(aligned_upper_new_high, upper_high(), sizeof(char)); 517 } 518 519 // Check contiguity. 520 assert(low_boundary() <= lower_high() && 521 lower_high() <= lower_high_boundary(), 522 "high address must be contained within the region"); 523 assert(lower_high_boundary() <= middle_high() && 524 middle_high() <= middle_high_boundary(), 525 "high address must be contained within the region"); 526 assert(middle_high_boundary() <= upper_high() && 527 upper_high() <= upper_high_boundary(), 528 "high address must be contained within the region"); 529 530 // Commit regions 531 if (lower_needs > 0) { 532 assert(low_boundary() <= lower_high() && 533 lower_high() + lower_needs <= lower_high_boundary(), 534 "must not expand beyond region"); 535 if (!os::commit_memory(lower_high(), lower_needs, _executable)) { 536 debug_only(warning("INFO: os::commit_memory(" PTR_FORMAT 537 ", lower_needs=" SIZE_FORMAT ", %d) failed", 538 lower_high(), lower_needs, _executable);) 539 return false; 540 } else { 541 _lower_high += lower_needs; 542 } 543 } 544 if (middle_needs > 0) { 545 assert(lower_high_boundary() <= middle_high() && 546 middle_high() + middle_needs <= middle_high_boundary(), 547 "must not expand beyond region"); 548 if (!os::commit_memory(middle_high(), middle_needs, middle_alignment(), 549 _executable)) { 550 debug_only(warning("INFO: os::commit_memory(" PTR_FORMAT 551 ", middle_needs=" SIZE_FORMAT ", " SIZE_FORMAT 552 ", %d) failed", middle_high(), middle_needs, 553 middle_alignment(), _executable);) 554 return false; 555 } 556 _middle_high += middle_needs; 557 } 558 if (upper_needs > 0) { 559 assert(middle_high_boundary() <= upper_high() && 560 upper_high() + upper_needs <= upper_high_boundary(), 561 "must not expand beyond region"); 562 if (!os::commit_memory(upper_high(), upper_needs, _executable)) { 563 debug_only(warning("INFO: os::commit_memory(" PTR_FORMAT 564 ", upper_needs=" SIZE_FORMAT ", %d) failed", 565 upper_high(), upper_needs, _executable);) 566 return false; 567 } else { 568 _upper_high += upper_needs; 569 } 570 } 571 572 if (pre_touch || AlwaysPreTouch) { 573 int vm_ps = os::vm_page_size(); 574 for (char* curr = previous_high; 575 curr < unaligned_new_high; 576 curr += vm_ps) { 577 // Note the use of a write here; originally we tried just a read, but 578 // since the value read was unused, the optimizer removed the read. 579 // If we ever have a concurrent touchahead thread, we'll want to use 580 // a read, to avoid the potential of overwriting data (if a mutator 581 // thread beats the touchahead thread to a page). There are various 582 // ways of making sure this read is not optimized away: for example, 583 // generating the code for a read procedure at runtime. 584 *curr = 0; 585 } |