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

Commits on Jun 29, 2016

  1. Copy the full SHA
    4fd319c View commit details
  2. Copy the full SHA
    16858bb View commit details
  3. Copy the full SHA
    7e239b3 View commit details
  4. Copy the full SHA
    afd412c View commit details
  5. Copy the full SHA
    9d58244 View commit details
  6. Copy the full SHA
    d27eaca View commit details
  7. Copy the full SHA
    91b3a08 View commit details
  8. Copy the full SHA
    286d49e View commit details
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/Main.java
Original file line number Diff line number Diff line change
@@ -465,7 +465,7 @@ private boolean checkStreamSyntax(Ruby runtime, InputStream in, String filename)
} catch (RaiseException re) {
if (re.getException().getMetaClass().getBaseName().equals("SyntaxError")) {
context.setErrorInfo($ex);
config.getError().println("SyntaxError in " + re.getException().message(runtime.getCurrentContext()));
config.getError().println("SyntaxError in " + re.getException().message(context));
return false;
}
throw re;
36 changes: 18 additions & 18 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -1240,10 +1240,10 @@ private void init() {
threadService.initMainThread();

// Get the main threadcontext (gets constructed for us)
ThreadContext tc = getCurrentContext();
final ThreadContext context = getCurrentContext();

// Construct the top-level execution frame and scope for the main thread
tc.prepareTopLevel(objectClass, topSelf);
context.prepareTopLevel(objectClass, topSelf);

// Initialize all the core classes
bootstrap();
@@ -1259,14 +1259,14 @@ private void init() {
// FIXME: This registers itself into static scope as a side-effect. Let's make this
// relationship handled either more directly or through a descriptice method
// FIXME: We need a failing test case for this since removing it did not regress tests
new IRScriptBody(irManager, "", tc.getCurrentScope().getStaticScope());
new IRScriptBody(irManager, "", context.getCurrentScope().getStaticScope());

// Initialize the "dummy" class used as a marker
dummyClass = new RubyClass(this, classClass);
dummyClass.freeze(tc);
dummyClass.freeze(context);

// Create global constants and variables
RubyGlobal.createGlobals(tc, this);
RubyGlobal.createGlobals(context, this);

// Prepare LoadService and load path
getLoadService().init(config.getLoadPaths());
@@ -1291,9 +1291,8 @@ && getInstanceConfig().getCompileMode() != CompileMode.TRUFFLE) {
isRestricted.set(null, false);
isRestricted.setAccessible(false);
} catch (Exception e) {
if (isDebug()) {
System.err.println("unable to enable unlimited-strength crypto");
e.printStackTrace();
if (isDebug() || LOG.isDebugEnabled()) {
LOG.debug("unable to enable unlimited-strength crypto", e);
}
}

@@ -1315,7 +1314,7 @@ && getInstanceConfig().getCompileMode() != CompileMode.TRUFFLE) {
initRubyPreludes();

// everything booted, so SizedQueue should be available; set up root fiber
ThreadFiber.initRootFiber(tc);
ThreadFiber.initRootFiber(context);
}

if(config.isProfiling()) {
@@ -1340,7 +1339,7 @@ && getInstanceConfig().getCompileMode() != CompileMode.TRUFFLE) {
// Require in all libraries specified on command line
if (getInstanceConfig().getCompileMode() != CompileMode.TRUFFLE) {
for (String scriptName : config.getRequiredLibraries()) {
topSelf.callMethod(getCurrentContext(), "require", RubyString.newString(this, scriptName));
topSelf.callMethod(context, "require", RubyString.newString(this, scriptName));
}
}
}
@@ -4362,18 +4361,19 @@ public ExecRecursiveParams() {}

private void recursivePush(IRubyObject list, IRubyObject obj, IRubyObject paired_obj) {
IRubyObject pair_list;
if(paired_obj == null) {
((RubyHash)list).op_aset(getCurrentContext(), obj, getTrue());
} else if((pair_list = ((RubyHash)list).fastARef(obj)) == null) {
((RubyHash)list).op_aset(getCurrentContext(), obj, paired_obj);
final ThreadContext context = getCurrentContext();
if (paired_obj == null) {
((RubyHash) list).op_aset(context, obj, getTrue());
} else if ((pair_list = ((RubyHash)list).fastARef(obj)) == null) {
((RubyHash) list).op_aset(context, obj, paired_obj);
} else {
if(!(pair_list instanceof RubyHash)) {
if (!(pair_list instanceof RubyHash)) {
IRubyObject other_paired_obj = pair_list;
pair_list = RubyHash.newHash(this);
((RubyHash)pair_list).op_aset(getCurrentContext(), other_paired_obj, getTrue());
((RubyHash)list).op_aset(getCurrentContext(), obj, pair_list);
((RubyHash) pair_list).op_aset(context, other_paired_obj, getTrue());
((RubyHash) list).op_aset(context, obj, pair_list);
}
((RubyHash)pair_list).op_aset(getCurrentContext(), paired_obj, getTrue());
((RubyHash)pair_list).op_aset(context, paired_obj, getTrue());
}
}

14 changes: 8 additions & 6 deletions core/src/main/java/org/jruby/RubyClassPathVariable.java
Original file line number Diff line number Diff line change
@@ -105,23 +105,25 @@ public IRubyObject size() {

@JRubyMethod
public IRubyObject each(Block block) {
URL[] urls = getRuntime().getJRubyClassLoader().getURLs();
ThreadContext ctx = getRuntime().getCurrentContext();
final ThreadContext context = getRuntime().getCurrentContext();
URL[] urls = context.runtime.getJRubyClassLoader().getURLs();
for(int i=0,j=urls.length;i<j;i++) {
block.yield(ctx, getRuntime().newString(urls[i].toString()));
block.yield(context, context.runtime.newString(urls[i].toString()));
}
return getRuntime().getNil();
return context.nil;
}

@Override
@JRubyMethod
public IRubyObject to_s() {
return callMethod(getRuntime().getCurrentContext(), "to_a").callMethod(getRuntime().getCurrentContext(), "to_s");
final ThreadContext context = getRuntime().getCurrentContext();
return callMethod(context, "to_a").callMethod(context, "to_s");
}

@Override
@JRubyMethod(name = "inspect")
public IRubyObject inspect() {
return callMethod(getRuntime().getCurrentContext(), "to_a").callMethod(getRuntime().getCurrentContext(), "inspect");
final ThreadContext context = getRuntime().getCurrentContext();
return callMethod(context, "to_a").callMethod(context, "inspect");
}
}// RubyClassPathVariable
26 changes: 12 additions & 14 deletions core/src/main/java/org/jruby/RubyKernel.java
Original file line number Diff line number Diff line change
@@ -1157,23 +1157,20 @@ private static RaiseException uncaughtThrow(Ruby runtime, IRubyObject tag, IRuby

@JRubyMethod(module = true, visibility = PRIVATE)
public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject message) {
Ruby runtime = context.runtime;
final Ruby runtime = context.runtime;

if (runtime.warningsEnabled()) {
IRubyObject out = runtime.getGlobalVariables().get("$stderr");
Helpers.invoke(context, out, "write", message);
Helpers.invoke(context, out, "write", runtime.getGlobalVariables().getDefaultSeparator());
}
return runtime.getNil();
return context.nil;
}

@JRubyMethod(module = true, required = 1, rest = true, visibility = PRIVATE)
public static IRubyObject warn(ThreadContext context, IRubyObject recv, IRubyObject... messages) {
Ruby runtime = context.runtime;

for (IRubyObject message : messages) warn(context, recv, message);

return runtime.getNil();
return context.nil;
}

@JRubyMethod(module = true, visibility = PRIVATE)
@@ -1194,7 +1191,7 @@ public static IRubyObject trace_var(ThreadContext context, IRubyObject recv, IRu
String var = args[0].toString();
// ignore if it's not a global var
if (var.charAt(0) != '$') {
return context.runtime.getNil();
return context.nil;
}
if (args.length == 1) {
proc = RubyProc.newProc(context.runtime, block, Block.Type.PROC);
@@ -1205,7 +1202,7 @@ public static IRubyObject trace_var(ThreadContext context, IRubyObject recv, IRu

context.runtime.getGlobalVariables().setTraceVar(var, proc);

return context.runtime.getNil();
return context.nil;
}

@JRubyMethod(required = 1, optional = 1, module = true, visibility = PRIVATE)
@@ -1217,11 +1214,11 @@ public static IRubyObject untrace_var(ThreadContext context, IRubyObject recv, I

// ignore if it's not a global var
if (var.charAt(0) != '$') {
return context.runtime.getNil();
return context.nil;
}

if (args.length > 1) {
ArrayList<IRubyObject> success = new ArrayList<IRubyObject>();
ArrayList<IRubyObject> success = new ArrayList<>(args.length);
for (int i = 1; i < args.length; i++) {
if (context.runtime.getGlobalVariables().untraceVar(var, args[i])) {
success.add(args[i]);
@@ -1232,7 +1229,7 @@ public static IRubyObject untrace_var(ThreadContext context, IRubyObject recv, I
context.runtime.getGlobalVariables().untraceVar(var);
}

return context.runtime.getNil();
return context.nil;
}

@JRubyMethod(required = 1, optional = 1, reads = VISIBILITY)
@@ -1259,8 +1256,9 @@ public static IRubyObject define_singleton_method(ThreadContext context, IRubyOb
}
}

@JRubyMethod(name = "proc", module = true, visibility = PRIVATE)
public static RubyProc proc(ThreadContext context, IRubyObject recv, Block block) {
return proc_1_9(context, recv, block);
return context.runtime.newProc(Block.Type.PROC, block);
}

@JRubyMethod(module = true, visibility = PRIVATE)
@@ -1271,9 +1269,9 @@ public static RubyProc lambda(ThreadContext context, IRubyObject recv, Block blo
return context.runtime.newProc(type, block);
}

@JRubyMethod(name = "proc", module = true, visibility = PRIVATE)
@Deprecated
public static RubyProc proc_1_9(ThreadContext context, IRubyObject recv, Block block) {
return context.runtime.newProc(Block.Type.PROC, block);
return proc(context, recv, block);
}

@JRubyMethod(name = "loop", module = true, visibility = PRIVATE)
20 changes: 11 additions & 9 deletions core/src/main/java/org/jruby/RubyThread.java
Original file line number Diff line number Diff line change
@@ -525,25 +525,27 @@ public static IRubyObject newInstance(IRubyObject recv, IRubyObject[] args, Bloc
* subclassed, then calling start in that subclass will not invoke the
* subclass's initialize method.
*/
public static RubyThread start(IRubyObject recv, IRubyObject[] args, Block block) {
return start19(recv, args, block);
}

@JRubyMethod(rest = true, name = "start", meta = true)
public static RubyThread start19(IRubyObject recv, IRubyObject[] args, Block block) {
Ruby runtime = recv.getRuntime();
public static RubyThread start(IRubyObject recv, IRubyObject[] args, Block block) {
// The error message may appear incongruous here, due to the difference
// between JRuby's Thread model and MRI's.
// We mimic MRI's message in the name of compatibility.
if (! block.isGiven()) throw runtime.newArgumentError("tried to create Proc object without a block");
if (! block.isGiven()) {
throw recv.getRuntime().newArgumentError("tried to create Proc object without a block");
}
return startThread(recv, args, false, block);
}

@Deprecated
public static RubyThread start19(IRubyObject recv, IRubyObject[] args, Block block) {
return start(recv, args, block);
}

public static RubyThread adopt(IRubyObject recv, Thread t) {
return adoptThread(recv, t, Block.NULL_BLOCK);
return adoptThread(recv, t);
}

private static RubyThread adoptThread(final IRubyObject recv, Thread t, Block block) {
private static RubyThread adoptThread(final IRubyObject recv, Thread t) {
final Ruby runtime = recv.getRuntime();
final RubyThread rubyThread = new RubyThread(runtime, (RubyClass) recv);

11 changes: 6 additions & 5 deletions core/src/main/java/org/jruby/internal/runtime/NativeThread.java
Original file line number Diff line number Diff line change
@@ -37,16 +37,17 @@
* @author cnutter
*/
public class NativeThread implements ThreadLike {
private Reference<Thread> nativeThread;
public RubyThread rubyThread;

private final Reference<Thread> nativeThread;
public final RubyThread rubyThread;

@Deprecated
public NativeThread(RubyThread rubyThread, IRubyObject[] args, Block block) {
throw new RuntimeException();
}

public NativeThread(RubyThread rubyThread, Thread nativeThread) {
this.rubyThread = rubyThread;
this.nativeThread = new WeakReference<Thread>(nativeThread);
this.nativeThread = new WeakReference<>(nativeThread);
}

public void start() {
@@ -98,7 +99,7 @@ public boolean isInterrupted() {
return false;
}

public Thread getThread() {
public final Thread getThread() {
return nativeThread.get();
}

Original file line number Diff line number Diff line change
@@ -246,7 +246,7 @@ public synchronized RubyThread[] getActiveRubyThreads() {
// all threads in ruby thread group plus main thread

synchronized(rubyThreadMap) {
List<RubyThread> rtList = new ArrayList<RubyThread>(rubyThreadMap.size());
List<RubyThread> rtList = new ArrayList<>(rubyThreadMap.size());

for (Map.Entry<Object, RubyThread> entry : rubyThreadMap.entrySet()) {
Object key = entry.getKey();
@@ -267,10 +267,7 @@ public synchronized RubyThread[] getActiveRubyThreads() {
rtList.add(entry.getValue());
}

RubyThread[] rubyThreads = new RubyThread[rtList.size()];
rtList.toArray(rubyThreads);

return rubyThreads;
return rtList.toArray(new RubyThread[rtList.size()]);
}
}

2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/ir/interpreter/Profiler.java
Original file line number Diff line number Diff line change
@@ -95,7 +95,7 @@ private static void analyzeProfile() {
for (IRScope s: calledScopes) {
c = scopeCounts.get(s);
if (c == null) {
c = new Long(0);
c = Long.valueOf(0);
scopeCounts.put(s, c);
}