diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EncodeString.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EncodeString.java index 9ab436ca6dc76559ac8ab5ae4107d78c00565c48..929833c85db81011d1549b1da642863bad781377 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EncodeString.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/EncodeString.java @@ -4,7 +4,7 @@ * http://www.gnu.org/licenses/gpl-2.0.html * * Copyright (c) 2014, Purdue University - * Copyright (c) 2014, 2016, Oracle and/or its affiliates + * Copyright (c) 2014, 2017, Oracle and/or its affiliates * * All rights reserved. */ @@ -28,6 +28,7 @@ import com.oracle.truffle.r.nodes.builtin.CastBuilder; import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.runtime.RError; import com.oracle.truffle.r.runtime.RRuntime; +import com.oracle.truffle.r.runtime.Utils; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.data.RDataFactory; import com.oracle.truffle.r.runtime.data.RStringVector; @@ -92,11 +93,6 @@ public abstract class EncodeString extends RBuiltinNode { return sb.toString(); } - @TruffleBoundary - private static String format(final String format, final String arg) { - return String.format(format, arg); - } - @SuppressWarnings("unused") @Specialization(guards = {"leftJustify(justify)", "encodeNA"}) protected RStringVector encodeStringLeftJustifyEncodeNA(RAbstractStringVector x, int width, final String quoteEl, RAbstractIntVector justify, boolean encodeNA) { @@ -110,9 +106,9 @@ public abstract class EncodeString extends RBuiltinNode { if (quoteEl.isEmpty()) { currentEl = concat("<", currentEl, ">"); } - result[i] = format(concat("%-", maxElWidth, "s"), currentEl); + result[i] = Utils.stringFormat(concat("%-", maxElWidth, "s"), currentEl); } else { - result[i] = format(concat("%-", maxElWidth, "s"), concat(quoteEl, currentEl, quoteEl)); + result[i] = Utils.stringFormat(concat("%-", maxElWidth, "s"), concat(quoteEl, currentEl, quoteEl)); } } return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR); @@ -132,7 +128,7 @@ public abstract class EncodeString extends RBuiltinNode { result[i] = currentEl; seenNA = true; } else { - result[i] = format(concat("%-", maxElWidth, "s"), concat(quoteEl, currentEl, quoteEl)); + result[i] = Utils.stringFormat(concat("%-", maxElWidth, "s"), concat(quoteEl, currentEl, quoteEl)); } } return RDataFactory.createStringVector(result, !seenNA); @@ -151,9 +147,9 @@ public abstract class EncodeString extends RBuiltinNode { if (quoteEl.isEmpty()) { currentEl = concat("<", currentEl, ">"); } - result[i] = format(concat("%", maxElWidth, "s"), currentEl); + result[i] = Utils.stringFormat(concat("%", maxElWidth, "s"), currentEl); } else { - result[i] = format(concat("%", maxElWidth, "s"), concat(quoteEl, currentEl, quoteEl)); + result[i] = Utils.stringFormat(concat("%", maxElWidth, "s"), concat(quoteEl, currentEl, quoteEl)); } } return RDataFactory.createStringVector(result, RDataFactory.COMPLETE_VECTOR); @@ -173,7 +169,7 @@ public abstract class EncodeString extends RBuiltinNode { result[i] = currentEl; seenNA = true; } else { - result[i] = format(concat("%", maxElWidth, "s"), concat(quoteEl, currentEl, quoteEl)); + result[i] = Utils.stringFormat(concat("%", maxElWidth, "s"), concat(quoteEl, currentEl, quoteEl)); } } return RDataFactory.createStringVector(result, !seenNA); diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRTry.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRTry.java index 315f1f2c0aad2161732c7d25cb6d09620e3a958d..4f36ba52d0e3d898517ba8461e3c8cb7a048cd30 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRTry.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/FastRTry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -25,6 +25,7 @@ package com.oracle.truffle.r.nodes.builtin.fastr; import static com.oracle.truffle.r.runtime.builtins.RBehavior.COMPLEX; import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE; +import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.frame.FrameSlot; import com.oracle.truffle.api.frame.VirtualFrame; @@ -33,7 +34,6 @@ import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; import com.oracle.truffle.r.nodes.function.RCallBaseNode; import com.oracle.truffle.r.nodes.function.RCallNode; import com.oracle.truffle.r.runtime.RRuntime; -import com.oracle.truffle.r.runtime.Utils; import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.data.RArgsValuesAndNames; import com.oracle.truffle.r.runtime.data.RFunction; @@ -56,10 +56,15 @@ public abstract class FastRTry extends RBuiltinNode { frame.setObject(frameSlot, RArgsValuesAndNames.EMPTY); call.execute(frame, func); } catch (Throwable ex) { - return Utils.stringFormat("Exception %s, message: %s", ex.getClass().getSimpleName(), ex.getMessage()); + return formatError(ex); } finally { frame.setObject(frameSlot, null); } return RRuntime.LOGICAL_TRUE; } + + @TruffleBoundary + private static String formatError(Throwable ex) { + return String.format("Exception %s, message: %s", ex.getClass().getSimpleName(), ex.getMessage()); + } } diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/ArrayAttributeNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/ArrayAttributeNode.java index cfe144c94ac383973b0dd0babfa49227070b4415..79e1029c41caf36bc291d62ba3383325411cd3e2 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/ArrayAttributeNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/ArrayAttributeNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -71,11 +71,10 @@ public abstract class ArrayAttributeNode extends AttributeIterativeAccessNode { Shape shape = attrs.getShape(); List<Property> props = shape.getPropertyList(); RAttribute[] result = new RAttribute[props.size()]; - int i = 0; - for (Property p : props) { + for (int i = 0; i < result.length; i++) { + Property p = props.get(i); Object value = readProperty(attrs, shape, p); result[i] = new RAttributesLayout.AttrInstance((String) p.getKey(), value); - i++; } return result; diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/CopyOfRegAttributesNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/CopyOfRegAttributesNode.java index d1422eebc32fb87cfcdb041b1b411aae9a1a2c35..05d4cf11a6e67f1c7f78397b8072c9184fd52655 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/CopyOfRegAttributesNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/attributes/CopyOfRegAttributesNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -22,6 +22,8 @@ */ package com.oracle.truffle.r.nodes.attributes; +import java.util.List; + import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.object.DynamicObject; import com.oracle.truffle.api.object.Property; @@ -111,7 +113,9 @@ public abstract class CopyOfRegAttributesNode extends RBaseNode { DynamicObject orgAttributes = source.getAttributes(); if (orgAttributes != null) { Shape shape = orgAttributes.getShape(); - for (Property p : shape.getProperties()) { + List<Property> properties = shape.getPropertyList(); + for (int i = 0; i < properties.size(); i++) { + Property p = properties.get(i); String name = (String) p.getKey(); if (name != RRuntime.DIM_ATTR_KEY && name != RRuntime.DIMNAMES_ATTR_KEY && name != RRuntime.NAMES_ATTR_KEY) { Object val = p.get(orgAttributes, shape); diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/TOMS708.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/TOMS708.java index 1b16b566ec9cf72601b1c0ba297249ca18c7f61c..4ce3b2c8b2cfeb4290b9e1c25efb16c5714c484d 100644 --- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/TOMS708.java +++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/nmath/TOMS708.java @@ -350,7 +350,7 @@ public final class TOMS708 { ierr = 8; } if (w1 < 0) { - RError.warning(RError.SHOW_CALLER, Message.GENERIC, String.format("bratio(a=%f, b=%f, x=%f): bgrat() -> w1 = %f", a, b, x, w1)); + RError.warning(RError.SHOW_CALLER, Message.GENERIC, Utils.stringFormat("bratio(a=%f, b=%f, x=%f): bgrat() -> w1 = %f", a, b, x, w1)); } state = States.L_end_from_w1; continue;