Skip to content

Conversation

@graalvmbot
Copy link
Collaborator

Allow the static analysis to discover never-null instance fields by

  1. outlining allocations into factory methods (already on by default, so nothing to do in this PR).
  2. inlining constructors into factory methods (see the changes in InlineBeforeAnalysisPolicyUtils).
  3. running escape analysis before building type flows (already on by default, so nothing to do in this PR).
  4. Actually adding the default value to instance field type flows only when an escape-analyzed allocation writes a default value; or when a non-escape-analyzed allocation remains.

Classes that can be allocated without running a constructor, via Unsafe or JNI, are excluded from the optimization (see PointsToAnalysisType.registerAsUnsafeAllocated).

When the analysis tracks primitive values, then also never-zero primitive instance fields will be optimized. But I expect that to be a rare case with limited impact.

This PR relies on #8869 which tightened the rules to require explicit reflection configuration for unsafe allocated objects. But in order to not break compatibility, this is only done when ThrowMissingRegistrationErrors is used (which is not enabled for our benchmarks yet), or when the new option -H:-AllowUnsafeAllocationOfAllInstantiatedTypes is used (which will be sufficient for our benchmarking for papers).

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jun 14, 2024
@graalvmbot graalvmbot merged commit 7a033b9 into master Jun 15, 2024
@graalvmbot graalvmbot deleted the cwi/GR-51974-never-null-fields branch June 15, 2024 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants