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: 6b92a92d44f4
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7c4a01f6b28c
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Feb 4, 2016

  1. [Truffle] Switched branching max value check with a bit shift based o…

    …ne to avoid branching.
    nirvdrum committed Feb 4, 2016
    2
    Copy the full SHA
    f251975 View commit details
  2. Copy the full SHA
    7c4a01f View commit details
Showing with 16 additions and 19 deletions.
  1. +16 −19 truffle/src/main/java/org/jruby/truffle/core/RopeNodes.java
35 changes: 16 additions & 19 deletions truffle/src/main/java/org/jruby/truffle/core/RopeNodes.java
Original file line number Diff line number Diff line change
@@ -131,7 +131,7 @@ public Rope substringConcatRope(ConcatRope base, int offset, int byteLength,
}
}

return executeMake(root, offset, byteLength);
return makeSubstring(root, offset, byteLength, is7BitProfile);
}

private Rope makeSubstring(Rope base, int offset, int byteLength, ConditionProfile is7BitProfile) {
@@ -222,42 +222,38 @@ public Rope concatLeaves(LeafRope left, LeafRope right, Encoding encoding,
public Rope concatLeavesGeneral(LeafRope left, LeafRope right, Encoding encoding,
@Cached("createBinaryProfile()") ConditionProfile sameCodeRangeProfile,
@Cached("createBinaryProfile()") ConditionProfile brokenCodeRangeProfile,
@Cached("createBinaryProfile()") ConditionProfile isLeftSingleByteOptimizableProfile,
@Cached("createBinaryProfile()") ConditionProfile leftDepthGreaterThanRightProfile) {
return concat(left, right, encoding, sameCodeRangeProfile, brokenCodeRangeProfile, isLeftSingleByteOptimizableProfile, leftDepthGreaterThanRightProfile);
@Cached("createBinaryProfile()") ConditionProfile isLeftSingleByteOptimizableProfile) {
return concat(left, right, encoding, sameCodeRangeProfile, brokenCodeRangeProfile, isLeftSingleByteOptimizableProfile);
}

@Specialization(guards = { "!left.isEmpty()", "!right.isEmpty()", "right.byteLength() < SHORT_LEAF_BYTESIZE_THRESHOLD" })
public Rope concatWithReduce(ConcatRope left, LeafRope right, Encoding encoding,
@Cached("createBinaryProfile()") ConditionProfile sameCodeRangeProfile,
@Cached("createBinaryProfile()") ConditionProfile brokenCodeRangeProfile,
@Cached("createBinaryProfile()") ConditionProfile isLeftSingleByteOptimizableProfile,
@Cached("createBinaryProfile()") ConditionProfile leftDepthGreaterThanRightProfile) {
@Cached("createBinaryProfile()") ConditionProfile isLeftSingleByteOptimizableProfile) {

if ((left.getRight().byteLength() < SHORT_LEAF_BYTESIZE_THRESHOLD) && (left.getRight() instanceof LeafRope)) {
final Rope compacted = concatLeaves((LeafRope) left.getRight(), right, encoding, sameCodeRangeProfile, brokenCodeRangeProfile);
return concat(left.getLeft(), compacted, encoding, sameCodeRangeProfile, brokenCodeRangeProfile, isLeftSingleByteOptimizableProfile, leftDepthGreaterThanRightProfile);
return concat(left.getLeft(), compacted, encoding, sameCodeRangeProfile, brokenCodeRangeProfile, isLeftSingleByteOptimizableProfile);
}

return concat(left, right, encoding, sameCodeRangeProfile, brokenCodeRangeProfile, isLeftSingleByteOptimizableProfile, leftDepthGreaterThanRightProfile);
return concat(left, right, encoding, sameCodeRangeProfile, brokenCodeRangeProfile, isLeftSingleByteOptimizableProfile);
}

@Specialization(guards = { "!left.isEmpty()", "!right.isEmpty()", "right.byteLength() < SHORT_LEAF_BYTESIZE_THRESHOLD" })
public Rope concatSubstringLeaf(SubstringRope left, LeafRope right, Encoding encoding,
@Cached("createBinaryProfile()") ConditionProfile sameCodeRangeProfile,
@Cached("createBinaryProfile()") ConditionProfile brokenCodeRangeProfile,
@Cached("createBinaryProfile()") ConditionProfile isLeftSingleByteOptimizableProfile,
@Cached("createBinaryProfile()") ConditionProfile leftDepthGreaterThanRightProfile) {
return concat(left, right, encoding, sameCodeRangeProfile, brokenCodeRangeProfile, isLeftSingleByteOptimizableProfile, leftDepthGreaterThanRightProfile);
@Cached("createBinaryProfile()") ConditionProfile isLeftSingleByteOptimizableProfile) {
return concat(left, right, encoding, sameCodeRangeProfile, brokenCodeRangeProfile, isLeftSingleByteOptimizableProfile);
}

@Specialization(guards = { "!left.isEmpty()", "!right.isEmpty()" })
public Rope concat(Rope left, Rope right, Encoding encoding,
@Cached("createBinaryProfile()") ConditionProfile sameCodeRangeProfile,
@Cached("createBinaryProfile()") ConditionProfile brokenCodeRangeProfile,
@Cached("createBinaryProfile()") ConditionProfile isLeftSingleByteOptimizableProfile,
@Cached("createBinaryProfile()") ConditionProfile leftDepthGreaterThanRightProfile) {
int depth = depth(left, right, leftDepthGreaterThanRightProfile);
@Cached("createBinaryProfile()") ConditionProfile isLeftSingleByteOptimizableProfile) {
int depth = depth(left, right);
/*if (depth >= 10) {
System.out.println("ConcatRope depth: " + depth);
}*/
@@ -291,12 +287,13 @@ private boolean isSingleByteOptimizable(Rope left, Rope right, ConditionProfile
return false;
}

private int depth(Rope left, Rope right, ConditionProfile leftDepthGreaterThanRightProfile) {
if (leftDepthGreaterThanRightProfile.profile(left.depth() >= right.depth())) {
return left.depth() + 1;
}
private int depth(Rope left, Rope right) {
final int x = left.depth();
final int y = right.depth();

int maxChildDepth = x - ((x - y) & ((x - y) >> (Integer.SIZE - 1)));

return right.depth() + 1;
return maxChildDepth + 1;
}

protected static boolean isShortLeafRope(Rope rope) {