[code-reflection] RFR: Model unitialized variables

Paul Sandoz psandoz at openjdk.org
Wed Oct 23 22:50:52 UTC 2024


Uninitialized variables are modeled as if they are variables initialized with a default value.

To directly model uninitialized variables we introduce the undefined value operation. This operation has a result that is an undefined value whose type is the undefined type. Such a value can be used as the init operand of a var operation. Thereby we can distinguish between the modeling of uninitialized variables and variables initialized with a default value.

The approach of using a special value means there are very little changes to code operating on models, and undefined values can be tracked. For example, there were no changes required to the SSA transformation. Although, we should update that transformation to check if a value being used is the unitialized value, and if so throw an exception that the variable is not definitely assigned.

A value of the undefined type holds another value of the undefined type's value type, but we don't know what the actual value is an nor can we obtain it.

-------------

Commit messages:
 - Model unitialized variables

Changes: https://git.openjdk.org/babylon/pull/263/files
  Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=263&range=00
  Stats: 145 lines in 9 files changed: 135 ins; 1 del; 9 mod
  Patch: https://git.openjdk.org/babylon/pull/263.diff
  Fetch: git fetch https://git.openjdk.org/babylon.git pull/263/head:pull/263

PR: https://git.openjdk.org/babylon/pull/263


More information about the babylon-dev mailing list