[Vm-dev] In porting Java code a hotspot error
Robert Withers
robert.withers at pm.me
Sat Jun 26 14:17:49 UTC 2021
Below is some Java code, with a comment, from ZXing's ReedSolomon error correction. It points out a hotspot bug with a workaround. What would be the Squeak code to calculate the denominator? I'm guessing that this hotspot bug does not exist in Squeak. I tried this code and it fails:
> denominator = field
> multiply: denominator
> by: (field
> addOrSubtract: 1
> by: (field
> multiply: (errorLocations at: j)
> by: xiInverse)).
Notice the commented out code in the first 2 lines of the java comment. The computation seems to revolve around
> field addOrSubtract: 1 by: term
or
> (term & 0x1) == 0 ? term | 1 : term & ~1;
Here is the Java code.
> //denominator = field.multiply(denominator,
> // GenericGF.addOrSubtract(1, field.multiply(errorLocations[j], xiInverse)));
> // Above should work but fails on some Apple and Linux JDKs due to a Hotspot bug.
> // Below is a funny-looking workaround from Steven Parkes
> int term = field.multiply(errorLocations[j], xiInverse);
> int termPlus1 = (term & 0x1) == 0 ? term | 1 : term & ~1;
> denominator = field.multiply(denominator, termPlus1);
--
---
Kindly,
Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20210626/1a74f0bc/attachment.html>
More information about the Vm-dev
mailing list