Skip to content
Snippets Groups Projects
Commit 746cb631 authored by Mick Jordan's avatar Mick Jordan
Browse files

fix use of reportLoopCount deprectaed method

parent ad5d5fe2
Branches
No related tags found
No related merge requests found
...@@ -28,6 +28,7 @@ import com.oracle.truffle.api.CompilerDirectives; ...@@ -28,6 +28,7 @@ import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.api.nodes.LoopNode;
import com.oracle.truffle.api.profiles.*; import com.oracle.truffle.api.profiles.*;
import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.nodes.builtin.*;
import com.oracle.truffle.r.runtime.*; import com.oracle.truffle.r.runtime.*;
...@@ -92,7 +93,7 @@ public abstract class Assign extends RInvisibleBuiltinNode { ...@@ -92,7 +93,7 @@ public abstract class Assign extends RInvisibleBuiltinNode {
} }
} else { } else {
if (CompilerDirectives.inInterpreter()) { if (CompilerDirectives.inInterpreter()) {
getRootNode().reportLoopCount(-1); LoopNode.reportLoopCount(this, -1);
} }
if (env == REnvironment.emptyEnv()) { if (env == REnvironment.emptyEnv()) {
errorProfile.enter(); errorProfile.enter();
......
...@@ -20,6 +20,7 @@ import com.oracle.truffle.api.*; ...@@ -20,6 +20,7 @@ import com.oracle.truffle.api.*;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.dsl.*;
import com.oracle.truffle.api.frame.*; import com.oracle.truffle.api.frame.*;
import com.oracle.truffle.api.nodes.LoopNode;
import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.*;
import com.oracle.truffle.r.nodes.access.*; import com.oracle.truffle.r.nodes.access.*;
...@@ -184,11 +185,7 @@ public class HiddenInternalFunctions { ...@@ -184,11 +185,7 @@ public class HiddenInternalFunctions {
@TruffleBoundary @TruffleBoundary
public Object lazyLoadDBFetchInternal(MaterializedFrame frame, RIntVector key, RStringVector datafile, int compression, RFunction envhook) { public Object lazyLoadDBFetchInternal(MaterializedFrame frame, RIntVector key, RStringVector datafile, int compression, RFunction envhook) {
if (CompilerDirectives.inInterpreter()) { if (CompilerDirectives.inInterpreter()) {
// TODO why is rootNode sometimes null LoopNode.reportLoopCount(this, -5);
RootNode rootNode = getRootNode();
if (rootNode != null) {
rootNode.reportLoopCount(-5);
}
} }
String dbPath = datafile.getDataAt(0); String dbPath = datafile.getDataAt(0);
String packageName = new File(dbPath).getName(); String packageName = new File(dbPath).getName();
...@@ -347,16 +344,16 @@ public class HiddenInternalFunctions { ...@@ -347,16 +344,16 @@ public class HiddenInternalFunctions {
@Override @Override
protected void createCasts(CastBuilder casts) { protected void createCasts(CastBuilder casts) {
casts.toInteger(2).toInteger(3); casts.toInteger(3);
} }
@Specialization @Specialization
protected RIntVector lazyLoadDBinsertValue(VirtualFrame frame, Object value, RAbstractStringVector file, int asciiL, int compression, RFunction hook) { protected RIntVector lazyLoadDBinsertValue(VirtualFrame frame, Object value, RAbstractStringVector file, byte asciiL, int compression, RFunction hook) {
return lazyLoadDBinsertValueInternal(frame.materialize(), value, file, asciiL, compression, hook); return lazyLoadDBinsertValueInternal(frame.materialize(), value, file, asciiL, compression, hook);
} }
@TruffleBoundary @TruffleBoundary
private RIntVector lazyLoadDBinsertValueInternal(MaterializedFrame frame, Object value, RAbstractStringVector file, int type, int compression, RFunction hook) { private RIntVector lazyLoadDBinsertValueInternal(MaterializedFrame frame, Object value, RAbstractStringVector file, byte asciiL, int compression, RFunction hook) {
if (!(compression == 1 || compression == 3)) { if (!(compression == 1 || compression == 3)) {
throw RError.error(this, Message.GENERIC, "unsupported compression"); throw RError.error(this, Message.GENERIC, "unsupported compression");
} }
...@@ -369,27 +366,27 @@ public class HiddenInternalFunctions { ...@@ -369,27 +366,27 @@ public class HiddenInternalFunctions {
}; };
try { try {
byte[] data = RSerialize.serialize(value, type, RSerialize.DEFAULT_VERSION, callHook); byte[] data = RSerialize.serialize(value, RRuntime.fromLogical(asciiL), false, RSerialize.DEFAULT_VERSION, callHook);
// See comment in LazyLoadDBFetch for format // See comment in LazyLoadDBFetch for format
int outLen; int outLen;
int offset; int offset;
RCompression.Type ctype; RCompression.Type type;
byte[] cdata; byte[] cdata;
if (compression == 1) { if (compression == 1) {
ctype = RCompression.Type.GZIP; type = RCompression.Type.GZIP;
offset = 4; offset = 4;
outLen = (int) (1.001 * data.length) + 20; outLen = (int) (1.001 * data.length) + 20;
cdata = new byte[outLen]; cdata = new byte[outLen];
boolean rc = RCompression.compress(ctype, data, cdata); boolean rc = RCompression.compress(type, data, cdata);
if (!rc) { if (!rc) {
throw RError.error(this, Message.GENERIC, "zlib compress error"); throw RError.error(this, Message.GENERIC, "zlib compress error");
} }
} else if (compression == 3) { } else if (compression == 3) {
ctype = RCompression.Type.LZMA; type = RCompression.Type.LZMA;
offset = 5; offset = 5;
outLen = data.length; outLen = data.length;
cdata = new byte[outLen]; cdata = new byte[outLen];
boolean rc = RCompression.compress(ctype, data, cdata); boolean rc = RCompression.compress(type, data, cdata);
if (!rc) { if (!rc) {
throw RError.error(this, Message.GENERIC, "lzma compress error"); throw RError.error(this, Message.GENERIC, "lzma compress error");
} }
...@@ -398,7 +395,7 @@ public class HiddenInternalFunctions { ...@@ -398,7 +395,7 @@ public class HiddenInternalFunctions {
} }
int[] intData = new int[2]; int[] intData = new int[2];
intData[1] = outLen + offset; // include length + type (compression == 3) intData[1] = outLen + offset; // include length + type (compression == 3)
intData[0] = appendFile(file.getDataAt(0), cdata, data.length, ctype); intData[0] = appendFile(file.getDataAt(0), cdata, data.length, type);
return RDataFactory.createIntVector(intData, RDataFactory.COMPLETE_VECTOR); return RDataFactory.createIntVector(intData, RDataFactory.COMPLETE_VECTOR);
} catch (Throwable ex) { } catch (Throwable ex) {
// Exceptions have been observed that were masked and very hard to find // Exceptions have been observed that were masked and very hard to find
......
...@@ -211,18 +211,12 @@ public abstract class RNode extends RBaseNode implements RInstrumentableNode { ...@@ -211,18 +211,12 @@ public abstract class RNode extends RBaseNode implements RInstrumentableNode {
reportWork(this, amount); reportWork(this, amount);
} }
@SuppressWarnings("unused")
public static void reportWork(Node base, long amount) { public static void reportWork(Node base, long amount) {
if (CompilerDirectives.inInterpreter()) { if (CompilerDirectives.inInterpreter()) {
if (amount >= WORK_SCALE_FACTOR) { if (amount >= WORK_SCALE_FACTOR) {
int scaledAmount = (int) (amount / WORK_SCALE_FACTOR); int scaledAmount = (int) (amount / WORK_SCALE_FACTOR);
if (amount > 0) { if (amount > 0) {
RootNode root = base.getRootNode(); LoopNode.reportLoopCount(base, scaledAmount);
/*
* TODO Is there a replacement for this now deprecated interface?? if (root !=
* null && root.getCallTarget() instanceof LoopCountReceiver) {
* ((LoopCountReceiver) root.getCallTarget()).reportLoopCount(scaledAmount); }
*/
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment