Repository navigation
perf(crypto): run MD5 implCompress0 as a native, as HotSpot intrinsifies it - #90
Conversation
…of computing them with Math.sin
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 12 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
This PR adds a native implementation for MD5's implCompress0 method in src/natives/crypto.ts, using RFC 1321's precomputed constants and little-endian input reading, matching HotSpot's intrinsic behavior. A comprehensive test Md5Digest.java verifies empty input, "abc", block boundaries up to 1MB, split/offset updates, chained digests, and UUID.nameUUIDFromBytes with UTF-8. The implementation correctly follows the MD5 specification across all four rounds with proper rotation amounts, g-index permutations, and boolean functions.
review-bot, model nvidia/nemotron-3-ultra-550b-a55b:free, verdict approve
What this changes
sun.security.provider.MD5.implCompress0runs as a native, as HotSpot intrinsifies it, next to the SHA ones insrc/natives/crypto.ts. It reads the samestateint[4] and the input little-endian. The round constants are RFC 1321's table rather than computed withMath.sin, which is not exact in every engine.Tests
Md5Digest, same output as HotSpot: empty input, "abc", sizes around every block boundary up to 1,000,000 bytes, updates split at odd offsets and from an offset, a chained digest, andUUID.nameUUIDFromBytesof six strings including multi-byte UTF-8.UUIDTest: no change beyond the spread (141 s against 147 s median, ranges overlap); most of its time is not MD5.passing.txttests underjava/security,sun/securityandjava/util/UUID: 39 of 39 pass. Full suite: 259 pass, 0 fail, 3 skipped.