use of com.oracle.graal.pointsto.meta.AnalysisMethod in project graal by oracle.
the class StaticAnalysisResultsBuilder method createMethodProfile.
private JavaMethodProfile createMethodProfile(Collection<AnalysisMethod> callees) {
ProfiledMethod[] pitems = new ProfiledMethod[callees.size()];
double probability = 1d / pitems.length;
int idx = 0;
for (AnalysisMethod aMethod : callees) {
ResolvedJavaMethod convertedMethod = converter == null ? aMethod : converter.lookup(aMethod);
pitems[idx++] = new ProfiledMethod(convertedMethod, probability);
}
return new JavaMethodProfile(0, pitems);
}
use of com.oracle.graal.pointsto.meta.AnalysisMethod in project graal by oracle.
the class TypeFlowGraphBuilder method checkFormalParameterBuilder.
/**
* Check if the formal parameter is a parameter of one of the wait/notify/hashCode methods. If
* so add it as a sink since it must be retained. Don't need to check the position of the
* parameter, since each of the checked methods has at most one object parameter.
*/
public void checkFormalParameterBuilder(TypeFlowBuilder<?> paramBuilder) {
AnalysisMethod method = (AnalysisMethod) ((ParameterNode) paramBuilder.getSource()).graph().method();
String methodFormat = method.format("%H.%n(%P)");
for (String specialMethodFormat : waitNotifyHashCodeMethods) {
if (methodFormat.equals(specialMethodFormat)) {
dataFlowSinkBuilders.add(paramBuilder);
}
}
}
use of com.oracle.graal.pointsto.meta.AnalysisMethod in project graal by oracle.
the class AnalysisMethodCalleeWalker method walkCallees.
/**
* Visit the callees of this method.
*/
VisitResult walkCallees(AnalysisMethod method, CallPathVisitor visitor) {
final StructuredGraph graph = method.getTypeFlow().getGraph();
if (graph != null) {
for (Invoke invoke : graph.getInvokes()) {
final CallTargetNode callTarget = invoke.callTarget();
final AnalysisMethod callee = (AnalysisMethod) callTarget.targetMethod();
walkMethodAndCallees(callee, method, invoke, visitor);
}
}
return VisitResult.CONTINUE;
}
use of com.oracle.graal.pointsto.meta.AnalysisMethod in project graal by oracle.
the class RestrictHeapAccessCalleesFeature method aggregateMethods.
/**
* Aggregate a set of methods that are annotated with {@link RestrictHeapAccess} or with
* {@link Uninterruptible}, or methods that are called from those methods.
*/
public void aggregateMethods(Collection<AnalysisMethod> methods) {
assert !initialized : "RestrictHeapAccessCallees.aggregateMethods: Should only initialize once.";
final Map<AnalysisMethod, RestrictionInfo> aggregation = new HashMap<>();
final MethodAggregator visitor = new MethodAggregator(aggregation, assertionErrorConstructorList);
final AnalysisMethodCalleeWalker walker = new AnalysisMethodCalleeWalker();
for (AnalysisMethod method : methods) {
final RestrictHeapAccess annotation = method.getAnnotation(RestrictHeapAccess.class);
if ((annotation != null && annotation.access() != Access.UNRESTRICTED) || method.isAnnotationPresent(Uninterruptible.class)) {
for (AnalysisMethod calleeImpl : method.getImplementations()) {
walker.walkMethod(calleeImpl, visitor);
}
}
}
calleeToCallerMap = Collections.unmodifiableMap(aggregation);
initialized = true;
}
use of com.oracle.graal.pointsto.meta.AnalysisMethod in project graal by oracle.
the class Target_com_oracle_truffle_api_interop_java_ObjectProxyHandler method beforeAnalysis.
@SuppressWarnings("deprecation")
@Override
public void beforeAnalysis(BeforeAnalysisAccess access) {
BeforeAnalysisAccessImpl config = (BeforeAnalysisAccessImpl) access;
getLanguageClasses().forEach(config::registerForReflectiveInstantiation);
config.registerHierarchyForReflectiveInstantiation(TruffleInstrument.class);
config.registerHierarchyForReflectiveInstantiation(com.oracle.truffle.api.instrumentation.InstrumentableFactory.class);
if (useTruffleCompiler()) {
SubstrateTruffleRuntime truffleRuntime = (SubstrateTruffleRuntime) Truffle.getRuntime();
GraalFeature graalFeature = ImageSingletons.lookup(GraalFeature.class);
SnippetReflectionProvider snippetReflection = graalFeature.getHostedProviders().getSnippetReflection();
SubstrateTruffleCompiler truffleCompiler = truffleRuntime.initTruffleCompiler();
truffleRuntime.lookupCallMethods(config.getMetaAccess());
PartialEvaluator partialEvaluator = truffleCompiler.getPartialEvaluator();
registerKnownTruffleFields(config, partialEvaluator.getKnownTruffleTypes());
support.registerInterpreterEntryMethodsAsCompiled(partialEvaluator, access);
GraphBuilderConfiguration graphBuilderConfig = partialEvaluator.getConfigForParsing();
if (Options.TruffleInlineDuringParsing.getValue()) {
graphBuilderConfig.getPlugins().appendInlineInvokePlugin(new TruffleParsingInlineInvokePlugin(graalFeature.getHostedProviders().getReplacements(), graphBuilderConfig.getPlugins().getInvocationPlugins(), partialEvaluator, method -> includeCallee(method, null, null)));
}
registerNeverPartOfCompilation(graphBuilderConfig.getPlugins().getInvocationPlugins());
graphBuilderConfig.getPlugins().getInvocationPlugins().closeRegistration();
HostedProviders newHostedProviders = new HostedProviders(partialEvaluator.getProviders().getMetaAccess(), partialEvaluator.getProviders().getCodeCache(), partialEvaluator.getProviders().getConstantReflection(), new HostedTruffleConstantFieldProvider(partialEvaluator.getProviders().getConstantFieldProvider()), partialEvaluator.getProviders().getForeignCalls(), partialEvaluator.getProviders().getLowerer(), partialEvaluator.getProviders().getReplacements(), partialEvaluator.getProviders().getStampProvider(), snippetReflection, graalFeature.getHostedProviders().getWordTypes());
newHostedProviders.setGraphBuilderPlugins(graphBuilderConfig.getPlugins());
graalFeature.initializeRuntimeCompilationConfiguration(newHostedProviders, graphBuilderConfig, this::includeCallee, this::deoptimizeOnException);
for (ResolvedJavaMethod method : partialEvaluator.getCompilationRootMethods()) {
graalFeature.prepareMethodForRuntimeCompilation(method, config);
}
initializeMethodBlacklist(config.getMetaAccess());
/*
* Stack frames that are visited by Truffle-level stack walking must have full frame
* information available, otherwise SubstrateStackIntrospection cannot visit them.
*/
for (ResolvedJavaMethod method : truffleRuntime.getAnyFrameMethod()) {
graalFeature.requireFrameInformationForMethod(method);
/*
* To avoid corner case errors, we also force compilation of these methods. This
* only affects builds where no Truffle language is included, because any real
* language makes these methods reachable (and therefore compiled).
*/
config.registerAsCompiled((AnalysisMethod) method);
}
}
firstAnalysisRun = true;
}
Aggregations