From 88f8b42af1ab852cea8c9a8479bb100dd9e09b43 Mon Sep 17 00:00:00 2001
From: Florian Angerer <florian.angerer@oracle.com>
Date: Fri, 1 Sep 2017 11:31:46 +0200
Subject: [PATCH] Cleanup AttribtuesAccessNodes.

---
 .../r/ffi/impl/nodes/AttributesAccessNodes.java  | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/AttributesAccessNodes.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/AttributesAccessNodes.java
index ca69260198..4927664418 100644
--- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/AttributesAccessNodes.java
+++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/AttributesAccessNodes.java
@@ -47,10 +47,14 @@ import com.oracle.truffle.r.runtime.data.RStringVector;
 public final class AttributesAccessNodes {
 
     abstract static class ATTRIB extends FFIUpCallNode.Arg1 {
-        @Child private GetAttributesNode getAttributesNode = GetAttributesNode.create();
+        @Child private GetAttributesNode getAttributesNode;
 
         @Specialization
         public Object doAttributable(RAttributable obj) {
+            if (getAttributesNode == null) {
+                CompilerDirectives.transferToInterpreterAndInvalidate();
+                getAttributesNode = GetAttributesNode.create();
+            }
             return getAttributesNode.execute(obj);
         }
 
@@ -106,14 +110,14 @@ public final class AttributesAccessNodes {
 
     abstract static class CopyMostAttrib extends FFIUpCallNode.Arg2 {
 
-        @Child protected CopyOfRegAttributesNode copyRegAttributes = CopyOfRegAttributesNode.create();
+        @Child protected CopyOfRegAttributesNode copyRegAttributes;
 
         @Specialization
         public Object doList(RAttributeStorage x, RAttributeStorage y) {
-// if (copyRegAttributes == null) {
-// CompilerDirectives.transferToInterpreterAndInvalidate();
-// copyRegAttributes = CopyOfRegAttributesNode.create();
-// }
+            if (copyRegAttributes == null) {
+                CompilerDirectives.transferToInterpreterAndInvalidate();
+                copyRegAttributes = CopyOfRegAttributesNode.create();
+            }
             copyRegAttributes.execute(x, y);
             return null;
         }
-- 
GitLab