001/*
002 * Copyright (c) 2007, 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.optimize;
024
025import org.junit.*;
026
027import com.oracle.graal.jtt.*;
028
029/*
030 */
031@SuppressWarnings("unused")
032public class List_reorder_bug extends JTTTest {
033
034    private static class TestClass {
035        String s;
036
037        private void print(String s2) {
038            this.s = s2;
039        }
040
041        private void match(Object a, int src, int id, int seq) {
042            print("match: " + src + ", " + id);
043            List item = list;
044            List itemPrev = null;
045            while (item != null) {
046                if (item.id == id) {
047                    if (item.bool) {
048                        outcall(item.id);
049                    }
050                    if (itemPrev != null) {
051                        itemPrev.next = item.next;
052                    } else {
053                        list = item.next;
054                    }
055
056                    item.next = null;
057                    return;
058                }
059
060                itemPrev = item;
061                item = item.next;
062            }
063        }
064    }
065
066    static class List {
067
068        List(int id) {
069            this.id = id;
070        }
071
072        List next;
073        int id;
074        boolean bool = true;
075    }
076
077    private static List list;
078
079    public static boolean test(int i) {
080        list = new List(5);
081        list.next = new List(6);
082        new TestClass().match(new Object(), 27, 6, 0);
083        return list.next == null;
084    }
085
086    static int globalId;
087
088    private static void outcall(int id) {
089        globalId = id;
090    }
091
092    @Test
093    public void run0() throws Throwable {
094        runTest("test", 0);
095    }
096
097}