1 /* 2 * Copyright (c) 2015, 2018, 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 25 package org.graalvm.compiler.jtt.loop; 26 27 import org.junit.Test; 28 29 import org.graalvm.compiler.jtt.JTTTest; 30 31 public class LoopSpilling extends JTTTest { 32 33 private static final int ITERATION = 64; 34 35 /** 36 * Modification of sun.security.provider.SHA2.implCompress(). 37 */ test(int[] state)38 void test(int[] state) { 39 40 int a1 = state[0]; 41 int b1 = state[1]; 42 int c1 = state[2]; 43 int d1 = state[3]; 44 int e1 = state[4]; 45 int f1 = state[5]; 46 int g1 = state[6]; 47 int h1 = state[7]; 48 49 // 2nd 50 int a2 = state[8]; 51 int b2 = state[9]; 52 int c2 = state[10]; 53 int d2 = state[11]; 54 int e2 = state[12]; 55 int f2 = state[13]; 56 int g2 = state[14]; 57 int h2 = state[15]; 58 59 for (int i = 0; i < ITERATION; i++) { 60 h1 = g1; 61 g1 = f1; 62 f1 = e1; 63 e1 = d1; 64 d1 = c1; 65 c1 = b1; 66 b1 = a1; 67 a1 = h1; 68 // 2nd 69 h2 = g2; 70 g2 = f2; 71 f2 = e2; 72 e2 = d2; 73 d2 = c2; 74 c2 = b2; 75 b2 = a2; 76 a2 = h2; 77 } 78 state[0] += a1; 79 state[1] += b1; 80 state[2] += c1; 81 state[3] += d1; 82 state[4] += e1; 83 state[5] += f1; 84 state[6] += g1; 85 state[7] += h1; 86 // 2nd 87 state[8] += a2; 88 state[9] += b2; 89 state[10] += c2; 90 state[11] += d2; 91 state[12] += e2; 92 state[13] += f2; 93 state[14] += g2; 94 state[15] += h2; 95 } 96 97 private static final int[] INITIAL_HASHES = {0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4, 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 98 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19}; 99 100 @Test run0()101 public void run0() throws Throwable { 102 runTest("test", supply(() -> INITIAL_HASHES.clone())); 103 } 104 105 } 106