use of com.oracle.graal.pointsto.meta.AnalysisMethod in project graal by oracle.
the class TypeFlowIterator method add.
private void add(TypeFlow<?> flow, WorkListEntry reason) {
if (processed.contains(flow)) {
return;
}
processed.add(flow);
WorkListEntry entry = new WorkListEntry(flow, reason);
worklist.add(entry);
if (!flow.isClone() && flow.getSource() instanceof ValueNode) {
AnalysisMethod method = (AnalysisMethod) ((ValueNode) flow.getSource()).graph().method();
for (MethodFlowsGraph methodFlow : method.getTypeFlow().getMethodContextFlows().values()) {
TypeFlow<?> curClone = methodFlow.lookupCloneOf(bb, flow);
add(curClone, entry);
}
}
}
use of com.oracle.graal.pointsto.meta.AnalysisMethod in project graal by oracle.
the class JNIFunctionTablesFeature method prepareCallTrampoline.
private static CFunctionPointer prepareCallTrampoline(CompilationAccessImpl access, CallVariant variant, boolean nonVirtual) {
JNICallTrampolineMethod trampolineMethod = JNIAccessFeature.singleton().getCallTrampolineMethod(variant, nonVirtual);
AnalysisMethod analysisTrampoline = access.getUniverse().getBigBang().getUniverse().lookup(trampolineMethod);
HostedMethod hostedTrampoline = access.getUniverse().lookup(analysisTrampoline);
hostedTrampoline.compilationInfo.setCustomParseFunction(trampolineMethod.createCustomParseFunction());
hostedTrampoline.compilationInfo.setCustomCompileFunction(trampolineMethod.createCustomCompileFunction());
return MethodPointer.factory(hostedTrampoline);
}
use of com.oracle.graal.pointsto.meta.AnalysisMethod in project graal by oracle.
the class JNIFunctionTablesFeature method buildFunctionsInitializer.
private JNIStructFunctionsInitializer<JNINativeInterface> buildFunctionsInitializer(CompilationAccessImpl access, CFunctionPointer unimplemented) {
Class<JNIFunctions> clazz = JNIFunctions.class;
HostedType functions = access.getMetaAccess().lookupJavaType(clazz);
HostedMethod[] methods = functions.getDeclaredMethods();
int index = 0;
int count = methods.length + generatedMethods.length;
// Call, CallStatic, CallNonvirtual: for each return value kind: array, va_list, varargs
// NewObject: array, va_list, varargs
count += (jniKinds.size() * 3 + 1) * 3;
int[] offsets = new int[count];
CFunctionPointer[] pointers = new CFunctionPointer[offsets.length];
for (HostedMethod method : methods) {
StructFieldInfo field = findFieldFor(functionTableMetadata, method.getName());
offsets[index] = field.getOffsetInfo().getProperty();
pointers[index] = getStubFunctionPointer(access, method);
index++;
}
for (ResolvedJavaMethod accessor : generatedMethods) {
StructFieldInfo field = findFieldFor(functionTableMetadata, accessor.getName());
AnalysisUniverse analysisUniverse = access.getUniverse().getBigBang().getUniverse();
AnalysisMethod analysisMethod = analysisUniverse.lookup(accessor);
HostedMethod hostedMethod = access.getUniverse().lookup(analysisMethod);
offsets[index] = field.getOffsetInfo().getProperty();
pointers[index] = MethodPointer.factory(hostedMethod);
index++;
}
for (CallVariant variant : CallVariant.values()) {
CFunctionPointer trampoline = prepareCallTrampoline(access, variant, false);
String suffix = (variant == CallVariant.ARRAY) ? "A" : ((variant == CallVariant.VA_LIST) ? "V" : "");
CFunctionPointer nonvirtualTrampoline = prepareCallTrampoline(access, variant, true);
for (JavaKind kind : jniKinds) {
String[] prefixes = { "Call", "CallStatic" };
for (String prefix : prefixes) {
StructFieldInfo field = findFieldFor(functionTableMetadata, prefix + kind.name() + "Method" + suffix);
offsets[index] = field.getOffsetInfo().getProperty();
pointers[index] = trampoline;
index++;
}
StructFieldInfo field = findFieldFor(functionTableMetadata, "CallNonvirtual" + kind.name() + "Method" + suffix);
offsets[index] = field.getOffsetInfo().getProperty();
pointers[index] = nonvirtualTrampoline;
index++;
}
StructFieldInfo field = findFieldFor(functionTableMetadata, "NewObject" + suffix);
offsets[index] = field.getOffsetInfo().getProperty();
pointers[index] = trampoline;
index++;
}
VMError.guarantee(index == offsets.length && index == pointers.length);
return new JNIStructFunctionsInitializer<>(JNINativeInterface.class, offsets, pointers, unimplemented);
}
use of com.oracle.graal.pointsto.meta.AnalysisMethod in project graal by oracle.
the class UniverseBuilder method collectHashCodeFieldInfo.
@SuppressWarnings("try")
private void collectHashCodeFieldInfo(BigBang bb) {
AnalysisMethod method;
try {
method = aMetaAccess.lookupJavaMethod(System.class.getMethod("identityHashCode", Object.class));
} catch (NoSuchMethodException | SecurityException e) {
throw shouldNotReachHere();
}
if (method == null) {
return;
}
DebugContext debug = bb.getDebug();
try (Indent ignore = debug.logAndIndent("check types for which identityHashCode is invoked")) {
// Check which types may be a parameter of System.identityHashCode (which is invoked by
// Object.hashCode).
TypeState thisParamState = method.getTypeFlow().getParameterTypeState(bb, 0);
assert thisParamState != null;
Iterable<AnalysisType> typesNeedHashCode = thisParamState.types();
if (typesNeedHashCode == null || thisParamState.isUnknown()) {
// This is the case if the identityHashCode parameter type is unknown. So all
// classes get the hashCode field.
// But this is only a fail-safe, because it cannot happen in the current
// implementation of the analysis pass.
debug.log("all types need a hashCode field");
for (HostedType hType : hUniverse.getTypes()) {
if (hType.isInstanceClass()) {
((HostedInstanceClass) hType).setNeedHashCodeField();
}
}
hUniverse.getObjectClass().setNeedHashCodeField();
} else {
for (AnalysisType type : typesNeedHashCode) {
debug.log("type %s is argument to identityHashCode", type);
/*
* Array types get a hash-code field by default. So we only have to deal with
* instance types here.
*/
if (type.isInstanceClass()) {
HostedInstanceClass hType = (HostedInstanceClass) hUniverse.lookup(type);
hType.setNeedHashCodeField();
}
}
}
}
}
use of com.oracle.graal.pointsto.meta.AnalysisMethod in project graal by oracle.
the class HostedType method wrappedResolveMethod.
private ResolvedJavaMethod wrappedResolveMethod(HostedMethod method, HostedType callerType) {
AnalysisMethod orig = wrapped.resolveConcreteMethod(method.wrapped, callerType.wrapped);
ResolvedJavaMethod result = orig == null ? null : universe.lookup(orig);
if (result != null && !isWordType() && !Arrays.asList(method.getImplementations()).contains(result)) {
/* Our static analysis found out that this method is not reachable. */
result = null;
}
return result;
}
Aggregations