@@ -165,7 +165,7 @@ private void updateSizeParametersLocked(SizeParameters params, SizeParameters pr
165165 long gcCount = avgMinorGcCost .getSampleCount () + avgMajorGcCost .getSampleCount ();
166166 if (previous == null || gcCount == 0 ) {
167167 survivorSize = params .initialSurvivorSize ;
168- edenSize = params .initialEdenSize () ;
168+ edenSize = params .initialEdenSize ;
169169 oldSize = params .initialOldSize ();
170170 promoSize = UnsignedUtils .min (edenSize , oldSize );
171171 tenuringThreshold = UninterruptibleUtils .Math .clamp (INITIAL_TENURING_THRESHOLD , 1 , HeapParameters .getMaxSurvivorSpaces () + 1 );
@@ -646,6 +646,7 @@ static final class SizeParameters {
646646 final UnsignedWord maxHeapSize ;
647647 final UnsignedWord maxYoungSize ;
648648 final UnsignedWord initialHeapSize ;
649+ final UnsignedWord initialEdenSize ;
649650 final UnsignedWord initialSurvivorSize ;
650651
651652 static SizeParameters compute () {
@@ -717,49 +718,57 @@ static SizeParameters compute() {
717718 } else {
718719 initialYoung = UnsignedUtils .clamp (alignUp (initialHeap .unsignedDivide (NEW_RATIO + 1 )), minSpaceSize (), maxYoung );
719720 }
720- /*
721- * In HotSpot, this is the reserved capacity of each of the From and To spaces, i.e.,
722- * together they occupy 2x this size. Our chunked heap doesn't reserve memory, so we use
723- * never occupy more than 1x this size for survivors except during collections. However,
724- * this is inconsistent with how we interpret the maximum size of the old generation,
725- * which we can exceed the (current) old gen size while copying during collections.
726- */
727- UnsignedWord initialSurvivor = minSpaceSize (alignUp (initialYoung .unsignedDivide (INITIAL_SURVIVOR_RATIO )));
721+ UnsignedWord initialEden ;
722+ UnsignedWord initialSurvivor ;
723+ if (HeapParameters .getMaxSurvivorSpaces () == 0 ) {
724+ initialSurvivor = WordFactory .zero ();
725+ initialEden = initialYoung ;
726+ } else {
727+ /*
728+ * In HotSpot, this is the reserved capacity of each of the survivor From and To
729+ * spaces, i.e., together they occupy 2x this size. Our chunked heap doesn't reserve
730+ * memory, so we use never occupy more than 1x this size for survivors except during
731+ * collections. However, this is inconsistent with how we interpret the maximum size
732+ * of the old generation, which we can exceed the (current) old gen size while
733+ * copying during collections.
734+ */
735+ initialSurvivor = minSpaceSize (alignUp (initialYoung .unsignedDivide (INITIAL_SURVIVOR_RATIO )));
736+ initialEden = initialSurvivor .multiply (2 );
737+ }
728738
729- return new SizeParameters (maxHeap , maxYoung , initialHeap , initialSurvivor );
739+ return new SizeParameters (maxHeap , maxYoung , initialHeap , initialEden , initialSurvivor );
730740 }
731741
732- private SizeParameters (UnsignedWord maxHeapSize , UnsignedWord maxYoungSize , UnsignedWord initialHeapSize , UnsignedWord initialSurvivorSize ) {
742+ private SizeParameters (UnsignedWord maxHeapSize , UnsignedWord maxYoungSize , UnsignedWord initialHeapSize , UnsignedWord initialEdenSize , UnsignedWord initialSurvivorSize ) {
733743 this .maxHeapSize = maxHeapSize ;
734744 this .maxYoungSize = maxYoungSize ;
735745 this .initialHeapSize = initialHeapSize ;
746+ this .initialEdenSize = initialEdenSize ;
736747 this .initialSurvivorSize = initialSurvivorSize ;
737748
738- assert isAligned (maxHeapSize ) && isAligned (maxYoungSize ) && isAligned (initialHeapSize ) && isAligned (initialSurvivorSize );
739- assert isAligned (maxSurvivorSize ()) && isAligned (initialYoungSize ()) && isAligned (initialEdenSize ()) && isAligned ( initialOldSize ()) && isAligned (maxOldSize ());
749+ assert isAligned (maxHeapSize ) && isAligned (maxYoungSize ) && isAligned (initialHeapSize ) && isAligned (initialEdenSize ) && isAligned ( initialSurvivorSize );
750+ assert isAligned (maxSurvivorSize ()) && isAligned (initialYoungSize ()) && isAligned (initialOldSize ()) && isAligned (maxOldSize ());
740751
741752 assert initialHeapSize .belowOrEqual (maxHeapSize );
742753 assert maxSurvivorSize ().belowThan (maxYoungSize );
743754 assert maxYoungSize .add (maxOldSize ()).equal (maxHeapSize );
744755 assert maxHeapSize .belowOrEqual (ReferenceAccess .singleton ().getAddressSpaceSize ());
745- assert initialEdenSize () .add (initialSurvivorSize .multiply (2 )).equal (initialYoungSize ());
756+ assert initialEdenSize .add (initialSurvivorSize .multiply (2 )).equal (initialYoungSize ());
746757 assert initialYoungSize ().add (initialOldSize ()).equal (initialHeapSize );
747758 }
748759
749760 @ Uninterruptible (reason = "Called from uninterruptible code." , mayBeInlined = true )
750761 UnsignedWord maxSurvivorSize () {
762+ if (HeapParameters .getMaxSurvivorSpaces () == 0 ) {
763+ return WordFactory .zero ();
764+ }
751765 UnsignedWord size = maxYoungSize .unsignedDivide (MIN_SURVIVOR_RATIO );
752766 return minSpaceSize (alignDown (size ));
753767 }
754768
755769 @ Uninterruptible (reason = "Called from uninterruptible code." , mayBeInlined = true )
756770 UnsignedWord initialYoungSize () {
757- return initialEdenSize ().add (initialSurvivorSize .multiply (2 ));
758- }
759-
760- @ Uninterruptible (reason = "Called from uninterruptible code." , mayBeInlined = true )
761- UnsignedWord initialEdenSize () {
762- return initialSurvivorSize .multiply (2 );
771+ return initialEdenSize .add (initialSurvivorSize .multiply (2 ));
763772 }
764773
765774 @ Uninterruptible (reason = "Called from uninterruptible code." , mayBeInlined = true )
0 commit comments