annotate graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/Assumptions.java @ 21556:48c1ebd24120

renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
author Doug Simon <doug.simon@oracle.com>
date Wed, 27 May 2015 00:36:16 +0200
parents graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Assumptions.java@082417ac43e4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
21556
48c1ebd24120 renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21411
diff changeset
23 package com.oracle.jvmci.meta;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
8947
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
25 import java.lang.invoke.*;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26 import java.util.*;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 /**
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
29 * Class for recording assumptions made during compilation.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 */
21411
082417ac43e4 removed com.oracle.graal.hotspot.server and uses of Serializable it depended upon (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21368
diff changeset
31 public final class Assumptions implements Iterable<Assumptions.Assumption> {
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
32
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5711
diff changeset
33 /**
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
34 * Abstract base class for assumptions. An assumption assumes a property of the runtime that may
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
35 * be invalidated by subsequent execution (e.g., that a class has no subclasses implementing
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
36 * {@link NoFinalizableSubclass Object.finalize()}).
6329
92bc58dc5b5e More clean up and documentation in api.code and api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5711
diff changeset
37 */
21411
082417ac43e4 removed com.oracle.graal.hotspot.server and uses of Serializable it depended upon (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21368
diff changeset
38 public abstract static class Assumption {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40
19249
ec8402f4e00a introduced OptimisiticAssumption base class and improved javadoc in Assumptions API
Doug Simon <doug.simon@oracle.com>
parents: 18823
diff changeset
41 /**
19800
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
42 * A class for providing information that is only valid in association with a set of
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
43 * {@link Assumption}s.
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
44 *
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
45 * @param <T>
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
46 */
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
47 public static class AssumptionResult<T> {
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
48 Assumption[] assumptions;
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
49 final T result;
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
50
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
51 private static final Assumption[] EMPTY = new Assumption[0];
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
52
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
53 public AssumptionResult(T result, Assumption... assumptions) {
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
54 this.result = result;
20008
b47d7ebcfa4e Don't bother cloning assumptions array
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19801
diff changeset
55 this.assumptions = assumptions;
19800
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
56 }
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
57
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
58 public AssumptionResult(T result) {
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
59 this(result, EMPTY);
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
60 }
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
61
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
62 public T getResult() {
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
63 return result;
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
64 }
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
65
21368
d256b81b6335 Optimize assumption-free checks when compiling without optimistic optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20008
diff changeset
66 public boolean isAssumptionFree() {
d256b81b6335 Optimize assumption-free checks when compiling without optimistic optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20008
diff changeset
67 return assumptions.length == 0;
d256b81b6335 Optimize assumption-free checks when compiling without optimistic optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20008
diff changeset
68 }
d256b81b6335 Optimize assumption-free checks when compiling without optimistic optimizations
Christian Wimmer <christian.wimmer@oracle.com>
parents: 20008
diff changeset
69
19800
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
70 public void add(AssumptionResult<T> other) {
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
71 Assumption[] newAssumptions = Arrays.copyOf(this.assumptions, this.assumptions.length + other.assumptions.length);
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
72 System.arraycopy(other.assumptions, 0, newAssumptions, this.assumptions.length, other.assumptions.length);
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
73 this.assumptions = newAssumptions;
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
74 }
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
75 }
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
76
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
77 /**
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
78 * An assumption that a given class has no subclasses implementing {@link Object#finalize()}).
19249
ec8402f4e00a introduced OptimisiticAssumption base class and improved javadoc in Assumptions API
Doug Simon <doug.simon@oracle.com>
parents: 18823
diff changeset
79 */
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
80 public static final class NoFinalizableSubclass extends Assumption {
9012
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
81
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
82 private ResolvedJavaType receiverType;
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
83
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
84 public NoFinalizableSubclass(ResolvedJavaType receiverType) {
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
85 this.receiverType = receiverType;
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
86 }
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
87
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
88 @Override
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
89 public int hashCode() {
9125
5b25562f8bd7 assumptions: simplify hashCode()
Bernhard Urban <bernhard.urban@jku.at>
parents: 9012
diff changeset
90 return 31 + receiverType.hashCode();
9012
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
91 }
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
92
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
93 @Override
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
94 public boolean equals(Object obj) {
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
95 if (obj instanceof NoFinalizableSubclass) {
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
96 NoFinalizableSubclass other = (NoFinalizableSubclass) obj;
14158
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14157
diff changeset
97 return other.receiverType.equals(receiverType);
9012
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
98 }
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
99 return false;
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
100 }
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
101
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
102 @Override
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
103 public String toString() {
16479
558cf39c646b moved toJavaName(JavaType type) from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents: 16476
diff changeset
104 return "NoFinalizableSubclass[receiverType=" + receiverType.toJavaName() + "]";
9012
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
105 }
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
106
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
107 }
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
108
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109 /**
19801
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
110 * An assumption that a given abstract or interface type has one direct concrete subtype. There
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
111 * is no requirement that the subtype is a leaf type.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 */
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
113 public static final class ConcreteSubtype extends Assumption {
4670
41034914e2ee add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents: 4199
diff changeset
114
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
115 /**
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 * Type the assumption is made about.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 */
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
118 public final ResolvedJavaType context;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120 /**
19801
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
121 * Assumed concrete sub-type of the context type.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 */
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
123 public final ResolvedJavaType subtype;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
125 public ConcreteSubtype(ResolvedJavaType context, ResolvedJavaType subtype) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
126 this.context = context;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 this.subtype = subtype;
19801
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
128 assert context.isAbstract();
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
129 assert subtype.isConcrete() || context.isInterface() : subtype.toString() + " : " + context.toString();
16476
92f75d104b4b moved getElementalType() from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents: 15729
diff changeset
130 assert !subtype.isArray() || subtype.getElementalType().isFinal() : subtype.toString() + " : " + context.toString();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134 public int hashCode() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
135 final int prime = 31;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 int result = 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 result = prime * result + context.hashCode();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 result = prime * result + subtype.hashCode();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 public boolean equals(Object obj) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144 if (obj instanceof ConcreteSubtype) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 ConcreteSubtype other = (ConcreteSubtype) obj;
14158
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14157
diff changeset
146 return other.context.equals(context) && other.subtype.equals(subtype);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
148 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149 }
7086
902f60aa20cc added toString() implementation to Assumption classes
Doug Simon <doug.simon@oracle.com>
parents: 7064
diff changeset
150
902f60aa20cc added toString() implementation to Assumption classes
Doug Simon <doug.simon@oracle.com>
parents: 7064
diff changeset
151 @Override
902f60aa20cc added toString() implementation to Assumption classes
Doug Simon <doug.simon@oracle.com>
parents: 7064
diff changeset
152 public String toString() {
16479
558cf39c646b moved toJavaName(JavaType type) from MetaUtil to be a default method in JavaType
Doug Simon <doug.simon@oracle.com>
parents: 16476
diff changeset
153 return "ConcreteSubtype[context=" + context.toJavaName() + ", subtype=" + subtype.toJavaName() + "]";
7086
902f60aa20cc added toString() implementation to Assumption classes
Doug Simon <doug.simon@oracle.com>
parents: 7064
diff changeset
154 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157 /**
19801
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
158 * An assumption that a given type has no subtypes.
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
159 */
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
160 public static final class LeafType extends Assumption {
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
161
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
162 /**
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
163 * Type the assumption is made about.
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
164 */
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
165 public final ResolvedJavaType context;
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
166
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
167 public LeafType(ResolvedJavaType context) {
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
168 this.context = context;
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
169 }
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
170
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
171 @Override
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
172 public int hashCode() {
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
173 final int prime = 31;
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
174 int result = 1;
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
175 result = prime * result + context.hashCode();
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
176 return result;
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
177 }
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
178
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
179 @Override
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
180 public boolean equals(Object obj) {
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
181 if (obj instanceof LeafType) {
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
182 LeafType other = (LeafType) obj;
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
183 return other.context.equals(context);
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
184 }
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
185 return false;
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
186 }
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
187
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
188 @Override
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
189 public String toString() {
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
190 return "LeafSubtype[context=" + context.toJavaName() + "]";
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
191 }
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
192 }
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
193
deab43a789ad Split LeafType off from ConcreteSubtype
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19800
diff changeset
194 /**
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
195 * An assumption that a given virtual method has a given unique implementation.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 */
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
197 public static final class ConcreteMethod extends Assumption {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
198
4142
bc8527f3071c Adjust code base to new level of warnings.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3733
diff changeset
199 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7223
diff changeset
200 * A virtual (or interface) method whose unique implementation for the receiver type in
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7223
diff changeset
201 * {@link #context} is {@link #impl}.
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
202 */
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
203 public final ResolvedJavaMethod method;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
204
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
205 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206 * A receiver type.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
207 */
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
208 public final ResolvedJavaType context;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
209
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 * The unique implementation of {@link #method} for {@link #context}.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
212 */
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
213 public final ResolvedJavaMethod impl;
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
214
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
215 public ConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType context, ResolvedJavaMethod impl) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 this.method = method;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
217 this.context = context;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
218 this.impl = impl;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
219 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
220
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
222 public int hashCode() {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223 final int prime = 31;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
224 int result = 1;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
225 result = prime * result + method.hashCode();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
226 result = prime * result + context.hashCode();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
227 result = prime * result + impl.hashCode();
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228 return result;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
231 @Override
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232 public boolean equals(Object obj) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
233 if (obj instanceof ConcreteMethod) {
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
234 ConcreteMethod other = (ConcreteMethod) obj;
14158
fd7fcd2d2072 replaced == with .equals() for comparisons between JavaMethod/JavaField/JavaType values
Doug Simon <doug.simon@oracle.com>
parents: 14157
diff changeset
235 return other.method.equals(method) && other.context.equals(context) && other.impl.equals(impl);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
236 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237 return false;
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238 }
7086
902f60aa20cc added toString() implementation to Assumption classes
Doug Simon <doug.simon@oracle.com>
parents: 7064
diff changeset
239
902f60aa20cc added toString() implementation to Assumption classes
Doug Simon <doug.simon@oracle.com>
parents: 7064
diff changeset
240 @Override
902f60aa20cc added toString() implementation to Assumption classes
Doug Simon <doug.simon@oracle.com>
parents: 7064
diff changeset
241 public String toString() {
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19249
diff changeset
242 return "ConcreteMethod[method=" + method.format("%H.%n(%p)%r") + ", context=" + context.toJavaName() + ", impl=" + impl.format("%H.%n(%p)%r") + "]";
7086
902f60aa20cc added toString() implementation to Assumption classes
Doug Simon <doug.simon@oracle.com>
parents: 7064
diff changeset
243 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246 /**
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
247 * An assumption that a given call site's method handle did not change.
4670
41034914e2ee add MethodContents assumption to fix debbugging issue
Lukas Stadler <lukas.stadler@jku.at>
parents: 4199
diff changeset
248 */
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
249 public static final class CallSiteTargetValue extends Assumption {
8947
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
250
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
251 public final CallSite callSite;
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
252 public final MethodHandle methodHandle;
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
253
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
254 public CallSiteTargetValue(CallSite callSite, MethodHandle methodHandle) {
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
255 this.callSite = callSite;
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
256 this.methodHandle = methodHandle;
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
257 }
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
258
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
259 @Override
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
260 public int hashCode() {
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
261 final int prime = 31;
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
262 int result = 1;
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
263 result = prime * result + callSite.hashCode();
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
264 result = prime * result + methodHandle.hashCode();
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
265 return result;
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
266 }
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
267
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
268 @Override
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
269 public boolean equals(Object obj) {
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
270 if (obj instanceof CallSiteTargetValue) {
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
271 CallSiteTargetValue other = (CallSiteTargetValue) obj;
18342
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
272 return callSite.equals(other.callSite) && methodHandle.equals(other.methodHandle);
8947
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
273 }
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
274 return false;
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
275 }
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
276
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
277 @Override
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
278 public String toString() {
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
279 return "CallSiteTargetValue[callSite=" + callSite + ", methodHandle=" + methodHandle + "]";
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
280 }
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
281 }
707b20dd9512 draft call site target value assumption
Andreas Woess <andreas.woess@jku.at>
parents: 7645
diff changeset
282
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
283 private final Set<Assumption> assumptions = new HashSet<>();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
285 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286 * Returns whether any assumptions have been registered.
15729
59a85df7a418 Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14158
diff changeset
287 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
288 * @return {@code true} if at least one assumption has been registered, {@code false} otherwise.
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
289 */
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
290 public boolean isEmpty() {
19252
f91bf352023a replaced use of expandable array with HashSet for recording assumptions
Doug Simon <doug.simon@oracle.com>
parents: 19251
diff changeset
291 return assumptions.isEmpty();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
292 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
293
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
294 @Override
18342
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
295 public int hashCode() {
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
296 throw new UnsupportedOperationException("hashCode");
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
297 }
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
298
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
299 @Override
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
300 public boolean equals(Object obj) {
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
301 if (this == obj) {
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
302 return true;
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
303 }
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
304 if (obj instanceof Assumptions) {
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
305 Assumptions that = (Assumptions) obj;
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
306 if (!this.assumptions.equals(that.assumptions)) {
18342
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
307 return false;
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
308 }
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
309 return true;
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
310 }
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
311 return false;
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
312 }
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
313
d60dd21329f2 implemented .equals() for CompilationResult and the objects it encapsulates
Doug Simon <doug.simon@oracle.com>
parents: 16480
diff changeset
314 @Override
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
315 public Iterator<Assumption> iterator() {
19252
f91bf352023a replaced use of expandable array with HashSet for recording assumptions
Doug Simon <doug.simon@oracle.com>
parents: 19251
diff changeset
316 return assumptions.iterator();
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
317 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
318
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320 * Records an assumption that the specified type has no finalizable subclasses.
15729
59a85df7a418 Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14158
diff changeset
321 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
322 * @param receiverType the type that is assumed to have no finalizable subclasses
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
323 */
9012
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
324 public void recordNoFinalizableSubclassAssumption(ResolvedJavaType receiverType) {
2979aaac95af assumptions: enable NoFinalizableSubclass assumption
Bernhard Urban <bernhard.urban@jku.at>
parents: 8947
diff changeset
325 record(new NoFinalizableSubclass(receiverType));
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
326 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
327
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
328 /**
7530
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7223
diff changeset
329 * Records that {@code subtype} is the only concrete subtype in the class hierarchy below
5e3d1a68664e applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents: 7223
diff changeset
330 * {@code context}.
15729
59a85df7a418 Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14158
diff changeset
331 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
332 * @param context the root of the subtree of the class hierarchy that this assumptions is about
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
333 * @param subtype the one concrete subtype
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
334 */
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
335 public void recordConcreteSubtype(ResolvedJavaType context, ResolvedJavaType subtype) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
336 record(new ConcreteSubtype(context, subtype));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
337 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
338
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
339 /**
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
340 * Records that {@code impl} is the only possible concrete target for a virtual call to
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
341 * {@code method} with a receiver of type {@code context}.
15729
59a85df7a418 Add some assertions and tests to TestResolvedJavaType.findUniqueConcreteSubtypeTest
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 14158
diff changeset
342 *
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
343 * @param method a method that is the target of a virtual call
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
344 * @param context the receiver type of a call to {@code method}
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
345 * @param impl the concrete method that is the only possible target for the virtual call
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
346 */
5541
b4c406861c33 More renamings to drop Ri* prefix completely. Deleted graph.BitMap class and replaced with java.util.BitSet.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5510
diff changeset
347 public void recordConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType context, ResolvedJavaMethod impl) {
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
348 record(new ConcreteMethod(method, context, impl));
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
349 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
350
19800
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
351 public void record(AssumptionResult<?> result) {
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
352 for (Assumption assumption : result.assumptions) {
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
353 record(assumption);
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
354 }
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
355 }
3362ba500371 Connect required Assumptions with answer to CHA query
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 19306
diff changeset
356
7223
e2ea829fafd9 use CHA more frequently for inlining
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220
diff changeset
357 public void record(Assumption assumption) {
19252
f91bf352023a replaced use of expandable array with HashSet for recording assumptions
Doug Simon <doug.simon@oracle.com>
parents: 19251
diff changeset
358 assumptions.add(assumption);
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
359 }
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
360
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19249
diff changeset
361 /**
19251
063e8873bd14 changed type of assumptions field in CompilationResult from Assumptions to Assumption[]
Doug Simon <doug.simon@oracle.com>
parents: 19250
diff changeset
362 * Gets a copy of the assumptions recorded in this object as an array.
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19249
diff changeset
363 */
19255
131fb3dd493b removed unnecessary use of an Assumptions object
Doug Simon <doug.simon@oracle.com>
parents: 19252
diff changeset
364 public Assumption[] toArray() {
19252
f91bf352023a replaced use of expandable array with HashSet for recording assumptions
Doug Simon <doug.simon@oracle.com>
parents: 19251
diff changeset
365 return assumptions.toArray(new Assumption[assumptions.size()]);
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19249
diff changeset
366 }
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19249
diff changeset
367
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19249
diff changeset
368 /**
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19249
diff changeset
369 * Copies assumptions recorded by another {@link Assumptions} object into this object.
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19249
diff changeset
370 */
19252
f91bf352023a replaced use of expandable array with HashSet for recording assumptions
Doug Simon <doug.simon@oracle.com>
parents: 19251
diff changeset
371 public void record(Assumptions other) {
f91bf352023a replaced use of expandable array with HashSet for recording assumptions
Doug Simon <doug.simon@oracle.com>
parents: 19251
diff changeset
372 assert other != this;
f91bf352023a replaced use of expandable array with HashSet for recording assumptions
Doug Simon <doug.simon@oracle.com>
parents: 19251
diff changeset
373 assumptions.addAll(other.assumptions);
9699
9529ab567367 Drafted version of an inlining policy that uses the callee graph size as its metric.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 9125
diff changeset
374 }
10611
1546866ebb8d First draft of Truffle graph caching.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9841
diff changeset
375
19250
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19249
diff changeset
376 @Override
8ab925a6f724 made Assumptions be part of a StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19249
diff changeset
377 public String toString() {
19306
a0a760b0fb5f pulled method evolution dependencies out of Assumptions and directly into StructuredGraph
Doug Simon <doug.simon@oracle.com>
parents: 19255
diff changeset
378 return "Assumptions[" + assumptions + "]";
10611
1546866ebb8d First draft of Truffle graph caching.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 9841
diff changeset
379 }
3733
e233f5660da4 Added Java files from Maxine project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
380 }