Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7f8d612a98c0
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8037c76e6ce5
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Apr 14, 2016

  1. Copy the full SHA
    93a98da View commit details
  2. Copy the full SHA
    0e80cdb View commit details
  3. Copy the full SHA
    8037c76 View commit details
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.RubyContext;
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.language.RubyNode;

/**
@@ -28,7 +29,7 @@ public StringToSymbolNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isRubyString(string)")
public DynamicObject doString(DynamicObject string) {
return getSymbol(string.toString());
return getSymbol(Layouts.STRING.getRope(string));
}

}
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@
import org.jruby.truffle.core.rope.Rope;
import org.jruby.truffle.core.rope.RopeNodes;
import org.jruby.truffle.core.rope.RopeNodesFactory;
import org.jruby.truffle.core.rope.RopeOperations;
import org.jruby.truffle.core.rubinius.ObjectPrimitiveNodes;
import org.jruby.truffle.core.rubinius.ObjectPrimitiveNodesFactory;
import org.jruby.truffle.core.string.StringCachingGuards;
@@ -687,7 +688,8 @@ private CodeLoader.DeferredCall doEvalX(DynamicObject rubySource,

// TODO (pitr 15-Oct-2015): fix this ugly hack, required for AS, copy-paste
final String space = new String(new char[Math.max(line - 1, 0)]).replace("\0", "\n");
final Source source = Source.fromText(space + code, filename);
// TODO CS 14-Apr-15 concat space + code as a rope, otherwise the string will be copied after the rope is converted
final Source source = Source.fromText(space + RopeOperations.decodeRope(getContext().getJRubyRuntime(), code), filename);

final MaterializedFrame frame = Layouts.BINDING.getFrame(binding);
final DeclarationContext declarationContext = RubyArguments.getDeclarationContext(frame);
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
import org.jruby.truffle.core.CoreMethod;
import org.jruby.truffle.core.CoreMethodArrayArgumentsNode;
import org.jruby.truffle.core.Layouts;
import org.jruby.truffle.core.rope.LazyIntRope;
import org.jruby.truffle.core.rope.RopeConstants;
import org.jruby.truffle.language.NotProvided;
import org.jruby.truffle.language.RubyNode;
@@ -1122,9 +1123,10 @@ public ToSNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@TruffleBoundary
@Specialization
public DynamicObject toS(int n, NotProvided base) {
return createString(RopeConstants.getIntegerRope(n));
return create7BitString(Integer.toString(n), USASCIIEncoding.INSTANCE);
}

@TruffleBoundary
Original file line number Diff line number Diff line change
@@ -54,26 +54,4 @@ public class RopeConstants {
}
}

private static final Map<Integer, WeakReference<LeafRope>> integerRopes = new ConcurrentHashMap<>();

@TruffleBoundary
public static LeafRope getIntegerRope(int value) {
WeakReference<LeafRope> ropeReference = integerRopes.get(value);

if (ropeReference != null && ropeReference.get() != null) {
return ropeReference.get();
}

// On misses we don't care too much about racing to populate the cache

final LeafRope rope = new AsciiOnlyLeafRope(
Integer.toString(value).getBytes(StandardCharsets.UTF_8), USASCIIEncoding.INSTANCE);

ropeReference = new WeakReference<>(rope);

integerRopes.put(value, ropeReference);

return rope;
}

}
Original file line number Diff line number Diff line change
@@ -664,7 +664,7 @@ public static Rope format(RubyContext context, Object... values) {
valueRope = StringOperations.encodeRope(decodeRope(context.getJRubyRuntime(), stringRope), UTF8Encoding.INSTANCE);
}
} else if (value instanceof Integer) {
valueRope = RopeConstants.getIntegerRope((int) value);
valueRope = StringOperations.encodeRope(Integer.toString((int) value), UTF8Encoding.INSTANCE, CodeRange.CR_7BIT);
} else if (value instanceof String) {
valueRope = context.getRopeTable().getRope((String) value);
} else {