Add support for taking parameters in optimizing compiler.
- Fix stack layout to mimic Quick's.
- Implement some sub operations.
Change-Id: I8cf75a4d29b662381a64f02c0bc61d859482fc4e
diff --git a/test/401-optimizing-compiler/expected.txt b/test/401-optimizing-compiler/expected.txt
index a65e544..97492a4 100644
--- a/test/401-optimizing-compiler/expected.txt
+++ b/test/401-optimizing-compiler/expected.txt
@@ -7,3 +7,7 @@
Forced GC
In static method with object arg class java.lang.Object
Forced GC
+Forced GC
+Forced GC
+Forced GC
+Forced GC
diff --git a/test/401-optimizing-compiler/src/Main.java b/test/401-optimizing-compiler/src/Main.java
index aa08137..e5706a5 100644
--- a/test/401-optimizing-compiler/src/Main.java
+++ b/test/401-optimizing-compiler/src/Main.java
@@ -28,6 +28,84 @@
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() {