Mercurial > hg > graal-compiler
comparison test/compiler/EscapeAnalysis/Test8020215.java @ 11163:c90c698831d7
8020215: Different execution plan when using JIT vs interpreter
Summary: fix bytecode analyzer
Reviewed-by: twisti
author | kvn |
---|---|
date | Fri, 12 Jul 2013 14:01:37 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
11111:dec841e0c9aa | 11163:c90c698831d7 |
---|---|
1 /* | |
2 * Copyright (c) 2013, 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 * @test | |
26 * @bug 8020215 | |
27 * @summary Different execution plan when using JIT vs interpreter | |
28 * @run main Test8020215 | |
29 */ | |
30 | |
31 import java.util.ArrayList; | |
32 import java.util.List; | |
33 | |
34 public class Test8020215 { | |
35 public static class NamedObject { | |
36 public int id; | |
37 public String name; | |
38 public NamedObject(int id, String name) { | |
39 this.id = id; | |
40 this.name = name; | |
41 } | |
42 } | |
43 | |
44 public static class NamedObjectList { | |
45 public List<NamedObject> namedObjectList = new ArrayList<NamedObject>(); | |
46 | |
47 public NamedObject getBest(int id) { | |
48 NamedObject bestObject = null; | |
49 for (NamedObject o : namedObjectList) { | |
50 bestObject = id==o.id ? getBetter(bestObject, o) : bestObject; | |
51 } | |
52 return (bestObject != null) ? bestObject : null; | |
53 } | |
54 | |
55 private static NamedObject getBetter(NamedObject p1, NamedObject p2) { | |
56 return (p1 == null) ? p2 : (p2 == null) ? p1 : (p2.name.compareTo(p1.name) >= 0) ? p2 : p1; | |
57 } | |
58 } | |
59 | |
60 static void test(NamedObjectList b, int i) { | |
61 NamedObject x = b.getBest(2); | |
62 // test | |
63 if (x == null) { | |
64 throw new RuntimeException("x should never be null here! (i=" + i + ")"); | |
65 } | |
66 } | |
67 | |
68 public static void main(String[] args) { | |
69 // setup | |
70 NamedObjectList b = new NamedObjectList(); | |
71 for (int i = 0; i < 10000; i++) { | |
72 b.namedObjectList.add(new NamedObject(1, "2012-12-31")); | |
73 } | |
74 b.namedObjectList.add(new NamedObject(2, "2013-12-31")); | |
75 | |
76 // execution | |
77 for (int i = 0; i < 12000; i++) { | |
78 test(b, i); | |
79 } | |
80 System.out.println("PASSED"); | |
81 } | |
82 } |