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

Commits on Jul 9, 2015

  1. Copy the full SHA
    05393c3 View commit details
  2. Copy the full SHA
    4ea5001 View commit details
  3. Copy the full SHA
    c4635e3 View commit details
  4. Copy the full SHA
    5006a23 View commit details
  5. Copy the full SHA
    3299e5d View commit details
  6. Extract a local variable to hold the ByteList in StringIO.

    * Use begin() accessor instead of deprecated field.
    eregon committed Jul 9, 2015
    Copy the full SHA
    3912d25 View commit details
  7. Copy the full SHA
    ac5cf32 View commit details
7 changes: 4 additions & 3 deletions core/src/main/java/org/jruby/ext/stringio/StringIO.java
Original file line number Diff line number Diff line change
@@ -1126,10 +1126,11 @@ public IRubyObject write(ThreadContext context, IRubyObject arg) {

enc = ptr.string.getEncoding();
enc2 = str.getEncoding();
final ByteList strByteList = str.getByteList();
if (enc != enc2 && enc != EncodingUtils.ascii8bitEncoding(runtime)
// this is a hack because we don't seem to handle incoming ASCII-8BIT properly in transcoder
&& enc2 != ASCIIEncoding.INSTANCE) {
str = runtime.newString(EncodingUtils.strConvEnc(context, str.getByteList(), enc2, enc));
str = runtime.newString(EncodingUtils.strConvEnc(context, strByteList, enc2, enc));
}
len = str.size();
if (len == 0) return RubyFixnum.zero(runtime);
@@ -1139,11 +1140,11 @@ public IRubyObject write(ThreadContext context, IRubyObject arg) {
ptr.pos = olen;
}
if (ptr.pos == olen) {
EncodingUtils.encStrBufCat(runtime, ptr.string, str.getByteList(), enc);
EncodingUtils.encStrBufCat(runtime, ptr.string, strByteList, enc);
} else {
strioExtend(ptr.pos, len);
ByteList ptrByteList = ptr.string.getByteList();
System.arraycopy(str.getByteList().getUnsafeBytes(), str.getByteList().getBegin(), ptrByteList.getUnsafeBytes(), ptrByteList.begin + ptr.pos, len);
System.arraycopy(strByteList.getUnsafeBytes(), strByteList.getBegin(), ptrByteList.getUnsafeBytes(), ptrByteList.begin() + ptr.pos, len);
}
ptr.string.infectBy(str);
ptr.string.infectBy(this);
3 changes: 0 additions & 3 deletions spec/truffle/tags/core/kernel/__dir___tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
fails:Kernel#__dir__ returns the name of the directory containing the currently-executing file
fails:Kernel#__dir__ when used in eval with top level binding returns the name of the directory containing the currently-executing file
fails:Kernel#__dir__ returns the real name of the directory containing the currently-executing file
fails:Kernel#__dir__ when used in eval with top level binding returns the real name of the directory containing the currently-executing file
Original file line number Diff line number Diff line change
@@ -1207,8 +1207,8 @@ public RubyBasicObject includedModules(RubyModule module) {

final List<RubyModule> modules = new ArrayList<>();

for (RubyModule included : module.parentAncestors()) {
if (included.isOnlyAModule()) {
for (RubyModule included : module.ancestors()) {
if (included.isOnlyAModule() && included != module) {
modules.add(included);
}
}
Original file line number Diff line number Diff line change
@@ -34,7 +34,9 @@
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.BranchProfile;
import com.oracle.truffle.api.utilities.ConditionProfile;

import jnr.posix.POSIX;

import org.jcodings.Encoding;
import org.jcodings.exception.EncodingException;
import org.jcodings.specific.ASCIIEncoding;
@@ -755,12 +757,14 @@ public ASCIIOnlyNode(RubyContext context, SourceSection sourceSection) {
@TruffleBoundary
@Specialization
public boolean asciiOnly(RubyString string) {
if (!getByteList(string).getEncoding().isAsciiCompatible()) {
final ByteList byteList = StringNodes.getByteList(string);

if (!byteList.getEncoding().isAsciiCompatible()) {
return false;
}

for (byte b : getByteList(string).unsafeBytes()) {
if ((b & 0x80) != 0) {
for (int i = 0; i < byteList.length(); i++) {
if ((byteList.get(i) & 0x80) != 0) {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -44,7 +44,8 @@ protected static Activation getActivation(RubyBasicObject threadBacktraceLocatio
return (Activation) ACTIVATION_PROPERTY.get(threadBacktraceLocation.getDynamicObject(), true);
}

@CoreMethod(names = "absolute_path")
@CoreMethod(names = { "absolute_path", "path" })
// TODO (eregon, 8 July 2015): these two methods are slightly different (path can be relative if it is the main script)
public abstract static class AbsolutePathNode extends UnaryCoreMethodNode {

public AbsolutePathNode(RubyContext context, SourceSection sourceSection) {
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
import com.oracle.truffle.api.frame.MaterializedFrame;
import com.oracle.truffle.api.source.Source;
import com.oracle.truffle.api.source.SourceSection;

import org.jruby.Ruby;
import org.jruby.RubyGC;
import org.jruby.ext.rbconfig.RbConfigLibrary;
@@ -35,6 +36,7 @@
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.truffle.runtime.hash.BucketsStrategy;
import org.jruby.truffle.runtime.subsystems.SimpleShell;
import org.jruby.util.ByteList;
import org.jruby.util.Memo;

import java.util.HashMap;
@@ -196,8 +198,10 @@ public DumpStringNode(RubyContext context, SourceSection sourceSection) {
public RubyBasicObject dumpString(RubyString string) {
final StringBuilder builder = new StringBuilder();

for (byte b : StringNodes.getByteList(string).unsafeBytes()) {
builder.append(String.format("\\x%02x", b));
final ByteList byteList = StringNodes.getByteList(string);

for (int i = 0; i < byteList.length(); i++) {
builder.append(String.format("\\x%02x", byteList.get(i)));
}

return createString(builder.toString());
Original file line number Diff line number Diff line change
@@ -135,8 +135,7 @@ public LocateNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public Object getByte(RubyBasicObject bytes, RubyString pattern, int start, int length) {
final int index = new ByteList(getBytes(bytes).unsafeBytes(), start, length)
.indexOf(StringNodes.getByteList(pattern));
final int index = new ByteList(getBytes(bytes), start, length).indexOf(StringNodes.getByteList(pattern));

if (index == -1) {
return nil();
Original file line number Diff line number Diff line change
@@ -159,7 +159,8 @@ public IOBufferUnshiftPrimitiveNode(RubyContext context, SourceSection sourceSec
public int unshift(VirtualFrame frame, RubyBasicObject ioBuffer, RubyString string, int startPosition) {
setWriteSynced(ioBuffer, false);

int stringSize = StringNodes.getByteList(string).realSize() - startPosition;
final ByteList byteList = StringNodes.getByteList(string);
int stringSize = byteList.realSize() - startPosition;
final int usedSpace = getUsed(ioBuffer);
final int availableSpace = IOBUFFER_SIZE - usedSpace;

@@ -170,7 +171,7 @@ public int unshift(VirtualFrame frame, RubyBasicObject ioBuffer, RubyString stri
ByteList storage = ByteArrayNodes.getBytes(getStorage(ioBuffer));

// Data is copied here - can we do something COW?
System.arraycopy(StringNodes.getByteList(string).unsafeBytes(), startPosition, storage.getUnsafeBytes(), usedSpace, stringSize);
System.arraycopy(byteList.unsafeBytes(), byteList.begin() + startPosition, storage.getUnsafeBytes(), storage.begin() + usedSpace, stringSize);

setUsed(ioBuffer, usedSpace + stringSize);

Original file line number Diff line number Diff line change
@@ -238,7 +238,8 @@ public int truncate(RubyString path, int length) {

@Specialization
public int truncate(RubyString path, long length) {
final String pathString = RubyEncoding.decodeUTF8(StringNodes.getByteList(path).getUnsafeBytes(), StringNodes.getByteList(path).getBegin(), StringNodes.getByteList(path).getRealSize());
final ByteList byteList = StringNodes.getByteList(path);
final String pathString = RubyEncoding.decodeUTF8(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize());
final int result = posix().truncate(pathString, length);
if (result == -1) {
CompilerDirectives.transferToInterpreter();
@@ -469,15 +470,14 @@ public IOWritePrimitiveNode(RubyContext context, SourceSection sourceSection) {
public int write(VirtualFrame frame, RubyBasicObject file, RubyString string) {
final int fd = getDescriptor(file);

final ByteList byteList = StringNodes.getByteList(string);

if (getContext().getDebugStandardOut() != null && fd == STDOUT) {
getContext().getDebugStandardOut().write(StringNodes.getByteList(string).unsafeBytes(), StringNodes.getByteList(string).begin(), StringNodes.getByteList(string).length());
return StringNodes.getByteList(string).length();
getContext().getDebugStandardOut().write(byteList.unsafeBytes(), byteList.begin(), byteList.length());
return byteList.length();
}

// We have to copy here as write starts at byte[0], and the ByteList may not

final ByteList byteList = StringNodes.getByteList(string);

// TODO (eregon, 11 May 2015): review consistency under concurrent modification
final ByteBuffer buffer = ByteBuffer.wrap(byteList.unsafeBytes(), byteList.begin(), byteList.length());

Original file line number Diff line number Diff line change
@@ -12,8 +12,10 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;

import jnr.constants.platform.Fcntl;
import jnr.ffi.Pointer;

import org.jruby.RubyEncoding;
import org.jruby.platform.Platform;
import org.jruby.truffle.nodes.core.CoreClass;
@@ -24,6 +26,7 @@
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.util.ByteList;

import java.nio.charset.StandardCharsets;

@@ -314,7 +317,8 @@ public ReadlinkNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isRubyPointer(pointer)")
public int readlink(RubyString path, RubyBasicObject pointer, int bufsize) {
final String pathString = RubyEncoding.decodeUTF8(StringNodes.getByteList(path).getUnsafeBytes(), StringNodes.getByteList(path).getBegin(), StringNodes.getByteList(path).getRealSize());
final ByteList byteList = StringNodes.getByteList(path);
final String pathString = RubyEncoding.decodeUTF8(byteList.unsafeBytes(), byteList.begin(), byteList.length());

final int result = posix().readlink(pathString, PointerNodes.getPointer(pointer), bufsize);
if (result == -1) {
@@ -369,7 +373,8 @@ public UnlinkNode(RubyContext context, SourceSection sourceSection) {

@Specialization
public int unlink(RubyString path) {
return posix().unlink(RubyEncoding.decodeUTF8(StringNodes.getByteList(path).getUnsafeBytes(), StringNodes.getByteList(path).getBegin(), StringNodes.getByteList(path).getRealSize()));
final ByteList byteList = StringNodes.getByteList(path);
return posix().unlink(RubyEncoding.decodeUTF8(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize()));
}

}
@@ -397,7 +402,8 @@ public UnsetenvNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isRubyString(name)")
public int unsetenv(RubyBasicObject name) {
final String nameString = RubyEncoding.decodeUTF8(StringNodes.getByteList(name).getUnsafeBytes(), StringNodes.getByteList(name).getBegin(), StringNodes.getByteList(name).getRealSize());
final ByteList byteList = StringNodes.getByteList(name);
final String nameString = RubyEncoding.decodeUTF8(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize());

return posix().unsetenv(nameString);
}
@@ -413,7 +419,8 @@ public UtimesNode(RubyContext context, SourceSection sourceSection) {

@Specialization(guards = "isRubyPointer(pointer)")
public int utimes(RubyString path, RubyBasicObject pointer) {
final String pathString = RubyEncoding.decodeUTF8(StringNodes.getByteList(path).getUnsafeBytes(), StringNodes.getByteList(path).getBegin(), StringNodes.getByteList(path).getRealSize());
final ByteList byteList = StringNodes.getByteList(path);
final String pathString = RubyEncoding.decodeUTF8(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize());

final int result = posix().utimes(pathString, PointerNodes.getPointer(pointer));
if (result == -1) {
Original file line number Diff line number Diff line change
@@ -13,14 +13,17 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.HiddenKey;
import com.oracle.truffle.api.source.SourceSection;

import jnr.posix.FileStat;

import org.jruby.RubyEncoding;
import org.jruby.truffle.nodes.core.StringNodes;
import org.jruby.truffle.nodes.objectstorage.ReadHeadObjectFieldNode;
import org.jruby.truffle.nodes.objectstorage.WriteHeadObjectFieldNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.util.ByteList;

public abstract class StatPrimitiveNodes {

@@ -168,7 +171,8 @@ public StatStatPrimitiveNode(RubyContext context, SourceSection sourceSection) {
@Specialization
public int stat(RubyBasicObject rubyStat, RubyString path) {
final FileStat stat = posix().allocateStat();
final String pathString = RubyEncoding.decodeUTF8(StringNodes.getByteList(path).getUnsafeBytes(), StringNodes.getByteList(path).getBegin(), StringNodes.getByteList(path).getRealSize());
final ByteList byteList = StringNodes.getByteList(path);
final String pathString = RubyEncoding.decodeUTF8(byteList.getUnsafeBytes(), byteList.getBegin(), byteList.getRealSize());
final int code = posix().stat(pathString, stat);

if (code == 0) {
Loading