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

Commits on Apr 8, 2015

  1. Copy the full SHA
    cf76d2f View commit details
  2. Copy the full SHA
    542af64 View commit details
  3. Copy the full SHA
    ddf95ff View commit details
  4. Copy the full SHA
    17c4879 View commit details
  5. Copy the full SHA
    f871a55 View commit details
  6. Copy the full SHA
    56339df View commit details
  7. Copy the full SHA
    1d4f0f7 View commit details
3 changes: 2 additions & 1 deletion spec/truffle/tags/core/kernel/autoload_tags.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
fails:Kernel.autoload sets the autoload constant in Object's metaclass's constant table
fails:Kernel.autoload sets the autoload constant in Object's constant table
fails:Kernel.autoload calls #to_path on non-String filenames
slow:Kernel#autoload when Object is frozen raises a RuntimeError before defining the constant
1 change: 0 additions & 1 deletion spec/truffle/tags/core/process/egid_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
fails:Process.egid returns the effective group ID for this process
fails:Process.egid also goes by Process::GID.eid
fails:Process.egid also goes by Process::Sys.getegid
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/process/euid_tags.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
fails:Process.euid returns the effective user ID for this process
fails:Process.euid also goes by Process::UID.eid
fails:Process.euid also goes by Process::Sys.geteuid
fails:Process.euid= raises TypeError if not passed an Integer
fails:Process.euid= raises Errno::ERPERM if run by a non superuser trying to set the superuser id
fails:Process.euid= raises Errno::ERPERM if run by a non superuser trying to set the superuser id from username
fails:Process.euid= needs to be reviewed for spec completeness
1 change: 0 additions & 1 deletion spec/truffle/tags/core/process/gid_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
fails:Process.gid returns the correct gid for the user executing this process
fails:Process.gid also goes by Process::GID.rid
fails:Process.gid also goes by Process::Sys.getgid
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/process/uid_tags.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
fails:Process.uid returns the correct uid for the user executing this process
fails:Process.uid also goes by Process::UID.rid
fails:Process.uid also goes by Process::Sys.getuid
fails:Process.uid= raises TypeError if not passed an Integer
fails:Process.uid= raises Errno::ERPERM if run by a non privileged user trying to set the superuser id
fails:Process.uid= raises Errno::ERPERM if run by a non privileged user trying to set the superuser id from username
fails:Process.uid= needs to be reviewed for spec completeness
14 changes: 0 additions & 14 deletions spec/truffle/truffle.mspec
Original file line number Diff line number Diff line change
@@ -17,14 +17,6 @@ class MSpecScript
# Can't load these - so tags aren't enough to exclude them. The problem is
# either fixtures or syntax. Some of them are probably easy fixes.

# as_superuser, as_user, Process.euid
"^spec/ruby/core/file/chown_spec.rb",
"^spec/ruby/core/file/lchown_spec.rb",
"^spec/ruby/core/process/euid_spec.rb",
"^spec/ruby/core/process/kill_spec.rb",
"^spec/ruby/core/process/setpriority_spec.rb",
"^spec/ruby/core/process/uid_spec.rb",

# require 'socket'
"^spec/ruby/core/file/socket_spec.rb",

@@ -38,12 +30,6 @@ class MSpecScript
# require 'fcntl'
"^spec/ruby/core/io/reopen_spec.rb",

# __method__ in fixtures
"^spec/ruby/core/kernel/__method___spec.rb",

# autoload in describe
"^spec/ruby/core/kernel/autoload_spec.rb",

# seem side-effecting when not run in isolation
"^spec/ruby/core/marshal/dump_spec.rb",
"^spec/ruby/core/marshal/float_spec.rb",
Original file line number Diff line number Diff line change
@@ -287,11 +287,7 @@ private Object methodMissing(Object self, RubySymbol name, Object[] args, RubyPr
getContext().getCoreLibrary().getLogicalClass(self).getName(),
this));
} else {
throw new RaiseException(
getContext().getCoreLibrary().noMethodError(
name.toString(),
getContext().getCoreLibrary().getLogicalClass(self),
this));
throw new RaiseException(getContext().getCoreLibrary().noMethodErrorOnReceiver(name.toString(), self, this));
}
}

Original file line number Diff line number Diff line change
@@ -1748,7 +1748,7 @@ private RubyModule undefMethod(RubyModule module, String name) {

final InternalMethod method = ModuleOperations.lookupMethod(module, name);
if (method == null) {
throw new RaiseException(getContext().getCoreLibrary().noMethodError(name, module, this));
throw new RaiseException(getContext().getCoreLibrary().noMethodErrorOnModule(name, module, this));
}
module.undefMethod(this, method);
return module;
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ protected InternalMethod lookup(
// Check for methods that are explicitly undefined

if (method.isUndefined()) {
throw new RaiseException(getContext().getCoreLibrary().noMethodError(name, getContext().getCoreLibrary().getLogicalClass(receiver), this));
throw new RaiseException(getContext().getCoreLibrary().noMethodErrorOnReceiver(name, receiver, this));
}

// Check visibility
Original file line number Diff line number Diff line change
@@ -28,7 +28,25 @@
@CoreClass(name = "Rubinius::FFI::Platform::POSIX")
public abstract class PosixNodes {

@CoreMethod(names = "geteuid", isModuleFunction = true, needsSelf = false)
@CoreMethod(names = "getegid", isModuleFunction = true)
public abstract static class GetEGIDNode extends CoreMethodNode {

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

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

@Specialization
public int getEGID() {
return getContext().getRuntime().getPosix().getegid();
}

}

@CoreMethod(names = "geteuid", isModuleFunction = true)
public abstract static class GetEUIDNode extends CoreMethodNode {

public GetEUIDNode(RubyContext context, SourceSection sourceSection) {
@@ -46,7 +64,25 @@ public int getEUID() {

}

@CoreMethod(names = "getgroups", isModuleFunction = true, needsSelf = false, required = 2)
@CoreMethod(names = "getgid", isModuleFunction = true)
public abstract static class GetGIDNode extends CoreMethodNode {

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

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

@Specialization
public int getGID() {
return getContext().getRuntime().getPosix().getgid();
}

}

@CoreMethod(names = "getgroups", isModuleFunction = true, required = 2)
public abstract static class GetGroupsNode extends PointerPrimitiveNodes.ReadAddressPrimitiveNode {

public GetGroupsNode(RubyContext context, SourceSection sourceSection) {
@@ -72,6 +108,24 @@ public int getGroups(int max, RubyBasicObject pointer) {

}

@CoreMethod(names = "getuid", isModuleFunction = true)
public abstract static class GetUIDNode extends CoreMethodNode {

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

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

@Specialization
public int getUID() {
return getContext().getRuntime().getPosix().getuid();
}

}

@CoreMethod(names = "memset", isModuleFunction = true, required = 3)
public abstract static class MemsetNode extends PointerPrimitiveNodes.ReadAddressPrimitiveNode {

@@ -85,6 +139,11 @@ public MemsetNode(MemsetNode prev) {

@Specialization
public RubyBasicObject memset(RubyBasicObject pointer, int c, int length) {
return memset(pointer, c, (long) length);
}

@Specialization
public RubyBasicObject memset(RubyBasicObject pointer, int c, long length) {
final long address = getAddress(pointer);
UnsafeHolder.U.setMemory(address, length, (byte) c);
return pointer;
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ public class CoreLibrary {
private final RubyClass numericClass;
private final RubyClass objectClass;
private final RubyClass procClass;
private final RubyClass processClass;
private final RubyModule processModule;
private final RubyClass rangeClass;
private final RubyClass rangeErrorClass;
private final RubyClass rationalClass;
@@ -279,7 +279,7 @@ public CoreLibrary(RubyContext context) {
defineClass("Mutex", MutexNodes.createMutexAllocator(context.getEmptyShape()));
nilClass = defineClass("NilClass");
procClass = defineClass("Proc", new RubyProc.ProcAllocator());
processClass = defineClass("Process");
processModule = defineModule("Process");
rangeClass = defineClass("Range", new RubyRange.RangeAllocator());
regexpClass = defineClass("Regexp", new RubyRegexp.RegexpAllocator());
stringClass = defineClass("String", new RubyString.StringAllocator());
@@ -426,8 +426,8 @@ private void initializeConstants() {
fileClass.setConstant(null, "PATH_SEPARATOR", RubyString.fromJavaString(stringClass, File.pathSeparator));
fileClass.setConstant(null, "FNM_SYSCASE", 0);

processClass.setConstant(null, "CLOCK_MONOTONIC", ProcessNodes.CLOCK_MONOTONIC);
processClass.setConstant(null, "CLOCK_REALTIME", ProcessNodes.CLOCK_REALTIME);
processModule.setConstant(null, "CLOCK_MONOTONIC", ProcessNodes.CLOCK_MONOTONIC);
processModule.setConstant(null, "CLOCK_REALTIME", ProcessNodes.CLOCK_REALTIME);

encodingConverterClass.setConstant(null, "INVALID_MASK", EConvFlags.INVALID_MASK);
encodingConverterClass.setConstant(null, "INVALID_REPLACE", EConvFlags.INVALID_REPLACE);
@@ -910,11 +910,21 @@ public RubyException noMethodError(String message, Node currentNode) {
return new RubyException(context.getCoreLibrary().getNoMethodErrorClass(), context.makeString(message), RubyCallStack.getBacktrace(currentNode));
}

public RubyException noMethodError(String name, RubyModule module, Node currentNode) {
public RubyException noMethodErrorOnModule(String name, RubyModule module, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return noMethodError(String.format("undefined method `%s' for %s", name, module.getName()), currentNode);
}

public RubyException noMethodErrorOnReceiver(String name, Object receiver, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
RubyClass logicalClass = getLogicalClass(receiver);
String repr = logicalClass.getName();
if (receiver instanceof RubyModule) {
repr = ((RubyModule) receiver).getName() + ":" + repr;
}
return noMethodError(String.format("undefined method `%s' for %s", name, repr), currentNode);
}

public RubyException privateMethodError(String name, RubyModule module, Node currentNode) {
CompilerAsserts.neverPartOfCompilation();
return noMethodError(String.format("private method `%s' called for %s", name, module.toString()), currentNode);
Original file line number Diff line number Diff line change
@@ -333,7 +333,7 @@ public void alias(Node currentNode, String newName, String oldName) {

if (method == null) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().noMethodError(oldName, this, currentNode));
throw new RaiseException(getContext().getCoreLibrary().noMethodErrorOnModule(oldName, this, currentNode));
}

addMethod(currentNode, method.withNewName(newName));
2 changes: 1 addition & 1 deletion truffle/src/main/ruby/core/rubinius/bootstrap/process.rb
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@

# Only part of Rubinius' process.rb

class Process
module Process
def self.time
Rubinius.primitive :vm_time
raise PrimitiveFailure, "Process.time primitive failed"
26 changes: 25 additions & 1 deletion truffle/src/main/ruby/core/rubinius/common/process.rb
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@

# Only part of Rubinius' process.rb

class Process
module Process

FFI = Rubinius::FFI

@@ -42,6 +42,30 @@ def maxgroups=(m)
end
end

def self.uid
ret = FFI::Platform::POSIX.getuid
Errno.handle if ret == -1
ret
end

def self.gid
ret = FFI::Platform::POSIX.getgid
Errno.handle if ret == -1
ret
end

def self.euid
ret = FFI::Platform::POSIX.geteuid
Errno.handle if ret == -1
ret
end

def self.egid
ret = FFI::Platform::POSIX.getegid
Errno.handle if ret == -1
ret
end

def self.groups
g = []
FFI::MemoryPointer.new(:int, @maxgroups) { |p|