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

[GR-2798] A few smaller fixes.

PullRequest: fastr/1511
parents cb6e03d9 91adf886
No related branches found
No related tags found
No related merge requests found
...@@ -65,6 +65,7 @@ import com.oracle.truffle.r.runtime.ffi.RFFIVariables; ...@@ -65,6 +65,7 @@ import com.oracle.truffle.r.runtime.ffi.RFFIVariables;
import com.oracle.truffle.r.runtime.ffi.StatsRFFI; import com.oracle.truffle.r.runtime.ffi.StatsRFFI;
import com.oracle.truffle.r.runtime.ffi.ToolsRFFI; import com.oracle.truffle.r.runtime.ffi.ToolsRFFI;
import com.oracle.truffle.r.runtime.ffi.ZipRFFI; import com.oracle.truffle.r.runtime.ffi.ZipRFFI;
import java.util.ArrayDeque;
import sun.misc.Unsafe; import sun.misc.Unsafe;
...@@ -109,7 +110,7 @@ final class TruffleNFI_Context extends RFFIContext { ...@@ -109,7 +110,7 @@ final class TruffleNFI_Context extends RFFIContext {
* this is less efficient than GNUR's version, we may need to implement it properly should the * this is less efficient than GNUR's version, we may need to implement it properly should the
* performance be a problem. * performance be a problem.
*/ */
public final ArrayList<Long> transientAllocations = new ArrayList<>(); public final ArrayDeque<ArrayList<Long>> transientAllocations = new ArrayDeque<>();
public void setLastUpCallException(RuntimeException ex) { public void setLastUpCallException(RuntimeException ex) {
assert ex == null || lastException == null : "last up-call exception is already set"; assert ex == null || lastException == null : "last up-call exception is already set";
...@@ -352,8 +353,8 @@ final class TruffleNFI_Context extends RFFIContext { ...@@ -352,8 +353,8 @@ final class TruffleNFI_Context extends RFFIContext {
@Override @Override
public long beforeDowncall() { public long beforeDowncall() {
assert transientAllocations.size() == 0 : "transientAllocations should have been cleared in afterDowncall";
super.beforeDowncall(); super.beforeDowncall();
transientAllocations.push(new ArrayList<>());
if (hasAccessLock) { if (hasAccessLock) {
acquireLock(); acquireLock();
} }
...@@ -364,10 +365,9 @@ final class TruffleNFI_Context extends RFFIContext { ...@@ -364,10 +365,9 @@ final class TruffleNFI_Context extends RFFIContext {
public void afterDowncall(long beforeValue) { public void afterDowncall(long beforeValue) {
super.afterDowncall(beforeValue); super.afterDowncall(beforeValue);
popCallbacks(beforeValue); popCallbacks(beforeValue);
for (Long ptr : transientAllocations) { for (Long ptr : transientAllocations.pop()) {
UnsafeAdapter.UNSAFE.freeMemory(ptr); UnsafeAdapter.UNSAFE.freeMemory(ptr);
} }
transientAllocations.clear();
RuntimeException lastUpCallEx = getLastUpCallException(); RuntimeException lastUpCallEx = getLastUpCallException();
setLastUpCallException(null); setLastUpCallException(null);
if (hasAccessLock) { if (hasAccessLock) {
......
...@@ -63,7 +63,7 @@ public class TruffleNFI_UpCallsRFFIImpl extends JavaUpCallsRFFIImpl { ...@@ -63,7 +63,7 @@ public class TruffleNFI_UpCallsRFFIImpl extends JavaUpCallsRFFIImpl {
@Override @Override
public Object R_alloc(int n, int size) { public Object R_alloc(int n, int size) {
long result = UnsafeAdapter.UNSAFE.allocateMemory(n * size); long result = UnsafeAdapter.UNSAFE.allocateMemory(n * size);
getContext().transientAllocations.add(result); getContext().transientAllocations.peek().add(result);
return result; return result;
} }
......
...@@ -231,6 +231,12 @@ public final class AttributesAccessNodes { ...@@ -231,6 +231,12 @@ public final class AttributesAccessNodes {
return RNull.instance; return RNull.instance;
} }
@Specialization
protected Object doIt(RSharingAttributeStorage target, RNull attributes) {
clearAttrs(target);
return RNull.instance;
}
@Fallback @Fallback
protected Object doOthers(Object target, Object attrs) { protected Object doOthers(Object target, Object attrs) {
throw unsupportedTypes("SET_ATTRIB", target, attrs); throw unsupportedTypes("SET_ATTRIB", target, attrs);
......
...@@ -22,23 +22,37 @@ ...@@ -22,23 +22,37 @@
*/ */
package com.oracle.truffle.r.ffi.impl.nodes; package com.oracle.truffle.r.ffi.impl.nodes;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Fallback; import com.oracle.truffle.api.dsl.Fallback;
import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.dsl.TypeSystemReference;
import com.oracle.truffle.r.nodes.builtin.MatchInternalNode;
import com.oracle.truffle.r.nodes.builtin.MatchInternalNodeGen;
import com.oracle.truffle.r.runtime.RError;
import static com.oracle.truffle.r.runtime.RError.Message.MATCH_VECTOR_ARGS;
import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.RInternalError;
import com.oracle.truffle.r.runtime.RRuntime; import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.data.RTypes; import com.oracle.truffle.r.runtime.data.RTypes;
import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector; import com.oracle.truffle.r.runtime.data.model.RAbstractStringVector;
import com.oracle.truffle.r.runtime.data.model.RAbstractVector;
public final class MatchNodes { public final class MatchNodes {
@TypeSystemReference(RTypes.class) @TypeSystemReference(RTypes.class)
public abstract static class MatchNode extends FFIUpCallNode.Arg3 { public abstract static class MatchNode extends FFIUpCallNode.Arg3 {
@SuppressWarnings("unused") @Child MatchInternalNode match = MatchInternalNodeGen.create();
@Specialization @Specialization
Object match(Object itables, Object ix, int nmatch) { Object match(RAbstractVector x, RAbstractVector table, int noMatch) {
throw RInternalError.unimplemented("Rf_match"); return match.execute(x, table, noMatch);
}
@SuppressWarnings("unused")
@Fallback
Object match(Object itables, Object ix, Object nmatch) {
CompilerDirectives.transferToInterpreter();
throw RError.error(this, MATCH_VECTOR_ARGS);
} }
public static MatchNode create() { public static MatchNode create() {
......
...@@ -51,7 +51,7 @@ public abstract class RSuicide { ...@@ -51,7 +51,7 @@ public abstract class RSuicide {
} }
public static RuntimeException rSuicide(RContext ctx, @SuppressWarnings("unused") Throwable cause, String msg) { public static RuntimeException rSuicide(RContext ctx, @SuppressWarnings("unused") Throwable cause, String msg) {
// TODO: output "cause" RInternalError.reportError(cause);
invokeUserDefinedSuicide(ctx, msg); invokeUserDefinedSuicide(ctx, msg);
throw rSuicideDefault(msg); throw rSuicideDefault(msg);
} }
......
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