< prev index next >

src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 20,43 **** * or visit www.oracle.com if you need additional information or have any * questions. */ package jdk.vm.ci.hotspot; ! import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.*; ! import static jdk.vm.ci.hotspot.HotSpotResolvedJavaFieldImpl.Options.*; ! import java.lang.annotation.*; ! import java.lang.reflect.*; ! import jdk.vm.ci.common.*; ! import jdk.vm.ci.meta.*; ! import jdk.vm.ci.options.*; /** * Represents a field in a HotSpot type. */ ! public class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField, HotSpotProxified { static class Options { //@formatter:off @Option(help = "Mark well-known stable fields as such.", type = OptionType.Debug) public static final OptionValue<Boolean> ImplicitStableValues = new OptionValue<>(true); --- 20,50 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ package jdk.vm.ci.hotspot; ! import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; ! import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; ! import java.lang.annotation.Annotation; ! import java.lang.reflect.Field; ! import jdk.vm.ci.common.JVMCIError; ! import jdk.vm.ci.meta.JavaType; ! import jdk.vm.ci.meta.LocationIdentity; ! import jdk.vm.ci.meta.MetaAccessProvider; ! import jdk.vm.ci.meta.ModifiersProvider; ! import jdk.vm.ci.meta.ResolvedJavaField; ! import jdk.vm.ci.meta.ResolvedJavaType; ! import jdk.vm.ci.options.Option; ! import jdk.vm.ci.options.OptionType; ! import jdk.vm.ci.options.OptionValue; /** * Represents a field in a HotSpot type. */ ! class HotSpotResolvedJavaFieldImpl implements HotSpotResolvedJavaField, HotSpotProxified { static class Options { //@formatter:off @Option(help = "Mark well-known stable fields as such.", type = OptionType.Debug) public static final OptionValue<Boolean> ImplicitStableValues = new OptionValue<>(true);
*** 89,99 **** public String toString() { return inner.getName(); } } ! public HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, String name, JavaType type, long offset, int modifiers) { this.holder = holder; this.name = name; this.type = type; assert offset != -1; assert offset == (int) offset : "offset larger than int"; --- 96,106 ---- public String toString() { return inner.getName(); } } ! HotSpotResolvedJavaFieldImpl(HotSpotResolvedObjectTypeImpl holder, String name, JavaType type, long offset, int modifiers) { this.holder = holder; this.name = name; this.type = type; assert offset != -1; assert offset == (int) offset : "offset larger than int";
*** 128,138 **** return modifiers & ModifiersProvider.jvmFieldModifiers(); } @Override public boolean isInternal() { ! return (modifiers & runtime().getConfig().jvmAccFieldInternal) != 0; } /** * Determines if a given object contains this field. * --- 135,145 ---- return modifiers & ModifiersProvider.jvmFieldModifiers(); } @Override public boolean isInternal() { ! return (modifiers & config().jvmAccFieldInternal) != 0; } /** * Determines if a given object contains this field. *
*** 181,204 **** return format("HotSpotField<%H.%n %t:") + offset + ">"; } @Override public boolean isSynthetic() { ! return (runtime().getConfig().syntheticFlag & modifiers) != 0; } /** * Checks if this field has the {@link Stable} annotation. * * @return true if field has {@link Stable} annotation, false otherwise */ public boolean isStable() { ! if ((runtime().getConfig().jvmAccFieldStable & modifiers) != 0) { return true; } assert getAnnotation(Stable.class) == null; ! if (ImplicitStableValues.getValue() && isImplicitStableField()) { return true; } return false; } --- 188,211 ---- return format("HotSpotField<%H.%n %t:") + offset + ">"; } @Override public boolean isSynthetic() { ! return (config().syntheticFlag & modifiers) != 0; } /** * Checks if this field has the {@link Stable} annotation. * * @return true if field has {@link Stable} annotation, false otherwise */ public boolean isStable() { ! if ((config().jvmAccFieldStable & modifiers) != 0) { return true; } assert getAnnotation(Stable.class) == null; ! if (Options.ImplicitStableValues.getValue() && isImplicitStableField()) { return true; } return false; }
*** 241,263 **** JavaType fieldType = getType(); return fieldType instanceof ResolvedJavaType && ((ResolvedJavaType) fieldType).isArray(); } private boolean isImplicitStableField() { ! if (isSynthetic()) { ! if (isSyntheticImplicitStableField()) { return true; } ! } else if (isWellKnownImplicitStableField()) { return true; } return false; } ! private boolean isSyntheticImplicitStableField() { ! assert this.isSynthetic(); ! if (isStatic() && isArray()) { if (isFinal() && name.equals("$VALUES") || name.equals("ENUM$VALUES")) { // generated int[] field for EnumClass::values() return true; } else if (name.startsWith("$SwitchMap$") || name.startsWith("$SWITCH_TABLE$")) { // javac and ecj generate a static field in an inner class for a switch on an enum --- 248,276 ---- JavaType fieldType = getType(); return fieldType instanceof ResolvedJavaType && ((ResolvedJavaType) fieldType).isArray(); } private boolean isImplicitStableField() { ! if (isSyntheticEnumSwitchMap()) { return true; } ! if (isWellKnownImplicitStableField()) { return true; } return false; } ! public boolean isDefaultStable() { ! assert this.isStable(); ! if (isSyntheticEnumSwitchMap()) { ! return true; ! } ! return false; ! } ! ! private boolean isSyntheticEnumSwitchMap() { ! if (isSynthetic() && isStatic() && isArray()) { if (isFinal() && name.equals("$VALUES") || name.equals("ENUM$VALUES")) { // generated int[] field for EnumClass::values() return true; } else if (name.startsWith("$SwitchMap$") || name.startsWith("$SWITCH_TABLE$")) { // javac and ecj generate a static field in an inner class for a switch on an enum
*** 279,288 **** --- 292,302 ---- public static boolean test(HotSpotResolvedJavaField field) { return field.equals(STRING_VALUE_FIELD); } private static final ResolvedJavaField STRING_VALUE_FIELD; + static { try { MetaAccessProvider metaAccess = runtime().getHostJVMCIBackend().getMetaAccess(); STRING_VALUE_FIELD = metaAccess.lookupJavaField(String.class.getDeclaredField("value")); } catch (SecurityException | NoSuchFieldException e) {
< prev index next >