Skip to content
Snippets Groups Projects
Commit fe4bdace authored by Christian Humer's avatar Christian Humer
Browse files

Recursive sharing bug is no issue anymore in the new DSL layout.

parent 007ae842
No related branches found
No related tags found
No related merge requests found
......@@ -22,7 +22,6 @@
*/
package com.oracle.truffle.r.nodes.builtin;
import java.lang.reflect.*;
import java.util.*;
import com.oracle.truffle.api.*;
......@@ -130,41 +129,6 @@ public abstract class RBuiltinNode extends LeafCallNode implements VisibilityCon
return executeDouble(frame);
}
/**
* WORKAROUND for recursive sharing bug. A shallow copy is insufficient because is can cause
* shared state in the {@code arguments} field to be overwritten during a re-specialization.
* This is an ugly fix that uses reflection to update the hidden {@code arguments} field, and
* should go away with an upcoming Truffle fix.
*/
@Override
public Node copy() {
RBuiltinNode copy = (RBuiltinNode) super.copy();
RNode[] args = getArguments();
RNode[] copyArgs = Arrays.copyOf(args, args.length);
try {
Field field = getArgumentsField(getClass());
field.setAccessible(true);
field.set(copy, copyArgs);
} catch (IllegalAccessException | NoSuchFieldException ex) {
Utils.fatalError("failed to update RBuiltinNode.arguments");
}
return copy;
}
/**
* WORKAROUND support method.
*/
private Field getArgumentsField(Class<?> klass) throws NoSuchFieldException {
if (klass == RBuiltinNode.class) {
throw new NoSuchFieldException();
}
try {
return klass.getDeclaredField("arguments");
} catch (NoSuchFieldException ex) {
return getArgumentsField(klass.getSuperclass());
}
}
private static RNode[] createAccessArgumentsNodes(RBuiltinFactory builtin) {
int total = builtin.getRBuiltin().parameterNames().length;
RNode[] args = new RNode[total];
......
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