comparison graal/com.oracle.graal.lir/src/com/oracle/graal/lir/CompositeValueClass.java @ 19526:8fc336a04d77

Create TYPE fields for LIRInstruction and CompositeValue. Renaming NodeClass#get to NodeClass#create.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Fri, 20 Feb 2015 22:22:55 +0100
parents d216de21bfe8
children a69a7c0e0ccc
comparison
equal deleted inserted replaced
19525:35481bcb5882 19526:8fc336a04d77
38 * such fields.</li> 38 * such fields.</li>
39 * </ul> 39 * </ul>
40 */ 40 */
41 public class CompositeValueClass<T> extends LIRIntrospection<T> { 41 public class CompositeValueClass<T> extends LIRIntrospection<T> {
42 42
43 @SuppressWarnings("unchecked") 43 public static final <T extends CompositeValue> CompositeValueClass<T> create(Class<T> c) {
44 public static final <T extends CompositeValue> CompositeValueClass<T> get(Class<T> c) { 44 return new CompositeValueClass<>(c);
45 CompositeValueClass<T> clazz = (CompositeValueClass<T>) allClasses.get(c);
46 if (clazz != null) {
47 return clazz;
48 }
49
50 // We can have a race of multiple threads creating the LIRInstructionClass at the same time.
51 // However, only one will be put into the map, and this is the one returned by all threads.
52 clazz = new CompositeValueClass<>(c);
53 CompositeValueClass<T> oldClazz = (CompositeValueClass<T>) allClasses.putIfAbsent(c, clazz);
54 if (oldClazz != null) {
55 return oldClazz;
56 } else {
57 return clazz;
58 }
59 } 45 }
60 46
61 public CompositeValueClass(Class<T> clazz) { 47 public CompositeValueClass(Class<T> clazz) {
62 this(clazz, new FieldsScanner.DefaultCalcOffset()); 48 this(clazz, new FieldsScanner.DefaultCalcOffset());
63 } 49 }