From 53cdffbc562f498aee13cee678f41db681bb4932 Mon Sep 17 00:00:00 2001 From: Adam Welc <adam.welc@oracle.com> Date: Fri, 12 Feb 2016 15:27:53 +0100 Subject: [PATCH] Class name caching in dispatch generic should no work in more cases at a small additional cost. --- .../truffle/r/nodes/objects/DispatchGeneric.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/objects/DispatchGeneric.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/objects/DispatchGeneric.java index 70770c2e89..312a4e8ae6 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/objects/DispatchGeneric.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/objects/DispatchGeneric.java @@ -18,6 +18,7 @@ import com.oracle.truffle.api.dsl.Cached; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.VirtualFrame; import com.oracle.truffle.api.profiles.ConditionProfile; +import com.oracle.truffle.api.profiles.BranchProfile; import com.oracle.truffle.r.nodes.access.variables.LocalReadVariableNode; import com.oracle.truffle.r.nodes.access.variables.ReadVariableNode; import com.oracle.truffle.r.nodes.function.signature.RArgumentsNode; @@ -32,6 +33,7 @@ public abstract class DispatchGeneric extends RBaseNode { public abstract Object executeObject(VirtualFrame frame, REnvironment mtable, RStringVector classes, RFunction fdef, String fname); private final ConditionProfile singleStringProfile = ConditionProfile.createBinaryProfile(); + private final BranchProfile equalsMethodRequired = BranchProfile.create(); @Child private RArgumentsNode argsNode = RArgumentsNode.create(); @Child private LoadMethod loadMethod = LoadMethodNodeGen.create(); @Child private ExecuteMethod executeMethod = new ExecuteMethod(); @@ -98,7 +100,13 @@ public abstract class DispatchGeneric extends RBaseNode { // TODO: makes sure equality is good enough here, but it's for optimization only // anwyay if (cachedClasses.getDataAt(i) != classes.getDataAt(i)) { - return false; + equalsMethodRequired.enter(); + if (cachedClasses.getDataAt(i).equals(classes.getDataAt(i))) { + return true; + } + else { + return false; + } } } return true; -- GitLab