Mercurial > hg > truffle
annotate test/compiler/types/correctness/scenarios/Scenario.java @ 20698:57490e455c30
Merge
author | lana |
---|---|
date | Thu, 11 Dec 2014 13:39:41 -0800 |
parents | 534fbe3d90f0 |
children |
rev | line source |
---|---|
17881
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
1 /* |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
4 * |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
8 * |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
13 * accompanied this code). |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
14 * |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
18 * |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
21 * questions. |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
22 */ |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
23 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
24 package scenarios; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
25 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
26 import hierarchies.TypeHierarchy; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
27 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
28 /** |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
29 * Test scenario |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
30 * |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
31 * @param <T> parameter type |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
32 * @param <R> result type |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
33 */ |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
34 public abstract class Scenario<T extends TypeHierarchy.I, R> { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
35 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
36 private final String name; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
37 public final ProfilingType profilingType; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
38 public final TypeHierarchy <? extends T, ? extends T> hierarchy; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
39 protected volatile T field; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
40 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
41 /** |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
42 * Constructor |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
43 * |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
44 * @param name scenario name |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
45 * @param profilingType tested profiling type |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
46 * @param hierarchy type hierarchy |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
47 */ |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
48 protected Scenario(String name, ProfilingType profilingType, |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
49 TypeHierarchy<? extends T, ? extends T> hierarchy) { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
50 this.profilingType = profilingType; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
51 this.name = name + " # " + profilingType.name(); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
52 this.hierarchy = hierarchy; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
53 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
54 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
55 /** |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
56 * Returns the object which should be used as a parameter |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
57 * for the methods used for profile data |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
58 * |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
59 * @return profiled type object |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
60 */ |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
61 public T getProfiled() { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
62 return hierarchy.getM(); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
63 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
64 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
65 /** |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
66 * Returns the object which makes a conflict for a profiled data |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
67 * when passed instead of {@linkplain Scenario#getProfiled} |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
68 * |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
69 * @return incompatible to profiled object |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
70 */ |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
71 public T getConflict() { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
72 return hierarchy.getN(); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
73 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
74 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
75 /** |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
76 * @return scenario name |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
77 */ |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
78 public String getName() { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
79 return name; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
80 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
81 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
82 /** Is this scenario applicable for a hierarchy it was constructed with */ |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
83 public boolean isApplicable() { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
84 return true; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
85 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
86 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
87 /** |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
88 * Runs test scenario |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
89 * |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
90 * @param t subject of the test |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
91 * @return result of the test invocation |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
92 */ |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
93 public abstract R run(T t); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
94 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
95 /** Used for a return type profiling */ |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
96 protected final T collectReturnType(T t) { |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
97 return t; |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
98 } |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
99 |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
100 /** |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
101 * Checks the result for R and T |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
102 * |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
103 * @param r result |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
104 * @param t original |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
105 * @throws java.lang.RuntimeException on result mismatch |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
106 */ |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
107 public abstract void check(R r, T t); |
534fbe3d90f0
8038418: New tests development for type profiling and speculation
iignatyev
parents:
diff
changeset
|
108 } |