3030
3131import com .oracle .svm .core .Isolates ;
3232import com .oracle .svm .core .heap .GCCause ;
33+ import com .oracle .svm .core .thread .VMOperation ;
3334import com .oracle .svm .core .util .BasedOnJDKFile ;
3435import com .oracle .svm .core .util .TimeUtils ;
3536import com .oracle .svm .core .util .Timer ;
@@ -264,45 +265,45 @@ private void computeSurvivorSpaceSizeAndThreshold(boolean isSurvivorOverflow, Un
264265 }
265266
266267 protected void computeEdenSpaceSize (@ SuppressWarnings ("unused" ) boolean completeCollection , @ SuppressWarnings ("unused" ) GCCause cause ) {
267- UnsignedWord curEdenSize = sizes .getEdenSize ();
268- UnsignedWord curPromoSize = sizes .getPromoSize ();
268+ UnsignedWord curEden = sizes .getEdenSize ();
269+ UnsignedWord curPromo = sizes .getPromoSize ();
269270
270271 boolean expansionReducesCost = true ; // general assumption
271272 if (shouldUseEstimator (youngGenChangeForMinorThroughput , minorGcCost ())) {
272- expansionReducesCost = expansionSignificantlyReducesTotalCost (minorCostEstimator , curEdenSize , majorGcCost (), curPromoSize );
273+ expansionReducesCost = expansionSignificantlyReducesTotalCost (minorCostEstimator , curEden , majorGcCost (), curPromo );
273274 /*
274275 * Note that if the estimator thinks expanding does not lead to significant improvement,
275276 * shrink so to not get stuck in a supposed optimum and to keep collecting data points.
276277 */
277278 }
278279
279- UnsignedWord desiredEdenSize = curEdenSize ;
280+ UnsignedWord desiredEdenSize = curEden ;
280281 if (expansionReducesCost && adjustedMutatorCost () < THROUGHPUT_GOAL && gcCost () > 0 ) {
281282 // from adjust_eden_for_throughput():
282- UnsignedWord edenHeapDelta = edenIncrementWithSupplementAlignedUp (curEdenSize );
283+ UnsignedWord edenHeapDelta = edenIncrementWithSupplementAlignedUp (curEden );
283284 double scaleByRatio = minorGcCost () / gcCost ();
284285 assert scaleByRatio >= 0 && scaleByRatio <= 1 ;
285286 UnsignedWord scaledEdenHeapDelta = UnsignedUtils .fromDouble (scaleByRatio * UnsignedUtils .toDouble (edenHeapDelta ));
286287
287288 desiredEdenSize = alignUp (desiredEdenSize .add (scaledEdenHeapDelta ));
288- desiredEdenSize = UnsignedUtils .max (desiredEdenSize , curEdenSize );
289+ desiredEdenSize = UnsignedUtils .max (desiredEdenSize , curEden );
289290 youngGenChangeForMinorThroughput ++;
290291 }
291292 if (!expansionReducesCost || (USE_ADAPTIVE_SIZE_POLICY_FOOTPRINT_GOAL && youngGenPolicyIsReady && adjustedMutatorCost () >= THROUGHPUT_GOAL )) {
292- UnsignedWord desiredSum = curEdenSize .add (curPromoSize );
293- desiredEdenSize = adjustEdenForFootprint (curEdenSize , desiredSum );
293+ UnsignedWord desiredSum = curEden .add (curPromo );
294+ desiredEdenSize = adjustEdenForFootprint (curEden , desiredSum );
294295 }
295296 assert isAligned (desiredEdenSize );
296297 desiredEdenSize = minSpaceSize (desiredEdenSize );
297298
298- UnsignedWord edenLimit = getMaximumEdenSize ();
299+ UnsignedWord edenLimit = computeEdenLimit ();
299300 if (desiredEdenSize .aboveThan (edenLimit )) {
300301 /*
301302 * If the policy says to get a larger eden but is hitting the limit, don't decrease
302303 * eden. This can lead to a general drifting down of the eden size. Let the tenuring
303304 * calculation push more into the old gen.
304305 */
305- desiredEdenSize = UnsignedUtils .max (edenLimit , curEdenSize );
306+ desiredEdenSize = UnsignedUtils .max (edenLimit , curEden );
306307 }
307308 sizes .setEdenSize (desiredEdenSize );
308309 }
@@ -486,40 +487,40 @@ public void onCollectionEnd(boolean completeCollection, GCCause cause) { // {maj
486487 }
487488
488489 private void computeOldGenSpaceSize (UnsignedWord oldLive ) { // compute_old_gen_free_space
489- UnsignedWord curEdenSize = sizes .getEdenSize ();
490- UnsignedWord curMaxOldSize = sizes .getMaxOldSize ();
491- UnsignedWord curPromoSize = sizes .getPromoSize ();
490+ UnsignedWord curEden = sizes .getEdenSize ();
491+ UnsignedWord curPromo = sizes .getPromoSize ();
492+ UnsignedWord curMaxOld = sizes .getMaxOldSize ();
492493
493494 avgOldLive .sample (oldLive );
494495
495496 // NOTE: if maxOldSize shrunk and difference is negative, unsigned conversion results in 0
496- UnsignedWord promoLimit = UnsignedUtils .fromDouble (UnsignedUtils .toDouble (curMaxOldSize ) - avgOldLive .getAverage ());
497- promoLimit = alignDown (UnsignedUtils .max (curPromoSize , promoLimit ));
497+ UnsignedWord promoLimit = UnsignedUtils .fromDouble (UnsignedUtils .toDouble (curMaxOld ) - avgOldLive .getAverage ());
498+ promoLimit = alignDown (UnsignedUtils .max (curPromo , promoLimit ));
498499
499500 boolean expansionReducesCost = true ; // general assumption
500501 if (shouldUseEstimator (oldGenChangeForMajorThroughput , majorGcCost ())) {
501- expansionReducesCost = expansionSignificantlyReducesTotalCost (majorCostEstimator , curPromoSize , minorGcCost (), curEdenSize );
502+ expansionReducesCost = expansionSignificantlyReducesTotalCost (majorCostEstimator , curPromo , minorGcCost (), curEden );
502503 /*
503504 * Note that if the estimator thinks expanding does not lead to significant improvement,
504505 * shrink so to not get stuck in a supposed optimum and to keep collecting data points.
505506 */
506507 }
507508
508- UnsignedWord desiredPromoSize = curPromoSize ;
509+ UnsignedWord desiredPromoSize = curPromo ;
509510 if (expansionReducesCost && adjustedMutatorCost () < THROUGHPUT_GOAL && gcCost () > 0 ) {
510511 // from adjust_promo_for_throughput():
511- UnsignedWord promoHeapDelta = promoIncrementWithSupplementAlignedUp (curPromoSize );
512+ UnsignedWord promoHeapDelta = promoIncrementWithSupplementAlignedUp (curPromo );
512513 double scaleByRatio = majorGcCost () / gcCost ();
513514 assert scaleByRatio >= 0 && scaleByRatio <= 1 ;
514515 UnsignedWord scaledPromoHeapDelta = UnsignedUtils .fromDouble (scaleByRatio * UnsignedUtils .toDouble (promoHeapDelta ));
515516
516- desiredPromoSize = alignUp (curPromoSize .add (scaledPromoHeapDelta ));
517- desiredPromoSize = UnsignedUtils .max (desiredPromoSize , curPromoSize );
517+ desiredPromoSize = alignUp (curPromo .add (scaledPromoHeapDelta ));
518+ desiredPromoSize = UnsignedUtils .max (desiredPromoSize , curPromo );
518519 oldGenChangeForMajorThroughput ++;
519520 }
520521 if (!expansionReducesCost || (USE_ADAPTIVE_SIZE_POLICY_FOOTPRINT_GOAL && youngGenPolicyIsReady && adjustedMutatorCost () >= THROUGHPUT_GOAL )) {
521- UnsignedWord desiredSum = curEdenSize .add (curPromoSize );
522- desiredPromoSize = adjustPromoForFootprint (curPromoSize , desiredSum );
522+ UnsignedWord desiredSum = curEden .add (curPromo );
523+ desiredPromoSize = adjustPromoForFootprint (curPromo , desiredSum );
523524 }
524525 assert isAligned (desiredPromoSize );
525526 desiredPromoSize = minSpaceSize (desiredPromoSize );
@@ -530,7 +531,7 @@ private void computeOldGenSpaceSize(UnsignedWord oldLive) { // compute_old_gen_f
530531 // from PSOldGen::resize
531532 UnsignedWord desiredFreeSpace = calculatedOldFreeSizeInBytes ();
532533 UnsignedWord desiredOldSize = alignUp (oldLive .add (desiredFreeSpace ));
533- sizes .setOldSize (UnsignedUtils .clamp (desiredOldSize , minSpaceSize (), curMaxOldSize ));
534+ sizes .setOldSize (UnsignedUtils .clamp (desiredOldSize , minSpaceSize (), curMaxOld ));
534535 }
535536
536537 UnsignedWord calculatedOldFreeSizeInBytes () {
@@ -580,6 +581,11 @@ protected boolean shouldUpdateStats(GCCause cause) { // should_update_{eden,prom
580581 return cause == GenScavengeGCCause .OnAllocation || USE_ADAPTIVE_SIZE_POLICY_WITH_SYSTEM_GC ;
581582 }
582583
584+ protected UnsignedWord computeEdenLimit () {
585+ assert VMOperation .isGCInProgress () : "result wouldn't be consistent otherwise" ;
586+ return alignDown (sizes .getMaxYoungSize ().subtract (sizes .getSurvivorSize ().multiply (2 )));
587+ }
588+
583589 private void updateCollectionEndAverages (AdaptiveWeightedAverage costAverage , AdaptivePaddedAverage pauseAverage , ReciprocalLeastSquareFit costEstimator ,
584590 AdaptiveWeightedAverage intervalSeconds , GCCause cause , long mutatorNanos , long pauseNanos , UnsignedWord sizeBytes ) {
585591 if (shouldUpdateStats (cause )) {
0 commit comments