12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @bug 8230956
27 * @summary JVMTI agents can obtain references to not escaping objects using JVMTI Heap functions.
28 * Therefore optimizations based on escape analysis have to be reverted,
29 * i.e. scalar replaced objects need to be reallocated on the heap and objects with eliminated locking
30 * need to be relocked.
31 * @requires ((vm.compMode == "Xmixed") & vm.compiler2.enabled)
32 * @library /test/lib
33 * @compile IterateHeapWithEscapeAnalysisEnabled.java
34 *
35 * @comment BLOCK BEGIN EXCLUSIVE TESTCASES {
36 *
37 * The following test cases are executed in fresh VMs, because they require that the
38 * capability can_tag_objects is not taken until dontinline_testMethod is jit compiled and
39 * an activation of the compiled version is on stack of the target thread.
40 *
41 * Without JDK-8227745 these test cases require that escape analysis is disabled at
42 * start-up, because can_tag_objects can be taken lazily, potentially after loading an
43 * agent dynamically by means of the attach API. Disabling escape analysis and invalidating
44 * compiled methods does not help then, because there may be compiled frames with ea-based
45 * optimizations on stack. Just like in this collection of test cases.
46 *
47 * @run main/othervm/native
48 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
49 * -XX:+UnlockDiagnosticVMOptions
50 * -Xms256m -Xmx256m
51 * -XX:+PrintCompilation -XX:+PrintInlining
52 * -Xbatch
53 * -XX:CompileCommand=dontinline,*::dontinline_*
54 * -XX:+DoEscapeAnalysis
55 * IterateHeapWithEscapeAnalysisEnabled IterateOverReachableObjects
56 * @run main/othervm/native
57 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
58 * -XX:+UnlockDiagnosticVMOptions
59 * -Xms256m -Xmx256m
60 * -XX:+PrintCompilation -XX:+PrintInlining
61 * -Xbatch
62 * -XX:CompileCommand=dontinline,*::dontinline_*
63 * -XX:+DoEscapeAnalysis
64 * IterateHeapWithEscapeAnalysisEnabled IterateOverHeap
65 * @run main/othervm/native
66 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
67 * -XX:+UnlockDiagnosticVMOptions
68 * -Xms256m -Xmx256m
69 * -XX:+PrintCompilation -XX:+PrintInlining
70 * -Xbatch
71 * -XX:CompileCommand=dontinline,*::dontinline_*
72 * -XX:+DoEscapeAnalysis
73 * IterateHeapWithEscapeAnalysisEnabled IterateOverInstancesOfClass
74 * @run main/othervm/native
75 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
76 * -XX:+UnlockDiagnosticVMOptions
77 * -Xms256m -Xmx256m
78 * -XX:+PrintCompilation -XX:+PrintInlining
79 * -Xbatch
80 * -XX:CompileCommand=dontinline,*::dontinline_*
81 * -XX:+DoEscapeAnalysis
82 * IterateHeapWithEscapeAnalysisEnabled FollowReferences
83 * @run main/othervm/native
84 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
85 * -XX:+UnlockDiagnosticVMOptions
86 * -Xms256m -Xmx256m
87 * -XX:+PrintCompilation -XX:+PrintInlining
88 * -Xbatch
89 * -XX:CompileCommand=dontinline,*::dontinline_*
90 * -XX:+DoEscapeAnalysis
91 * IterateHeapWithEscapeAnalysisEnabled IterateThroughHeap
92 *
93 * @comment } BLOCK END EXCLUSIVE TESTCASES
94 *
95 * @comment BLOCK BEGIN NON EXCLUSIVE TESTCASES {
96 *
97 * @run main/othervm/native
98 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
99 * -XX:+UnlockDiagnosticVMOptions
100 * -Xms256m -Xmx256m
101 * -XX:CompileCommand=dontinline,*::dontinline_*
102 * -XX:+PrintCompilation
103 * -XX:+PrintInlining
104 * -Xbatch
105 * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks -XX:+UseBiasedLocking
106 * IterateHeapWithEscapeAnalysisEnabled
107 * @run main/othervm/native
108 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
109 * -XX:+UnlockDiagnosticVMOptions
110 * -Xms256m -Xmx256m
111 * -XX:CompileCommand=dontinline,*::dontinline_*
112 * -XX:+PrintCompilation
113 * -XX:+PrintInlining
114 * -Xbatch
115 * -XX:+DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks -XX:+UseBiasedLocking
116 * IterateHeapWithEscapeAnalysisEnabled
117 * @run main/othervm/native
118 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
119 * -XX:+UnlockDiagnosticVMOptions
120 * -Xms256m -Xmx256m
121 * -XX:CompileCommand=dontinline,*::dontinline_*
122 * -XX:+PrintCompilation
123 * -XX:+PrintInlining
124 * -Xbatch
125 * -XX:-DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks -XX:+UseBiasedLocking
126 * IterateHeapWithEscapeAnalysisEnabled
127 *
128 * @comment } BLOCK END NON EXCLUSIVE TESTCASES
129 */
130
131 import jdk.test.lib.Asserts;
132
133 public class IterateHeapWithEscapeAnalysisEnabled {
134
135 public static final int COMPILE_THRESHOLD = 20000;
136
137 public static native int jvmtiTagClass(Class<?> cls, long tag);
138
139 // Methods to tag or count instances of a given class available in JVMTI
140 public static enum TaggingAndCountingMethods {
141 IterateOverReachableObjects,
142 IterateOverHeap,
143 IterateOverInstancesOfClass,
144 FollowReferences,
145 IterateThroughHeap
146 }
147
148 public static native int acquireCanTagObjectsCapability();
149 public static native int registerMethod(TaggingAndCountingMethods m, String name);
150 public static native void agentTearDown();
151
152 /**
153 * Count and tag instances of a given class.
154 * @param cls Used by the method {@link TaggingAndCountingMethods#IterateOverInstancesOfClass} as class to count and tag instances of.
155 * Ignored by other counting methods.
346 super.setUp();
347 }
348 }
349
350 public void setUpAfterWarmUp() {
351 if (acquireCanTagObjectsCapabilityAfterWarmup) {
352 msg("Acquire capability can_tag_objects " + (warmUpDone ? "after" : "before") + " warmup.");
353 int err = acquireCanTagObjectsCapability();
354 Asserts.assertEQ(0, err, "acquireCanTagObjectsCapability FAILED");
355 super.setUp();
356 }
357 }
358
359 public void run() {
360 try {
361 msgHL(getClass().getName() + ": test if object that may be scalar replaced is found using " + taggingMethod);
362 msg("The capability can_tag_object is acquired " + (acquireCanTagObjectsCapabilityAfterWarmup ? "AFTER" : "BEFORE")
363 + " warmup.");
364 setUp();
365 warmUp();
366 System.gc(); // get rid of dead instances from previous test cases
367 runTest(taggingMethod);
368 } catch (Exception e) {
369 Asserts.fail("Unexpected Exception", e);
370 }
371 }
372
373 public void runTest(TaggingAndCountingMethods m) throws Exception {
374 loopCount = 1L << 62; // endless loop
375 doLoop = true;
376 testMethod_result = 0;
377 Thread t1 = new Thread(() -> dontinline_testMethod(), "Target Thread (" + getClass().getName() + ")");
378 try {
379 t1.start();
380 try {
381 waitUntilTargetThreadHasEnteredEndlessLoop();
382 setUpAfterWarmUp();
383 msg("count and tag instances of " + taggedClass.getName() + " with tag " + instanceTag + " using JVMTI " + m.name());
384 int count = countAndTagInstancesOfClass(taggedClass, classTag, instanceTag, m);
385 msg("Done. Count is " + count);
386 Asserts.assertGreaterThanOrEqual(count, 0, "countAndTagInstancesOfClass FAILED");
431 * synchronized method {@link ABBox#check()} on the escaped instance.
432 */
433 public static class TestCase02a extends TestCaseBase {
434
435 public long instanceTag;
436
437 public TestCase02a(long classTag) {
438 super(classTag, ABBox.class);
439 instanceTag = classTag + 1;
440 }
441
442 public void run() {
443 try {
444 msgHL(getClass().getName() + ": test if owning frame is deoptimized if ArgEscape escapes globally");
445 setUp();
446 warmUp();
447 for (TaggingAndCountingMethods m : TaggingAndCountingMethods.values()) {
448 msgHL(getClass().getName() + ": Tag and Get of ArgEscapes using " + m.name());
449 waitingForCheck = false;
450 checkingNow = false;
451 System.gc(); // get rid of dead instances from previous test cases
452 runTest(m);
453 }
454 } catch (Exception e) {
455 Asserts.fail("Unexpected Exception", e);
456 }
457 }
458
459 public void runTest(TaggingAndCountingMethods m) throws Exception {
460 loopCount = 1L << 62; // endless loop
461 doLoop = true;
462 Thread t1 = new Thread(() -> dontinline_testMethod(), "Target Thread (" + getClass().getName() + ")");
463 try {
464 t1.start();
465 try {
466 waitUntilTargetThreadHasEnteredEndlessLoop();
467 msg("count and tag instances of " + taggedClass.getName() + " with tag " + instanceTag + " using JVMTI " + m.name());
468 int count = countAndTagInstancesOfClass(taggedClass, classTag, instanceTag, m);
469 msg("Done. Count is " + count);
470 Asserts.assertGreaterThanOrEqual(count, 0, "countAndTagInstancesOfClass FAILED");
471 Asserts.assertEQ(count, 1, "unexpected number of instances");
506 * ArgEscape escapes it is not referenced by a local variable.
507 */
508 public static class TestCase02b extends TestCaseBase {
509
510 public long instanceTag;
511
512 public TestCase02b(long classTag) {
513 super(classTag, ABBox.class);
514 instanceTag = classTag + 1;
515 }
516
517 public void run() {
518 try {
519 msgHL(getClass().getName() + ": test if owning frame is deoptimized if ArgEscape escapes globally");
520 setUp();
521 warmUp();
522 for (TaggingAndCountingMethods m : TaggingAndCountingMethods.values()) {
523 msgHL(getClass().getName() + ": Tag and Get of ArgEscapes using " + m.name());
524 waitingForCheck = false;
525 checkingNow = false;
526 System.gc(); // get rid of dead instances from previous test cases
527 runTest(m);
528 }
529 } catch (Exception e) {
530 Asserts.fail("Unexpected Exception", e);
531 }
532 }
533
534 public void runTest(TaggingAndCountingMethods m) throws Exception {
535 loopCount = 1L << 62; // endless loop
536 doLoop = true;
537 Thread t1 = new Thread(() -> dontinline_testMethod(), "Target Thread (" + getClass().getName() + ")");
538 try {
539 t1.start();
540 try {
541 waitUntilTargetThreadHasEnteredEndlessLoop();
542 msg("count and tag instances of " + taggedClass.getName() + " with tag " + instanceTag + " using JVMTI " + m.name());
543 int count = countAndTagInstancesOfClass(taggedClass, classTag, instanceTag, m);
544 msg("Done. Count is " + count);
545 Asserts.assertGreaterThanOrEqual(count, 0, "countAndTagInstancesOfClass FAILED");
546 Asserts.assertEQ(count, 1, "unexpected number of instances");
|
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @bug 8230956
27 * @summary JVMTI agents can obtain references to not escaping objects using JVMTI Heap functions.
28 * Therefore optimizations based on escape analysis have to be reverted,
29 * i.e. scalar replaced objects need to be reallocated on the heap and objects with eliminated locking
30 * need to be relocked.
31 * @requires ((vm.compMode == "Xmixed") & vm.compiler2.enabled)
32 * @library /test/lib /test/hotspot/jtreg
33 * @build sun.hotspot.WhiteBox
34 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
35 * @compile IterateHeapWithEscapeAnalysisEnabled.java
36 *
37 * @comment BLOCK BEGIN EXCLUSIVE TESTCASES {
38 *
39 * The following test cases are executed in fresh VMs, because they require that the
40 * capability can_tag_objects is not taken until dontinline_testMethod is jit compiled and
41 * an activation of the compiled version is on stack of the target thread.
42 *
43 * Without JDK-8227745 these test cases require that escape analysis is disabled at
44 * start-up, because can_tag_objects can be taken lazily, potentially after loading an
45 * agent dynamically by means of the attach API. Disabling escape analysis and invalidating
46 * compiled methods does not help then, because there may be compiled frames with ea-based
47 * optimizations on stack. Just like in this collection of test cases.
48 *
49 * @run main/othervm/native
50 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
51 * -XX:+UnlockDiagnosticVMOptions
52 * -Xms256m -Xmx256m
53 * -XX:+PrintCompilation -XX:+PrintInlining
54 * -XX:+WhiteBoxAPI -Xbootclasspath/a:.
55 * -Xbatch
56 * -XX:CompileCommand=dontinline,*::dontinline_*
57 * -XX:+DoEscapeAnalysis
58 * IterateHeapWithEscapeAnalysisEnabled IterateOverReachableObjects
59 * @run main/othervm/native
60 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
61 * -XX:+UnlockDiagnosticVMOptions
62 * -Xms256m -Xmx256m
63 * -XX:+PrintCompilation -XX:+PrintInlining
64 * -XX:+WhiteBoxAPI -Xbootclasspath/a:.
65 * -Xbatch
66 * -XX:CompileCommand=dontinline,*::dontinline_*
67 * -XX:+DoEscapeAnalysis
68 * IterateHeapWithEscapeAnalysisEnabled IterateOverHeap
69 * @run main/othervm/native
70 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
71 * -XX:+UnlockDiagnosticVMOptions
72 * -Xms256m -Xmx256m
73 * -XX:+PrintCompilation -XX:+PrintInlining
74 * -XX:+WhiteBoxAPI -Xbootclasspath/a:.
75 * -Xbatch
76 * -XX:CompileCommand=dontinline,*::dontinline_*
77 * -XX:+DoEscapeAnalysis
78 * IterateHeapWithEscapeAnalysisEnabled IterateOverInstancesOfClass
79 * @run main/othervm/native
80 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
81 * -XX:+UnlockDiagnosticVMOptions
82 * -Xms256m -Xmx256m
83 * -XX:+PrintCompilation -XX:+PrintInlining
84 * -XX:+WhiteBoxAPI -Xbootclasspath/a:.
85 * -Xbatch
86 * -XX:CompileCommand=dontinline,*::dontinline_*
87 * -XX:+DoEscapeAnalysis
88 * IterateHeapWithEscapeAnalysisEnabled FollowReferences
89 * @run main/othervm/native
90 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
91 * -XX:+UnlockDiagnosticVMOptions
92 * -Xms256m -Xmx256m
93 * -XX:+PrintCompilation -XX:+PrintInlining
94 * -XX:+WhiteBoxAPI -Xbootclasspath/a:.
95 * -Xbatch
96 * -XX:CompileCommand=dontinline,*::dontinline_*
97 * -XX:+DoEscapeAnalysis
98 * IterateHeapWithEscapeAnalysisEnabled IterateThroughHeap
99 *
100 * @comment } BLOCK END EXCLUSIVE TESTCASES
101 *
102 * @comment BLOCK BEGIN NON EXCLUSIVE TESTCASES {
103 *
104 * @run main/othervm/native
105 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
106 * -XX:+UnlockDiagnosticVMOptions
107 * -Xms256m -Xmx256m
108 * -XX:CompileCommand=dontinline,*::dontinline_*
109 * -XX:+PrintCompilation
110 * -XX:+PrintInlining
111 * -XX:+WhiteBoxAPI -Xbootclasspath/a:.
112 * -Xbatch
113 * -XX:+DoEscapeAnalysis -XX:+EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks -XX:+UseBiasedLocking
114 * IterateHeapWithEscapeAnalysisEnabled
115 * @run main/othervm/native
116 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
117 * -XX:+UnlockDiagnosticVMOptions
118 * -Xms256m -Xmx256m
119 * -XX:CompileCommand=dontinline,*::dontinline_*
120 * -XX:+PrintCompilation
121 * -XX:+PrintInlining
122 * -XX:+WhiteBoxAPI -Xbootclasspath/a:.
123 * -Xbatch
124 * -XX:+DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks -XX:+UseBiasedLocking
125 * IterateHeapWithEscapeAnalysisEnabled
126 * @run main/othervm/native
127 * -agentlib:IterateHeapWithEscapeAnalysisEnabled
128 * -XX:+UnlockDiagnosticVMOptions
129 * -Xms256m -Xmx256m
130 * -XX:CompileCommand=dontinline,*::dontinline_*
131 * -XX:+PrintCompilation
132 * -XX:+PrintInlining
133 * -XX:+WhiteBoxAPI -Xbootclasspath/a:.
134 * -Xbatch
135 * -XX:-DoEscapeAnalysis -XX:-EliminateAllocations -XX:+EliminateLocks -XX:+EliminateNestedLocks -XX:+UseBiasedLocking
136 * IterateHeapWithEscapeAnalysisEnabled
137 *
138 * @comment } BLOCK END NON EXCLUSIVE TESTCASES
139 */
140
141 import compiler.whitebox.CompilerWhiteBoxTest;
142 import jdk.test.lib.Asserts;
143 import sun.hotspot.WhiteBox;
144
145 public class IterateHeapWithEscapeAnalysisEnabled {
146
147 public static final WhiteBox WB = WhiteBox.getWhiteBox();
148
149 public static final int COMPILE_THRESHOLD = CompilerWhiteBoxTest.THRESHOLD;
150
151 public static native int jvmtiTagClass(Class<?> cls, long tag);
152
153 // Methods to tag or count instances of a given class available in JVMTI
154 public static enum TaggingAndCountingMethods {
155 IterateOverReachableObjects,
156 IterateOverHeap,
157 IterateOverInstancesOfClass,
158 FollowReferences,
159 IterateThroughHeap
160 }
161
162 public static native int acquireCanTagObjectsCapability();
163 public static native int registerMethod(TaggingAndCountingMethods m, String name);
164 public static native void agentTearDown();
165
166 /**
167 * Count and tag instances of a given class.
168 * @param cls Used by the method {@link TaggingAndCountingMethods#IterateOverInstancesOfClass} as class to count and tag instances of.
169 * Ignored by other counting methods.
360 super.setUp();
361 }
362 }
363
364 public void setUpAfterWarmUp() {
365 if (acquireCanTagObjectsCapabilityAfterWarmup) {
366 msg("Acquire capability can_tag_objects " + (warmUpDone ? "after" : "before") + " warmup.");
367 int err = acquireCanTagObjectsCapability();
368 Asserts.assertEQ(0, err, "acquireCanTagObjectsCapability FAILED");
369 super.setUp();
370 }
371 }
372
373 public void run() {
374 try {
375 msgHL(getClass().getName() + ": test if object that may be scalar replaced is found using " + taggingMethod);
376 msg("The capability can_tag_object is acquired " + (acquireCanTagObjectsCapabilityAfterWarmup ? "AFTER" : "BEFORE")
377 + " warmup.");
378 setUp();
379 warmUp();
380 WB.deflateIdleMonitors();
381 WB.fullGC(); // get rid of dead instances from previous test cases
382 runTest(taggingMethod);
383 } catch (Exception e) {
384 Asserts.fail("Unexpected Exception", e);
385 }
386 }
387
388 public void runTest(TaggingAndCountingMethods m) throws Exception {
389 loopCount = 1L << 62; // endless loop
390 doLoop = true;
391 testMethod_result = 0;
392 Thread t1 = new Thread(() -> dontinline_testMethod(), "Target Thread (" + getClass().getName() + ")");
393 try {
394 t1.start();
395 try {
396 waitUntilTargetThreadHasEnteredEndlessLoop();
397 setUpAfterWarmUp();
398 msg("count and tag instances of " + taggedClass.getName() + " with tag " + instanceTag + " using JVMTI " + m.name());
399 int count = countAndTagInstancesOfClass(taggedClass, classTag, instanceTag, m);
400 msg("Done. Count is " + count);
401 Asserts.assertGreaterThanOrEqual(count, 0, "countAndTagInstancesOfClass FAILED");
446 * synchronized method {@link ABBox#check()} on the escaped instance.
447 */
448 public static class TestCase02a extends TestCaseBase {
449
450 public long instanceTag;
451
452 public TestCase02a(long classTag) {
453 super(classTag, ABBox.class);
454 instanceTag = classTag + 1;
455 }
456
457 public void run() {
458 try {
459 msgHL(getClass().getName() + ": test if owning frame is deoptimized if ArgEscape escapes globally");
460 setUp();
461 warmUp();
462 for (TaggingAndCountingMethods m : TaggingAndCountingMethods.values()) {
463 msgHL(getClass().getName() + ": Tag and Get of ArgEscapes using " + m.name());
464 waitingForCheck = false;
465 checkingNow = false;
466 WB.deflateIdleMonitors();
467 WB.fullGC(); // get rid of dead instances from previous test cases
468 runTest(m);
469 }
470 } catch (Exception e) {
471 Asserts.fail("Unexpected Exception", e);
472 }
473 }
474
475 public void runTest(TaggingAndCountingMethods m) throws Exception {
476 loopCount = 1L << 62; // endless loop
477 doLoop = true;
478 Thread t1 = new Thread(() -> dontinline_testMethod(), "Target Thread (" + getClass().getName() + ")");
479 try {
480 t1.start();
481 try {
482 waitUntilTargetThreadHasEnteredEndlessLoop();
483 msg("count and tag instances of " + taggedClass.getName() + " with tag " + instanceTag + " using JVMTI " + m.name());
484 int count = countAndTagInstancesOfClass(taggedClass, classTag, instanceTag, m);
485 msg("Done. Count is " + count);
486 Asserts.assertGreaterThanOrEqual(count, 0, "countAndTagInstancesOfClass FAILED");
487 Asserts.assertEQ(count, 1, "unexpected number of instances");
522 * ArgEscape escapes it is not referenced by a local variable.
523 */
524 public static class TestCase02b extends TestCaseBase {
525
526 public long instanceTag;
527
528 public TestCase02b(long classTag) {
529 super(classTag, ABBox.class);
530 instanceTag = classTag + 1;
531 }
532
533 public void run() {
534 try {
535 msgHL(getClass().getName() + ": test if owning frame is deoptimized if ArgEscape escapes globally");
536 setUp();
537 warmUp();
538 for (TaggingAndCountingMethods m : TaggingAndCountingMethods.values()) {
539 msgHL(getClass().getName() + ": Tag and Get of ArgEscapes using " + m.name());
540 waitingForCheck = false;
541 checkingNow = false;
542 WB.deflateIdleMonitors();
543 WB.fullGC(); // get rid of dead instances from previous test cases
544 runTest(m);
545 }
546 } catch (Exception e) {
547 Asserts.fail("Unexpected Exception", e);
548 }
549 }
550
551 public void runTest(TaggingAndCountingMethods m) throws Exception {
552 loopCount = 1L << 62; // endless loop
553 doLoop = true;
554 Thread t1 = new Thread(() -> dontinline_testMethod(), "Target Thread (" + getClass().getName() + ")");
555 try {
556 t1.start();
557 try {
558 waitUntilTargetThreadHasEnteredEndlessLoop();
559 msg("count and tag instances of " + taggedClass.getName() + " with tag " + instanceTag + " using JVMTI " + m.name());
560 int count = countAndTagInstancesOfClass(taggedClass, classTag, instanceTag, m);
561 msg("Done. Count is " + count);
562 Asserts.assertGreaterThanOrEqual(count, 0, "countAndTagInstancesOfClass FAILED");
563 Asserts.assertEQ(count, 1, "unexpected number of instances");
|