diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java
index f8776dbb218a5030515d5565857f811ebbcaa00a..d5efff6efc4373ec4a7162d411aa4f4d9615b327 100644
--- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java
+++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/common/JavaUpCallsRFFIImpl.java
@@ -1764,4 +1764,9 @@ public abstract class JavaUpCallsRFFIImpl implements UpCallsRFFI {
         throw implementedAsNode();
     }
 
+    @Override
+    public Object octsize(Object size) {
+        throw implementedAsNode();
+    }
+
 }
diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MiscNodes.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MiscNodes.java
index 9fed0338aa1805925b3a7d6aebf42fdb98bcbfe6..a4cb9c71e727ea4346493fdbdf4e3c07a691cf10 100644
--- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MiscNodes.java
+++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/nodes/MiscNodes.java
@@ -22,13 +22,17 @@
  */
 package com.oracle.truffle.r.ffi.impl.nodes;
 
+import java.nio.charset.Charset;
+
 import com.oracle.truffle.api.CompilerDirectives;
+import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
 import com.oracle.truffle.api.dsl.Cached;
 import com.oracle.truffle.api.dsl.Fallback;
 import com.oracle.truffle.api.dsl.Specialization;
 import com.oracle.truffle.api.dsl.TypeSystemReference;
 import com.oracle.truffle.r.ffi.impl.nodes.MiscNodesFactory.GetFunctionEnvironmentNodeGen;
 import com.oracle.truffle.r.ffi.impl.nodes.MiscNodesFactory.LENGTHNodeGen;
+import com.oracle.truffle.r.ffi.impl.nodes.MiscNodesFactory.OctSizeNodeGen;
 import com.oracle.truffle.r.ffi.impl.nodes.MiscNodesFactory.RDoNewObjectNodeGen;
 import com.oracle.truffle.r.ffi.impl.nodes.MiscNodesFactory.RDoSlotAssignNodeGen;
 import com.oracle.truffle.r.ffi.impl.nodes.MiscNodesFactory.RDoSlotNodeGen;
@@ -43,14 +47,22 @@ import com.oracle.truffle.r.nodes.attributes.SpecialAttributesFunctionsFactory.S
 import com.oracle.truffle.r.nodes.builtin.EnvironmentNodes.GetFunctionEnvironmentNode;
 import com.oracle.truffle.r.nodes.objects.NewObject;
 import com.oracle.truffle.r.nodes.objects.NewObjectNodeGen;
+import com.oracle.truffle.r.nodes.unary.CastDoubleBaseNode;
+import com.oracle.truffle.r.nodes.unary.CastDoubleBaseNodeGen;
 import com.oracle.truffle.r.runtime.RError;
+import com.oracle.truffle.r.runtime.RRuntime;
 import com.oracle.truffle.r.runtime.data.CharSXPWrapper;
 import com.oracle.truffle.r.runtime.data.RArgsValuesAndNames;
+import com.oracle.truffle.r.runtime.data.RDataFactory;
 import com.oracle.truffle.r.runtime.data.RFunction;
 import com.oracle.truffle.r.runtime.data.RNull;
+import com.oracle.truffle.r.runtime.data.RRawVector;
 import com.oracle.truffle.r.runtime.data.RSymbol;
 import com.oracle.truffle.r.runtime.data.RTypes;
 import com.oracle.truffle.r.runtime.data.model.RAbstractContainer;
+import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector;
+import com.oracle.truffle.r.runtime.data.nodes.GetDataAt;
+import com.oracle.truffle.r.runtime.data.nodes.SetDataAt;
 import com.oracle.truffle.r.runtime.env.REnvironment;
 import com.oracle.truffle.r.runtime.gnur.SEXPTYPE;
 
@@ -252,4 +264,59 @@ public final class MiscNodes {
         }
     }
 
+    @TypeSystemReference(RTypes.class)
+    public abstract static class OctSizeNode extends FFIUpCallNode.Arg1 {
+
+        private Charset asciiCharset;
+
+        protected CastDoubleBaseNode createCast() {
+            return CastDoubleBaseNodeGen.create(false, false, false);
+        }
+
+        @Specialization(guards = "size.getLength() == 1")
+        protected RRawVector octSize(RAbstractIntVector size,
+                        @Cached("create()") GetDataAt.Int getDataNode) {
+
+            int s = getDataNode.execute(size, size.getInternalStore(), 0);
+            byte[] buf = toOctalAsciiString(s);
+            return RDataFactory.createRawVector(buf);
+        }
+
+        @TruffleBoundary
+        private byte[] toOctalAsciiString(int s) {
+            if (asciiCharset == null) {
+                asciiCharset = Charset.forName("US-ASCII");
+            }
+            return asciiCharset.encode(Integer.toOctalString(s)).array();
+        }
+
+        // Transcribed from ".../utils/src/stubs.c"
+        @Specialization
+        protected RRawVector octSize(Object size,
+                        @Cached("create()") SetDataAt.Raw setDataNode,
+                        @Cached("createCast()") CastDoubleBaseNode castToDoubleNode) {
+
+            double s = (double) castToDoubleNode.executeDouble(size);
+
+            if (!RRuntime.isFinite(s) && s >= 0) {
+                throw RError.error(RError.SHOW_CALLER, RError.Message.GENERIC, "size must be finite and >= 0");
+            }
+
+            RRawVector ans = RDataFactory.createRawVector(11);
+            byte[] store = ans.getInternalStore();
+
+            for (int i = 0; i < 11; i++) {
+                double s2 = Math.floor(s / 8.0);
+                double t = s - 8.0 * s2;
+                s = s2;
+                setDataNode.setDataAtAsObject(ans, store, 10 - i, (byte) 48 + t);
+            }
+            return ans;
+        }
+
+        public static OctSizeNode create() {
+            return OctSizeNodeGen.create();
+        }
+    }
+
 }
diff --git a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/StdUpCallsRFFI.java b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/StdUpCallsRFFI.java
index 70dbd8d13a804fb8b7b1a3a095a449573f3aa841..f8a81aab1f9996222b0b2c9522cdedce03a03b1d 100644
--- a/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/StdUpCallsRFFI.java
+++ b/com.oracle.truffle.r.ffi.impl/src/com/oracle/truffle/r/ffi/impl/upcalls/StdUpCallsRFFI.java
@@ -400,4 +400,8 @@ public interface StdUpCallsRFFI {
 
     @RFFIUpCallNode(MiscNodes.GetFunctionEnvironment.class)
     Object CLOENV(Object x);
+
+    @RFFIUpCallNode(MiscNodes.OctSizeNode.class)
+    Object octsize(Object size);
+
 }
diff --git a/com.oracle.truffle.r.native/fficall/src/common/rffi_upcalls.h b/com.oracle.truffle.r.native/fficall/src/common/rffi_upcalls.h
index dca71097ea6f3248e318f18e7403cabe1fb0d80e..f7f80924ca61a74e5e53154ff4eab6cb0ddea981 100644
--- a/com.oracle.truffle.r.native/fficall/src/common/rffi_upcalls.h
+++ b/com.oracle.truffle.r.native/fficall/src/common/rffi_upcalls.h
@@ -281,6 +281,7 @@ typedef SEXP (*call_getvar)();
 typedef SEXP (*call_R_ParseVector)(SEXP text, int n, SEXP srcFile);
 typedef SEXPTYPE (*call_Rf_str2type)(const char *s);
 typedef SEXP (*call_CLOENV)(SEXP closure);
+typedef SEXP (*call_octsize)(SEXP size);
 
 // connections
 
diff --git a/com.oracle.truffle.r.native/fficall/src/common/rffi_upcallsindex.h b/com.oracle.truffle.r.native/fficall/src/common/rffi_upcallsindex.h
index faf4a45a09695111a4a4b722f1a434f4a2daa4c4..8008fede3e7cc374695fea9e699d25b50020fb22 100644
--- a/com.oracle.truffle.r.native/fficall/src/common/rffi_upcallsindex.h
+++ b/com.oracle.truffle.r.native/fficall/src/common/rffi_upcallsindex.h
@@ -170,12 +170,13 @@
 #define getOpenModeString_x 165
 #define getSummaryDescription_x 166
 #define isSeekable_x 167
-#define registerCCallable_x 168
-#define registerRoutines_x 169
-#define setDotSymbolValues_x 170
-#define unif_rand_x 171
-#define useDynamicSymbols_x 172
+#define octsize_x 168
+#define registerCCallable_x 169
+#define registerRoutines_x 170
+#define setDotSymbolValues_x 171
+#define unif_rand_x 172
+#define useDynamicSymbols_x 173
 
-#define UPCALLS_TABLE_SIZE 173
+#define UPCALLS_TABLE_SIZE 174
 
 #endif // RFFI_UPCALLSINDEX_H
diff --git a/com.oracle.truffle.r.native/fficall/src/truffle_common/Utils.c b/com.oracle.truffle.r.native/fficall/src/truffle_common/Utils.c
index 7b3a17dfc2a2dbd3fccb08d5040d491df232d83e..b5fec41f5205a2ed51775a334e96b1e0c84275bd 100644
--- a/com.oracle.truffle.r.native/fficall/src/truffle_common/Utils.c
+++ b/com.oracle.truffle.r.native/fficall/src/truffle_common/Utils.c
@@ -22,6 +22,7 @@
  */
 
 #include <rffiutils.h>
+#include "rffi_upcalls.h"
 
 void R_CheckStack(void) {
     // TODO: check for stack overflow
@@ -48,3 +49,9 @@ Rboolean isOrdered(SEXP s)
 	    && inherits(s, "factor")
 	    && inherits(s, "ordered"));
 }
+
+
+SEXP octsize(SEXP s)
+{
+	return ((call_octsize) callbacks[octsize_x])(s);
+}