RFR: 8367531: Template Framework: use scopes and tokens instead of misbehaving immediate-return-queries [v11]
Emanuel Peter
epeter at openjdk.org
Wed Nov 5 11:52:31 UTC 2025
On Wed, 5 Nov 2025 11:46:13 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> test/hotspot/jtreg/testlibrary_tests/template_framework/examples/TestTutorial.java line 501:
>>
>>> 499: // Let us go back to where we anchored the hook with anchor() and define a field named $field1 there.
>>> 500: """,
>>> 501: myHook.insert(scope( // <- insertion scope
>>
>> I'm not yet clear on that one. What happens when we insert a transparentScope here and for example add a `let("y", 42)`. Where could we then use `#y` (might not be a thing one might want to do, though)? Anywhere in the anchor scope and/or in the caller scope?
>
> I have examples like that in `TestTemplate.java`. A good example is in `testHookAndScopes2`.
>
> 3054 hook1.insert(transparentScope(
> 3055 let("nameTransparentScope", "x1c"), // escapes to caller
> 3056 addStructuralName("x1c", myStructuralTypeA), // escapes to anchor scope
> 3057 "inserted transparentScope: #nameTransparentScope\n",
> 3058 "local1: #local1\n",
> 3059 listNamesTemplate.asToken()
> 3060 )),
>
>
> Note: `let` escapes to the caller, and `addDataName` excapes to the anchor scope.
This is not exactly a great way to code though... most likely we don't really want the `let` to escape, and so a `hashtagScope` would be best.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27255#discussion_r2494128890
More information about the hotspot-compiler-dev
mailing list