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: 71e6131a5b5a
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f472cbb69215
Choose a head ref

Commits on Jan 14, 2015

  1. [Truffle] JT: jt test fast [*ARGS]

    * 21s versus 74s while skipping only 32 examples out of 4056 for all specs.
    * 5 vs 43s for language specs.
    eregon committed Jan 14, 2015
    Copy the full SHA
    e8ca19d View commit details
  2. Copy the full SHA
    9f4d9a4 View commit details
  3. Copy the full SHA
    dc30c92 View commit details
  4. Copy the full SHA
    697b06a View commit details
  5. Copy the full SHA
    47bc672 View commit details
  6. Copy the full SHA
    f129eab View commit details
  7. Copy the full SHA
    0e8e197 View commit details
  8. Revert "More missing bits transplanted from DL."

    This reverts commit 0e8e197.
    headius committed Jan 14, 2015
    Copy the full SHA
    e7b1ba3 View commit details
  9. Copy the full SHA
    7b15e95 View commit details
  10. Copy the full SHA
    9be5e6a View commit details
  11. Copy the full SHA
    afa37e5 View commit details
  12. Copy the full SHA
    58c28cd View commit details
  13. Add File::NONBLOCK for Windows.

    According to jnr-constants, this is not a defined value on
    Windows, but MRI appears to use the value "1".
    headius committed Jan 14, 2015
    Copy the full SHA
    faea8f0 View commit details
  14. Copy the full SHA
    84fe15e View commit details
  15. Copy the full SHA
    414e5fe View commit details
  16. Copy the full SHA
    213d935 View commit details
  17. Copy the full SHA
    1217305 View commit details
  18. Copy the full SHA
    a2ef35f View commit details
  19. Fix multiple issues with const access using :: forms.

    * Symbols with :: should raise errors.
    * Leading :: starts from Object (fixes #1487).
    * const_defined? supports :: too (fixes #2319).
    headius committed Jan 14, 2015
    Copy the full SHA
    5868779 View commit details
  20. Fixed a typo.

    nirvdrum committed Jan 14, 2015
    Copy the full SHA
    73d5f0f View commit details
  21. Copy the full SHA
    496c638 View commit details
  22. Copy the full SHA
    b5d6fbf View commit details
  23. Copy the full SHA
    a36def4 View commit details
  24. Revert "const_defined? should not trigger autoload."

    This reverts commit 496c638.
    headius committed Jan 14, 2015
    Copy the full SHA
    ccfee85 View commit details
  25. Copy the full SHA
    cffeaab View commit details

Commits on Jan 15, 2015

  1. Copy the full SHA
    f9a6bfb View commit details
  2. Copy the full SHA
    f472cbb View commit details
Showing with 1,521 additions and 100 deletions.
  1. +4 −1 core/src/main/java/org/jruby/RubyFile.java
  2. +1 −1 core/src/main/java/org/jruby/RubyGlobal.java
  3. +1 −1 core/src/main/java/org/jruby/RubyKernel.java
  4. +35 −4 core/src/main/java/org/jruby/RubyModule.java
  5. +52 −33 core/src/main/java/org/jruby/RubyThread.java
  6. +2 −1 core/src/main/java/org/jruby/ext/socket/RubyBasicSocket.java
  7. +2 −1 core/src/main/java/org/jruby/ext/tempfile/Tempfile.java
  8. +1 −1 core/src/main/java/org/jruby/internal/runtime/methods/DynamicMethod.java
  9. +33 −21 core/src/main/java/org/jruby/runtime/Signature.java
  10. +1 −0 core/src/main/java/org/jruby/truffle/nodes/RubyNode.java
  11. +2 −0 core/src/main/java/org/jruby/truffle/nodes/RubyTypes.java
  12. +3 −3 core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
  13. +2 −0 core/src/main/java/org/jruby/truffle/runtime/core/RubyBasicObject.java
  14. +1 −0 core/src/main/java/org/jruby/truffle/runtime/core/RubyHash.java
  15. +1 −0 core/src/main/java/org/jruby/truffle/runtime/core/RubyString.java
  16. +2 −1 core/src/main/java/org/jruby/util/RegularFileResource.java
  17. +5 −0 core/src/main/java/org/jruby/util/TypeConverter.java
  18. +2 −1 core/src/main/java/org/jruby/util/io/ChannelFD.java
  19. +2 −1 core/src/main/java/org/jruby/util/io/ModeFlags.java
  20. +1 −1 core/src/main/java/org/jruby/util/io/PosixShim.java
  21. +26 −5 lib/ruby/stdlib/fiddle.rb
  22. +176 −0 lib/ruby/stdlib/fiddle/cparser.rb
  23. +11 −0 lib/ruby/stdlib/fiddle/function.rb
  24. +314 −0 lib/ruby/stdlib/fiddle/import.rb
  25. +265 −16 lib/ruby/stdlib/fiddle/jruby.rb
  26. +128 −0 lib/ruby/stdlib/fiddle/pack.rb
  27. +243 −0 lib/ruby/stdlib/fiddle/struct.rb
  28. +71 −0 lib/ruby/stdlib/fiddle/types.rb
  29. +112 −0 lib/ruby/stdlib/fiddle/value.rb
  30. +1 −1 lib/ruby/stdlib/io/console.rb
  31. +8 −1 lib/ruby/stdlib/win32/registry.rb
  32. +1 −0 spec/tags/ruby/core/module/autoload_tags.txt
  33. +2 −1 test/jruby/test_autoload.rb
  34. +0 −3 test/mri/excludes/TestModule.rb
  35. +3 −1 tool/globals_2_2_0.rb
  36. +7 −1 tool/jt.rb
5 changes: 4 additions & 1 deletion core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -153,6 +153,9 @@ public static RubyClass createFileClass(Ruby runtime) {
}
/* do not block on open or for data to become available */
constants.setConstant("NONBLOCK", runtime.newFixnum(OpenFlags.O_NONBLOCK.intValue()));
} else if (Platform.IS_WINDOWS) {
// FIXME: Should NONBLOCK exist for Windows fcntl flags?
constants.setConstant("NONBLOCK", runtime.newFixnum(1));
}
/* truncate size to 0 */
constants.setConstant("TRUNC", runtime.newFixnum(OpenFlags.O_TRUNC.intValue()));
@@ -1140,7 +1143,7 @@ public static IRubyObject unlink(ThreadContext context, IRubyObject recv, IRubyO
Ruby runtime = context.runtime;
POSIX posix = runtime.getPosix();

if (!posix.isNative()) return delete(context, recv, args);
if (!posix.isNative() || Platform.IS_WINDOWS) return delete(context, recv, args);

for (int i = 0; i < args.length; i++) {
RubyString filename = get_path(context, args[i]);
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyGlobal.java
Original file line number Diff line number Diff line change
@@ -276,7 +276,7 @@ public static void createGlobals(ThreadContext context, Ruby runtime) {
}

private static Channel prepareStdioChannel(Ruby runtime, STDIO stdio, Object stream) {
if (runtime.getPosix().isNative() && stdio.isJVMDefault(stream)) {
if (runtime.getPosix().isNative() && stdio.isJVMDefault(stream) && !Platform.IS_WINDOWS) {
// use real native channel for stdio
return new NativeDeviceChannel(stdio.fileno());
} else {
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -1441,7 +1441,7 @@ public static IRubyObject test(ThreadContext context, IRubyObject recv, IRubyObj
public static IRubyObject backquote(ThreadContext context, IRubyObject recv, IRubyObject str) {
Ruby runtime = context.runtime;

if (runtime.getPosix().isNative()) {
if (runtime.getPosix().isNative() && !Platform.IS_WINDOWS) {
IRubyObject port;
IRubyObject result;
OpenFile fptr;
39 changes: 35 additions & 4 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
@@ -2792,11 +2792,33 @@ public RubyBoolean const_defined_p(ThreadContext context, IRubyObject symbol) {

@JRubyMethod(name = "const_defined?", required = 1, optional = 1)
public RubyBoolean const_defined_p19(ThreadContext context, IRubyObject[] args) {
IRubyObject symbol = args[0];
Ruby runtime = context.runtime;
String fullName = args[0].asJavaString();
String symbol = fullName;
boolean inherit = args.length == 1 || (!args[1].isNil() && args[1].isTrue());

// Note: includes part of fix for JRUBY-1339
return context.runtime.newBoolean(fastIsConstantDefined19(validateConstant(symbol).intern(), inherit));
// symbol form does not allow ::
if (args[0] instanceof RubySymbol && symbol.indexOf("::") != -1) {
throw runtime.newNameError("wrong constant name", symbol);
}

RubyModule mod = this;

if (symbol.startsWith("::")) mod = runtime.getObject();

int sep;
while((sep = symbol.indexOf("::")) != -1) {
String segment = symbol.substring(0, sep);
symbol = symbol.substring(sep + 2);
IRubyObject obj = mod.getConstantNoConstMissing(validateConstant(segment, args[0]), inherit, inherit);
if(obj instanceof RubyModule) {
mod = (RubyModule)obj;
} else {
throw runtime.newTypeError(segment + " does not refer to class/module");
}
}

return runtime.newBoolean(mod.getConstantNoConstMissing(validateConstant(symbol, args[0]), inherit, inherit) != null);
}

/** rb_mod_const_get
@@ -2812,11 +2834,20 @@ public IRubyObject const_get_1_9(ThreadContext context, IRubyObject[] args) {

@JRubyMethod(name = "const_get", required = 1, optional = 1)
public IRubyObject const_get_2_0(ThreadContext context, IRubyObject[] args) {
Ruby runtime = context.runtime;
String fullName = args[0].asJavaString();
String symbol = fullName;
boolean inherit = args.length == 1 || (!args[1].isNil() && args[1].isTrue());

// symbol form does not allow ::
if (args[0] instanceof RubySymbol && symbol.indexOf("::") != -1) {
throw context.runtime.newNameError("wrong constant name", symbol);
}

RubyModule mod = this;

if (symbol.startsWith("::")) mod = runtime.getObject();

int sep;
while((sep = symbol.indexOf("::")) != -1) {
String segment = symbol.substring(0, sep);
@@ -2825,7 +2856,7 @@ public IRubyObject const_get_2_0(ThreadContext context, IRubyObject[] args) {
if(obj instanceof RubyModule) {
mod = (RubyModule)obj;
} else {
throw context.runtime.newTypeError(segment + " does not refer to class/module");
throw runtime.newTypeError(segment + " does not refer to class/module");
}
}

85 changes: 52 additions & 33 deletions core/src/main/java/org/jruby/RubyThread.java
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@
import java.nio.channels.SelectableChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.util.Collections;
import java.util.Iterator;
import java.util.Queue;
import java.util.Vector;
@@ -104,32 +105,32 @@ public class RubyThread extends RubyObject implements ExecutionContext {
private static final Logger LOG = LoggerFactory.getLogger("RubyThread");

/** The thread-like think that is actually executing */
private ThreadLike threadImpl;
private volatile ThreadLike threadImpl;

/** Normal thread-local variables */
private transient Map<IRubyObject, IRubyObject> threadLocalVariables;
private volatile transient Map<IRubyObject, IRubyObject> threadLocalVariables;

/** Context-local variables, internal-ish thread locals */
private final Map<Object, IRubyObject> contextVariables = new WeakHashMap<Object, IRubyObject>();

/** Whether this thread should try to abort the program on exception */
private boolean abortOnException;
private volatile boolean abortOnException;

/** The final value resulting from the thread's execution */
private IRubyObject finalResult;
private volatile IRubyObject finalResult;

/**
* The exception currently being raised out of the thread. We reference
* it here to continue propagating it while handling thread shutdown
* logic and abort_on_exception.
*/
private RaiseException exitingException;
private volatile RaiseException exitingException;

/** The ThreadGroup to which this thread belongs */
private RubyThreadGroup threadGroup;
private volatile RubyThreadGroup threadGroup;

/** Per-thread "current exception" */
private IRubyObject errorInfo;
private volatile IRubyObject errorInfo;

/** Weak reference to the ThreadContext for this thread. */
private volatile WeakReference<ThreadContext> contextRef;
@@ -138,11 +139,14 @@ public class RubyThread extends RubyObject implements ExecutionContext {
private volatile boolean handleInterrupt = true;

/** Stack of interrupt masks active for this thread */
private final List<RubyHash> interruptMaskStack = new ArrayList<RubyHash>();
private final List<RubyHash> interruptMaskStack = Collections.synchronizedList(new ArrayList<RubyHash>());

/** Thread-local tuple used for sleeping (semaphore, millis, nanos) */
private final SleepTask2 sleepTask = new SleepTask2();

private static final boolean DEBUG = false;
private int RUBY_MIN_THREAD_PRIORITY = -3;
private int RUBY_MAX_THREAD_PRIORITY = 3;
private static final int RUBY_MIN_THREAD_PRIORITY = -3;
private static final int RUBY_MAX_THREAD_PRIORITY = 3;

/** Thread statuses */
public static enum Status {
@@ -162,10 +166,10 @@ public static enum Status {
private final Queue<IRubyObject> pendingInterruptQueue = new ConcurrentLinkedQueue();

/** A function to use to unblock this thread, if possible */
private Unblocker unblockFunc;
private volatile Unblocker unblockFunc;

/** Argument to pass to the unblocker */
private Object unblockArg;
private volatile Object unblockArg;

/** The list of locks this thread currently holds, so they can be released on exit */
private final List<Lock> heldLocks = new Vector<Lock>();
@@ -1172,12 +1176,16 @@ public synchronized IRubyObject run() {
*/
public boolean sleep(long millis) throws InterruptedException {
assert this == getRuntime().getCurrentContext().getThread();
Semaphore sem = new Semaphore(1);
sem.acquire();
if (executeTask(getContext(), new Object[]{sem, millis, 0}, SLEEP_TASK2) >= millis) {
return true;
} else {
return false;
sleepTask.millis = millis;
try {
if (executeTask(getContext(), null, sleepTask) >= millis) {
return true;
} else {
return false;
}
} finally {
// ensure we've re-acquired the semaphore, or a subsequent sleep may return immediately
sleepTask.semaphore.drainPermits();
}
}

@@ -1240,30 +1248,41 @@ public void wakeup() {
}
}

private static final class SleepTask2 implements Task<Object[], Long> {
@Override
public Long run(ThreadContext context, Object[] data) throws InterruptedException {
long millis = (Long)data[1];
int nanos = (Integer)data[2];
/**
* A Task for sleeping.
*
* The Semaphore is immediately drained on construction, so that any subsequent acquire will block.
* The sleep is interrupted by releasing a permit. All permits are drained again on exit to ensure
* the next sleep blocks.
*/
private class SleepTask2 implements Task<Object, Long> {
final Semaphore semaphore = new Semaphore(1);
long millis;
{semaphore.drainPermits();}

@Override
public Long run(ThreadContext context, Object data) throws InterruptedException {
long start = System.currentTimeMillis();
// TODO: nano handling?
if (millis == 0) {
((Semaphore) data[0]).acquire();
} else {
((Semaphore) data[0]).tryAcquire(millis, TimeUnit.MILLISECONDS);

try {
if (millis == 0) {
semaphore.acquire();
} else {
semaphore.tryAcquire(millis, TimeUnit.MILLISECONDS);
}

return System.currentTimeMillis() - start;
} finally {
semaphore.drainPermits();
}
return System.currentTimeMillis() - start;
}

@Override
public void wakeup(RubyThread thread, Object[] data) {
((Semaphore)data[0]).release();
public void wakeup(RubyThread thread, Object data) {
semaphore.release();
}
}

private static final Task<Object[], Long> SLEEP_TASK2 = new SleepTask2();

@Deprecated
public void executeBlockingTask(BlockingTask task) throws InterruptedException {
try {
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/ext/socket/RubyBasicSocket.java
Original file line number Diff line number Diff line change
@@ -55,6 +55,7 @@
import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
import org.jruby.ext.fcntl.FcntlLibrary;
import org.jruby.platform.Platform;
import org.jruby.runtime.Arity;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.ThreadContext;
@@ -608,7 +609,7 @@ public boolean doNotReverseLookup(ThreadContext context) {
protected static ChannelFD newChannelFD(Ruby runtime, Channel channel) {
ChannelFD fd = new ChannelFD(channel, runtime.getPosix(), runtime.getFilenoUtil());

if (runtime.getPosix().isNative() && fd.realFileno >= 0) {
if (runtime.getPosix().isNative() && fd.realFileno >= 0 && !Platform.IS_WINDOWS) {
runtime.getPosix().fcntlInt(fd.realFileno, Fcntl.F_SETFD, FcntlLibrary.FD_CLOEXEC);
}

3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/ext/tempfile/Tempfile.java
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@
import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
import org.jruby.exceptions.RaiseException;
import org.jruby.platform.Platform;
import org.jruby.runtime.Arity;
import org.jruby.runtime.Block;
import org.jruby.runtime.BlockCallback;
@@ -201,7 +202,7 @@ public IRubyObject unlink(ThreadContext context) {
Ruby runtime = context.runtime;
POSIX posix = runtime.getPosix();

if (posix.isNative()) {
if (posix.isNative() && !Platform.IS_WINDOWS) {
try {
RubyFile.unlink(context, this);
} catch (RaiseException re) {
Original file line number Diff line number Diff line change
@@ -145,7 +145,7 @@ public void setIsBuiltin(boolean isBuiltin) {

/**
* The minimum 'call' method required for a dynamic method handle.
* Subclasses must impleemnt this method, but may implement the other
* Subclasses must implement this method, but may implement the other
* signatures to provide faster, non-boxing call paths. Typically
* subclasses will implement this method to check variable arity calls,
* then performing a specific-arity invocation to the appropriate method
Loading