Skip to content

Commit

Permalink
Workaround for a bug in the Zing JVM: do not call Math.unsignedMultip…
Browse files Browse the repository at this point in the history
…lyHigh(long,long).
  • Loading branch information
wrandelshofer committed Oct 25, 2024
1 parent 388d54e commit d53bd95
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 9 deletions.
8 changes: 4 additions & 4 deletions deployment/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ can upload to the nexus repository manager.

```shell
cp ../fastdoubleparser/target/*.jar .
cp ../fastdoubleparser-java21/target/*javadoc.jar fastdoubleparser-1.0.1-javadoc.jar
cp ../fastdoubleparser-java22/target/*javadoc.jar fastdoubleparser-1.0.90-javadoc.jar
rm -rf META-INF
mkdir META-INF
cp ../LICENSE META-INF
cp ../fastdoubleparser-dev/src/main/resources/ch.randelshofer.fastdoubleparser/META-INF/thirdparty-LICENSE META-INF
cp ../NOTICE META-INF
jar -uf fastdoubleparser-1.0.1-javadoc.jar META-INF/*
jar -uf fastdoubleparser-1.0.1-sources.jar META-INF/*
jar -uf fastdoubleparser-1.0.90-javadoc.jar META-INF/*
jar -uf fastdoubleparser-1.0.90-sources.jar META-INF/*
rm *.asc
for f in *.jar; do gpg -ab "$f"; done
for f in *.xml; do gpg -ab "$f"; done
rm *bundle.jar
jar -cf fastdoubleparser-1.0.1-bundle.jar $(ls -1 pom*|xargs) $(ls -1 fastdoubleparser*|xargs)
jar -cf fastdoubleparser-1.0.90-bundle.jar $(ls -1 pom*|xargs) $(ls -1 fastdoubleparser*|xargs)
```
2 changes: 1 addition & 1 deletion deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.randelshofer</groupId>
<artifactId>fastdoubleparser</artifactId>
<version>1.0.1</version>
<version>1.0.90</version>
<packaging>jar</packaging>

<name>ch.randelshofer:fastdoubleparser</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,33 @@ static void fillPowersOfNFloor16Recursive(NavigableMap<Integer, BigInteger> powe
}
}

static long unsignedMultiplyHigh(long x, long y) {//since Java 18
return Math.unsignedMultiplyHigh(x, y);
/**
* Workaround for a bug in the Zing JVM.
* <pre>
* OpenJDK Runtime Environment Zing24.09.0.0+5 (build 21.0.4+4-LTS)
* Zing 64-Bit Tiered VM Zing24.09.0.0+5 (build 21.0.4-zing_24.09.0.0-b5-release-linux-X86_64, mixed mode)
* </pre>
* Instead of calling {@link Math#unsignedMultiplyHigh(long, long)}
* we use our own implementation.
*
* @param x the first value
* @param y the second value
* @return the result
*/
//static long unsignedMultiplyHigh(long x, long y) {//since Java 18
// return Math.unsignedMultiplyHigh(x, y);
//}
static long unsignedMultiplyHigh(long x, long y) {//before Java 18
long x0 = x & 0xffffffffL, x1 = x >>> 32;
long y0 = y & 0xffffffffL, y1 = y >>> 32;
long p11 = x1 * y1, p01 = x0 * y1;
long p10 = x1 * y0, p00 = x0 * y0;

// 64-bit product + two 32-bit values
long middle = p10 + (p00 >>> 32) + (p01 & 0xffffffffL);

// 64-bit product + two 32-bit values
return p11 + (middle >>> 32) + (p01 >>> 32);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion fastdoubleparser/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</configuration>
</execution>
<execution>
<id>copy-sources-from-fastdoubleparser-java21</id>
<id>copy-sources-from-fastdoubleparser-java22</id>
<phase>generate-sources</phase>
<goals>
<goal>copy-resources</goal>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<maven.compiler.source>${javaVersion}</maven.compiler.source>
<maven.compiler.target>${javaVersion}</maven.compiler.target>
<project.build.outputTimestamp>${git.commit.time}</project.build.outputTimestamp>
<revision>1.0.1</revision>
<revision>1.0.90</revision>
<license.url>
https://github.com/wrandelshofer/FastDoubleParser/blob/9a3ccae38254c9bf84b5e6a218a47675bf80ed9f/LICENSE
</license.url>
Expand Down

0 comments on commit d53bd95

Please sign in to comment.