Skip to content

Commit

Permalink
Assertion fix. test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
roberttoyonaga committed Nov 28, 2024
1 parent 511d339 commit fec12e8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ private void remove(JfrOldObject sample) {
next.increaseSpan(sample.getSpan());
queue.add(next);
} else {
/* No remaining elements, we can't redistribute the weight. */
/*
* No younger element, we can't redistribute the weight. The next sample should absorb
* the extra span.
*/
totalInQueue = totalInQueue.subtract(sample.getSpan());
assert totalInQueue.equal(0);
assert totalInQueue.aboveOrEqual(0);
}
queue.remove(sample);
release(sample);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
import java.util.Collections;
import java.util.List;

import jdk.jfr.Recording;
import org.graalvm.word.WordFactory;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import com.oracle.svm.core.jfr.HasJfrSupport;
Expand All @@ -45,6 +47,14 @@
import jdk.graal.compiler.api.directives.GraalDirectives;

public class TestOldObjectProfiler extends AbstractJfrTest {

/* Old object samples will not have allocation ticks set correctly if JfrTicks is not first initialized.
* We need to create the first JFR recording to lazily initialize JfrTicks.*/
@BeforeClass
public static void initializeJfrTicks() {
GraalDirectives.blackhole(new Recording());
}

@Test
public void testScavenge() {
int count = 10;
Expand Down

0 comments on commit fec12e8

Please sign in to comment.