Mercurial > hg > graal-compiler
diff c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java @ 2057:89bf01e6b049
Treat C1XOptions fields as final.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Fri, 14 Jan 2011 16:29:42 +0100 |
parents | 99ad52189524 |
children | f21664b3dd1c 569d3fe7d65c |
line wrap: on
line diff
--- a/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java Fri Jan 14 13:22:50 2011 +0100 +++ b/c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java Fri Jan 14 16:29:42 2011 +0100 @@ -21,6 +21,9 @@ package com.sun.hotspot.c1x; +import java.lang.reflect.*; + +import com.sun.c1x.*; import com.sun.cri.ci.CiConstant; import com.sun.cri.ci.CiKind; import com.sun.cri.ri.RiField; @@ -55,6 +58,30 @@ @Override public CiConstant constantValue(Object object) { if (object == null) { + if (constant == null && holder.isResolved() && holder.javaClass() == C1XOptions.class) { + Field f; + try { + f = C1XOptions.class.getField(name); + } catch (SecurityException e1) { + return null; + } catch (NoSuchFieldException e1) { + return null; + } + f.setAccessible(true); + if (Modifier.isStatic(f.getModifiers())) { + CiKind kind = CiKind.fromJavaClass(f.getType()); + Object value; + try { + value = f.get(null); + } catch (IllegalArgumentException e) { + return null; + } catch (IllegalAccessException e) { + return null; + } + constant = CiConstant.forBoxed(kind, value); + } + } + // Constant part only valid for static fields. return constant; }