From ca4db4a4971b5bcc25cf7c5845359efe2517276d Mon Sep 17 00:00:00 2001 From: Zbynek Slajchrt <zbynek.slajchrt@oracle.com> Date: Fri, 9 Dec 2016 12:54:34 +0100 Subject: [PATCH] More getNames() occurences treated --- .../truffle/r/nodes/builtin/base/infix/AccessField.java | 5 +++-- .../truffle/r/nodes/builtin/base/infix/SpecialsUtils.java | 6 ++++-- .../truffle/r/nodes/builtin/base/infix/UpdateField.java | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/AccessField.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/AccessField.java index 3686607446..9f848c5156 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/AccessField.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/AccessField.java @@ -39,6 +39,7 @@ import com.oracle.truffle.r.nodes.EmptyTypeSystemFlatLayout; import com.oracle.truffle.r.nodes.access.vector.ElementAccessMode; import com.oracle.truffle.r.nodes.access.vector.ExtractListElement; import com.oracle.truffle.r.nodes.access.vector.ExtractVectorNode; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.ArgumentsSignature; @@ -69,8 +70,8 @@ abstract class AccessFieldSpecial extends SpecialsUtils.ListFieldSpecialBase { } @Specialization(contains = "doList", guards = {"isSimpleList(list)", "list.getNames() != null"}) - public Object doListDynamic(RList list, String field) { - return doList(list, field, getIndex(list.getNames(), field)); + public Object doListDynamic(RList list, String field, @Cached("create()") GetNamesAttributeNode getNamesNode) { + return doList(list, field, getIndex(getNamesNode.getNames(list), field)); } @Fallback diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/SpecialsUtils.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/SpecialsUtils.java index a72d60cf05..793d882e1a 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/SpecialsUtils.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/SpecialsUtils.java @@ -26,6 +26,7 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.CompilerDirectives.CompilationFinal; import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.profiles.ValueProfile; +import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctions.GetNamesAttributeNode; import com.oracle.truffle.r.nodes.function.ClassHierarchyNode; import com.oracle.truffle.r.runtime.ArgumentsSignature; import com.oracle.truffle.r.runtime.data.RList; @@ -84,12 +85,13 @@ class SpecialsUtils { @CompilationFinal private String cachedField; @CompilationFinal private RStringVector cachedNames; @Child private ClassHierarchyNode hierarchyNode = ClassHierarchyNode.create(); + @Child protected GetNamesAttributeNode getNamesNode = GetNamesAttributeNode.create(); protected final void updateCache(RList list, String field) { if (cachedField == null) { CompilerDirectives.transferToInterpreterAndInvalidate(); cachedField = field; - cachedNames = list.getNames(); + cachedNames = getNamesNode.getNames(list); } } @@ -98,7 +100,7 @@ class SpecialsUtils { } protected final boolean isCached(RList list, String field) { - return cachedField == null || (cachedField == field && list.getNames() == cachedNames); + return cachedField == null || (cachedField == field && getNamesNode.getNames(list) == cachedNames); } protected static int getIndex(RStringVector names, String field) { diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/UpdateField.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/UpdateField.java index da44b6344d..ebbd01a056 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/UpdateField.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/infix/UpdateField.java @@ -83,7 +83,7 @@ abstract class UpdateFieldSpecial extends SpecialsUtils.ListFieldSpecialBase { @Specialization(contains = "doList", guards = {"isSimpleList(list)", "!list.isShared()", "list.getNames() != null", "isNotRNullRList(value)"}) public RList doListDynamic(RList list, String field, Object value) { - return doList(list, field, value, getIndex(list.getNames(), field)); + return doList(list, field, value, getIndex(getNamesNode.getNames(list), field)); } @SuppressWarnings("unused") -- GitLab