[crac] RFR: 8368929: [CRaC] Move CPUFeatures check to C/R engine [v4]

Radim Vansa rvansa at openjdk.org
Tue Oct 7 12:11:43 UTC 2025


On Tue, 7 Oct 2025 11:57:44 GMT, Radim Vansa <rvansa at openjdk.org> wrote:

>>> This should be a idiomatic use of perfect forwarding, since `T` is deduced the `T &&` is a universal reference and is treated as lvalue, depending on its use. The current code copies the argument; for `std::move` I would have to pass rvalue reference (therefore the method wouldn't be usable with const value). Sources:
>> 
>> One can try it does not compile:
>> 
>> #include "hashtable.hpp"
>> int main() {
>>   Hashtable<int> h(nullptr, 10);
>>   int i = 42;
>>   h.put("foo", i);
>> }
>> h.cpp:5:16: error: rvalue reference to type 'int' cannot bind to lvalue of type 'int'
>>     5 |   h.put("foo", i);
>>       |                ^
>> src/java.base/share/native/libcrexec/hashtable.hpp:47:33: note: passing argument to parameter 'value' here
>>    47 |   bool put(const char *key, T&& value);
>>       |                                 ^
>> 1 error generated.
>> 
>> Couldn't we use a new template parameter for the method?
>> [tu.patch](https://github.com/user-attachments/files/22741639/tu.patch)
>
> You are right, it didn't work when I've tried to pass lvalue references in a test (and thanks to testing separately I found a bug in the list impl itself...). While this is not critical for CRaC itself I took the opportunity to improve my C++ knowledge and do the structures right :) Here is a standalone check to ensure that the containers work as expected: https://gist.github.com/rvansa/5f4cb76ddb4f694d2feb9a1ffb09d630
> Note that I use two methods in `linkedlist.hpp` rather than universal reference in the end, as the universal reference template would consider `{ ... }` a braced initializer list rather than a struct initializer.

With the last change I can't use aggregate initializer anyway as the move ctor is defined :-/ Good ol' Java.

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

PR Review Comment: https://git.openjdk.org/crac/pull/266#discussion_r2410402435


More information about the crac-dev mailing list