Cleanups and tests for new cases.
Signed-off-by: Tomek Grabiec <[email protected]>
---
regression/jvm/TrampolineBackpatchingTest.java | 74 ++++++++++++++----------
1 files changed, 43 insertions(+), 31 deletions(-)
diff --git a/regression/jvm/TrampolineBackpatchingTest.java
b/regression/jvm/TrampolineBackpatchingTest.java
index 66d63fe..734d3eb 100644
--- a/regression/jvm/TrampolineBackpatchingTest.java
+++ b/regression/jvm/TrampolineBackpatchingTest.java
@@ -29,50 +29,62 @@ package jvm;
* @author Tomasz Grabiec
*/
public class TrampolineBackpatchingTest extends TestCase {
-
- public static int test(int x) {
+ public static int staticMethod(int x) {
return x+x;
}
- public static int testBackpatchingOnTheFly(int x) {
- /* No trampoline call should be generated for this,
- because method test() is already compiled */
- return test(x);
+ private class A {
+ public int virtualMethod(int x) {
+ return x+x;
+ }
+
+ private int privateMethod(int x) {
+ return x+x;
+ }
+
+ public int invokePrivate(int x) {
+ return privateMethod(x);
+ }
}
- static void testVTableBackpatching() {
- /* Instantiating RuntimeException calls virtual method
- Throwable.fillInStackTrace. This tests proper functioning
- of vtable back-patching */
- new RuntimeException("foo");
+ private class B extends A {
+ public int invokeSuper(int x) {
+ return super.virtualMethod(x);
+ }
+
+ public int invokeVirtual(int x) {
+ return virtualMethod(x);
+ }
}
- public int testArg(int a) {
- return a+1;
+ public static void testInvokestatic() {
+ assertEquals(staticMethod(4), 8);
}
- public static void main(String [] args) {
- int x;
- TrampolineBackpatchingTest t = new TrampolineBackpatchingTest();
+ public void testInvokevirtual() {
+ assertEquals(new A().virtualMethod(4), 8);
+ assertEquals(new B().invokeVirtual(4), 8);
+ }
- /* Test backpatching of multiple call sites
- at once */
- x = 1;
- x = test(x);
- x = test(x);
- x = test(x);
- assertEquals(x, 8);
+ public void testInvokespecial() {
+ assertEquals(new A().invokePrivate(4), 8);
+ assertEquals(new B().invokeSuper(4), 8);
+ }
- x = testBackpatchingOnTheFly(8);
- assertEquals(x, 16);
+ public static void main(String [] args) {
+ TrampolineBackpatchingTest t = new TrampolineBackpatchingTest();
- testVTableBackpatching();
+ testInvokestatic();
+ t.testInvokevirtual();
+ t.testInvokespecial();
- /* Another invokevirtual backpatching test */
- x = 1;
- x = t.testArg(x);
- x = t.testArg(x);
- assertEquals(x, 3);
+ /*
+ * Run tests again to check if all call sites have
+ * been properly fixed.
+ */
+ testInvokestatic();
+ t.testInvokevirtual();
+ t.testInvokespecial();
exit();
}
--
1.6.0.6
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel