Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.lir/src/com/oracle/graal/lir/CompositeValue.java @ 16094:c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Fri, 13 Jun 2014 11:47:44 +0200 |
parents | 5d5bfb75dae0 |
children | f315b1c0a590 |
rev | line source |
---|---|
8165 | 1 /* |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
11486
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
8165 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.graal.lir; | |
24 | |
25 import java.lang.annotation.*; | |
26 | |
27 import com.oracle.graal.api.meta.*; | |
11486
5d5bfb75dae0
added metrics for total number of Nodes, LIRInstructions and CompositeValues created (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents:
9640
diff
changeset
|
28 import com.oracle.graal.debug.*; |
8165 | 29 import com.oracle.graal.lir.LIRInstruction.OperandFlag; |
30 import com.oracle.graal.lir.LIRInstruction.OperandMode; | |
31 import com.oracle.graal.lir.LIRInstruction.ValueProcedure; | |
32 | |
33 /** | |
34 * Base class to represent values that need to be stored in more than one register. | |
35 */ | |
36 public abstract class CompositeValue extends Value { | |
37 | |
38 private static final long serialVersionUID = -169180052684126180L; | |
39 | |
40 @Retention(RetentionPolicy.RUNTIME) | |
41 @Target(ElementType.FIELD) | |
42 public static @interface Component { | |
43 | |
44 OperandFlag[] value() default OperandFlag.REG; | |
45 } | |
46 | |
47 private final CompositeValueClass valueClass; | |
48 | |
11486
5d5bfb75dae0
added metrics for total number of Nodes, LIRInstructions and CompositeValues created (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents:
9640
diff
changeset
|
49 private static final DebugMetric COMPOSITE_VALUE_COUNT = Debug.metric("CompositeValues"); |
5d5bfb75dae0
added metrics for total number of Nodes, LIRInstructions and CompositeValues created (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents:
9640
diff
changeset
|
50 |
16094
c0b8d395368b
Introduce LIRKind to accurately track oop references in backend.
Roland Schatz <roland.schatz@oracle.com>
parents:
11486
diff
changeset
|
51 public CompositeValue(LIRKind kind) { |
8165 | 52 super(kind); |
11486
5d5bfb75dae0
added metrics for total number of Nodes, LIRInstructions and CompositeValues created (GRAAL-448)
Doug Simon <doug.simon@oracle.com>
parents:
9640
diff
changeset
|
53 COMPOSITE_VALUE_COUNT.increment(); |
8165 | 54 valueClass = CompositeValueClass.get(getClass()); |
55 } | |
56 | |
57 public final void forEachComponent(OperandMode mode, ValueProcedure proc) { | |
58 valueClass.forEachComponent(this, mode, proc); | |
59 } | |
60 | |
61 @Override | |
62 public String toString() { | |
63 return valueClass.toString(this); | |
64 } | |
9631
3c9aeef2702c
Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents:
9422
diff
changeset
|
65 |
3c9aeef2702c
Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents:
9422
diff
changeset
|
66 @Override |
3c9aeef2702c
Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents:
9422
diff
changeset
|
67 public int hashCode() { |
9640
65d7696fb58a
Value: tidy up generated `hashCode()' and `equals()' methods a bit
Bernhard Urban <bernhard.urban@jku.at>
parents:
9631
diff
changeset
|
68 return 53 * super.hashCode() + valueClass.hashCode(); |
9631
3c9aeef2702c
Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents:
9422
diff
changeset
|
69 } |
3c9aeef2702c
Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents:
9422
diff
changeset
|
70 |
3c9aeef2702c
Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents:
9422
diff
changeset
|
71 @Override |
3c9aeef2702c
Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents:
9422
diff
changeset
|
72 public boolean equals(Object obj) { |
9640
65d7696fb58a
Value: tidy up generated `hashCode()' and `equals()' methods a bit
Bernhard Urban <bernhard.urban@jku.at>
parents:
9631
diff
changeset
|
73 if (obj instanceof CompositeValue) { |
65d7696fb58a
Value: tidy up generated `hashCode()' and `equals()' methods a bit
Bernhard Urban <bernhard.urban@jku.at>
parents:
9631
diff
changeset
|
74 CompositeValue other = (CompositeValue) obj; |
65d7696fb58a
Value: tidy up generated `hashCode()' and `equals()' methods a bit
Bernhard Urban <bernhard.urban@jku.at>
parents:
9631
diff
changeset
|
75 return super.equals(other) && valueClass.equals(other.valueClass); |
9631
3c9aeef2702c
Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents:
9422
diff
changeset
|
76 } |
9640
65d7696fb58a
Value: tidy up generated `hashCode()' and `equals()' methods a bit
Bernhard Urban <bernhard.urban@jku.at>
parents:
9631
diff
changeset
|
77 return false; |
9631
3c9aeef2702c
Value: provide proper `hashCode()' and `equals()' implementations
Bernhard Urban <bernhard.urban@jku.at>
parents:
9422
diff
changeset
|
78 } |
8165 | 79 } |