RFR: 8344942: Template-Based Testing Framework [v32]

Emanuel Peter epeter at openjdk.org
Mon May 19 14:38:03 UTC 2025


On Fri, 16 May 2025 12:02:29 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:

>> Emanuel Peter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   fix up review suggestions
>
> Some more comments, I will take this up again on Monday. Looking good so far :-) Great work!

@chhagedorn @mhaessig Thanks for the offline meeting, we really made some good progress.

Here the whiteboard we worked on:
![image](https://github.com/user-attachments/assets/c75bb45a-3e51-415f-9029-6f62deb588bb)

We decided to have two kinds of `Name`s:
- `DataName`: can be mutable or immutable. These are used to model variables and fields.
- `StructuralName`: for things like methods, classes, labels, etc. They are "structural" and it does not really make sense to talk about them being mutable or immutable.
- Accordingly, we also have `DataType` and `StructuralType`.

Accordingly, we will have:
- `addDataName(String name, DataType type, Mutability mutability, int weight)`. The weight is optional, default `1`. `Mutability` has 2 options here: `MUTABLE` and `IMMUTABLE`.
- `dataNames(Mutability mutability)` gets us a `DataNamesView`. `Mutability` can either pick `MUTABLE`, `IMMUTABLE` or `DONT_CARE`.
  - Optionally, we can filter with `subtypeOf(DataType)`, `exactOf(DataType)` or `supertypeOf(DataType)`.
  - As "terminal operators", we have:
    - `sample()`
    - `count()`
    - `hasAny()`
    - `toList()`
    - I will probably remove the `weight()` operator, as its use is not very clear, we could still add it later on.
- `addStructuralName(String name, StructuralType type, int weight)`, weight it optional, default `1`.
- `dataNames()` gets us a `StructuralNamesView`.
  - Optionally, we can filter with `subtypeOf(StructuralType)`, `exactOf(StructuralType)` or `supertypeOf(StructuralType)`.
  - As "terminal operators", we have:
    - `sample()`
    - `count()`
    - `hasAny()`
    - `toList()`

Some additional feedback I want to incorporate:
- Templates are often declared from innermost scope first to outermost last. But it can make sense to start reading the examples from the outermost first, to understand the context.
- `Hook.set` should instead be `Hook.anchor`. That is more clear.
- I need to have a very clear example that makes it clear how the `addDataName` interacts with the Template scope and the Hook scope, especially when we `Hook.insert`, and the name spills out one scope.

I will work on this ASAP.
@mhaessig @chhagedorn @robcasloz You can still review anything other than the Names, I only intend to refactor things around the Names.

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

PR Comment: https://git.openjdk.org/jdk/pull/24217#issuecomment-2891271844


More information about the hotspot-compiler-dev mailing list