Implement native method to calculate hash code for valuetypes - #23502
Conversation
|
With these changes the following OpenJDK tests are passing:
Passing Test: |
29d6177 to
6f419cf
Compare
| private: | ||
| protected: | ||
| public: | ||
| struct ValueTypeHashQueueEntry { |
There was a problem hiding this comment.
This struct and the new helper methods can be under private in this file.
There was a problem hiding this comment.
I've encountered compilers that don't handle private types properly in all situations.
59a45e3 to
437659e
Compare
| break; | ||
| } | ||
| default: | ||
| break; |
There was a problem hiding this comment.
This should result in an error.
There was a problem hiding this comment.
I initially thought of using Assert_VM_unreachable(), but I think it can't be used here.
Could you please suggest on what error to throw here.
There was a problem hiding this comment.
Use Assert_VM_unreachable() (or similar) seems reasonable; reaching line 324 means the signature is invalid - which should have been detected long before we get here.
There was a problem hiding this comment.
I think you can add a comment like https://github.com/eclipse-openj9/openj9/blob/master/runtime/oti/ObjectHash.hpp#L121 instead. edit: didn't see Keith's answer before posting this.
| private: | ||
| protected: | ||
| public: | ||
| struct ValueTypeHashQueueEntry { |
There was a problem hiding this comment.
I've encountered compilers that don't handle private types properly in all situations.
437659e to
c5f3c7e
Compare
It throws a compiler error: |
75c5db8 to
9aeaac9
Compare
theresa-m
left a comment
There was a problem hiding this comment.
I suggest summarizing how hashcodes are updated for value types or link #15768 (comment) in the description so it is easy to find.
168ca66 to
111a450
Compare
111a450 to
01beea1
Compare
|
Sorry, I probably missed something, I was under impression that during VT hash code calculation if visited sub-object has hash code stored in the slot already, this code can be used instead of walking this object again. Is it right? If so, where it is implemented in the code? Just want to double check. |
https://github.com/eclipse-openj9/openj9/pull/23502/changes#diff-9aa50703bc7320e2410d7093b1f619ded056a3aeed5f75e2477603d7a5772712R269-R329 For value types, the hash slot is not checked, and the current implementation walks through all the fields to compute the hash. |
|
Sorry about the delay. I have updated the changes. |
|
|
||
| uint32_t *hashCodePointer = (uint32_t*)((uint8_t*) destinationObjectPtr + hashOffset); | ||
| *hashCodePointer = convertValueToHash(_javaVM, (uintptr_t)forwardedHeader->getObject()); | ||
| int32_t *hashCodePointer = (int32_t*)((uint8_t*)destinationObjectPtr + hashOffset); |
There was a problem hiding this comment.
If you are going to touch code after this point please add spaces before stars:
int32_t *hashCodePointer = (int32_t *)((uint8_t *)destinationObjectPtr + hashOffset);
ef15912 to
362e893
Compare
65e7666 to
fb05683
Compare
keithc-ca
left a comment
There was a problem hiding this comment.
Please squash and rebase.
fb05683 to
4f1b712
Compare
|
Please update the commit message to spell "hash code" consistently (two words), punctuate consistently, and ensure that no line in the body is more than 72 characters long. |
- Remove valueHashCode function. - Add implementation for convertValueObjectAtOffsetToHash to iteratively compute hash codes for value objects using field values. - Add function inlineConvertObjectToHash to handle hash computation for both value objects and identity objects. - Update inlineObjectHashCode to handle hash calculation for value objects. GC changes: - Update GC to skip value type hash computation during copy operations. - Hash calculations should be triggered by the VM when it reads the hash slot and discovers 0 in the slot. - Add wrapper functions convertValueToHashForObject and computeObjectAddressToHashForObject to return 0 for value types during copy operations. - Add convertObjectToHash as a GC-side wrapper to handle hash calculation for both value and identity objects. Test changes: - Add tests to verify hash code behaviour for empty and similar value classes. - Re-enable tests related to hash codes for value objects. Fixes: eclipse-openj9#15768 Signed-off-by: Aditi Srinivas M <Aditi.Srini@ibm.com>
4f1b712 to
f59105c
Compare
|
The commit message is much better. Thank you. |
|
Jenkins test sanity,extended aix,amac,plinux,win jdk25 |
|
Jenkins test sanity.functional,extended zlinuxval jdknext |
|
jenkins compile win,win32 jdk8 |
| * @return finalized hash value | ||
| */ | ||
| static VMINLINE U_32 | ||
| finalizeMurmur3Hash(U_32 hashValue, U_32 numBytesHashed) |
There was a problem hiding this comment.
DDR should be updated to match these changes; see ObjectHash.
|
The one test failure appears to be a known issue: #21871. |
GC changes:
Test changes:
Fixes: #15768
This change follows the approach described in 15768(comment)