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

Commits on Jun 11, 2016

  1. [Truffle] Fixed a typo.

    nirvdrum committed Jun 11, 2016
    Copy the full SHA
    1c5d0a3 View commit details
  2. Copy the full SHA
    18d90e8 View commit details
  3. Copy the full SHA
    f1d1716 View commit details
  4. Copy the full SHA
    fb0a8c8 View commit details
Showing with 46 additions and 6 deletions.
  1. +1 −1 tool/jt.rb
  2. +7 −3 truffle/src/main/java/org/jruby/truffle/core/rope/Rope.java
  3. +38 −2 truffle/src/main/java/org/jruby/truffle/core/string/StringNodes.java
2 changes: 1 addition & 1 deletion tool/jt.rb
Original file line number Diff line number Diff line change
@@ -182,7 +182,7 @@ def self.find_jvmci
end

def self.igv_running?
`ps ax`.include?('IdealGraphVisualizer')
`ps ax`.include?('idealgraphvisualizer')
end

def self.ensure_igv_running
10 changes: 7 additions & 3 deletions truffle/src/main/java/org/jruby/truffle/core/rope/Rope.java
Original file line number Diff line number Diff line change
@@ -84,13 +84,17 @@ public final int depth() {

@Override
public final int hashCode() {
if (hashCode == 0) {
if (! isHashCodeCalculated()) {
hashCode = RopeOperations.hashForRange(this, 1, 0, byteLength);
}

return hashCode;
}

public final boolean isHashCodeCalculated() {
return hashCode != 0;
}

@Override
public final boolean equals(Object o) {
if (this == o) {
@@ -100,11 +104,11 @@ public final boolean equals(Object o) {
if (o instanceof Rope) {
final Rope other = (Rope) o;

if ((hashCode != 0) && (other.hashCode != 0) && (hashCode != other.hashCode)) {
if (isHashCodeCalculated() && other.isHashCodeCalculated() && (hashCode != other.hashCode)) {
return false;
}

// TODO (nirvdrum 21-Jan-16): We really should be taking the encoding into account here. We're currenly not because it breaks the symbol table.
// TODO (nirvdrum 21-Jan-16): We really should be taking the encoding into account here. We're currently not because it breaks the symbol table.
return byteLength() == other.byteLength() && Arrays.equals(getBytes(), other.getBytes());
}

Original file line number Diff line number Diff line change
@@ -3071,11 +3071,47 @@ public boolean equalCharacters(DynamicObject string, DynamicObject other) {
"!bytesReferenceEqual(string, other)",
"byteLength(string) == byteLength(other)"
}, contains = "equalCharacters")
public boolean fullEqual(DynamicObject string, DynamicObject other) {
public boolean fullEqual(DynamicObject string, DynamicObject other,
@Cached("createBinaryProfile()") ConditionProfile hashCodesCalculatedProfile,
@Cached("createBinaryProfile()") ConditionProfile differentHashCodesProfile,
@Cached("createBinaryProfile()") ConditionProfile aHasRawBytesProfile,
@Cached("createBinaryProfile()") ConditionProfile bHasRawBytesProfile) {
final Rope a = rope(string);
final Rope b = rope(other);

return a.equals(b);
if (hashCodesCalculatedProfile.profile(a.isHashCodeCalculated() && b.isHashCodeCalculated())) {
if (differentHashCodesProfile.profile(a.hashCode() != b.hashCode())) {
return false;
}
}

final byte[] aBytes;
if (aHasRawBytesProfile.profile(a.getRawBytes() != null)) {
aBytes = a.getRawBytes();
} else {
aBytes = a.getBytes();
}

final byte[] bBytes;
if (bHasRawBytesProfile.profile(b.getRawBytes() != null)) {
bBytes = b.getRawBytes();
} else {
bBytes = b.getBytes();
}

return arraysEquals(aBytes, bBytes);
}

private boolean arraysEquals(byte[] a, byte[] b) {
assert a.length == b.length;

for (int i = 0; i < a.length; i++) {
if (a[i] != b[i]) {
return false;
}
}

return true;
}

protected boolean areComparable(DynamicObject first, DynamicObject second) {