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

Commits on Jan 6, 2017

  1. Revert "[Truffle] Simplify POSIX#getgroups."

    This reverts commit 1717c08.
    nirvdrum committed Jan 6, 2017
    Copy the full SHA
    0da8d64 View commit details
  2. [Truffle] Switched back to using jnr-posix's version of getgroups.

    The upstream bug producing bad results is fixed and using UnixSystem doesn't work with AOT.
    nirvdrum committed Jan 6, 2017
    Copy the full SHA
    1d88edf View commit details
  3. Copy the full SHA
    5c1dcc2 View commit details
Showing with 27 additions and 13 deletions.
  1. +18 −11 truffle/src/main/java/org/jruby/truffle/extra/TrufflePosixNodes.java
  2. +9 −2 truffle/src/main/ruby/core/process.rb
Original file line number Diff line number Diff line change
@@ -12,14 +12,13 @@
import com.kenai.jffi.Platform;
import com.kenai.jffi.Platform.OS;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.TruffleOptions;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.profiles.BranchProfile;
import com.sun.security.auth.module.UnixSystem;
import jnr.constants.platform.Fcntl;
import jnr.ffi.Pointer;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.truffle.Layouts;
import org.jruby.truffle.builtins.CoreClass;
@@ -183,23 +182,31 @@ public int getGID() {

}

@CoreMethod(names = "getgroups", isModuleFunction = true, unsafe = {UnsafeGroup.MEMORY, UnsafeGroup.PROCESSES})
@CoreMethod(names = "getgroups", isModuleFunction = true, required = 2, lowerFixnum = 1, unsafe = {UnsafeGroup.MEMORY, UnsafeGroup.PROCESSES})
public abstract static class GetGroupsNode extends CoreMethodArrayArgumentsNode {

@Specialization
public DynamicObject getgroups() {
final long[] groups = getGroups();
return createArray(groups, groups.length);
@TruffleBoundary
@Specialization(guards = "isNil(pointer)")
public int getGroupsNil(int max, DynamicObject pointer) {
return getContext().getNativePlatform().getPosix().getgroups().length;
}

@TruffleBoundary
private static long[] getGroups() {
if (TruffleOptions.AOT) {
throw new UnsupportedOperationException("UnixSystem is not supported with AOT.");
@Specialization(guards = "isRubyPointer(pointer)")
public int getGroups(int max, DynamicObject pointer) {
final long[] groups = getContext().getNativePlatform().getPosix().getgroups();

final Pointer pointerValue = Layouts.POINTER.getPointer(pointer);

for (int n = 0; n < groups.length && n < max; n++) {
// TODO CS 16-May-15 this is platform dependent
pointerValue.putInt(4 * n, (int) groups[n]);

}

return new UnixSystem().getGroups();
return groups.length;
}

}

@CoreMethod(names = "getrlimit", isModuleFunction = true, required = 2, lowerFixnum = 1, unsafe = {UnsafeGroup.PROCESSES, UnsafeGroup.MEMORY})
11 changes: 9 additions & 2 deletions truffle/src/main/ruby/core/process.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. This
# Copyright (c) 2016, 2017 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:
#
@@ -431,7 +431,14 @@ def self.setpriority(kind, id, priority)
end

def self.groups
Truffle::POSIX.getgroups
g = []
count = Truffle::POSIX.getgroups(0, nil)
FFI::MemoryPointer.new(:int, count) do |p|
num_groups = Truffle::POSIX.getgroups(count, p)
Errno.handle if num_groups == -1
g = p.read_array_of_int(num_groups)
end
g
end

def self.groups=(g)