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: ea64ba180249
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 43dddfb8da0d
Choose a head ref
  • 3 commits
  • 3 files changed
  • 1 contributor

Commits on Mar 28, 2016

  1. Copy the full SHA
    cb0f0a9 View commit details
  2. [Truffle] Switched to optimized RopeNodes.GetByteNode for single byte…

    …-optimizable String#ord.
    nirvdrum committed Mar 28, 2016
    Copy the full SHA
    ca4915f View commit details
  3. Copy the full SHA
    43dddfb View commit details
Original file line number Diff line number Diff line change
@@ -82,8 +82,9 @@ public Rope substringZeroBytes(Rope base, int offset, int byteLength,
public Rope substringOneByte(Rope base, int offset, int byteLength,
@Cached("createBinaryProfile()") ConditionProfile isUTF8,
@Cached("createBinaryProfile()") ConditionProfile isUSAscii,
@Cached("createBinaryProfile()") ConditionProfile isAscii8Bit) {
final int index = base.get(offset) & 0xff;
@Cached("createBinaryProfile()") ConditionProfile isAscii8Bit,
@Cached("create(getContext(), getSourceSection())") GetByteNode getByteNode) {
final int index = getByteNode.executeGetByte(base, offset);

if (isUTF8.profile(base.getEncoding() == UTF8Encoding.INSTANCE)) {
return RopeConstants.UTF8_SINGLE_BYTE_ROPES[index];
@@ -634,6 +635,10 @@ protected int getCacheLimit() {
})
public abstract static class GetByteNode extends RubyNode {

public static GetByteNode create(RubyContext context, SourceSection sourceSection) {
return RopeNodesFactory.GetByteNodeGen.create(context, sourceSection, null, null);
}

public GetByteNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
Original file line number Diff line number Diff line change
@@ -1302,8 +1302,11 @@ public DynamicObject stringResizeCapacity(DynamicObject string, int capacity) {
@RubiniusPrimitive(name = "string_rindex", lowerFixnumParameters = 1)
public static abstract class StringRindexPrimitiveNode extends RubiniusPrimitiveArrayArgumentsNode {

@Child private RopeNodes.GetByteNode getByteNode;

public StringRindexPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
getByteNode = RopeNodes.GetByteNode.create(context, sourceSection);
}

@Specialization(guards = "isRubyString(pattern)")
@@ -1332,7 +1335,7 @@ public Object stringRindex(DynamicObject string, DynamicObject pattern, int star
}

case 1: {
final int matcher = patternRope.get(0);
final int matcher = getByteNode.executeGetByte(patternRope, 0);

while (pos >= 0) {
if (stringRope.get(pos) == matcher) {
Original file line number Diff line number Diff line change
@@ -1595,6 +1595,8 @@ public DynamicObject setNumBytes(DynamicObject string, int count) {
@ImportStatic(StringGuards.class)
public abstract static class OrdNode extends CoreMethodArrayArgumentsNode {

@Child private RopeNodes.GetByteNode ropeGetByteNode;

public OrdNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}
@@ -1608,7 +1610,12 @@ public int ordEmpty(DynamicObject string) {
// TODO (nirvdrum 03-Feb-16): Is it possible to have a single-byte optimizable string that isn't ASCII-compatible?
@Specialization(guards = { "!isEmpty(string)", "isSingleByteOptimizable(string)" })
public int ordAsciiOnly(DynamicObject string) {
return rope(string).get(0) & 0xff;
if (ropeGetByteNode == null) {
CompilerDirectives.transferToInterpreter();
ropeGetByteNode = insert(RopeNodes.GetByteNode.create(getContext(), getSourceSection()));
}

return ropeGetByteNode.executeGetByte(rope(string), 0);
}

@Specialization(guards = { "!isEmpty(string)", "!isSingleByteOptimizable(string)" })