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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8165
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
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
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
4 *
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
8 *
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
13 * accompanied this code).
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
14 *
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
18 *
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
21 * questions.
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
22 */
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.lir;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
24
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
25 import java.lang.annotation.*;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
26
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
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
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
29 import com.oracle.graal.lir.LIRInstruction.OperandFlag;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
30 import com.oracle.graal.lir.LIRInstruction.OperandMode;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
31 import com.oracle.graal.lir.LIRInstruction.ValueProcedure;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
32
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
33 /**
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
34 * Base class to represent values that need to be stored in more than one register.
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
35 */
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
36 public abstract class CompositeValue extends Value {
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
37
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
38 private static final long serialVersionUID = -169180052684126180L;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
39
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
40 @Retention(RetentionPolicy.RUNTIME)
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
41 @Target(ElementType.FIELD)
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
42 public static @interface Component {
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
43
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
44 OperandFlag[] value() default OperandFlag.REG;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
45 }
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
46
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
47 private final CompositeValueClass valueClass;
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
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
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
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
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
54 valueClass = CompositeValueClass.get(getClass());
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
55 }
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
56
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
57 public final void forEachComponent(OperandMode mode, ValueProcedure proc) {
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
58 valueClass.forEachComponent(this, mode, proc);
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
59 }
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
60
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
61 @Override
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
62 public String toString() {
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
63 return valueClass.toString(this);
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
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
a85ef330ffe7 Composite value.
Roland Schatz <roland.schatz@oracle.com>
parents:
diff changeset
79 }