1 /*
   2  * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 /*
  24  * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
  25  */
  26 /*
  27  */
  28 package org.graalvm.compiler.jtt.micro;
  29 
  30 import org.junit.Test;
  31 
  32 import org.graalvm.compiler.jtt.JTTTest;
  33 
  34 public class BigParamsAlignment extends JTTTest {
  35 
  36     public static int test(int num) {
  37         int sum = 0;
  38         if (num == 0) {
  39             sum += testA(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
  40             sum += testA(1, 1, 2, 3, 4, 5, 6, 7, 8, 9);
  41             sum += testA(2, 1, 2, 3, 4, 5, 6, 7, 8, 9);
  42             sum += testA(3, 1, 2, 3, 4, 5, 6, 7, 8, 9);
  43             sum += testA(4, 1, 2, 3, 4, 5, 6, 7, 8, 9);
  44             sum += testA(5, 1, 2, 3, 4, 5, 6, 7, 8, 9);
  45             sum += testA(6, 1, 2, 3, 4, 5, 6, 7, 8, 9);
  46             sum += testA(7, 1, 2, 3, 4, 5, 6, 7, 8, 9);
  47             sum += testA(8, 1, 2, 3, 4, 5, 6, 7, 8, 9);
  48         } else if (num == 1) {
  49             sum += testB(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  50             sum += testB(1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  51             sum += testB(2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  52             sum += testB(3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  53             sum += testB(4, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  54             sum += testB(5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  55             sum += testB(6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  56             sum += testB(7, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  57             sum += testB(8, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  58             sum += testB(9, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  59         } else if (num == 2) {
  60             for (int i = 0; i < 9; i++) {
  61                 sum += testA(i, 1, 2, 3, 4, 5, 6, 7, 8, 9);
  62             }
  63         } else if (num == 3) {
  64             for (int i = 0; i < 10; i++) {
  65                 sum += testB(i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  66             }
  67         } else if (num == 4) {
  68             for (int i = 0; i < 11; i++) {
  69                 sum += testC(i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
  70             }
  71         } else if (num == 5) {
  72             for (int i = 0; i < 12; i++) {
  73                 sum += testD(i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
  74             }
  75         }
  76         return sum;
  77     }
  78 
  79     private static int testA(int choice, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8) {
  80         switch (choice) {
  81             case 0:
  82                 return p0;
  83             case 1:
  84                 return p1;
  85             case 2:
  86                 return p2;
  87             case 3:
  88                 return p3;
  89             case 4:
  90                 return p4;
  91             case 5:
  92                 return p5;
  93             case 6:
  94                 return p6;
  95             case 7:
  96                 return p7;
  97             case 8:
  98                 return p8;
  99         }
 100         return 42;
 101     }
 102 
 103     private static int testB(int choice, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9) {
 104         switch (choice) {
 105             case 0:
 106                 return p0;
 107             case 1:
 108                 return p1;
 109             case 2:
 110                 return p2;
 111             case 3:
 112                 return p3;
 113             case 4:
 114                 return p4;
 115             case 5:
 116                 return p5;
 117             case 6:
 118                 return p6;
 119             case 7:
 120                 return p7;
 121             case 8:
 122                 return p8;
 123             case 9:
 124                 return p9;
 125         }
 126         return 42;
 127     }
 128 
 129     private static int testC(int choice, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10) {
 130         switch (choice) {
 131             case 0:
 132                 return p0;
 133             case 1:
 134                 return p1;
 135             case 2:
 136                 return p2;
 137             case 3:
 138                 return p3;
 139             case 4:
 140                 return p4;
 141             case 5:
 142                 return p5;
 143             case 6:
 144                 return p6;
 145             case 7:
 146                 return p7;
 147             case 8:
 148                 return p8;
 149             case 9:
 150                 return p9;
 151             case 10:
 152                 return p10;
 153         }
 154         return 42;
 155     }
 156 
 157     private static int testD(int choice, int p0, int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10, int p11) {
 158         switch (choice) {
 159             case 0:
 160                 return p0;
 161             case 1:
 162                 return p1;
 163             case 2:
 164                 return p2;
 165             case 3:
 166                 return p3;
 167             case 4:
 168                 return p4;
 169             case 5:
 170                 return p5;
 171             case 6:
 172                 return p6;
 173             case 7:
 174                 return p7;
 175             case 8:
 176                 return p8;
 177             case 9:
 178                 return p9;
 179             case 10:
 180                 return p10;
 181             case 11:
 182                 return p11;
 183         }
 184         return 42;
 185     }
 186 
 187     @Test
 188     public void run0() throws Throwable {
 189         runTest("test", 0);
 190     }
 191 
 192     @Test
 193     public void run1() throws Throwable {
 194         runTest("test", 1);
 195     }
 196 
 197     @Test
 198     public void run2() throws Throwable {
 199         runTest("test", 2);
 200     }
 201 
 202     @Test
 203     public void run3() throws Throwable {
 204         runTest("test", 3);
 205     }
 206 
 207     @Test
 208     public void run4() throws Throwable {
 209         runTest("test", 4);
 210     }
 211 
 212     @Test
 213     public void run5() throws Throwable {
 214         runTest("test", 5);
 215     }
 216 
 217     @Test
 218     public void run6() throws Throwable {
 219         runTest("test", 6);
 220     }
 221 
 222 }