From 746cb631a31838bef7b7f4143cc4cca6cfa9c449 Mon Sep 17 00:00:00 2001 From: Mick Jordan <mick.jordan@oracle.com> Date: Sun, 13 Mar 2016 17:50:49 -0700 Subject: [PATCH] fix use of reportLoopCount deprectaed method --- .../truffle/r/nodes/builtin/base/Assign.java | 3 ++- .../builtin/base/HiddenInternalFunctions.java | 27 +++++++++---------- .../oracle/truffle/r/runtime/nodes/RNode.java | 8 +----- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Assign.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Assign.java index 36138af8a4..11592c3b77 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Assign.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Assign.java @@ -28,6 +28,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; +import com.oracle.truffle.api.nodes.LoopNode; import com.oracle.truffle.api.profiles.*; import com.oracle.truffle.r.nodes.builtin.*; import com.oracle.truffle.r.runtime.*; @@ -92,7 +93,7 @@ public abstract class Assign extends RInvisibleBuiltinNode { } } else { if (CompilerDirectives.inInterpreter()) { - getRootNode().reportLoopCount(-1); + LoopNode.reportLoopCount(this, -1); } if (env == REnvironment.emptyEnv()) { errorProfile.enter(); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/HiddenInternalFunctions.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/HiddenInternalFunctions.java index 8ce6311f25..ed3a128b99 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/HiddenInternalFunctions.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/HiddenInternalFunctions.java @@ -20,6 +20,7 @@ import com.oracle.truffle.api.*; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.*; import com.oracle.truffle.api.frame.*; +import com.oracle.truffle.api.nodes.LoopNode; import com.oracle.truffle.api.nodes.RootNode; import com.oracle.truffle.r.nodes.*; import com.oracle.truffle.r.nodes.access.*; @@ -184,11 +185,7 @@ public class HiddenInternalFunctions { @TruffleBoundary public Object lazyLoadDBFetchInternal(MaterializedFrame frame, RIntVector key, RStringVector datafile, int compression, RFunction envhook) { if (CompilerDirectives.inInterpreter()) { - // TODO why is rootNode sometimes null - RootNode rootNode = getRootNode(); - if (rootNode != null) { - rootNode.reportLoopCount(-5); - } + LoopNode.reportLoopCount(this, -5); } String dbPath = datafile.getDataAt(0); String packageName = new File(dbPath).getName(); @@ -347,16 +344,16 @@ public class HiddenInternalFunctions { @Override protected void createCasts(CastBuilder casts) { - casts.toInteger(2).toInteger(3); + casts.toInteger(3); } @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); } @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)) { throw RError.error(this, Message.GENERIC, "unsupported compression"); } @@ -369,27 +366,27 @@ public class HiddenInternalFunctions { }; 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 int outLen; int offset; - RCompression.Type ctype; + RCompression.Type type; byte[] cdata; if (compression == 1) { - ctype = RCompression.Type.GZIP; + type = RCompression.Type.GZIP; offset = 4; outLen = (int) (1.001 * data.length) + 20; cdata = new byte[outLen]; - boolean rc = RCompression.compress(ctype, data, cdata); + boolean rc = RCompression.compress(type, data, cdata); if (!rc) { throw RError.error(this, Message.GENERIC, "zlib compress error"); } } else if (compression == 3) { - ctype = RCompression.Type.LZMA; + type = RCompression.Type.LZMA; offset = 5; outLen = data.length; cdata = new byte[outLen]; - boolean rc = RCompression.compress(ctype, data, cdata); + boolean rc = RCompression.compress(type, data, cdata); if (!rc) { throw RError.error(this, Message.GENERIC, "lzma compress error"); } @@ -398,7 +395,7 @@ public class HiddenInternalFunctions { } int[] intData = new int[2]; 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); } catch (Throwable ex) { // Exceptions have been observed that were masked and very hard to find diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/RNode.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/RNode.java index 6686ae76c8..96734c5702 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/RNode.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/RNode.java @@ -211,18 +211,12 @@ public abstract class RNode extends RBaseNode implements RInstrumentableNode { reportWork(this, amount); } - @SuppressWarnings("unused") public static void reportWork(Node base, long amount) { if (CompilerDirectives.inInterpreter()) { if (amount >= WORK_SCALE_FACTOR) { int scaledAmount = (int) (amount / WORK_SCALE_FACTOR); if (amount > 0) { - RootNode root = base.getRootNode(); - /* - * TODO Is there a replacement for this now deprecated interface?? if (root != - * null && root.getCallTarget() instanceof LoopCountReceiver) { - * ((LoopCountReceiver) root.getCallTarget()).reportLoopCount(scaledAmount); } - */ + LoopNode.reportLoopCount(base, scaledAmount); } } } -- GitLab