implements Cloneable {
- private static final DebugMetric metricTypeRegistered = Debug.metric("TypeRegistered");
- private static final DebugMetric metricNullnessRegistered = Debug.metric("NullnessRegistered");
- private static final DebugMetric metricObjectEqualsRegistered = Debug.metric("ObjectEqualsRegistered");
- private static final DebugMetric metricImpossiblePathDetected = Debug.metric("ImpossiblePathDetected");
+ private static final DebugMetric metricTypeRegistered = Debug.metric("FSR-TypeRegistered");
+ private static final DebugMetric metricNullnessRegistered = Debug.metric("FSR-NullnessRegistered");
+ private static final DebugMetric metricObjectEqualsRegistered = Debug.metric("FSR-ObjectEqualsRegistered");
+ private static final DebugMetric metricImpossiblePathDetected = Debug.metric("FSR-ImpossiblePathDetected");
/**
*
@@ -141,6 +141,18 @@
this.falseFacts = new IdentityHashMap<>(other.falseFacts);
}
+ public boolean repOK() {
+ // trueFacts and falseFacts disjoint
+ for (LogicNode trueFact : trueFacts.keySet()) {
+ assert !falseFacts.containsKey(trueFact) : trueFact + " tracked as both true and false fact.";
+ }
+ // no scrutinee tracked as both known-null and known-non-null
+ for (ValueNode subject : knownNull.keySet()) {
+ assert !isNonNull(subject) : subject + " tracked as both known-null and known-non-null.";
+ }
+ return true;
+ }
+
/**
* @return A new list containing only those states that are reachable.
*/
@@ -300,6 +312,9 @@
this.trueFacts = mergeTrueFacts(withReachableStates, merge);
this.falseFacts = mergeFalseFacts(withReachableStates, merge);
+
+ assert repOK();
+
return true;
}
@@ -531,6 +546,7 @@
Witness w = getOrElseAddTypeInfo(object);
if (w.trackNN(anchor)) {
versionNr++;
+ assert repOK();
return true;
}
return false;
@@ -563,6 +579,7 @@
if (w.trackCC(observed, anchor)) {
versionNr++;
metricTypeRegistered.increment();
+ assert repOK();
return true;
}
return false;
@@ -589,6 +606,7 @@
if (w.trackIO(observed, anchor)) {
versionNr++;
metricTypeRegistered.increment();
+ assert repOK();
return true;
}
return false;
@@ -670,6 +688,7 @@
} else {
addFactPrimordial(condition, isTrue ? trueFacts : falseFacts, anchor);
}
+ assert repOK();
}
/**
@@ -781,6 +800,7 @@
trackNN(original, anchor);
}
}
+ assert repOK();
}
/**
diff -r d968c2db220b -r 130e0183b7e2 graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitCore.java Mon May 05 18:40:13 2014 +0200
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.test;
+
+import java.util.*;
+
+import junit.runner.*;
+
+import org.junit.internal.*;
+import org.junit.runner.*;
+import org.junit.runner.notification.*;
+
+public class GraalJUnitCore {
+
+ /**
+ * Run the tests contained in the classes named in the args
. If all tests run
+ * successfully, exit with a status of 0. Otherwise exit with a status of 1. Write feedback
+ * while tests are running and write stack traces for all failed tests after the tests all
+ * complete.
+ *
+ * @param args names of classes in which to find tests to run
+ */
+ public static void main(String... args) {
+ JUnitSystem system = new RealSystem();
+ JUnitCore junitCore = new JUnitCore();
+ system.out().println("GraalJUnitCore");
+ system.out().println("JUnit version " + Version.id());
+ List> classes = new ArrayList<>();
+ List missingClasses = new ArrayList<>();
+ boolean verbose = false;
+ boolean enableTiming = false;
+ for (String each : args) {
+ if (each.charAt(0) == '-') {
+ // command line arguments
+ if (each.contentEquals("-JUnitVerbose")) {
+ verbose = true;
+ } else if (each.contentEquals("-JUnitEnableTiming")) {
+ enableTiming = true;
+ } else {
+ system.out().println("Unknown command line argument: " + each);
+ }
+
+ } else {
+ try {
+ classes.add(Class.forName(each));
+ } catch (ClassNotFoundException e) {
+ system.out().println("Could not find class: " + each);
+ Description description = Description.createSuiteDescription(each);
+ Failure failure = new Failure(description, e);
+ missingClasses.add(failure);
+ }
+ }
+ }
+ GraalJUnitRunListener graalListener;
+ if (!verbose) {
+ graalListener = new GraalTextListener(system);
+ } else {
+ graalListener = new GraalVerboseTextListener(system);
+ }
+ if (enableTiming) {
+ graalListener = new TimingDecorator(graalListener);
+ }
+ junitCore.addListener(GraalTextListener.createRunListener(graalListener));
+ Result result = junitCore.run(classes.toArray(new Class[0]));
+ for (Failure each : missingClasses) {
+ result.getFailures().add(each);
+ }
+ System.exit(result.wasSuccessful() ? 0 : 1);
+ }
+}
diff -r d968c2db220b -r 130e0183b7e2 graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitRunListener.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitRunListener.java Mon May 05 18:40:13 2014 +0200
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.test;
+
+import java.io.*;
+
+import org.junit.internal.*;
+import org.junit.runner.*;
+import org.junit.runner.notification.*;
+
+public interface GraalJUnitRunListener {
+
+ /**
+ * Called before any tests have been run.
+ *
+ * @param description describes the tests to be run
+ */
+ public void testRunStarted(Description description);
+
+ /**
+ * Called when all tests have finished
+ *
+ * @param result the summary of the test run, including all the tests that failed
+ */
+ public void testRunFinished(Result result);
+
+ /**
+ * Called when a test class is about to be started.
+ *
+ * @param clazz the test class
+ */
+ void testClassStarted(Class> clazz);
+
+ /**
+ * Called when all tests of a test class have finished.
+ *
+ * @param clazz the test class
+ */
+ void testClassFinished(Class> clazz);
+
+ /**
+ * Called when an atomic test is about to be started. This is also called for ignored tests.
+ *
+ * @param description the description of the test that is about to be run (generally a class and
+ * method name)
+ */
+ void testStarted(Description description);
+
+ /**
+ * Called when an atomic test has finished, whether the test succeeds, fails or is ignored.
+ *
+ * @param description the description of the test that just ran
+ */
+ void testFinished(Description description);
+
+ /**
+ * Called when an atomic test fails.
+ *
+ * @param failure describes the test that failed and the exception that was thrown
+ */
+ void testFailed(Failure failure);
+
+ /**
+ * Called when a test will not be run, generally because a test method is annotated with
+ * {@link org.junit.Ignore}.
+ *
+ * @param description describes the test that will not be run
+ */
+ public void testIgnored(Description description);
+
+ /**
+ * Called when an atomic test succeeds.
+ *
+ * @param description describes the test that will not be run
+ */
+ void testSucceeded(Description description);
+
+ /**
+ * Called when an atomic test flags that it assumes a condition that is false
+ *
+ * @param failure describes the test that failed and the {@link AssumptionViolatedException}
+ * that was thrown
+ */
+ public void testAssumptionFailure(Failure failure);
+
+ /**
+ * Called after {@link #testClassFinished(Class)}.
+ */
+ public void testClassFinishedDelimiter();
+
+ /**
+ * Called after {@link #testClassStarted(Class)}
+ */
+ public void testClassStartedDelimiter();
+
+ /**
+ * Called after {@link #testStarted(Description)}
+ */
+ public void testStartedDelimiter();
+
+ /**
+ * Called after {@link #testFailed(Failure)}
+ */
+ public void testFinishedDelimiter();
+
+ public PrintStream getWriter();
+
+}
diff -r d968c2db220b -r 130e0183b7e2 graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitRunListenerDecorator.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalJUnitRunListenerDecorator.java Mon May 05 18:40:13 2014 +0200
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.test;
+
+import java.io.*;
+
+import org.junit.runner.*;
+import org.junit.runner.notification.*;
+
+public class GraalJUnitRunListenerDecorator implements GraalJUnitRunListener {
+
+ private final GraalJUnitRunListener l;
+
+ public GraalJUnitRunListenerDecorator(GraalJUnitRunListener l) {
+ this.l = l;
+ }
+
+ @Override
+ public void testRunStarted(Description description) {
+ l.testRunStarted(description);
+ }
+
+ @Override
+ public void testRunFinished(Result result) {
+ l.testRunFinished(result);
+ }
+
+ @Override
+ public void testAssumptionFailure(Failure failure) {
+ l.testAssumptionFailure(failure);
+ }
+
+ @Override
+ public void testIgnored(Description description) {
+ l.testIgnored(description);
+ }
+
+ @Override
+ public void testClassStarted(Class> clazz) {
+ l.testClassStarted(clazz);
+ }
+
+ @Override
+ public void testClassFinished(Class> clazz) {
+ l.testClassFinished(clazz);
+ }
+
+ @Override
+ public void testStarted(Description description) {
+ l.testStarted(description);
+ }
+
+ @Override
+ public void testFinished(Description description) {
+ l.testFinished(description);
+ }
+
+ @Override
+ public void testFailed(Failure failure) {
+ l.testFailed(failure);
+ }
+
+ @Override
+ public void testSucceeded(Description description) {
+ l.testSucceeded(description);
+ }
+
+ @Override
+ public PrintStream getWriter() {
+ return l.getWriter();
+ }
+
+ public void testClassFinishedDelimiter() {
+ l.testClassFinishedDelimiter();
+ }
+
+ public void testClassStartedDelimiter() {
+ l.testClassStartedDelimiter();
+ }
+
+ public void testStartedDelimiter() {
+ l.testStartedDelimiter();
+ }
+
+ public void testFinishedDelimiter() {
+ l.testFinishedDelimiter();
+ }
+
+}
diff -r d968c2db220b -r 130e0183b7e2 graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTextListener.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTextListener.java Mon May 05 18:40:13 2014 +0200
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.test;
+
+import java.io.*;
+
+import org.junit.internal.*;
+import org.junit.runner.*;
+import org.junit.runner.notification.*;
+
+public class GraalTextListener implements GraalJUnitRunListener {
+
+ private final PrintStream fWriter;
+
+ public GraalTextListener(JUnitSystem system) {
+ this(system.out());
+ }
+
+ public GraalTextListener(PrintStream writer) {
+ fWriter = writer;
+ }
+
+ @Override
+ public PrintStream getWriter() {
+ return fWriter;
+ }
+
+ @Override
+ public void testRunStarted(Description description) {
+ }
+
+ @Override
+ public void testRunFinished(Result result) {
+ }
+
+ @Override
+ public void testAssumptionFailure(Failure failure) {
+ }
+
+ @Override
+ public void testClassStarted(Class> clazz) {
+ }
+
+ @Override
+ public void testClassFinished(Class> clazz) {
+ }
+
+ @Override
+ public void testStarted(Description description) {
+ getWriter().print('.');
+ }
+
+ @Override
+ public void testFinished(Description description) {
+ }
+
+ @Override
+ public void testFailed(Failure failure) {
+ getWriter().print('E');
+ }
+
+ @Override
+ public void testSucceeded(Description description) {
+ }
+
+ @Override
+ public void testIgnored(Description description) {
+ getWriter().print('I');
+ }
+
+ @Override
+ public void testClassFinishedDelimiter() {
+ }
+
+ @Override
+ public void testClassStartedDelimiter() {
+ }
+
+ @Override
+ public void testStartedDelimiter() {
+ }
+
+ @Override
+ public void testFinishedDelimiter() {
+ }
+
+ public static RunListener createRunListener(GraalJUnitRunListener l) {
+ return new TextListener(l.getWriter()) {
+ private Class> lastClass;
+ private boolean failed;
+
+ @Override
+ public final void testStarted(Description description) {
+ Class> currentClass = description.getTestClass();
+ if (currentClass != lastClass) {
+ if (lastClass != null) {
+ l.testClassFinished(lastClass);
+ l.testClassFinishedDelimiter();
+ }
+ lastClass = currentClass;
+ l.testClassStarted(currentClass);
+ l.testClassStartedDelimiter();
+ }
+ failed = false;
+ l.testStarted(description);
+ l.testStartedDelimiter();
+ }
+
+ @Override
+ public final void testFailure(Failure failure) {
+ failed = true;
+ l.testFailed(failure);
+ }
+
+ @Override
+ public final void testFinished(Description description) {
+ // we have to do this because there is no callback for successful tests
+ if (!failed) {
+ l.testSucceeded(description);
+ }
+ l.testFinished(description);
+ l.testFinishedDelimiter();
+ }
+
+ @Override
+ public void testIgnored(Description description) {
+ l.testStarted(description);
+ l.testStartedDelimiter();
+ l.testIgnored(description);
+ l.testFinished(description);
+ l.testFinishedDelimiter();
+ }
+
+ @Override
+ public void testRunStarted(Description description) {
+ l.testRunStarted(description);
+ }
+
+ @Override
+ public void testRunFinished(Result result) {
+ if (lastClass != null) {
+ l.testClassFinished(lastClass);
+ }
+ l.testRunFinished(result);
+ super.testRunFinished(result);
+ }
+
+ @Override
+ public void testAssumptionFailure(Failure failure) {
+ l.testAssumptionFailure(failure);
+ }
+
+ };
+ }
+
+}
diff -r d968c2db220b -r 130e0183b7e2 graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalVerboseTextListener.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalVerboseTextListener.java Mon May 05 18:40:13 2014 +0200
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.test;
+
+import java.io.*;
+
+import org.junit.internal.*;
+import org.junit.runner.*;
+import org.junit.runner.notification.*;
+
+public class GraalVerboseTextListener extends GraalTextListener {
+
+ public GraalVerboseTextListener(JUnitSystem system) {
+ this(system.out());
+ }
+
+ public GraalVerboseTextListener(PrintStream writer) {
+ super(writer);
+ }
+
+ @Override
+ public void testClassStarted(Class> clazz) {
+ getWriter().print(clazz.getName() + " started");
+ }
+
+ @Override
+ public void testClassFinished(Class> clazz) {
+ getWriter().print(clazz.getName() + " finished");
+ }
+
+ @Override
+ public void testStarted(Description description) {
+ getWriter().print(" " + description.getMethodName() + ": ");
+ }
+
+ @Override
+ public void testIgnored(Description description) {
+ getWriter().print("Ignored");
+ }
+
+ @Override
+ public void testSucceeded(Description description) {
+ getWriter().print("Passed");
+ }
+
+ @Override
+ public void testFailed(Failure failure) {
+ getWriter().print("FAILED");
+ }
+
+ @Override
+ public void testClassFinishedDelimiter() {
+ getWriter().println();
+ }
+
+ @Override
+ public void testClassStartedDelimiter() {
+ getWriter().println();
+ }
+
+ @Override
+ public void testFinishedDelimiter() {
+ getWriter().println();
+ }
+
+}
diff -r d968c2db220b -r 130e0183b7e2 graal/com.oracle.graal.test/src/com/oracle/graal/test/TimingDecorator.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/TimingDecorator.java Mon May 05 18:40:13 2014 +0200
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.graal.test;
+
+import org.junit.runner.*;
+
+/**
+ * Timing support for JUnit test runs.
+ */
+public class TimingDecorator extends GraalJUnitRunListenerDecorator {
+
+ private long startTime;
+ private long classStartTime;
+
+ public TimingDecorator(GraalJUnitRunListener l) {
+ super(l);
+ }
+
+ @Override
+ public void testClassStarted(Class> clazz) {
+ classStartTime = System.nanoTime();
+ super.testClassStarted(clazz);
+ }
+
+ @Override
+ public void testClassFinished(Class> clazz) {
+ long totalTime = System.nanoTime() - classStartTime;
+ super.testClassFinished(clazz);
+ getWriter().print(' ' + valueToString(totalTime));
+ }
+
+ @Override
+ public void testStarted(Description description) {
+ startTime = System.nanoTime();
+ super.testStarted(description);
+ }
+
+ @Override
+ public void testFinished(Description description) {
+ long totalTime = System.nanoTime() - startTime;
+ super.testFinished(description);
+ getWriter().print(" " + valueToString(totalTime));
+ }
+
+ private static String valueToString(long value) {
+ return String.format("%d.%d ms", value / 1000000, (value / 100000) % 10);
+ }
+
+}
diff -r d968c2db220b -r 130e0183b7e2 mx/JUnitWrapper.java
--- a/mx/JUnitWrapper.java Mon May 05 18:39:29 2014 +0200
+++ b/mx/JUnitWrapper.java Mon May 05 18:40:13 2014 +0200
@@ -27,8 +27,7 @@
* linux [depending on the settings]: ~2097k)
* see http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx
*/
-
-import org.junit.runner.*;
+import com.oracle.graal.test.*;
import java.io.*;
import java.util.*;
@@ -44,6 +43,10 @@
System.exit(1);
}
ArrayList tests = new ArrayList(1000);
+ // add JUnit command line arguments
+ for (int i = 1; i < args.length; i++) {
+ tests.add(args[i]);
+ }
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(args[0]));
@@ -72,6 +75,6 @@
} else {
System.out.printf("executing junit tests now... (%d test classes)\n", strargs.length);
}
- JUnitCore.main(strargs);
+ GraalJUnitCore.main(strargs);
}
}
diff -r d968c2db220b -r 130e0183b7e2 mx/mx_graal.py
--- a/mx/mx_graal.py Mon May 05 18:39:29 2014 +0200
+++ b/mx/mx_graal.py Mon May 05 18:40:13 2014 +0200
@@ -946,7 +946,7 @@
f_testfile.close()
harness(projectscp, vmArgs)
-def _unittest(args, annotations, prefixcp="", whitelist=None):
+def _unittest(args, annotations, prefixcp="", whitelist=None, verbose=False, enable_timing=False):
mxdir = dirname(__file__)
name = 'JUnitWrapper'
javaSource = join(mxdir, name + '.java')
@@ -955,6 +955,12 @@
if testfile is None:
(_, testfile) = tempfile.mkstemp(".testclasses", "graal")
os.close(_)
+ corecp = mx.classpath(['com.oracle.graal.test'])
+ coreArgs = []
+ if verbose:
+ coreArgs.append('-JUnitVerbose')
+ if enable_timing:
+ coreArgs.append('-JUnitEnableTiming')
def harness(projectscp, vmArgs):
if not exists(javaClass) or getmtime(javaClass) < getmtime(javaSource):
@@ -968,9 +974,9 @@
if len(testclasses) == 1:
# Execute Junit directly when one test is being run. This simplifies
# replaying the VM execution in a native debugger (e.g., gdb).
- vm(prefixArgs + vmArgs + ['-cp', prefixcp + projectscp, 'org.junit.runner.JUnitCore'] + testclasses)
+ vm(prefixArgs + vmArgs + ['-cp', prefixcp + corecp + ':' + projectscp, 'com.oracle.graal.test.GraalJUnitCore'] + coreArgs + testclasses)
else:
- vm(prefixArgs + vmArgs + ['-cp', prefixcp + projectscp + os.pathsep + mxdir, name] + [testfile])
+ vm(prefixArgs + vmArgs + ['-cp', prefixcp + corecp + ':' + projectscp + os.pathsep + mxdir, name] + [testfile] + coreArgs)
try:
_run_tests(args, harness, annotations, testfile, whitelist)
@@ -983,6 +989,8 @@
--whitelist run only testcases which are included
in the given whitelist
+ --verbose enable verbose JUnit output
+ --enable-timing enable JUnit test timing
To avoid conflicts with VM options '--' can be used as delimiter.
@@ -1020,6 +1028,8 @@
epilog=_unittestHelpSuffix,
)
parser.add_argument('--whitelist', help='run testcases specified in whitelist only', metavar='')
+ parser.add_argument('--verbose', help='enable verbose JUnit output', action='store_true')
+ parser.add_argument('--enable-timing', help='enable JUnit test timing', action='store_true')
ut_args = []
delimiter = False
@@ -1046,7 +1056,7 @@
except IOError:
mx.log('warning: could not read whitelist: ' + parsed_args.whitelist)
- _unittest(args, ['@Test', '@Parameters'], whitelist=whitelist)
+ _unittest(args, ['@Test', '@Parameters'], whitelist=whitelist, verbose=parsed_args.verbose, enable_timing=parsed_args.enable_timing)
def shortunittest(args):
"""alias for 'unittest --whitelist test/whitelist_shortunittest.txt'{0}"""
diff -r d968c2db220b -r 130e0183b7e2 mxtool/mx.py
--- a/mxtool/mx.py Mon May 05 18:39:29 2014 +0200
+++ b/mxtool/mx.py Mon May 05 18:40:13 2014 +0200
@@ -1811,7 +1811,7 @@
return get_env('JDT', join(_primary_suite.mxDir, 'ecj.jar'))
class JavaCompileTask:
- def __init__(self, args, proj, reason, javafilelist, jdk, outputDir, deps):
+ def __init__(self, args, proj, reason, javafilelist, jdk, outputDir, jdtJar, deps):
self.proj = proj
self.reason = reason
self.javafilelist = javafilelist
@@ -1819,6 +1819,7 @@
self.jdk = jdk
self.outputDir = outputDir
self.done = False
+ self.jdtJar = jdtJar
self.args = args
def __str__(self):
@@ -1853,20 +1854,8 @@
cp = classpath(self.proj.name, includeSelf=True)
toBeDeleted = [argfileName]
- jdtJar = None
- if not args.javac and args.jdt is not None:
- if not args.jdt.endswith('.jar'):
- abort('Path for Eclipse batch compiler does not look like a jar file: ' + args.jdt)
- jdtJar = args.jdt
- if not exists(jdtJar):
- if os.path.abspath(jdtJar) == os.path.abspath(_defaultEcjPath()) and get_env('JDT', None) is None:
- # Silently ignore JDT if default location is used but does not exist
- jdtJar = None
- else:
- abort('Eclipse batch compiler jar does not exist: ' + args.jdt)
-
try:
- if not jdtJar:
+ if not self.jdtJar:
mainJava = java()
if not args.error_prone:
self.logCompilation('javac')
@@ -1891,7 +1880,7 @@
else:
self.logCompilation('JDT')
- jdtVmArgs = ['-Xmx1g', '-jar', jdtJar]
+ jdtVmArgs = ['-Xmx1g', '-jar', self.jdtJar]
jdtArgs = ['-' + compliance,
'-cp', cp, '-g', '-enableJavadoc',
@@ -1959,12 +1948,23 @@
compilerSelect.add_argument('--jdt', help='path to ecj.jar, the Eclipse batch compiler', default=_defaultEcjPath(), metavar='')
compilerSelect.add_argument('--force-javac', action='store_true', dest='javac', help='use javac despite ecj.jar is found or not')
-
if suppliedParser:
parser.add_argument('remainder', nargs=REMAINDER, metavar='...')
args = parser.parse_args(args)
+ jdtJar = None
+ if not args.javac and args.jdt is not None:
+ if not args.jdt.endswith('.jar'):
+ abort('Path for Eclipse batch compiler does not look like a jar file: ' + args.jdt)
+ jdtJar = args.jdt
+ if not exists(jdtJar):
+ if os.path.abspath(jdtJar) == os.path.abspath(_defaultEcjPath()) and get_env('JDT', None) is None:
+ # Silently ignore JDT if default location is used but does not exist
+ jdtJar = None
+ else:
+ abort('Eclipse batch compiler jar does not exist: ' + args.jdt)
+
if args.only is not None:
# N.B. This build will not include dependencies including annotation processor dependencies
sortedProjects = [project(name) for name in args.only.split(',')]
@@ -2100,7 +2100,7 @@
logv('[no Java sources for {0} - skipping]'.format(p.name))
continue
- task = JavaCompileTask(args, p, buildReason, javafilelist, jdk, outputDir, taskDeps)
+ task = JavaCompileTask(args, p, buildReason, javafilelist, jdk, outputDir, jdtJar, taskDeps)
if args.parallelize:
# Best to initialize class paths on main process
@@ -2143,9 +2143,9 @@
def compareTasks(t1, t2):
d = remainingDepsDepth(t1) - remainingDepsDepth(t2)
if d == 0:
- d = len(t1.proj.annotation_processors()) - len(t2.proj.annotation_processors())
- if d == 0:
- d = len(t1.javafilelist) - len(t2.javafilelist)
+ t1Work = (1 + len(t1.proj.annotation_processors())) * len(t1.javafilelist)
+ t2Work = (1 + len(t2.proj.annotation_processors())) * len(t2.javafilelist)
+ d = t1Work - t2Work
return d
def sortWorklist(tasks):
diff -r d968c2db220b -r 130e0183b7e2 src/share/vm/code/nmethod.cpp
--- a/src/share/vm/code/nmethod.cpp Mon May 05 18:39:29 2014 +0200
+++ b/src/share/vm/code/nmethod.cpp Mon May 05 18:40:13 2014 +0200
@@ -1064,7 +1064,6 @@
void nmethod::print_on(outputStream* st, const char* msg) const {
if (st != NULL) {
ttyLocker ttyl;
- if (CIPrintCompilerName) st->print("%s:", compiler()->name());
if (WizardMode) {
CompileTask::print_compilation(st, this, msg, /*short_form:*/ true);
st->print_cr(" (" INTPTR_FORMAT ")", this);
diff -r d968c2db220b -r 130e0183b7e2 src/share/vm/compiler/compileBroker.cpp
--- a/src/share/vm/compiler/compileBroker.cpp Mon May 05 18:39:29 2014 +0200
+++ b/src/share/vm/compiler/compileBroker.cpp Mon May 05 18:40:13 2014 +0200
@@ -370,8 +370,6 @@
// CompileTask::print_line
void CompileTask::print_line() {
ttyLocker ttyl; // keep the following output all in one block
- // print compiler name if requested
- if (CIPrintCompilerName) tty->print("%s:", CompileBroker::compiler_name(comp_level()));
print_compilation();
}
@@ -384,6 +382,8 @@
if (!short_form) {
st->print("%7d ", (int) st->time_stamp().milliseconds()); // print timestamp
}
+ // print compiler name if requested
+ if (CIPrintCompilerName) tty->print("%s:", CompileBroker::compiler_name(comp_level));
st->print("%4d ", compile_id); // print compilation number
// For unloaded methods the transition to zombie occurs after the
diff -r d968c2db220b -r 130e0183b7e2 src/share/vm/graal/graalCompiler.cpp
--- a/src/share/vm/graal/graalCompiler.cpp Mon May 05 18:39:29 2014 +0200
+++ b/src/share/vm/graal/graalCompiler.cpp Mon May 05 18:40:13 2014 +0200
@@ -48,10 +48,6 @@
return;
}
- ThreadToNativeFromVM trans(JavaThread::current());
- JavaThread* THREAD = JavaThread::current();
- TRACE_graal_1("GraalCompiler::initialize");
-
uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end();
uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024;
AMD64_ONLY(guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)"));
@@ -71,6 +67,10 @@
}
#endif
+ ThreadToNativeFromVM trans(JavaThread::current());
+ JavaThread* THREAD = JavaThread::current();
+ TRACE_graal_1("GraalCompiler::initialize");
+
JNIEnv *env = ((JavaThread *) Thread::current())->jni_environment();
jclass klass = env->FindClass("com/oracle/graal/hotspot/bridge/CompilerToVMImpl");
if (klass == NULL) {