Skip to content
Snippets Groups Projects
Commit e7c9a51f authored by Lukas Stadler's avatar Lukas Stadler
Browse files

check for boolean frame slots in “executeEndOfFunction” and produce proper error message

parent 3aadff8d
No related branches found
No related tags found
No related merge requests found
...@@ -526,7 +526,7 @@ final class REngine implements Engine, Engine.Timings { ...@@ -526,7 +526,7 @@ final class REngine implements Engine, Engine.Timings {
if (topLevel) { if (topLevel) {
RErrorHandling.printWarnings(suppressWarnings); RErrorHandling.printWarnings(suppressWarnings);
} }
setVisibility.executeEndOfFunction(vf); setVisibility.executeEndOfFunction(vf, this);
} catch (RError e) { } catch (RError e) {
CompilerDirectives.transferToInterpreter(); CompilerDirectives.transferToInterpreter();
throw e; throw e;
...@@ -558,6 +558,11 @@ final class REngine implements Engine, Engine.Timings { ...@@ -558,6 +558,11 @@ final class REngine implements Engine, Engine.Timings {
return result; return result;
} }
@Override
public String getName() {
return description;
}
@Override @Override
public String toString() { public String toString() {
return description; return description;
......
...@@ -105,4 +105,9 @@ public abstract class RRootNode extends RootNode implements HasSignature { ...@@ -105,4 +105,9 @@ public abstract class RRootNode extends RootNode implements HasSignature {
public boolean isCloningAllowed() { public boolean isCloningAllowed() {
return true; return true;
} }
@Override
public final String toString() {
return getName();
}
} }
...@@ -89,7 +89,7 @@ public final class RBuiltinRootNode extends RRootNode { ...@@ -89,7 +89,7 @@ public final class RBuiltinRootNode extends RRootNode {
throw new RInternalError(e, "internal error"); throw new RInternalError(e, "internal error");
} finally { } finally {
visibility.execute(frame, factory.getVisibility()); visibility.execute(frame, factory.getVisibility());
visibility.executeEndOfFunction(frame); visibility.executeEndOfFunction(frame, this);
} }
} }
...@@ -121,9 +121,4 @@ public final class RBuiltinRootNode extends RRootNode { ...@@ -121,9 +121,4 @@ public final class RBuiltinRootNode extends RRootNode {
public String getName() { public String getName() {
return "RBuiltin(" + builtin + ")"; return "RBuiltin(" + builtin + ")";
} }
@Override
public String toString() {
return getName();
}
} }
...@@ -278,7 +278,7 @@ public final class FunctionDefinitionNode extends RRootNode implements RSyntaxNo ...@@ -278,7 +278,7 @@ public final class FunctionDefinitionNode extends RRootNode implements RSyntaxNo
* has no exit handlers (by fiat), so any exceptions from onExits handlers will be * has no exit handlers (by fiat), so any exceptions from onExits handlers will be
* caught above. * caught above.
*/ */
visibility.executeEndOfFunction(frame); visibility.executeEndOfFunction(frame, this);
if (argPostProcess != null) { if (argPostProcess != null) {
resetArgs.enter(); resetArgs.enter();
argPostProcess.execute(frame); argPostProcess.execute(frame);
...@@ -406,11 +406,6 @@ public final class FunctionDefinitionNode extends RRootNode implements RSyntaxNo ...@@ -406,11 +406,6 @@ public final class FunctionDefinitionNode extends RRootNode implements RSyntaxNo
return name == null ? "<no source>" : name; return name == null ? "<no source>" : name;
} }
@Override
public String toString() {
return getName();
}
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
*/ */
package com.oracle.truffle.r.nodes.function.visibility; package com.oracle.truffle.r.nodes.function.visibility;
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives; 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.frame.Frame; import com.oracle.truffle.api.frame.Frame;
...@@ -32,6 +33,7 @@ import com.oracle.truffle.api.frame.VirtualFrame; ...@@ -32,6 +33,7 @@ import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.Node; import com.oracle.truffle.api.nodes.Node;
import com.oracle.truffle.api.nodes.NodeCost; import com.oracle.truffle.api.nodes.NodeCost;
import com.oracle.truffle.api.nodes.NodeInfo; import com.oracle.truffle.api.nodes.NodeInfo;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.r.runtime.RArguments; import com.oracle.truffle.r.runtime.RArguments;
import com.oracle.truffle.r.runtime.RCaller; import com.oracle.truffle.r.runtime.RCaller;
import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.RInternalError;
...@@ -86,12 +88,19 @@ public final class SetVisibilityNode extends Node { ...@@ -86,12 +88,19 @@ public final class SetVisibilityNode extends Node {
* Needs to be called at the end of each function, so that the visibility is transferred from * Needs to be called at the end of each function, so that the visibility is transferred from
* the current frame into the {@link RCaller}. * the current frame into the {@link RCaller}.
*/ */
public void executeEndOfFunction(VirtualFrame frame) { public void executeEndOfFunction(VirtualFrame frame, RootNode root) {
ensureFrameSlot(frame); ensureFrameSlot(frame);
try { try {
Object visibility = frame.getBoolean(frameSlot); if (frame.isBoolean(frameSlot)) {
if (visibility != null) { RArguments.getCall(frame).setVisibility(frame.getBoolean(frameSlot) == Boolean.TRUE);
RArguments.getCall(frame).setVisibility(visibility == Boolean.TRUE); } else {
CompilerDirectives.transferToInterpreter();
/*
* Most likely the (only) builtin call in the function was configured to
* RVisibility.CUSTOM and didn't actually set the visibility. Another possible
* problem is a node that is created by RASTBuilder that does not set visibility.
*/
throw RInternalError.shouldNotReachHere("visibility not set at the end of " + root.getName());
} }
} catch (FrameSlotTypeException e) { } catch (FrameSlotTypeException e) {
throw RInternalError.shouldNotReachHere(e); throw RInternalError.shouldNotReachHere(e);
...@@ -102,6 +111,7 @@ public final class SetVisibilityNode extends Node { ...@@ -102,6 +111,7 @@ public final class SetVisibilityNode extends Node {
* Slow-path version of {@link #executeAfterCall(VirtualFrame, RCaller)}. * Slow-path version of {@link #executeAfterCall(VirtualFrame, RCaller)}.
*/ */
public static void executeAfterCallSlowPath(Frame frame, RCaller caller) { public static void executeAfterCallSlowPath(Frame frame, RCaller caller) {
CompilerAsserts.neverPartOfCompilation();
frame.setBoolean(frame.getFrameDescriptor().findOrAddFrameSlot(RFrameSlot.Visibility, FrameSlotKind.Boolean), caller.getVisibility()); frame.setBoolean(frame.getFrameDescriptor().findOrAddFrameSlot(RFrameSlot.Visibility, FrameSlotKind.Boolean), caller.getVisibility());
} }
} }
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