Mercurial > hg > truffle
changeset 18878:d0f34a3055cf
made AMD64HotSpotRegisterConfig.categorized stable across VM executions to support replay compilation
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 19 Jan 2015 14:46:21 +0100 |
parents | c446d00f2cdf |
children | ec7dcd210467 |
files | graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PlatformKind.java graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java |
diffstat | 3 files changed, 50 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java Sat Jan 17 11:26:18 2015 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/Kind.java Mon Jan 19 14:46:21 2015 +0100 @@ -70,6 +70,7 @@ private final boolean isStackInt; private final Class<?> primitiveJavaClass; private final Class<?> boxedJavaClass; + private final EnumKey key = new EnumKey(this); private Kind(char typeChar, String javaName, boolean isStackInt, Class<?> primitiveJavaClass, Class<?> boxedJavaClass) { this.typeChar = typeChar; @@ -95,6 +96,10 @@ return javaName; } + public Key getKey() { + return key; + } + /** * Checks whether this type is a Java primitive type. *
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PlatformKind.java Sat Jan 17 11:26:18 2015 +0100 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/PlatformKind.java Mon Jan 19 14:46:21 2015 +0100 @@ -22,6 +22,8 @@ */ package com.oracle.graal.api.meta; +import com.sun.javafx.collections.MappingChange.Map; + /** * Represents a platform-specific low-level type for values. */ @@ -31,6 +33,43 @@ JavaConstant getDefaultValue(); + public interface Key { + + } + + public class EnumKey implements Key { + @SuppressWarnings("rawtypes") private final Enum e; + + @SuppressWarnings("rawtypes") + public EnumKey(Enum e) { + this.e = e; + } + + @Override + public int hashCode() { + return e.ordinal() ^ e.name().hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof EnumKey) { + EnumKey that = (EnumKey) obj; + return this.e == that.e; + } + return false; + } + } + + /** + * Gets a value associated with this object that can be used as a stable key in a {@link Map}. + * The {@link Object#hashCode()} implementation of the returned value should be stable between + * VM executions. + */ + Key getKey(); + default int getVectorLength() { return 1; }
--- a/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Sat Jan 17 11:26:18 2015 +0100 +++ b/graal/com.oracle.graal.hotspot.amd64/src/com/oracle/graal/hotspot/amd64/AMD64HotSpotRegisterConfig.java Mon Jan 19 14:46:21 2015 +0100 @@ -52,7 +52,7 @@ private final boolean allAllocatableAreCallerSaved; - private final Map<PlatformKind, Register[]> categorized = new ConcurrentHashMap<>(); + private final Map<PlatformKind.Key, Register[]> categorized = new ConcurrentHashMap<>(); private final RegisterAttributes[] attributesMap; @@ -66,8 +66,10 @@ } public Register[] getAllocatableRegisters(PlatformKind kind) { - if (categorized.containsKey(kind)) { - return categorized.get(kind); + PlatformKind.Key key = kind.getKey(); + if (categorized.containsKey(key)) { + Register[] val = categorized.get(key); + return val; } ArrayList<Register> list = new ArrayList<>(); @@ -78,7 +80,7 @@ } Register[] ret = list.toArray(new Register[list.size()]); - categorized.put(kind, ret); + categorized.put(key, ret); return ret; }