From f583e5976e1de9aa206fb8de4f91000180685066 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Mon, 7 Apr 2014 13:20:42 +0100 Subject: Add support for taking parameters in optimizing compiler. - Fix stack layout to mimic Quick's. - Implement some sub operations. Change-Id: I8cf75a4d29b662381a64f02c0bc61d859482fc4e --- test/401-optimizing-compiler/src/Main.java | 78 ++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'test/401-optimizing-compiler/src/Main.java') diff --git a/test/401-optimizing-compiler/src/Main.java b/test/401-optimizing-compiler/src/Main.java index aa08137caa..e5706a52fe 100644 --- a/test/401-optimizing-compiler/src/Main.java +++ b/test/401-optimizing-compiler/src/Main.java @@ -28,6 +28,84 @@ public class Main { System.out.println(error); $opt$TestInvokeNew(); + + int result = $opt$TestInvokeIntParameter(42); + if (result != 42) { + throw new Error("Different value returned: " + result); + } + + + $opt$TestInvokeObjectParameter(new Object()); + + Object a = new Object(); + Object b = $opt$TestInvokeObjectParameter(a); + if (a != b) { + throw new Error("Different object returned " + a + " " + b); + } + + result = $opt$TestInvokeWith2Parameters(10, 9); + if (result != 1) { + throw new Error("Unexpected result: " + result); + } + + result = $opt$TestInvokeWith3Parameters(10, 9, 1); + if (result != 0) { + throw new Error("Unexpected result: " + result); + } + + result = $opt$TestInvokeWith5Parameters(10000, 1000, 100, 10, 1); + if (result != 8889) { + throw new Error("Unexpected result: " + result); + } + + result = $opt$TestInvokeWith7Parameters(100, 6, 5, 4, 3, 2, 1); + if (result != 79) { + throw new Error("Unexpected result: " + result); + } + + Main m = new Main(); + if (m.$opt$TestThisParameter(m) != m) { + throw new Error("Unexpected value returned"); + } + + if (m.$opt$TestOtherParameter(new Main()) == m) { + throw new Error("Unexpected value returned"); + } + } + + static int $opt$TestInvokeIntParameter(int param) { + return param; + } + + static Object $opt$TestInvokeObjectParameter(Object a) { + forceGCStaticMethod(); + return a; + } + + static int $opt$TestInvokeWith2Parameters(int a, int b) { + return a - b; + } + + static int $opt$TestInvokeWith3Parameters(int a, int b, int c) { + return a - b - c; + } + + static int $opt$TestInvokeWith5Parameters(int a, int b, int c, int d, int e) { + return a - b - c - d - e; + } + + static int $opt$TestInvokeWith7Parameters(int a, int b, int c, int d, int e, int f, int g) { + return a - b - c - d - e - f - g; + } + + Object $opt$TestThisParameter(Object other) { + forceGCStaticMethod(); + return other; + } + + Object $opt$TestOtherParameter(Object other) { + forceGCStaticMethod(); + return other; } public static void $opt$TestInvokeStatic() { -- cgit v1.2.3-59-g8ed1b