001/* 002 * Copyright (c) 2012, 2012, 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.micro; 024 025import org.junit.*; 026 027import com.oracle.graal.jtt.*; 028 029public class FloatingReads extends JTTTest { 030 031 public static long init = Runtime.getRuntime().totalMemory(); 032 private final int f = 10; 033 private int a; 034 private int b; 035 private int c; 036 037 public int test(int d) { 038 a = 3; 039 b = 5; 040 c = 7; 041 for (int i = 0; i < d; i++) { 042 if (i % 2 == 0) { 043 a += b; 044 } 045 if (i % 4 == 0) { 046 b += c; 047 } else if (i % 3 == 0) { 048 b -= a; 049 } 050 if (i % 5 == 0) { 051 for (int j = 0; j < i; j++) { 052 c += a; 053 } 054 a -= f; 055 } 056 b = a ^ c; 057 if (i % 6 == 0) { 058 c--; 059 } else if (i % 7 == 0) { 060 Runtime.getRuntime().totalMemory(); 061 } 062 } 063 return a + b + c; 064 } 065 066 @Test 067 public void run0() { 068 runTest("test", 10); 069 } 070 071 @Test 072 public void run1() { 073 runTest("test", 1000); 074 } 075 076 @Test 077 public void run2() { 078 runTest("test", 1); 079 } 080 081 @Test 082 public void run3() { 083 runTest("test", 0); 084 } 085}