Mercurial > hg > truffle
annotate graal/com.oracle.jvmci.meta/src/com/oracle/jvmci/meta/LIRKind.java @ 21610:f555efead2f2
Fix options in makefile
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Fri, 29 May 2015 20:43:55 -0700 |
parents | 48c1ebd24120 |
children |
rev | line source |
---|---|
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
1 /* |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
4 * |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
8 * |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
14 * |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
18 * |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
21 * questions. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@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:
21444
diff
changeset
|
23 package com.oracle.jvmci.meta; |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
24 |
21444
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
25 import java.util.*; |
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
26 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
27 /** |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
28 * Represents the type of values in the LIR. It is composed of a {@link PlatformKind} that gives the |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
29 * low level representation of the value, and a {@link #referenceMask} that describes the location |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
30 * of object references in the value. |
16347
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
31 * |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
32 * <h2>Constructing {@link LIRKind} instances</h2> |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
33 * |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
34 * During LIR generation, every new {@link Value} should get a {@link LIRKind} of the correct |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
35 * {@link PlatformKind} that also contains the correct reference information. {@linkplain LIRKind |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
36 * LIRKinds} should be created as follows: |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
37 * |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
38 * <p> |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
39 * If the result value is created from one or more input values, the {@link LIRKind} should be |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
40 * created with {@link LIRKind#derive}(inputs). If the result has a different {@link PlatformKind} |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
41 * than the inputs, {@link LIRKind#derive}(inputs).{@link #changeType}(resultKind) should be used. |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
42 * <p> |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
43 * If the result is an exact copy of one of the inputs, {@link Value#getLIRKind()} can be used. Note |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
44 * that this is only correct for move-like operations, like conditional move or compare-and-swap. |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
45 * For convert operations, {@link LIRKind#derive} should be used. |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
46 * <p> |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
47 * If it is known that the result will be a reference (e.g. pointer arithmetic where the end result |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
48 * is a valid oop), {@link LIRKind#reference} should be used. |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
49 * <p> |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
50 * If it is known that the result will neither be a reference nor be derived from a reference, |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
51 * {@link LIRKind#value} can be used. If the operation producing this value has inputs, this is very |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
52 * likely wrong, and {@link LIRKind#derive} should be used instead. |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
53 * <p> |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
54 * If it is known that the result is derived from a reference, {@link LIRKind#derivedReference} can |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
55 * be used. In most cases, {@link LIRKind#derive} should be used instead, since it is able to detect |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
56 * this automatically. |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
57 */ |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
58 public final class LIRKind { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
59 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
60 /** |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
61 * The non-type. This uses {@link #derivedReference}, so it can never be part of an oop map. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
62 */ |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
63 public static final LIRKind Illegal = derivedReference(Kind.Illegal); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
64 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
65 private final PlatformKind platformKind; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
66 private final int referenceMask; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
67 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
68 private static final int DERIVED_REFERENCE = -1; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
69 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
70 private LIRKind(PlatformKind platformKind, int referenceMask) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
71 this.platformKind = platformKind; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
72 this.referenceMask = referenceMask; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
73 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
74 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
75 /** |
16347
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
76 * Create a {@link LIRKind} of type {@code platformKind} that contains a primitive value. Should |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
77 * be only used when it's guaranteed that the value is not even indirectly derived from a |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
78 * reference. Otherwise, {@link #derive(Value...)} should be used instead. |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
79 */ |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
80 public static LIRKind value(PlatformKind platformKind) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
81 assert platformKind != Kind.Object : "Object should always be used as reference type"; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
82 return new LIRKind(platformKind, 0); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
83 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
84 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
85 /** |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
86 * Create a {@link LIRKind} of type {@code platformKind} that contains a single tracked oop |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
87 * reference. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
88 */ |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
89 public static LIRKind reference(PlatformKind platformKind) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
90 int length = platformKind.getVectorLength(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
91 assert 0 < length && length < 32 : "vector of " + length + " references not supported"; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
92 return new LIRKind(platformKind, (1 << length) - 1); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
93 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
94 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
95 /** |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
96 * Create a {@link LIRKind} of type {@code platformKind} that contains a value that is derived |
16347
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
97 * from a reference. Values of this {@link LIRKind} can not be live at safepoints. In most |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
98 * cases, this should not be called directly. {@link #derive} should be used instead to |
c6a1215d025b
Improve documentation of LIRKind.
Roland Schatz <roland.schatz@oracle.com>
parents:
16346
diff
changeset
|
99 * automatically propagate this information. |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
100 */ |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
101 public static LIRKind derivedReference(PlatformKind platformKind) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
102 return new LIRKind(platformKind, DERIVED_REFERENCE); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
103 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
104 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
105 /** |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
106 * Derive a new type from inputs. The result will have the {@link PlatformKind} of one of the |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
107 * inputs. If all inputs are values, the result is a value. Otherwise, the result is a derived |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
108 * reference. |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
109 * |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
110 * This method should be used to construct the result {@link LIRKind} of any operation that |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
111 * modifies values (e.g. arithmetics). |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
112 */ |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
113 public static LIRKind derive(Value... inputs) { |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
114 assert inputs.length > 0; |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
115 for (Value input : inputs) { |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
116 LIRKind kind = input.getLIRKind(); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
117 if (kind.isDerivedReference()) { |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
118 return kind; |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
119 } else if (!kind.isValue()) { |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
120 return kind.makeDerivedReference(); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
121 } |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
122 } |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
123 |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
124 // all inputs are values, just return one of them |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
125 return inputs[0].getLIRKind(); |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
126 } |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
127 |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
128 /** |
21195 | 129 * Merge the types of the inputs. The result will have the {@link PlatformKind} of one of the |
130 * inputs. If all inputs are values (references), the result is a value (reference). Otherwise, | |
131 * the result is a derived reference. | |
132 * | |
133 * This method should be used to construct the result {@link LIRKind} of merge operation that do | |
134 * not modify values (e.g. phis). | |
135 */ | |
136 public static LIRKind merge(Value... inputs) { | |
137 assert inputs.length > 0; | |
21444
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
138 ArrayList<LIRKind> kinds = new ArrayList<>(inputs.length); |
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
139 for (int i = 0; i < inputs.length; i++) { |
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
140 kinds.add(inputs[i].getLIRKind()); |
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
141 } |
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
142 return merge(kinds); |
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
143 } |
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
144 |
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
145 /** |
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
146 * @see #merge(Value...) |
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
147 */ |
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
148 public static LIRKind merge(Iterable<LIRKind> kinds) { |
21309
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
149 LIRKind mergeKind = null; |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
150 |
21444
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
151 for (LIRKind kind : kinds) { |
21309
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
152 |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
153 assert mergeKind == null || verifyMoveKinds(mergeKind, kind) : String.format("Input kinds do not match %s vs. %s", mergeKind, kind); |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
154 |
21195 | 155 if (kind.isDerivedReference()) { |
21309
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
156 /** |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
157 * Kind is a derived reference therefore the result can only be also a derived |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
158 * reference. |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
159 */ |
21195 | 160 return kind; |
161 } | |
21309
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
162 if (mergeKind == null) { |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
163 mergeKind = kind; |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
164 continue; |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
165 } |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
166 |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
167 if (kind.isValue()) { |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
168 /* Kind is a value. */ |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
169 if (mergeKind.referenceMask != 0) { |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
170 /* |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
171 * Inputs consists of values and references. Make the result a derived |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
172 * reference. |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
173 */ |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
174 return mergeKind.makeDerivedReference(); |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
175 } |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
176 /* Check that other inputs are also values. */ |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
177 } else { |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
178 /* Kind is a reference. */ |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
179 if (mergeKind.referenceMask != kind.referenceMask) { |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
180 /* |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
181 * Reference maps do not match so the result can only be a derived reference. |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
182 */ |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
183 return mergeKind.makeDerivedReference(); |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
184 } |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
185 } |
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
186 |
21195 | 187 } |
21444
0ad4c6aa8063
LIRKind: add merge(Iterable<LIRKind>).
Josef Eisl <josef.eisl@jku.at>
parents:
21309
diff
changeset
|
188 assert mergeKind != null; |
21195 | 189 |
190 // all inputs are values or references, just return one of them | |
21309
0217a8e00642
LIRKind#merge: be more precise about references.
Josef Eisl <josef.eisl@jku.at>
parents:
21306
diff
changeset
|
191 return mergeKind; |
21195 | 192 } |
193 | |
194 /** | |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
195 * Create a new {@link LIRKind} with the same reference information and a new |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
196 * {@linkplain #getPlatformKind platform kind}. If the new kind is a longer vector than this, |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
197 * the new elements are marked as untracked values. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
198 */ |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
199 public LIRKind changeType(PlatformKind newPlatformKind) { |
16346
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
200 if (newPlatformKind == platformKind) { |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
201 return this; |
bbf051d717f5
Propagate reference information through arithmetics.
Roland Schatz <roland.schatz@oracle.com>
parents:
16094
diff
changeset
|
202 } else if (isDerivedReference()) { |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
203 return derivedReference(newPlatformKind); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
204 } else if (referenceMask == 0) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
205 // value type |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
206 return new LIRKind(newPlatformKind, 0); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
207 } else { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
208 // reference type |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
209 int newLength = Math.min(32, newPlatformKind.getVectorLength()); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
210 int newReferenceMask = referenceMask & (0xFFFFFFFF >>> (32 - newLength)); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
211 assert newReferenceMask != DERIVED_REFERENCE; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
212 return new LIRKind(newPlatformKind, newReferenceMask); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
213 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
214 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
215 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
216 /** |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
217 * Create a new {@link LIRKind} with a new {@linkplain #getPlatformKind platform kind}. If the |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
218 * new kind is longer than this, the reference positions are repeated to fill the vector. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
219 */ |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
220 public LIRKind repeat(PlatformKind newPlatformKind) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
221 if (isDerivedReference()) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
222 return derivedReference(newPlatformKind); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
223 } else if (referenceMask == 0) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
224 // value type |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
225 return new LIRKind(newPlatformKind, 0); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
226 } else { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
227 // reference type |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
228 int oldLength = platformKind.getVectorLength(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
229 int newLength = newPlatformKind.getVectorLength(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
230 assert oldLength <= newLength && newLength < 32 && (newLength % oldLength) == 0; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
231 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
232 // repeat reference mask to fill new kind |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
233 int newReferenceMask = 0; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
234 for (int i = 0; i < newLength; i += platformKind.getVectorLength()) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
235 newReferenceMask |= referenceMask << i; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
236 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
237 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
238 assert newReferenceMask != DERIVED_REFERENCE; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
239 return new LIRKind(newPlatformKind, newReferenceMask); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
240 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
241 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
242 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
243 /** |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
244 * Create a new {@link LIRKind} with the same type, but marked as containing a derivedReference. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
245 */ |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
246 public LIRKind makeDerivedReference() { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
247 return new LIRKind(platformKind, DERIVED_REFERENCE); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
248 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
249 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
250 /** |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
251 * Get the low level type that is used in code generation. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
252 */ |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
253 public PlatformKind getPlatformKind() { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
254 return platformKind; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
255 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
256 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
257 /** |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
258 * Check whether this value is derived from a reference. If this returns {@code true}, this |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
259 * value must not be live at safepoints. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
260 */ |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
261 public boolean isDerivedReference() { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
262 return referenceMask == DERIVED_REFERENCE; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
263 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
264 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
265 /** |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
266 * Check whether the {@code idx}th part of this value is a reference that must be tracked at |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
267 * safepoints. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
268 * |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
269 * @param idx The index into the vector if this is a vector kind. Must be 0 if this is a scalar |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
270 * kind. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
271 */ |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
272 public boolean isReference(int idx) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
273 assert 0 <= idx && idx < platformKind.getVectorLength() : "invalid index " + idx + " in " + this; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
274 return !isDerivedReference() && (referenceMask & 1 << idx) != 0; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
275 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
276 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
277 /** |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
278 * Check whether this kind is a value type that doesn't need to be tracked at safepoints. |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
279 */ |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
280 public boolean isValue() { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
281 return referenceMask == 0; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
282 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
283 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
284 @Override |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
285 public String toString() { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
286 if (isValue()) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
287 return platformKind.name(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
288 } else if (isDerivedReference()) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
289 return platformKind.name() + "[*]"; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
290 } else { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
291 StringBuilder ret = new StringBuilder(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
292 ret.append(platformKind.name()); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
293 ret.append('['); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
294 for (int i = 0; i < platformKind.getVectorLength(); i++) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
295 if (isReference(i)) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
296 ret.append('.'); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
297 } else { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
298 ret.append(' '); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
299 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
300 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
301 ret.append(']'); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
302 return ret.toString(); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
303 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
304 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
305 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
306 @Override |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
307 public int hashCode() { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
308 final int prime = 31; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
309 int result = 1; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
310 result = prime * result + ((platformKind == null) ? 0 : platformKind.hashCode()); |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
311 result = prime * result + referenceMask; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
312 return result; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
313 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
314 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
315 @Override |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
316 public boolean equals(Object obj) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
317 if (this == obj) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
318 return true; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
319 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
320 if (!(obj instanceof LIRKind)) { |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
321 return false; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
322 } |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
323 |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
324 LIRKind other = (LIRKind) obj; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
325 return platformKind == other.platformKind && referenceMask == other.referenceMask; |
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff
changeset
|
326 } |
21305
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
327 |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
328 public static boolean verifyMoveKinds(LIRKind dst, LIRKind src) { |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
329 if (src.equals(dst)) { |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
330 return true; |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
331 } |
21306
335374eed0da
LIRKind#verifyMoveKinds: relax stack kind comparison.
Josef Eisl <josef.eisl@jku.at>
parents:
21305
diff
changeset
|
332 /* |
335374eed0da
LIRKind#verifyMoveKinds: relax stack kind comparison.
Josef Eisl <josef.eisl@jku.at>
parents:
21305
diff
changeset
|
333 * TODO(je,rs) What we actually want is toStackKind(src.getPlatformKind()).equals( |
335374eed0da
LIRKind#verifyMoveKinds: relax stack kind comparison.
Josef Eisl <josef.eisl@jku.at>
parents:
21305
diff
changeset
|
334 * dst.getPlatformKind()) but due to the handling of sub-integer at the current point |
335374eed0da
LIRKind#verifyMoveKinds: relax stack kind comparison.
Josef Eisl <josef.eisl@jku.at>
parents:
21305
diff
changeset
|
335 * (phi-)moves from e.g. integer to short can happen. Therefore we compare stack kinds. |
335374eed0da
LIRKind#verifyMoveKinds: relax stack kind comparison.
Josef Eisl <josef.eisl@jku.at>
parents:
21305
diff
changeset
|
336 */ |
335374eed0da
LIRKind#verifyMoveKinds: relax stack kind comparison.
Josef Eisl <josef.eisl@jku.at>
parents:
21305
diff
changeset
|
337 if (toStackKind(src.getPlatformKind()).equals(toStackKind(dst.getPlatformKind()))) { |
21305
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
338 return !src.isDerivedReference() || dst.isDerivedReference(); |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
339 } |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
340 return false; |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
341 } |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
342 |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
343 private static PlatformKind toStackKind(PlatformKind platformKind) { |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
344 if (platformKind instanceof Kind) { |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
345 return ((Kind) platformKind).getStackKind(); |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
346 } |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
347 return platformKind; |
951ecb5473c3
LIRKind: add verifyMoveKinds.
Josef Eisl <josef.eisl@jku.at>
parents:
21195
diff
changeset
|
348 } |
18163
c88ab4f1f04a
re-enabled Checkstyle with the release of 6.0 that supports Java 8; fixed existing Checkstyle warnings
Doug Simon <doug.simon@oracle.com>
parents:
16347
diff
changeset
|
349 } |