Mercurial > hg > truffle
changeset 18508:f56a5c4cd859
Treat String.value as implicit stable field
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Tue, 25 Nov 2014 20:28:56 +0100 |
parents | c2b45b536677 |
children | 7bf2965140de |
files | graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java |
diffstat | 1 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java Tue Nov 25 20:26:59 2014 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaFieldImpl.java Tue Nov 25 20:28:56 2014 +0100 @@ -30,6 +30,7 @@ import java.lang.reflect.*; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.common.*; import com.oracle.graal.hotspot.*; /** @@ -180,6 +181,8 @@ if (isSyntheticImplicitStableField()) { return true; } + } else if (isWellKnownImplicitStableField()) { + return true; } return false; } @@ -198,4 +201,27 @@ } return false; } + + private boolean isWellKnownImplicitStableField() { + return WellKnownImplicitStableField.test(this); + } + + static class WellKnownImplicitStableField { + /** + * @return {@code true} if the field is a well-known stable field. + */ + public static boolean test(HotSpotResolvedJavaField field) { + return field == STRING_VALUE_FIELD; + } + + private static final ResolvedJavaField STRING_VALUE_FIELD; + static { + try { + MetaAccessProvider metaAccess = runtime().getHostProviders().getMetaAccess(); + STRING_VALUE_FIELD = metaAccess.lookupJavaField(String.class.getDeclaredField("value")); + } catch (SecurityException | NoSuchFieldException e) { + throw new GraalInternalError(e); + } + } + } }