001/* 002 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. 003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 004 * 005 * This code is free software; you can redistribute it and/or modify it 006 * under the terms of the GNU General Public License version 2 only, as 007 * published by the Free Software Foundation. 008 * 009 * This code is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 011 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 012 * version 2 for more details (a copy is included in the LICENSE file that 013 * accompanied this code). 014 * 015 * You should have received a copy of the GNU General Public License version 016 * 2 along with this work; if not, write to the Free Software Foundation, 017 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 018 * 019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 020 * or visit www.oracle.com if you need additional information or have any 021 * questions. 022 */ 023package com.oracle.graal.jtt.loop; 024 025import org.junit.*; 026 027import com.oracle.graal.jtt.*; 028 029public class LoopSpilling extends JTTTest { 030 031 private static final int ITERATION = 64; 032 033 /** 034 * Modification of sun.security.provider.SHA2.implCompress(). 035 */ 036 void test(int[] state) { 037 038 int a1 = state[0]; 039 int b1 = state[1]; 040 int c1 = state[2]; 041 int d1 = state[3]; 042 int e1 = state[4]; 043 int f1 = state[5]; 044 int g1 = state[6]; 045 int h1 = state[7]; 046 047 // 2nd 048 int a2 = state[8]; 049 int b2 = state[9]; 050 int c2 = state[10]; 051 int d2 = state[11]; 052 int e2 = state[12]; 053 int f2 = state[13]; 054 int g2 = state[14]; 055 int h2 = state[15]; 056 057 for (int i = 0; i < ITERATION; i++) { 058 h1 = g1; 059 g1 = f1; 060 f1 = e1; 061 e1 = d1; 062 d1 = c1; 063 c1 = b1; 064 b1 = a1; 065 a1 = h1; 066 // 2nd 067 h2 = g2; 068 g2 = f2; 069 f2 = e2; 070 e2 = d2; 071 d2 = c2; 072 c2 = b2; 073 b2 = a2; 074 a2 = h2; 075 } 076 state[0] += a1; 077 state[1] += b1; 078 state[2] += c1; 079 state[3] += d1; 080 state[4] += e1; 081 state[5] += f1; 082 state[6] += g1; 083 state[7] += h1; 084 // 2nd 085 state[8] += a2; 086 state[9] += b2; 087 state[10] += c2; 088 state[11] += d2; 089 state[12] += e2; 090 state[13] += f2; 091 state[14] += g2; 092 state[15] += h2; 093 } 094 095 private static final int[] INITIAL_HASHES = {0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4, 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 096 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19}; 097 098 @Test 099 public void run0() throws Throwable { 100 runTest("test", supply(() -> INITIAL_HASHES.clone())); 101 } 102 103}