Skip to content

Refactor iterative analysis code to common method #3773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 19, 2021

Conversation

ziyilin
Copy link
Collaborator

@ziyilin ziyilin commented Sep 10, 2021

Extract the iteratively analyzing code from NativeImageGenerator to PointsToAnalysis so it can be used by both native image generation and standalone pointsto analysis.
This PR is related with Feature request: #3418

@oubidar-Abderrahim
Copy link
Member

Thank you for your contribution, this PR is tracked internally by GR-33705


if (stopIterationCriteria.getAsBoolean()) {
if (numTypes != universe.getTypes().size() || numMethods != universe.getMethods().size() || numFields != universe.getFields().size()) {
reportError.accept(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this error reporting code should remain in NativeImageGenerator. That avoids passing in a reportError handler. And duringAnalyssiAction and stopIterationCriteria can be combined to a single Predicate (i.e., boolean function). That way only one lambda needs to be passed into this method, making it maintainable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed as suggested.

@ziyilin ziyilin force-pushed the iterativelyAnalysis branch 2 times, most recently from 3add7df to 864222d Compare September 14, 2021 03:05
Copy link
Member

@cstancu cstancu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my comments.

int numMethods = aUniverse.getMethods().size();
int numFields = aUniverse.getFields().size();

String msg = ((NativeImagePointsToAnalysis) bb).iterativelyAnalyze(debug,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call the method runAnalysis and add it to the BigBang interface. This would avoid the cast here and allow instantiation of other analysis types.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed as suggested.

}
return !config.getAndResetRequireAnalysisIteration();
});
if (msg.length() > 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this approach of returning a String on error. Instead you could just throw an com.oracle.graal.pointsto.util.AnalysisError from PoinstToAnalysis.runAnalysis() then catch it here and wrap it in a user error, something like: throw UserError.abort(original, "Analysis step failed. Reason: %s.", original.getMessage());

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed as suggested

@@ -779,6 +744,8 @@ private boolean runPointsToAnalysis(String imageName, OptionValues options, Debu
return false;
}



Copy link
Member

@cstancu cstancu Sep 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These extra lines should be removed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@ziyilin ziyilin force-pushed the iterativelyAnalysis branch 2 times, most recently from a8ad963 to 5d03edc Compare September 22, 2021 02:51
Extract the iteratively analyzing code from NativeImageGenerator to
PointsToAnalysis so it can be used by both native image generation and
standalone pointsto analysis.
@ziyilin ziyilin force-pushed the iterativelyAnalysis branch from 5d03edc to 01f82d3 Compare October 9, 2021 06:34
@graalvmbot graalvmbot merged commit 01f82d3 into oracle:master Oct 19, 2021
@ziyilin ziyilin deleted the iterativelyAnalysis branch October 21, 2021 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants