RFR: 8330851: C2: More efficient TypeFunc creation [v2]
Amit Kumar
amitkumar at openjdk.org
Thu Nov 28 13:20:42 UTC 2024
On Thu, 28 Nov 2024 01:23:29 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:
> FYI I played a bit with template functions as TypeFunc factories [1]. Overall, it looks promising. I'm perfectly fine to cover that in a follow-up PR, but it would be good to align this patch accordingly.
Sure, that would be fine by me as you have already covered part of it.
>
> Some observations follow:
>
> (1) There's a bunch of other TypeFunc usages you may want to cover.
Okay I have increased the coverage. But still some of them I left alone as they are class-specific, they were accepting argument and using that in the Type creation. Which would be perfectly fine with the variadic templates but I am not sure if it could be done with current pattern of changes.
static const TypeFunc* alloc_type(const Type* t) {
const Type** fields = TypeTuple::fields(ParmLimit - TypeFunc::Parms);
fields[AllocSize] = TypeInt::POS;
fields[KlassNode] = TypeInstPtr::NOTNULL;
fields[InitialTest] = TypeInt::BOOL;
fields[ALength] = t; // length (can be a bad length)
fields[ValidLengthTest] = TypeInt::BOOL;
const TypeTuple *domain = TypeTuple::make(ParmLimit, fields);
// create result type (range)
fields = TypeTuple::fields(1);
fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
return TypeFunc::make(domain, range);
}
```
> (2) It turns out there are 2 types of `TypeFunc`s declared on OptoRuntime: those related to OptoRuntime stubs (populated by `C2_STUBS_DO`) and adhoc types for generated stubs and runtime calls. For the former a dedicated init method colocated with runtime entry looks preferred (`*_Type_Init()`) since both representations can be easily compared. For the former, an inline construction in `OptoRuntime::initialize_types()` looks more appropriate.
>
Most of them are now moved into `OptoRuntime::initialize_types()` method. And their `*_init` method is called from there. The other one are you talking about the class specific ones ? Or something else I need to update in this PR ?
-------------
PR Comment: https://git.openjdk.org/jdk/pull/21782#issuecomment-2506110873
More information about the hotspot-compiler-dev
mailing list