From c82d1f9fefe810cabef3005449793a48771e0df2 Mon Sep 17 00:00:00 2001 From: stepan <stepan.sindelar@oracle.com> Date: Thu, 1 Mar 2018 11:44:13 +0100 Subject: [PATCH] Remove RCallBaseNodeWrapperFactory and RNodeWrapperFactory --- .../r/nodes/function/RCallBaseNode.java | 1 - .../nodes/function/RCallBaseNodeWrapper.java | 151 +++++++++++++++++ .../function/RCallBaseNodeWrapperFactory.java | 154 ------------------ .../oracle/truffle/r/runtime/nodes/RNode.java | 2 +- .../nodes/instrumentation/RNodeWrapper.java | 138 ++++++++++++++++ .../instrumentation/RNodeWrapperFactory.java | 141 ---------------- 6 files changed, 290 insertions(+), 297 deletions(-) create mode 100644 com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallBaseNodeWrapper.java delete mode 100644 com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallBaseNodeWrapperFactory.java create mode 100644 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/instrumentation/RNodeWrapper.java delete mode 100644 com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/instrumentation/RNodeWrapperFactory.java diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallBaseNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallBaseNode.java index ea2338c9a7..c97c5fcd38 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallBaseNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallBaseNode.java @@ -25,7 +25,6 @@ package com.oracle.truffle.r.nodes.function; import com.oracle.truffle.api.dsl.TypeSystemReference; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.instrumentation.ProbeNode; -import com.oracle.truffle.r.nodes.function.RCallBaseNodeWrapperFactory.RCallBaseNodeWrapper; import com.oracle.truffle.r.runtime.Arguments; import com.oracle.truffle.r.runtime.data.RTypes; import com.oracle.truffle.r.runtime.nodes.RInstrumentableNode; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallBaseNodeWrapper.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallBaseNodeWrapper.java new file mode 100644 index 0000000000..3b90fa8871 --- /dev/null +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallBaseNodeWrapper.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.r.nodes.function; + +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode; +import com.oracle.truffle.api.instrumentation.ProbeNode; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.NodeCost; +import com.oracle.truffle.api.nodes.NodeInfo; +import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.r.runtime.Arguments; +import com.oracle.truffle.r.runtime.nodes.RNode; +import com.oracle.truffle.r.runtime.nodes.RSyntaxNode; + +@NodeInfo(cost = NodeCost.NONE) +public final class RCallBaseNodeWrapper extends RCallBaseNode implements WrapperNode { + @Child private RCallBaseNode delegate; + @Child private ProbeNode probeNode; + + public RCallBaseNodeWrapper(RCallBaseNode delegate, ProbeNode probeNode) { + assert delegate != null; + this.delegate = delegate; + this.probeNode = probeNode; + } + + @Override + public Arguments<RSyntaxNode> getArguments() { + return delegate.getArguments(); + } + + @Override + public RNode getFunction() { + return delegate.getFunction(); + } + + @Override + public Node getDelegateNode() { + return delegate; + } + + @Override + public ProbeNode getProbeNode() { + return probeNode; + } + + @Override + public Object execute(VirtualFrame frame) { + Object returnValue; + for (;;) { + boolean wasOnReturnExecuted = false; + try { + probeNode.onEnter(frame); + returnValue = delegate.execute(frame); + wasOnReturnExecuted = true; + probeNode.onReturnValue(frame, returnValue); + break; + } catch (Throwable t) { + Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); + if (result == ProbeNode.UNWIND_ACTION_REENTER) { + continue; + } else if (result != null) { + returnValue = result; + break; + } + throw t; + } + } + return returnValue; + } + + @Override + public Object visibleExecute(VirtualFrame frame) { + Object returnValue; + for (;;) { + boolean wasOnReturnExecuted = false; + try { + probeNode.onEnter(frame); + returnValue = delegate.visibleExecute(frame); + wasOnReturnExecuted = true; + probeNode.onReturnValue(frame, returnValue); + break; + } catch (Throwable t) { + Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); + if (result == ProbeNode.UNWIND_ACTION_REENTER) { + continue; + } else if (result != null) { + returnValue = result; + break; + } + throw t; + } + } + return returnValue; + } + + @Override + public Object execute(VirtualFrame frame, Object function) { + Object returnValue; + for (;;) { + boolean wasOnReturnExecuted = false; + try { + probeNode.onEnter(frame); + returnValue = delegate.execute(frame, function); + wasOnReturnExecuted = true; + probeNode.onReturnValue(frame, returnValue); + break; + } catch (Throwable t) { + Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); + if (result == ProbeNode.UNWIND_ACTION_REENTER) { + continue; + } else if (result != null) { + returnValue = result; + break; + } + throw t; + } + } + return returnValue; + } + + @Override + public RSyntaxNode getRSyntaxNode() { + return delegate.asRSyntaxNode(); + } + + @Override + public SourceSection getSourceSection() { + return delegate.getSourceSection(); + } +} diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallBaseNodeWrapperFactory.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallBaseNodeWrapperFactory.java deleted file mode 100644 index 350a11e0c3..0000000000 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/RCallBaseNodeWrapperFactory.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.nodes.function; - -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode; -import com.oracle.truffle.api.instrumentation.ProbeNode; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.source.SourceSection; -import com.oracle.truffle.r.runtime.Arguments; -import com.oracle.truffle.r.runtime.nodes.RNode; -import com.oracle.truffle.r.runtime.nodes.RSyntaxNode; - -public class RCallBaseNodeWrapperFactory { - - @NodeInfo(cost = NodeCost.NONE) - public static final class RCallBaseNodeWrapper extends RCallBaseNode implements WrapperNode { - @Child private RCallBaseNode delegate; - @Child private ProbeNode probeNode; - - public RCallBaseNodeWrapper(RCallBaseNode delegate, ProbeNode probeNode) { - assert delegate != null; - this.delegate = delegate; - this.probeNode = probeNode; - } - - @Override - public Arguments<RSyntaxNode> getArguments() { - return delegate.getArguments(); - } - - @Override - public RNode getFunction() { - return delegate.getFunction(); - } - - @Override - public Node getDelegateNode() { - return delegate; - } - - @Override - public ProbeNode getProbeNode() { - return probeNode; - } - - @Override - public Object execute(VirtualFrame frame) { - Object returnValue; - for (;;) { - boolean wasOnReturnExecuted = false; - try { - probeNode.onEnter(frame); - returnValue = delegate.execute(frame); - wasOnReturnExecuted = true; - probeNode.onReturnValue(frame, returnValue); - break; - } catch (Throwable t) { - Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); - if (result == ProbeNode.UNWIND_ACTION_REENTER) { - continue; - } else if (result != null) { - returnValue = result; - break; - } - throw t; - } - } - return returnValue; - } - - @Override - public Object visibleExecute(VirtualFrame frame) { - Object returnValue; - for (;;) { - boolean wasOnReturnExecuted = false; - try { - probeNode.onEnter(frame); - returnValue = delegate.visibleExecute(frame); - wasOnReturnExecuted = true; - probeNode.onReturnValue(frame, returnValue); - break; - } catch (Throwable t) { - Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); - if (result == ProbeNode.UNWIND_ACTION_REENTER) { - continue; - } else if (result != null) { - returnValue = result; - break; - } - throw t; - } - } - return returnValue; - } - - @Override - public Object execute(VirtualFrame frame, Object function) { - Object returnValue; - for (;;) { - boolean wasOnReturnExecuted = false; - try { - probeNode.onEnter(frame); - returnValue = delegate.execute(frame, function); - wasOnReturnExecuted = true; - probeNode.onReturnValue(frame, returnValue); - break; - } catch (Throwable t) { - Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); - if (result == ProbeNode.UNWIND_ACTION_REENTER) { - continue; - } else if (result != null) { - returnValue = result; - break; - } - throw t; - } - } - return returnValue; - } - - @Override - public RSyntaxNode getRSyntaxNode() { - return delegate.asRSyntaxNode(); - } - - @Override - public SourceSection getSourceSection() { - return delegate.getSourceSection(); - } - } -} 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 d83341908b..d585d0de62 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 @@ -32,7 +32,7 @@ import com.oracle.truffle.r.runtime.RInternalError; import com.oracle.truffle.r.runtime.context.RContext; import com.oracle.truffle.r.runtime.data.RTypes; import com.oracle.truffle.r.runtime.data.RTypesGen; -import com.oracle.truffle.r.runtime.nodes.instrumentation.RNodeWrapperFactory.RNodeWrapper; +import com.oracle.truffle.r.runtime.nodes.instrumentation.RNodeWrapper; @TypeSystemReference(RTypes.class) public abstract class RNode extends RBaseNode implements RInstrumentableNode { diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/instrumentation/RNodeWrapper.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/instrumentation/RNodeWrapper.java new file mode 100644 index 0000000000..f19f9fb1e8 --- /dev/null +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/instrumentation/RNodeWrapper.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.truffle.r.runtime.nodes.instrumentation; + +import com.oracle.truffle.api.frame.VirtualFrame; +import com.oracle.truffle.api.instrumentation.InstrumentableNode; +import com.oracle.truffle.api.instrumentation.ProbeNode; +import com.oracle.truffle.api.nodes.Node; +import com.oracle.truffle.api.nodes.NodeCost; +import com.oracle.truffle.api.nodes.NodeInfo; +import com.oracle.truffle.api.source.SourceSection; +import com.oracle.truffle.r.runtime.nodes.RNode; +import com.oracle.truffle.r.runtime.nodes.RSyntaxNode; + +@NodeInfo(cost = NodeCost.NONE) +public final class RNodeWrapper extends RNode implements InstrumentableNode.WrapperNode { + @Child private RNode delegate; + @Child private ProbeNode probeNode; + + public RNodeWrapper(RNode delegate, ProbeNode probeNode) { + assert delegate != null; + assert !(delegate instanceof RNodeWrapper); + this.delegate = delegate; + this.probeNode = probeNode; + } + + @Override + public Node getDelegateNode() { + return delegate; + } + + @Override + public ProbeNode getProbeNode() { + return probeNode; + } + + @Override + public Object execute(VirtualFrame frame) { + Object returnValue; + for (;;) { + boolean wasOnReturnExecuted = false; + try { + probeNode.onEnter(frame); + returnValue = delegate.execute(frame); + wasOnReturnExecuted = true; + probeNode.onReturnValue(frame, returnValue); + break; + } catch (Throwable t) { + Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); + if (result == ProbeNode.UNWIND_ACTION_REENTER) { + continue; + } else if (result != null) { + returnValue = result; + break; + } + throw t; + } + } + return returnValue; + } + + @Override + public void voidExecute(VirtualFrame frame) { + for (;;) { + boolean wasOnReturnExecuted = false; + try { + probeNode.onEnter(frame); + delegate.voidExecute(frame); + wasOnReturnExecuted = true; + probeNode.onReturnValue(frame, null); + break; + } catch (Throwable t) { + Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); + if (result == ProbeNode.UNWIND_ACTION_REENTER) { + continue; + } else if (result != null) { + break; + } + throw t; + } + } + } + + @Override + public Object visibleExecute(VirtualFrame frame) { + Object returnValue; + for (;;) { + boolean wasOnReturnExecuted = false; + try { + probeNode.onEnter(frame); + returnValue = delegate.visibleExecute(frame); + wasOnReturnExecuted = true; + probeNode.onReturnValue(frame, returnValue); + break; + } catch (Throwable t) { + Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); + if (result == ProbeNode.UNWIND_ACTION_REENTER) { + continue; + } else if (result != null) { + returnValue = result; + break; + } + throw t; + } + } + return returnValue; + } + + @Override + public RSyntaxNode getRSyntaxNode() { + return delegate.asRSyntaxNode(); + } + + @Override + public SourceSection getSourceSection() { + return delegate.getSourceSection(); + } +} diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/instrumentation/RNodeWrapperFactory.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/instrumentation/RNodeWrapperFactory.java deleted file mode 100644 index 480ebdc980..0000000000 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nodes/instrumentation/RNodeWrapperFactory.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.truffle.r.runtime.nodes.instrumentation; - -import com.oracle.truffle.api.frame.VirtualFrame; -import com.oracle.truffle.api.instrumentation.InstrumentableNode; -import com.oracle.truffle.api.instrumentation.ProbeNode; -import com.oracle.truffle.api.nodes.Node; -import com.oracle.truffle.api.nodes.NodeCost; -import com.oracle.truffle.api.nodes.NodeInfo; -import com.oracle.truffle.api.source.SourceSection; -import com.oracle.truffle.r.runtime.nodes.RNode; -import com.oracle.truffle.r.runtime.nodes.RSyntaxNode; - -public final class RNodeWrapperFactory { - - @NodeInfo(cost = NodeCost.NONE) - public static final class RNodeWrapper extends RNode implements InstrumentableNode.WrapperNode { - @Child private RNode delegate; - @Child private ProbeNode probeNode; - - public RNodeWrapper(RNode delegate, ProbeNode probeNode) { - assert delegate != null; - assert !(delegate instanceof RNodeWrapper); - this.delegate = delegate; - this.probeNode = probeNode; - } - - @Override - public Node getDelegateNode() { - return delegate; - } - - @Override - public ProbeNode getProbeNode() { - return probeNode; - } - - @Override - public Object execute(VirtualFrame frame) { - Object returnValue; - for (;;) { - boolean wasOnReturnExecuted = false; - try { - probeNode.onEnter(frame); - returnValue = delegate.execute(frame); - wasOnReturnExecuted = true; - probeNode.onReturnValue(frame, returnValue); - break; - } catch (Throwable t) { - Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); - if (result == ProbeNode.UNWIND_ACTION_REENTER) { - continue; - } else if (result != null) { - returnValue = result; - break; - } - throw t; - } - } - return returnValue; - } - - @Override - public void voidExecute(VirtualFrame frame) { - for (;;) { - boolean wasOnReturnExecuted = false; - try { - probeNode.onEnter(frame); - delegate.voidExecute(frame); - wasOnReturnExecuted = true; - probeNode.onReturnValue(frame, null); - break; - } catch (Throwable t) { - Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); - if (result == ProbeNode.UNWIND_ACTION_REENTER) { - continue; - } else if (result != null) { - break; - } - throw t; - } - } - } - - @Override - public Object visibleExecute(VirtualFrame frame) { - Object returnValue; - for (;;) { - boolean wasOnReturnExecuted = false; - try { - probeNode.onEnter(frame); - returnValue = delegate.visibleExecute(frame); - wasOnReturnExecuted = true; - probeNode.onReturnValue(frame, returnValue); - break; - } catch (Throwable t) { - Object result = probeNode.onReturnExceptionalOrUnwind(frame, t, wasOnReturnExecuted); - if (result == ProbeNode.UNWIND_ACTION_REENTER) { - continue; - } else if (result != null) { - returnValue = result; - break; - } - throw t; - } - } - return returnValue; - } - - @Override - public RSyntaxNode getRSyntaxNode() { - return delegate.asRSyntaxNode(); - } - - @Override - public SourceSection getSourceSection() { - return delegate.getSourceSection(); - } - } -} -- GitLab