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

Commits on Apr 17, 2015

  1. Copy the full SHA
    2c96b7e View commit details
  2. Copy the full SHA
    6d50e04 View commit details
Showing with 649 additions and 207 deletions.
  1. +9 −0 core/src/main/java/org/jruby/ext/JRubyPOSIXHandler.java
  2. +1 −0 spec/truffle/tags/core/encoding/default_external_tags.txt
  3. +0 −184 truffle/src/main/java/org/jruby/truffle/nodes/core/FileNodes.java
  4. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/IONodes.java
  5. +2 −2 truffle/src/main/java/org/jruby/truffle/nodes/core/ProcessNodes.java
  6. +1 −1 truffle/src/main/java/org/jruby/truffle/nodes/core/StringNodes.java
  7. +60 −0 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/ExceptionPrimitiveNodes.java
  8. +26 −8 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/PosixNodes.java
  9. +3 −0 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/RubiniusPrimitiveManager.java
  10. +4 −4 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/StatPrimitiveNodes.java
  11. +25 −4 truffle/src/main/java/org/jruby/truffle/nodes/rubinius/VMPrimitiveNodes.java
  12. +13 −2 truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java
  13. +1 −0 truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java
  14. +4 −0 truffle/src/main/java/org/jruby/truffle/runtime/core/RubyBasicObject.java
  15. +81 −0 truffle/src/main/java/org/jruby/truffle/runtime/subsystems/TrufflePOSIXHandler.java
  16. +1 −1 truffle/src/main/ruby/core.rb
  17. +12 −0 truffle/src/main/ruby/core/rubinius/bootstrap/rubinius.rb
  18. +45 −0 truffle/src/main/ruby/core/rubinius/common/errno.rb
  19. +98 −0 truffle/src/main/ruby/core/rubinius/common/exception.rb
  20. +262 −0 truffle/src/main/ruby/core/rubinius/common/file.rb
9 changes: 9 additions & 0 deletions core/src/main/java/org/jruby/ext/JRubyPOSIXHandler.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.ext;

import java.io.File;
1 change: 1 addition & 0 deletions spec/truffle/tags/core/encoding/default_external_tags.txt
Original file line number Diff line number Diff line change
@@ -3,3 +3,4 @@ windows:Encoding.default_external with command line options returns the encoding
slow:Encoding.default_external with command line options is not changed by the -U option
slow:Encoding.default_external with command line options returns the encoding specified by '-E external'
slow:Encoding.default_external with command line options returns the encoding specified by '-E external:'
fails:Encoding.default_external with command line options is not changed by the -U option
184 changes: 0 additions & 184 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/FileNodes.java
Original file line number Diff line number Diff line change
@@ -36,32 +36,6 @@
@CoreClass(name = "File")
public abstract class FileNodes {

@CoreMethod(names = "absolute_path", onSingleton = true, required = 1)
public abstract static class AbsolutePathNode extends CoreMethodNode {

public AbsolutePathNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public AbsolutePathNode(AbsolutePathNode prev) {
super(prev);
}

@Specialization
public RubyString absolutePath(RubyString path) {
notDesignedForCompilation();

String absolute = new File(path.toString()).getAbsolutePath();

if (getContext().isRunningOnWindows()) {
absolute = absolute.replace('\\', '/');
}

return getContext().makeString(absolute);
}

}

@CoreMethod(names = "close")
public abstract static class CloseNode extends CoreMethodNode {

@@ -83,32 +57,6 @@ public RubyNilClass close(RubyFile file) {

}

@CoreMethod(names = "dirname", onSingleton = true, required = 1)
public abstract static class DirnameNode extends CoreMethodNode {

public DirnameNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public DirnameNode(DirnameNode prev) {
super(prev);
}

@Specialization
public RubyString dirname(RubyString path) {
notDesignedForCompilation();

final String parent = new File(path.toString()).getParent();

if (parent == null) {
return getContext().makeString(".");
} else {
return getContext().makeString(parent);
}
}

}

@CoreMethod(names = "each_line", needsBlock = true)
public abstract static class EachLineNode extends YieldingCoreMethodNode {

@@ -151,69 +99,6 @@ public RubyNilClass eachLine(VirtualFrame frame, RubyFile file, RubyProc block)

}

@CoreMethod(names = "expand_path", onSingleton = true, required = 1, optional = 1)
public abstract static class ExpandPathNode extends CoreMethodNode {

public ExpandPathNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public ExpandPathNode(ExpandPathNode prev) {
super(prev);
}

@Specialization
public RubyString expandPath(RubyString path, UndefinedPlaceholder dir) {
return getContext().makeString(RubyFile.expandPath(getContext(), path.toString()));
}

@Specialization
public RubyString expandPath(RubyString path, RubyString dir) {
notDesignedForCompilation();

return getContext().makeString(RubyFile.expandPath(path.toString(), dir.toString()));
}

}

@CoreMethod(names = "join", onSingleton = true, argumentsAsArray = true)
public abstract static class JoinNode extends CoreMethodNode {

public JoinNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public JoinNode(JoinNode prev) {
super(prev);
}

@Specialization
public RubyString join(Object[] parts) {
notDesignedForCompilation();

final StringBuilder builder = new StringBuilder();
join(builder, parts);
return getContext().makeString(builder.toString());
}

@TruffleBoundary
public static void join(StringBuilder builder, Object[] parts) {
notDesignedForCompilation();

for (int n = 0; n < parts.length; n++) {
if (n > 0) {
builder.append("/");
}

if (parts[n] instanceof RubyArray) {
join(builder, ((RubyArray) parts[n]).slowToArray());
} else {
builder.append(parts[n].toString());
}
}
}
}

@CoreMethod(names = "open", onSingleton = true, needsBlock = true, required = 1, optional = 1)
public abstract static class OpenNode extends YieldingCoreMethodNode {

@@ -349,75 +234,6 @@ public RubyString read(RubyFile file) {

}

@CoreMethod(names = "realpath", onSingleton = true, required = 1, optional = 1)
public abstract static class RealpathNode extends CoreMethodNode {

public RealpathNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public RealpathNode(RealpathNode prev) {
super(prev);
}

@Specialization
public RubyString realpath(RubyString path, UndefinedPlaceholder dir) {
return getContext().makeString(realpath(path.toString(), null));
}

@Specialization
public RubyString realpath(RubyString path, RubyString dir) {
return getContext().makeString(realpath(path.toString(), dir.toString()));
}

private String realpath(String path, String dir) {
notDesignedForCompilation();

File file = new File(dir, path);

try {
return file.getCanonicalPath();
} catch (IOException e) {
throw new UnsupportedOperationException("realpath - " + file);
}
}

}

@CoreMethod(names = "symlink?", onSingleton = true, required = 1)
public abstract static class SymlinkQueryNode extends CoreMethodNode {

public SymlinkQueryNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public SymlinkQueryNode(SymlinkQueryNode prev) {
super(prev);
}

@Specialization
public boolean symlinkQuery(RubyString fileName) {
notDesignedForCompilation();

try {
// Note: We can't use file.exists() to check whether the symlink
// exists or not, because that method returns false for existing
// but broken symlink. So, we try without the existence check,
// but in the try-catch block.
// MRI behavior: symlink? on broken symlink should return true.
FileStat stat = getContext().getRuntime().getPosix().allocateStat();

if (getContext().getRuntime().getPosix().lstat(fileName.toString(), stat) < 0) {
stat = null;
}

return (stat != null && stat.isSymlink());
} catch (SecurityException re) {
return false;
}
}
}

@CoreMethod(names = "write", required = 1)
public abstract static class WriteNode extends CoreMethodNode {

Original file line number Diff line number Diff line change
@@ -251,7 +251,7 @@ public boolean isatty(Object self) {
// TODO (eregon 8-Apr-15) get the actual fd
final FileDescriptor fd = FileDescriptor.out;

return getContext().getRuntime().getPosix().isatty(fd);
return getContext().getPosix().isatty(fd);
}

}
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ public KillNode(KillNode prev) {
public int kill(RubySymbol signalName, int pid) {
notDesignedForCompilation();

int self = getContext().getRuntime().getPosix().getpid();
int self = getContext().getPosix().getpid();

if (self == pid) {
Signal signal = new Signal(signalName.toString());
@@ -130,7 +130,7 @@ public PidNode(PidNode prev) {
public int pid() {
notDesignedForCompilation();

return getContext().getRuntime().getPosix().getpid();
return getContext().getPosix().getpid();
}

}
Original file line number Diff line number Diff line change
@@ -923,7 +923,7 @@ public Object crypt(RubyString string, RubyString salt) {
throw new RaiseException(getContext().getCoreLibrary().argumentError("salt too short (need >= 2 bytes)", this));
}

final POSIX posix = getContext().getRuntime().getPosix();
final POSIX posix = getContext().getPosix();
final byte[] keyBytes = Arrays.copyOfRange(value.unsafeBytes(), value.begin(), value.realSize());
final byte[] saltBytes = Arrays.copyOfRange(otherBL.unsafeBytes(), otherBL.begin(), otherBL.realSize());

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.nodes.rubinius;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;
import jnr.constants.platform.Errno;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.*;

/**
* Rubinius primitives associated with the Ruby {@code Exception} class.
*/
public abstract class ExceptionPrimitiveNodes {

private static final int ENOENT = Errno.ENOENT.intValue();

@RubiniusPrimitive(name = "exception_errno_error", needsSelf = false)
public static abstract class ExceptionErrnoErrorPrimitiveNode extends RubiniusPrimitiveNode {

public ExceptionErrnoErrorPrimitiveNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public ExceptionErrnoErrorPrimitiveNode(ExceptionErrnoErrorPrimitiveNode prev) {
super(prev);
}

@Specialization(guards = "isENOENT(arguments[1])")
public RubyException enoent(RubyString message, int errno) {
return getContext().getCoreLibrary().fileNotFoundError(message.toString(), this);
}

@CompilerDirectives.TruffleBoundary
@Specialization(guards = "!isENOENT(arguments[1])")
public RubyException unsupported(RubyString message, int errno) {
final Errno errnoObject = Errno.valueOf(errno);

if (errnoObject == null) {
throw new UnsupportedOperationException("errno: " + errno + " " + message);
} else {
throw new UnsupportedOperationException("errno: " + errnoObject.name());
}
}

protected boolean isENOENT(int errno) {
return errno == ENOENT;
}

}

}
Loading