summaryrefslogtreecommitdiff
path: root/test/401-optimizing-compiler/src
diff options
context:
space:
mode:
Diffstat (limited to 'test/401-optimizing-compiler/src')
-rw-r--r--test/401-optimizing-compiler/src/Main.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/401-optimizing-compiler/src/Main.java b/test/401-optimizing-compiler/src/Main.java
index a5192e1e64..2c6d1c2b60 100644
--- a/test/401-optimizing-compiler/src/Main.java
+++ b/test/401-optimizing-compiler/src/Main.java
@@ -75,6 +75,37 @@ public class Main {
if (m.$opt$TestReturnNewObject(m) == m) {
throw new Error("Unexpected value returned");
}
+
+ // Loop enough iterations to hope for a crash if no write barrier
+ // is emitted.
+ for (int j = 0; j < 3; j++) {
+ Main m1 = new Main();
+ $opt$SetFieldInOldObject(m1);
+ for (int i = 0; i < 1000; ++i) {
+ Object o = new byte[1024];
+ }
+ }
+
+ // Test that we do NPE checks on invokedirect.
+ Exception exception = null;
+ try {
+ invokePrivate();
+ } catch (NullPointerException e) {
+ exception = e;
+ }
+
+ if (exception == null) {
+ throw new Error("Missing NullPointerException");
+ }
+ }
+
+ public static void invokePrivate() {
+ Main m = null;
+ m.privateMethod();
+ }
+
+ private void privateMethod() {
+ Object o = new Object();
}
static int $opt$TestInvokeIntParameter(int param) {
@@ -169,4 +200,10 @@ public class Main {
public static void throwStaticMethod() {
throw new Error("Error");
}
+
+ public static void $opt$SetFieldInOldObject(Main m) {
+ m.o = new Main();
+ }
+
+ Object o;
}