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

Commits on Sep 12, 2016

  1. [Truffle] All known encoding names are US-ASCII.

    While it's possible in theory to have a new encoding using non-ASCII names, all of the ones in jCodings are US-ASCII and MRI returns US-ASCII for the names of each encoding. Switching to US-ASCII avoids a code range scan, since an ASCII-8BIT string can be either CR_7BIT or CR_VALID, while US-ASCII can only be CR_7BIT. Also, since the jCodings names can't change, there's no need to make a defensive copy here, so we can do away with the unnecessary ByteList allocation.
    nirvdrum committed Sep 12, 2016
    Copy the full SHA
    c7fdb07 View commit details
  2. [Truffle] Removed unnecessary ByteList allocation.

    This also avoids the defensive copy of memory we make when converting a rope to a ByteList.
    nirvdrum committed Sep 12, 2016
    Copy the full SHA
    6dc0f91 View commit details
Original file line number Diff line number Diff line change
@@ -19,6 +19,7 @@
import org.jcodings.Encoding;
import org.jcodings.EncodingDB;
import org.jcodings.Ptr;
import org.jcodings.specific.USASCIIEncoding;
import org.jcodings.transcode.EConv;
import org.jcodings.transcode.EConvFlags;
import org.jcodings.transcode.EConvResult;
@@ -167,11 +168,11 @@ public Object transcodingMap(VirtualFrame frame) {
final TranscoderDB.Entry e = destinationEntry.value;

if (key == null) {
final Object upcased = upcaseNode.call(frame, createString(new ByteList(e.getSource())), "upcase");
final Object upcased = upcaseNode.call(frame, createString(e.getSource(), USASCIIEncoding.INSTANCE), "upcase");
key = toSymNode.call(frame, upcased, "to_sym");
}

final Object upcasedLookupTableKey = upcaseNode.call(frame, createString(new ByteList(e.getDestination())), "upcase");
final Object upcasedLookupTableKey = upcaseNode.call(frame, createString(e.getDestination(), USASCIIEncoding.INSTANCE), "upcase");
final Object lookupTableKey = toSymNode.call(frame, upcasedLookupTableKey, "to_sym");
final Object lookupTableValue = newTranscodingNode.call(frame, coreLibrary().getTranscodingClass(), "create", key, lookupTableKey);
lookupTableWriteNode.call(frame, value, "[]=", lookupTableKey, lookupTableValue);
Original file line number Diff line number Diff line change
@@ -465,7 +465,7 @@ public DynamicObject eachAlias(VirtualFrame frame, DynamicObject block) {
CompilerAsserts.neverPartOfCompilation();
for (HashEntry<Entry> entry : EncodingDB.getAliases().entryIterator()) {
final CaseInsensitiveBytesHashEntry<Entry> e = (CaseInsensitiveBytesHashEntry<Entry>) entry;
final ByteList aliasName = new ByteList(e.bytes, e.p, e.end - e.p);
final ByteList aliasName = new ByteList(e.bytes, e.p, e.end - e.p, USASCIIEncoding.INSTANCE, false);
yield(frame, block, createString(aliasName), entry.value.getIndex());
}
return nil();
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import jnr.ffi.Pointer;
import org.jcodings.specific.ASCIIEncoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.RubyContext;
@@ -318,7 +319,7 @@ public DynamicObject readNullPointer(DynamicObject pointer) {
@TruffleBoundary
@Specialization(guards = "!isNullPointer(pointer)")
public DynamicObject readStringToNull(DynamicObject pointer) {
return createString(new ByteList(MemoryIO.getInstance().getZeroTerminatedByteArray(Layouts.POINTER.getPointer(pointer).address())));
return createString(MemoryIO.getInstance().getZeroTerminatedByteArray(Layouts.POINTER.getPointer(pointer).address()), ASCIIEncoding.INSTANCE);
}

}