hotspot/test/compiler/6636138/Test2.java
author cfang
Mon, 31 Aug 2009 08:31:45 -0700
changeset 3799 6eddf8400cbc
parent 2864 1262819e8925
child 5547 f4b087cbb361
permissions -rw-r--r--
6876276: assert(!is_visited,"visit only once") Summary: schedule the superword loads based on dependence constraints Reviewed-by: kvn, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2334
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
     1
/*
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
     2
 * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
     4
 *
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
     7
 * published by the Free Software Foundation.
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
     8
 *
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    13
 * accompanied this code).
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    14
 *
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    18
 *
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    21
 * have any questions.
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    22
 */
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    23
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    24
/**
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    25
 * @test
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    26
 * @bug 6636138
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    27
 * @summary SuperWord::co_locate_pack(Node_List* p) generates memory graph that leads to memory order violation.
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    28
 *
2535
63a54cec2848 6829021: tests for 6636138 use UseSuperword instead of UseSuperWord
cfang
parents: 2334
diff changeset
    29
 * @run main/othervm -server -Xbatch -XX:CompileOnly=Test2.shift Test2
2334
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    30
 */
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    31
2864
1262819e8925 6837906: compiler tests of 6636138 fail with IllegalAccessException
twisti
parents: 2535
diff changeset
    32
public class Test2 {
2334
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    33
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    34
    public static void init(int src[]) {
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    35
        // Initialize the array
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    36
        for (int i = 0; i < src.length; i++)
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    37
            src[i] = i;
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    38
    }
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    39
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    40
   public static void shift(int src[]) {
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    41
       //left-shift the array
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    42
       for (int i = src.length-1; i > 0; i--){
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    43
           int tmp  = src[i];
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    44
           src[i]   = src[i-1];
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    45
           src[i-1] = tmp;
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    46
       }
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    47
    }
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    48
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    49
    public static void verify(int src[]) {
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    50
        for (int i = 0; i < src.length; i++){
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    51
            int value = (i-1 + src.length)%src.length; // correct value after shifting
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    52
                if (src[i] != value) {
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    53
                    System.out.println("Error: src["+i+"] should be "+ value + " instead of " + src[i]);
3799
6eddf8400cbc 6876276: assert(!is_visited,"visit only once")
cfang
parents: 2864
diff changeset
    54
                    System.exit(97);
2334
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    55
                }
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    56
        }
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    57
    }
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    58
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    59
    public static void test() {
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    60
        int[] src = new int[10];
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    61
        init(src);
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    62
        shift(src);
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    63
        verify(src);
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    64
    }
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    65
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    66
    public static void main(String[] args) {
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    67
        for (int i=0; i< 2000; i++)
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    68
            test();
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    69
    }
742b05aeec42 6636138: UseSuperWord enabled failure
cfang
parents:
diff changeset
    70
}