本文整理汇总了Java中jdk.vm.ci.meta.ResolvedJavaField类的典型用法代码示例。如果您正苦于以下问题:Java ResolvedJavaField类的具体用法?Java ResolvedJavaField怎么用?Java ResolvedJavaField使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ResolvedJavaField类属于jdk.vm.ci.meta包,在下文中一共展示了ResolvedJavaField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAOTKlassData
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
void addAOTKlassData(BinaryContainer binaryContainer) {
for (CompiledMethodInfo methodInfo : compiledMethods) {
// Record methods holder
methodInfo.addDependentKlassData(binaryContainer, resolvedJavaType);
// Record inlinee classes
ResolvedJavaMethod[] inlinees = methodInfo.getCompilationResult().getMethods();
if (inlinees != null) {
for (ResolvedJavaMethod m : inlinees) {
methodInfo.addDependentKlassData(binaryContainer, (HotSpotResolvedObjectType) m.getDeclaringClass());
}
}
// Record classes of fields that were accessed
ResolvedJavaField[] fields = methodInfo.getCompilationResult().getFields();
if (fields != null) {
for (ResolvedJavaField f : fields) {
methodInfo.addDependentKlassData(binaryContainer, (HotSpotResolvedObjectType) f.getDeclaringClass());
}
}
}
}
示例2: lookup
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
ResolvedJavaField lookup(ResolvedJavaType type, String name, String fieldType, boolean isStatic) {
FieldKey key = new FieldKey(name, fieldType);
if (isStatic) {
if (staticFields == null) {
// Racy initialization is safe since staticFields is volatile
staticFields = createFieldMap(type.getStaticFields());
}
return staticFields.get(key);
} else {
if (instanceFields == null) {
// Racy initialization is safe since instanceFields is volatile
instanceFields = createFieldMap(type.getInstanceFields(false));
}
return instanceFields.get(key);
}
}
示例3: resolveField
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
static ResolvedJavaField resolveField(ClassfileBytecodeProvider context, ResolvedJavaType c, String name, String fieldType, boolean isStatic) {
ResolvedJavaField field = context.findField(c, name, fieldType, isStatic);
if (field != null) {
return field;
}
if (!c.isJavaLangObject() && !c.isInterface()) {
field = resolveField(context, c.getSuperclass(), name, fieldType, isStatic);
if (field != null) {
return field;
}
}
for (ResolvedJavaType i : c.getInterfaces()) {
field = resolveField(context, i, name, fieldType, isStatic);
if (field != null) {
return field;
}
}
return null;
}
示例4: getInstanceFieldsTest
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
@Test
public void getInstanceFieldsTest() {
for (Class<?> c : classes) {
ResolvedJavaType type = metaAccess.lookupJavaType(c);
for (boolean includeSuperclasses : new boolean[]{true, false}) {
Set<Field> expected = getInstanceFields(c, includeSuperclasses);
ResolvedJavaField[] actual = type.getInstanceFields(includeSuperclasses);
for (Field f : expected) {
assertNotNull(lookupField(actual, f));
}
for (ResolvedJavaField rf : actual) {
if (!isHiddenFromReflection(rf)) {
assertEquals(rf.toString(), lookupField(expected, rf) != null, !rf.isInternal());
}
}
// Test stability of getInstanceFields
ResolvedJavaField[] actual2 = type.getInstanceFields(includeSuperclasses);
assertArrayEquals(actual, actual2);
}
}
}
示例5: handleStoreField
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
@Override
public boolean handleStoreField(GraphBuilderContext b, ValueNode object, ResolvedJavaField field, ValueNode value) {
if (field.getJavaKind() == JavaKind.Object) {
boolean isWordField = wordTypes.isWord(field.getType());
boolean isWordValue = value.getStackKind() == wordTypes.getWordKind();
if (isWordField && !isWordValue) {
throw bailout(b, "Cannot store a non-word value into a word field: " + field.format("%H.%n"));
} else if (!isWordField && isWordValue) {
throw bailout(b, "Cannot store a word value into a non-word field: " + field.format("%H.%n"));
}
}
/* We never need to intercept the field store. */
return false;
}
示例6: getStaticFieldsTest
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
@Test
public void getStaticFieldsTest() {
for (Class<?> c : classes) {
ResolvedJavaType type = metaAccess.lookupJavaType(c);
Set<Field> expected = getStaticFields(c);
ResolvedJavaField[] actual = type.getStaticFields();
for (Field f : expected) {
assertNotNull(lookupField(actual, f));
}
for (ResolvedJavaField rf : actual) {
if (!isHiddenFromReflection(rf)) {
assertEquals(lookupField(expected, rf) != null, !rf.isInternal());
}
}
// Test stability of getStaticFields
ResolvedJavaField[] actual2 = type.getStaticFields();
assertArrayEquals(actual, actual2);
}
}
示例7: canonical
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
private static ValueNode canonical(LoadFieldNode loadFieldNode, StampPair stamp, ValueNode forObject, ResolvedJavaField field,
ConstantFieldProvider constantFields, ConstantReflectionProvider constantReflection,
OptionValues options, MetaAccessProvider metaAccess, boolean canonicalizeReads, boolean allUsagesAvailable) {
LoadFieldNode self = loadFieldNode;
if (canonicalizeReads && metaAccess != null) {
ConstantNode constant = asConstant(constantFields, constantReflection, metaAccess, options, forObject, field);
if (constant != null) {
return constant;
}
if (allUsagesAvailable) {
PhiNode phi = asPhi(constantFields, constantReflection, metaAccess, options, forObject,
field, stamp.getTrustedStamp());
if (phi != null) {
return phi;
}
}
}
if (self != null && !field.isStatic() && forObject.isNullConstant()) {
return new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.NullCheckException);
}
if (self == null) {
self = new LoadFieldNode(stamp, forObject, field);
}
return self;
}
示例8: asPhi
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
private static PhiNode asPhi(ConstantFieldProvider constantFields, ConstantReflectionProvider constantReflection,
MetaAccessProvider metaAcccess, OptionValues options, ValueNode forObject, ResolvedJavaField field, Stamp stamp) {
if (!field.isStatic() && field.isFinal() && forObject instanceof ValuePhiNode && ((ValuePhiNode) forObject).values().filter(isNotA(ConstantNode.class)).isEmpty()) {
PhiNode phi = (PhiNode) forObject;
ConstantNode[] constantNodes = new ConstantNode[phi.valueCount()];
for (int i = 0; i < phi.valueCount(); i++) {
ConstantNode constant = ConstantFoldUtil.tryConstantFold(constantFields, constantReflection, metaAcccess, field, phi.valueAt(i).asJavaConstant(),
options);
if (constant == null) {
return null;
}
constantNodes[i] = constant;
}
return new ValuePhiNode(stamp, phi.merge(), constantNodes);
}
return null;
}
示例9: virtualize
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
@Override
public void virtualize(VirtualizerTool tool) {
/*
* Reference objects can escape into their ReferenceQueue at any safepoint, therefore
* they're excluded from escape analysis.
*/
if (!tool.getMetaAccessProvider().lookupJavaType(Reference.class).isAssignableFrom(instanceClass)) {
VirtualInstanceNode virtualObject = createVirtualInstanceNode(true);
ResolvedJavaField[] fields = virtualObject.getFields();
ValueNode[] state = new ValueNode[fields.length];
for (int i = 0; i < state.length; i++) {
state[i] = defaultFieldValue(fields[i]);
}
tool.createVirtualObject(virtualObject, state, Collections.<MonitorIdNode> emptyList(), false);
tool.replaceWithVirtual(virtualObject);
}
}
示例10: checkMidTierGraph
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
@Override
protected boolean checkMidTierGraph(StructuredGraph graph) {
final LoopsData loops = new LoopsData(graph);
boolean found = false;
for (LoopEx loop : loops.loops()) {
for (Node node : loop.inside().nodes()) {
if (node instanceof Access) {
Access access = (Access) node;
LocationIdentity location = access.getLocationIdentity();
if (location instanceof FieldLocationIdentity) {
ResolvedJavaField field = ((FieldLocationIdentity) location).getField();
if (field.getName().equals("referent") && field.getDeclaringClass().equals(getMetaAccess().lookupJavaType(Reference.class))) {
found = true;
}
}
}
}
}
if (!found) {
assertTrue(false, "Reference.referent not found in loop: " + getCanonicalGraphString(graph, true, false));
}
return true;
}
示例11: tryFastInlineAccessor
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
/**
* Tries to inline {@code targetMethod} if it is an instance field accessor. This avoids the
* overhead of creating and using a nested {@link BytecodeParser} object.
*/
private boolean tryFastInlineAccessor(ValueNode[] args, ResolvedJavaMethod targetMethod) {
byte[] bytecode = targetMethod.getCode();
if (bytecode != null && bytecode.length == ACCESSOR_BYTECODE_LENGTH &&
Bytes.beU1(bytecode, 0) == ALOAD_0 &&
Bytes.beU1(bytecode, 1) == GETFIELD) {
int b4 = Bytes.beU1(bytecode, 4);
if (b4 >= IRETURN && b4 <= ARETURN) {
int cpi = Bytes.beU2(bytecode, 2);
JavaField field = targetMethod.getConstantPool().lookupField(cpi, targetMethod, GETFIELD);
if (field instanceof ResolvedJavaField) {
ValueNode receiver = invocationPluginReceiver.init(targetMethod, args).get();
ResolvedJavaField resolvedField = (ResolvedJavaField) field;
genGetField(resolvedField, receiver);
notifyBeforeInline(targetMethod);
printInlining(targetMethod, targetMethod, true, "inline accessor method (bytecode parsing)");
notifyAfterInline(targetMethod);
return true;
}
}
}
return false;
}
示例12: findFieldWithOffset
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
private static ResolvedJavaField findFieldWithOffset(long offset, JavaKind expectedEntryKind, ResolvedJavaField[] declaredFields) {
for (ResolvedJavaField field : declaredFields) {
HotSpotResolvedJavaField resolvedField = (HotSpotResolvedJavaField) field;
long resolvedFieldOffset = resolvedField.offset();
// @formatter:off
if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN &&
expectedEntryKind.isPrimitive() &&
!expectedEntryKind.equals(JavaKind.Void) &&
resolvedField.getJavaKind().isPrimitive()) {
resolvedFieldOffset +=
resolvedField.getJavaKind().getByteCount() -
Math.min(resolvedField.getJavaKind().getByteCount(), 4 + expectedEntryKind.getByteCount());
}
if (resolvedFieldOffset == offset) {
return field;
}
// @formatter:on
}
return null;
}
示例13: readFieldValue
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
public JavaConstant readFieldValue(ResolvedJavaField field, JavaConstant receiver) {
HotSpotResolvedJavaField hotspotField = (HotSpotResolvedJavaField) field;
if (hotspotField.isStatic()) {
HotSpotResolvedJavaType holder = (HotSpotResolvedJavaType) hotspotField.getDeclaringClass();
if (holder.isInitialized()) {
return memoryAccess.readFieldValue(hotspotField, holder.mirror());
}
} else {
if (receiver.isNonNull()) {
Object object = ((HotSpotObjectConstantImpl) receiver).object();
if (hotspotField.isInObject(object)) {
return memoryAccess.readFieldValue(hotspotField, object);
}
}
}
return null;
}
示例14: resolveStaticFieldAccess
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
private ResolvedJavaField resolveStaticFieldAccess(JavaField field, ValueNode value) {
if (field instanceof ResolvedJavaField) {
ResolvedJavaField resolvedField = (ResolvedJavaField) field;
if (resolvedField.getDeclaringClass().isInitialized()) {
return resolvedField;
}
/*
* Static fields have initialization semantics but may be safely accessed under certain
* conditions while the class is being initialized. Executing in the clinit or init of
* classes which are subtypes of the field holder are sure to be running in a context
* where the access is safe.
*/
if (resolvedField.getDeclaringClass().isAssignableFrom(method.getDeclaringClass())) {
if (method.isClassInitializer() || method.isConstructor()) {
return resolvedField;
}
}
}
if (value == null) {
handleUnresolvedLoadField(field, null);
} else {
handleUnresolvedStoreField(field, value, null);
}
return null;
}
示例15: genPutStatic
import jdk.vm.ci.meta.ResolvedJavaField; //导入依赖的package包/类
private void genPutStatic(JavaField field) {
ValueNode value = frameState.pop(field.getJavaKind());
ResolvedJavaField resolvedField = resolveStaticFieldAccess(field, value);
if (resolvedField == null) {
return;
}
if (!parsingIntrinsic() && GeneratePIC.getValue(getOptions())) {
graph.recordField(resolvedField);
}
ClassInitializationPlugin classInitializationPlugin = this.graphBuilderConfig.getPlugins().getClassInitializationPlugin();
if (classInitializationPlugin != null && classInitializationPlugin.shouldApply(this, resolvedField.getDeclaringClass())) {
FrameState stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
classInitializationPlugin.apply(this, resolvedField.getDeclaringClass(), stateBefore);
}
for (NodePlugin plugin : graphBuilderConfig.getPlugins().getNodePlugins()) {
if (plugin.handleStoreStaticField(this, resolvedField, value)) {
return;
}
}
genStoreField(null, resolvedField, value);
}