diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java
index 30de7c5d7daaeceadfe21a932c989064b9d4a3d2..784cddf210d8607425d303da5ff9f39d42771fa5 100644
--- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java
+++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Parse.java
@@ -258,7 +258,7 @@ public abstract class Parse extends RBuiltinNode.Arg6 {
         }
         setSrcRefAttrNode.execute(exprs, RDataFactory.createList(srcrefData));
         int[] wholeSrcrefData = new int[8];
-        int endOffset = source.getCode().length() - 1;
+        int endOffset = source.getCharacters().length() - 1;
         wholeSrcrefData[0] = source.getLineNumber(0);
         wholeSrcrefData[3] = source.getLineNumber(endOffset);
         source.getColumnNumber(0);
diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/printer/FunctionPrinter.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/printer/FunctionPrinter.java
index d8de3b9f0c34652365a9f3a7665984c8d9426eb6..d3650ff31fa5796c78d09139533653838f0ca355 100644
--- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/printer/FunctionPrinter.java
+++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/printer/FunctionPrinter.java
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, 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
@@ -82,7 +82,7 @@ final class FunctionPrinter extends AbstractValuePrinter<RFunction> {
             if (printCtx.parameters().getUseSource()) {
                 SourceSection sourceSection = ((RSyntaxFunction) operand.getRootNode()).getLazySourceSection();
                 if (sourceSection != null && sourceSection != RSyntaxNode.LAZY_DEPARSE) {
-                    source = sourceSection.getCode();
+                    source = sourceSection.getCharacters().toString();
                 }
             }
             if (source == null) {
diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java
index 11cbc9ac724d29fb42f9bf2cc27bff32a31d5ed2..2b8924f85ebe078dad6f134e0c5762cc2c3d7fa3 100644
--- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java
+++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRInterop.java
@@ -713,9 +713,10 @@ public class FastRInterop {
         @Specialization(guards = "isJavaObject(obj)")
         @TruffleBoundary
         public Object toArray(TruffleObject obj, @SuppressWarnings("unused") RMissing missing, @SuppressWarnings("unused") boolean flat,
+                        @Cached("HAS_SIZE.createNode()") Node hasSize,
                         @Cached("WRITE.createNode()") Node write) {
 
-            if (JavaInterop.isArray(obj)) {
+            if (ForeignAccess.sendHasSize(hasSize, obj)) {
                 // TODO should return copy?
                 return obj;
             }
diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRSyntaxTree.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRSyntaxTree.java
index 41e42f0a135329bf7ec09355c304c36d8f4b5aa1..0ca769eaa5f61d79ae53d718546f80371122e906 100644
--- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRSyntaxTree.java
+++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRSyntaxTree.java
@@ -211,9 +211,12 @@ public abstract class FastRSyntaxTree extends RBuiltinNode.Arg4 {
     }
 
     private static void printSourceCode(SourceSection ss) {
-        String code = ss.getCode();
-        if (code.length() > 40) {
-            code = code.substring(0, 40) + " ....";
+        CharSequence codeText = ss.getCharacters();
+        String code;
+        if (codeText.length() > 40) {
+            code = codeText.subSequence(0, 40) + " ....";
+        } else {
+            code = codeText.toString();
         }
         code = code.replace("\n", "\\n ");
         writeString(" # ", false);
diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/MemAllocProfilerPrinter.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/MemAllocProfilerPrinter.java
index c3cda91fda8596729ce54f97f3c9b1ab2cf4a595..e7715289848c0b210efbc29ffab7bfafaccc0ab5 100644
--- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/MemAllocProfilerPrinter.java
+++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/MemAllocProfilerPrinter.java
@@ -110,7 +110,7 @@ public final class MemAllocProfilerPrinter {
                 out.println("No source available");
             } else {
                 out.format("<<< %s at %s:%s\n", entry.getName(), sel.getStartLine(), sel.getStartColumn());
-                out.println(sel.getCode());
+                out.println(sel.getCharacters());
                 out.format(">>> %s at %s:%s\n", entry.getName(), sel.getEndLine(), sel.getEndColumn());
             }
         }
diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTBuilder.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTBuilder.java
index 9804249bf44414d431978d3717805b1b4cf7b260..4f3115f233669eec29fe85ccfce468ae46e79744 100644
--- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTBuilder.java
+++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/RASTBuilder.java
@@ -170,8 +170,8 @@ public final class RASTBuilder implements RCodeBuilder<RSyntaxNode> {
         } else if (assignedTo instanceof RSyntaxLookup) {
             return ((RSyntaxLookup) assignedTo).getIdentifier();
         } else {
-            String functionBody = source.getCode();
-            return functionBody.substring(0, Math.min(functionBody.length(), 40)).replace("\n", "\\n");
+            CharSequence functionBody = source.getCharacters();
+            return functionBody.subSequence(0, Math.min(functionBody.length(), 40)).toString().replace("\n", "\\n");
         }
     }
 
diff --git a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/DefaultRParserFactory.java b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/DefaultRParserFactory.java
index b9cbcdb5646fd53dadd8c4de017941b878062982..c40e18b0de3aa845b13b8b83cf611bd65d66e007 100644
--- a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/DefaultRParserFactory.java
+++ b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/DefaultRParserFactory.java
@@ -88,8 +88,8 @@ public class DefaultRParserFactory extends RParserFactory {
         }
 
         private static ParseException handleRecognitionException(Source source, RecognitionException e) throws IncompleteSourceException, ParseException {
-            String line = e.line <= source.getLineCount() ? source.getCode(e.line) : "";
-            String substring = line.substring(0, Math.min(line.length(), e.charPositionInLine + 1));
+            CharSequence line = e.line <= source.getLineCount() ? source.getCharacters(e.line) : "";
+            String substring = line.subSequence(0, Math.min(line.length(), e.charPositionInLine + 1)).toString();
             String token = e.token == null ? (substring.length() == 0 ? "" : substring.substring(substring.length() - 1)) : e.token.getText();
             if (e.getUnexpectedType() == Token.EOF && (e instanceof NoViableAltException || e instanceof MismatchedTokenException)) {
                 // the parser got stuck at the eof, request another line
diff --git a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g
index bc0af11a7ac5e645ae0f930cdceb4b535ae59d9a..8e11dfacc9b097e2e20a305bb50b232f23b9a981 100644
--- a/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g
+++ b/com.oracle.truffle.r.parser/src/com/oracle/truffle/r/parser/R.g
@@ -76,7 +76,7 @@ import com.oracle.truffle.r.runtime.RError;
      * Always use this constructor to initialize the R specific fields.
      */
     public RParser(Source source, RCodeBuilder<T> builder, TruffleRLanguage language) {
-        super(new CommonTokenStream(new RLexer(new ANTLRStringStream(source.getCode()))));
+        super(new CommonTokenStream(new RLexer(new ANTLRStringStream(source.getCharacters().toString()))));
         assert source != null && builder != null;
         this.source = source;
         this.initialSource = source;
@@ -154,7 +154,7 @@ import com.oracle.truffle.r.runtime.RError;
 	    			String path = commentLine.substring(q0+1, q1);
 	    			try {
 	    			    String content = new String(Files.readAllBytes(Paths.get(path)), StandardCharsets.UTF_8);
-	    			    String lineEnding = detectLineEnding(initialSource.getCode());
+	    			    String lineEnding = detectLineEnding(initialSource.getCharacters());
 	    			    content = convertToLineEnding(content, lineEnding);
                         source = RSource.fromFileName(content, path, false);
                         fileStartOffset = commentToken.getStopIndex() + 1;
@@ -175,16 +175,22 @@ import com.oracle.truffle.r.runtime.RError;
 		fileStartOffset = 0;
 	}
 
-	private String detectLineEnding(String code) {
-		int lf = code.indexOf("\n");
-		int crlf = code.indexOf("\r\n");
-		
-		if(crlf != -1 && crlf < lf) {
-			return "\r\n";
-		}
-		return "\n";
-	}
-	
+        private String detectLineEnding(CharSequence code) {
+                int codeLen = code.length();
+                for (int i = 0; i < codeLen; i++) {
+                    switch (code.charAt(i)) {
+                        case '\r':
+                            if (i + 1 < codeLen && code.charAt(i+1) == '\n') {
+                                return "\r\n";
+                            }
+                            break;
+                        case '\n':
+                            return "\n";
+                    }
+                }
+                return "\n";
+        }
+                
 	private String convertToLineEnding(String content, String lineEnding) {
 		if("\n".equals(lineEnding)) {
 			return content.replaceAll("\\r\\n", "\n");
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSrcref.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSrcref.java
index e8da4c611e3dab75d3cc60c6baacf2a4d9c51162..2c12795441ea8f509b52d4db5d6d8cfdf4b5a7f5 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSrcref.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/RSrcref.java
@@ -164,7 +164,7 @@ public class RSrcref {
                 env.put(SrcrefFields.fixedNewlines.name(), RRuntime.LOGICAL_TRUE);
                 String[] lines = new String[source.getLineCount()];
                 for (int i = 0; i < lines.length; i++) {
-                    lines[i] = source.getCode(i + 1);
+                    lines[i] = source.getCharacters(i + 1).toString();
                 }
                 env.put(SrcrefFields.lines.name(), RDataFactory.createStringVector(lines, true));
                 env.safePut(SrcrefFields.Enc.name(), "unknown");
diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java
index 8dd0021279f5c625ccf18e4a945682a4dd27c662..9f9de365a6800be6007de366c8609813ea74a528 100644
--- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java
+++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/parser/TestParser.java
@@ -182,7 +182,7 @@ public class TestParser extends TestBase {
                     }
                     System.out.println("Error while parsing " + file.getAbsolutePath());
                     if (parser.isRecognitionException(t)) {
-                        System.out.println(source.getCode(parser.line(t)));
+                        System.out.println(source.getCharacters(parser.line(t)));
                         System.out.printf("%" + parser.charPositionInLine(t) + "s^%n", "");
                     }
                     System.out.println(t);
diff --git a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tck/FastRDebugTest.java b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tck/FastRDebugTest.java
index fb0161aacfad939b1c3475d327fdcde757e78a67..875dbfcf01e8c69ec2468f58781a6ff59457f181 100644
--- a/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tck/FastRDebugTest.java
+++ b/com.oracle.truffle.r.test/src/com/oracle/truffle/r/test/tck/FastRDebugTest.java
@@ -278,7 +278,7 @@ public class FastRDebugTest {
                         "}", RSource.Internal.DEBUGTEST_DEBUG);
         final Source source = RSource.fromTextInternal("x <- 10L\n" +
                         "makeActiveBinding('ab', function(v) { if(missing(v)) x else x <<- v }, .GlobalEnv)\n" +
-                        "main <- " + srcFunMain.getCode() + "\n",
+                        "main <- " + srcFunMain.getCharacters() + "\n",
                         RSource.Internal.DEBUGTEST_DEBUG);
         engine.eval(source);
 
@@ -289,7 +289,7 @@ public class FastRDebugTest {
             debuggerSession.suspendNextExecution();
         });
 
-        assertLocation(1, "main()", "x", 10, "ab", 10, "main", srcFunMain.getCode());
+        assertLocation(1, "main()", "x", 10, "ab", 10, "main", srcFunMain.getCharacters());
         stepInto(1);
         assertLocation(4, "i = 3L");
         stepOver(1);
@@ -303,7 +303,7 @@ public class FastRDebugTest {
         stepOver(1);
         assertScope(9, "i", true, false, "ab", 4, "x", 4);
         stepOut();
-        assertLocation(1, "main()", "x", 4, "ab", 4, "main", srcFunMain.getCode());
+        assertLocation(1, "main()", "x", 4, "ab", 4, "main", srcFunMain.getCharacters());
         performWork();
 
         final Source evalSource = RSource.fromTextInternal("main()\n", RSource.Internal.DEBUGTEST_EVAL);
@@ -486,7 +486,7 @@ public class FastRDebugTest {
                 assertNotNull(suspendedEvent);
                 final int currentLine = suspendedEvent.getSourceSection().getStartLine();
                 assertEquals(line, currentLine);
-                final String currentCode = suspendedEvent.getSourceSection().getCode().trim();
+                final String currentCode = suspendedEvent.getSourceSection().getCharacters().toString().trim();
                 assertEquals(code, currentCode);
                 compareScope(line, code, false, false, expectedFrame);
             } catch (RuntimeException | Error e) {
diff --git a/mx.fastr/suite.py b/mx.fastr/suite.py
index 154838f37e9a3a80639bf5b8f328a617909dc450..efdf2afa85f4ec3caa520350a887817ef76494a9 100644
--- a/mx.fastr/suite.py
+++ b/mx.fastr/suite.py
@@ -29,7 +29,7 @@ suite = {
             {
                "name" : "truffle",
                "subdir" : True,
-               "version" : "1a54617b9b05c825e6d4a9db1ef783a862fbaf01",
+               "version" : "73196584fec60b58ff8d70fd1c3d29cc2634d557",
                "urls" : [
                     {"url" : "https://github.com/graalvm/graal", "kind" : "git"},
                     {"url" : "https://curio.ssw.jku.at/nexus/content/repositories/snapshots", "kind" : "binary"},