Fix a braino in the stack layout.

Also do some refactoring to have this code be just in CodeGenerator.

Change-Id: I88de109889138af8d60027973c12a64bee813cb7
diff --git a/test/401-optimizing-compiler/src/Main.java b/test/401-optimizing-compiler/src/Main.java
index e5706a5..a5192e1 100644
--- a/test/401-optimizing-compiler/src/Main.java
+++ b/test/401-optimizing-compiler/src/Main.java
@@ -71,6 +71,10 @@
     if (m.$opt$TestOtherParameter(new Main()) == m) {
       throw new Error("Unexpected value returned");
     }
+
+    if (m.$opt$TestReturnNewObject(m) == m) {
+      throw new Error("Unexpected value returned");
+    }
   }
 
   static int $opt$TestInvokeIntParameter(int param) {
@@ -108,6 +112,12 @@
     return other;
   }
 
+  Object $opt$TestReturnNewObject(Object other) {
+    Object o = new Object();
+    forceGCStaticMethod();
+    return o;
+  }
+
   public static void $opt$TestInvokeStatic() {
     printStaticMethod();
     printStaticMethodWith2Args(1, 2);