本文整理匯總了Java中jdk.vm.ci.hotspot.HotSpotResolvedJavaField類的典型用法代碼示例。如果您正苦於以下問題:Java HotSpotResolvedJavaField類的具體用法?Java HotSpotResolvedJavaField怎麽用?Java HotSpotResolvedJavaField使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HotSpotResolvedJavaField類屬於jdk.vm.ci.hotspot包,在下文中一共展示了HotSpotResolvedJavaField類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testEquivalenceForInternalFields
import jdk.vm.ci.hotspot.HotSpotResolvedJavaField; //導入依賴的package包/類
/**
* Tests that {@code HotSpotResolvedObjectType#createField(String, JavaType, long, int)} always
* returns an {@linkplain ResolvedJavaField#equals(Object) equivalent} object for an internal
* field.
*
* @throws InvocationTargetException
* @throws IllegalArgumentException
* @throws IllegalAccessException
*/
@Test
public void testEquivalenceForInternalFields() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
for (Class<?> c : classesWithInternalFields) {
HotSpotResolvedObjectType type = HotSpotResolvedObjectType.fromObjectClass(c);
for (ResolvedJavaField field : type.getInstanceFields(false)) {
if (field.isInternal()) {
HotSpotResolvedJavaField expected = (HotSpotResolvedJavaField) field;
int index = indexField.getInt(expected);
ResolvedJavaField actual = (ResolvedJavaField) createFieldMethod.invoke(type, expected.getType(), expected.offset(), expected.getModifiers(), index);
Assert.assertEquals(expected, actual);
}
}
}
}
示例2: testIsInObject
import jdk.vm.ci.hotspot.HotSpotResolvedJavaField; //導入依賴的package包/類
@Test
public void testIsInObject() {
for (Field f : String.class.getDeclaredFields()) {
HotSpotResolvedJavaField rf = (HotSpotResolvedJavaField) getMetaAccess().lookupJavaField(f);
Assert.assertEquals(rf.toString(), rf.isInObject("a string"), !rf.isStatic());
}
}
示例3: fieldLoadBarrierType
import jdk.vm.ci.hotspot.HotSpotResolvedJavaField; //導入依賴的package包/類
@Override
protected BarrierType fieldLoadBarrierType(ResolvedJavaField f) {
HotSpotResolvedJavaField loadField = (HotSpotResolvedJavaField) f;
BarrierType barrierType = BarrierType.NONE;
if (runtime.getVMConfig().useG1GC && loadField.getJavaKind() == JavaKind.Object && metaAccess.lookupJavaType(Reference.class).equals(loadField.getDeclaringClass()) &&
loadField.getName().equals("referent")) {
barrierType = BarrierType.PRECISE;
}
return barrierType;
}
示例4: isStableField
import jdk.vm.ci.hotspot.HotSpotResolvedJavaField; //導入依賴的package包/類
@Override
protected boolean isStableField(ResolvedJavaField field, ConstantFieldTool<?> tool) {
if (!config.foldStableValues) {
return false;
}
if (field.isStatic() && !isStaticFieldConstant(field, tool.getOptions())) {
return false;
}
if (((HotSpotResolvedJavaField) field).isStable()) {
return true;
}
return super.isStableField(field, tool);
}
示例5: main
import jdk.vm.ci.hotspot.HotSpotResolvedJavaField; //導入依賴的package包/類
public static void main(String[] args) throws Throwable {
MetaAccessProvider metaAccess = JVMCI.getRuntime().getHostJVMCIBackend().getMetaAccess();
for (String name : new String[] {"myStaticField", "myInstanceField"}) {
java.lang.reflect.Field javaField = StableFieldTest.class.getDeclaredField(name);
HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) metaAccess.lookupJavaField(javaField);
if (!field.isStable()) {
throw new AssertionError("Expected HotSpotResolvedJavaField.isStable() to return true for " + javaField);
}
}
}
示例6: testReadConstantFieldValue
import jdk.vm.ci.hotspot.HotSpotResolvedJavaField; //導入依賴的package包/類
@Test(dataProvider = "readConstantFieldValueDataProvider",
dataProviderClass = ReadConstantFieldValueDataProvider.class)
public void testReadConstantFieldValue(ResolvedJavaField field, JavaConstant receiver, JavaConstant expected,
String testInfo) {
String msg = String.format("Unexpected result for %s. Field is stable = %s.", testInfo,
((HotSpotResolvedJavaField) field).isStable());
Assert.assertEquals(CONSTANT_REFLECTION_PROVIDER.readConstantFieldValue(field, receiver),
expected, msg);
}
示例7: staticFieldBase
import jdk.vm.ci.hotspot.HotSpotResolvedJavaField; //導入依賴的package包/類
@Override
public ValueNode staticFieldBase(StructuredGraph graph, ResolvedJavaField f) {
HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) f;
JavaConstant base = constantReflection.asJavaClass(field.getDeclaringClass());
return ConstantNode.forConstant(base, metaAccess, graph);
}
示例8: fieldOffset
import jdk.vm.ci.hotspot.HotSpotResolvedJavaField; //導入依賴的package包/類
@Override
public int fieldOffset(ResolvedJavaField f) {
HotSpotResolvedJavaField field = (HotSpotResolvedJavaField) f;
return field.offset();
}
示例9: getClassConstantReplacement
import jdk.vm.ci.hotspot.HotSpotResolvedJavaField; //導入依賴的package包/類
private ValueNode getClassConstantReplacement(StructuredGraph graph, PhaseContext context, JavaConstant constant) {
if (constant instanceof HotSpotObjectConstant) {
ConstantReflectionProvider constantReflection = context.getConstantReflection();
ResolvedJavaType type = constantReflection.asJavaType(constant);
if (type != null) {
MetaAccessProvider metaAccess = context.getMetaAccess();
Stamp stamp = StampFactory.objectNonNull(TypeReference.createExactTrusted(metaAccess.lookupJavaType(Class.class)));
if (type instanceof HotSpotResolvedObjectType) {
ConstantNode klass = ConstantNode.forConstant(KlassPointerStamp.klassNonNull(), ((HotSpotResolvedObjectType) type).klass(), metaAccess, graph);
ValueNode getClass = graph.unique(new HubGetClassNode(metaAccess, klass));
if (((HotSpotObjectConstant) constant).isCompressed()) {
return HotSpotCompressionNode.compress(getClass, oopEncoding);
} else {
return getClass;
}
} else {
/*
* Primitive classes are more difficult since they don't have a corresponding
* Klass* so get them from Class.TYPE for the java box type.
*/
HotSpotResolvedPrimitiveType primitive = (HotSpotResolvedPrimitiveType) type;
ResolvedJavaType boxingClass = metaAccess.lookupJavaType(primitive.getJavaKind().toBoxedJavaClass());
ConstantNode clazz = ConstantNode.forConstant(context.getConstantReflection().asJavaClass(boxingClass), metaAccess, graph);
HotSpotResolvedJavaField[] a = (HotSpotResolvedJavaField[]) boxingClass.getStaticFields();
HotSpotResolvedJavaField typeField = null;
for (HotSpotResolvedJavaField f : a) {
if (f.getName().equals("TYPE")) {
typeField = f;
break;
}
}
if (typeField == null) {
throw new GraalError("Can't find TYPE field in class");
}
if (oopEncoding != null) {
stamp = HotSpotNarrowOopStamp.compressed((AbstractObjectStamp) stamp, oopEncoding);
}
AddressNode address = graph.unique(new OffsetAddressNode(clazz, ConstantNode.forLong(typeField.offset(), graph)));
ValueNode read = graph.unique(new FloatingReadNode(address, FINAL_LOCATION, null, stamp));
if (oopEncoding == null || ((HotSpotObjectConstant) constant).isCompressed()) {
return read;
} else {
return HotSpotCompressionNode.uncompress(read, oopEncoding);
}
}
}
}
return null;
}