Skip to content
Snippets Groups Projects
Commit fcd825b9 authored by Tomas Stupka's avatar Tomas Stupka
Browse files

placed the org.tukaani.xz.check.CRC64 call behind a TruffleBoundary

parent 1200b4bd
No related branches found
No related tags found
No related merge requests found
......@@ -22,6 +22,7 @@
*/
package com.oracle.truffle.r.nodes.builtin.base;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import static com.oracle.truffle.r.runtime.builtins.RBehavior.PURE;
import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.INTERNAL;
......@@ -48,9 +49,7 @@ public abstract class CRC64 extends RBuiltinNode {
protected RAbstractStringVector crc64(RAbstractStringVector x) {
final String string = x.getDataAt(0);
byte[] bytes = string.getBytes();
org.tukaani.xz.check.CRC64 crc = new org.tukaani.xz.check.CRC64();
crc.update(bytes);
bytes = crc.finish();
bytes = crc64(bytes);
long l = 0;
for (int i = 0; i < bytes.length; i++) {
l += ((long) bytes[i] & 0xffL) << (8 * i);
......@@ -58,4 +57,11 @@ public abstract class CRC64 extends RBuiltinNode {
return RDataFactory.createStringVector(Long.toHexString(l));
}
@TruffleBoundary
private byte[] crc64(byte[] bytes) {
org.tukaani.xz.check.CRC64 crc = new org.tukaani.xz.check.CRC64();
crc.update(bytes);
return crc.finish();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment