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: 0b202a9aff5e
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d7067048bccb
Choose a head ref
  • 16 commits
  • 14 files changed
  • 4 contributors

Commits on Jun 23, 2016

  1. Copy the full SHA
    237f3e8 View commit details
  2. Copy the full SHA
    34c246d View commit details
  3. Copy the full SHA
    9e6aa8c View commit details
  4. more (internal) Enumerable cleanup - prefer "zip" instead of zip19

    + avoid support for having pre 1.9 zip "common" code altogether
    kares committed Jun 23, 2016
    Copy the full SHA
    6437b3d View commit details
  5. Copy the full SHA
    0f398e3 View commit details
  6. Copy the full SHA
    29b001a View commit details
  7. Copy the full SHA
    32e2135 View commit details
  8. Copy the full SHA
    872293f View commit details
  9. reference wrapped ThreadFiber instance might gc away

    ... by the time we attempt to raise on it
    
    happened on travis-ci and it errored with a NPE - now we'll log a warning
    kares committed Jun 23, 2016
    Copy the full SHA
    a7589a9 View commit details
  10. Copy the full SHA
    45a6aea View commit details
  11. [Truffle] add missing license

    pitr-ch committed Jun 23, 2016
    Copy the full SHA
    8a198dd View commit details
  12. Copy the full SHA
    39439aa View commit details
  13. Copy the full SHA
    e0a287c View commit details
  14. Copy the full SHA
    61ee324 View commit details
  15. Copy the full SHA
    1d583ec View commit details
  16. Copy the full SHA
    d706704 View commit details
123 changes: 60 additions & 63 deletions core/src/main/java/org/jruby/RubyEnumerable.java
Original file line number Diff line number Diff line change
@@ -82,6 +82,7 @@ public static IRubyObject callEach(Ruby runtime, ThreadContext context, IRubyObj
Signature.OPTIONAL, callback, context));
}

@Deprecated
public static IRubyObject callEach19(Ruby runtime, ThreadContext context, IRubyObject self,
BlockCallback callback) {
return Helpers.invoke(context, self, "each", CallBlock19.newCallClosure(self, runtime.getEnumerable(),
@@ -446,7 +447,7 @@ public static IRubyObject to_a(ThreadContext context, IRubyObject self, IRubyObj
public static IRubyObject to_a19(ThreadContext context, IRubyObject self) {
Ruby runtime = context.runtime;
RubyArray result = runtime.newArray();
callEach(runtime, context, self, Signature.OPTIONAL, new AppendBlockCallback(runtime, result));
callEach(runtime, context, self, Signature.OPTIONAL, new AppendBlockCallback(result));
result.infectBy(self);
return result;
}
@@ -455,7 +456,7 @@ public static IRubyObject to_a19(ThreadContext context, IRubyObject self, IRubyO
final Ruby runtime = context.runtime;
final RubyArray result = runtime.newArray();
Helpers.invoke(context, self, "each", args, CallBlock.newCallClosure(self, runtime.getEnumerable(),
Signature.OPTIONAL, new AppendBlockCallback(runtime, result), context));
Signature.OPTIONAL, new AppendBlockCallback(result), context));
result.infectBy(self);
return result;
}
@@ -465,7 +466,7 @@ public static IRubyObject to_h(ThreadContext context, IRubyObject self, IRubyObj
final Ruby runtime = context.runtime;
final RubyHash result = RubyHash.newHash(runtime);
Helpers.invoke(context, self, "each", args, CallBlock.newCallClosure(self, runtime.getEnumerable(),
Signature.OPTIONAL, new PutKeyValueCallback(runtime, result), context));
Signature.OPTIONAL, new PutKeyValueCallback(result), context));
result.infectBy(self);
return result;
}
@@ -475,7 +476,7 @@ public static IRubyObject sort(ThreadContext context, IRubyObject self, final Bl
final Ruby runtime = context.runtime;
final RubyArray result = runtime.newArray();

callEach(runtime, context, self, Signature.OPTIONAL, new AppendBlockCallback(runtime, result));
callEach(runtime, context, self, Signature.OPTIONAL, new AppendBlockCallback(result));
result.sort_bang(context, block);

return result;
@@ -1611,26 +1612,29 @@ public IRubyObject yield(ThreadContext context, IRubyObject[] args) {
return runtime.getFalse();
}

@JRubyMethod(name = "zip", rest = true)
public static IRubyObject zip(ThreadContext context, IRubyObject self, final IRubyObject[] args, final Block block) {
return zip19(context, self, args, block);
return zipCommon(context, self, args, block);
}

@JRubyMethod(name = "zip", rest = true)
@Deprecated
public static IRubyObject zip19(ThreadContext context, IRubyObject self, final IRubyObject[] args, final Block block) {
return zipCommon19(context, self, args, block);
return zip(context, self, args, block);
}

@Deprecated
public static IRubyObject[] zipCommonConvert(Ruby runtime, IRubyObject[] args) {
return zipCommonConvert(runtime, args, "to_a");
}

@Deprecated
public static IRubyObject[] zipCommonConvert(Ruby runtime, IRubyObject[] args, String method) {
RubyClass array = runtime.getArray();
final RubyClass Array = runtime.getArray();
ThreadContext context = runtime.getCurrentContext();

// 1.9 tries to convert, and failing that tries to "each" elements into a new array
for (int i = 0; i < args.length; i++) {
IRubyObject result = TypeConverter.convertToTypeWithCheck19(args[i], array, method);
IRubyObject result = TypeConverter.convertToTypeWithCheck19(args[i], Array, method);
if (result.isNil()) {
result = takeItems(context, args[i]);
}
@@ -1640,42 +1644,37 @@ public static IRubyObject[] zipCommonConvert(Ruby runtime, IRubyObject[] args, S
return args;
}

public static IRubyObject zipCommon(ThreadContext context, IRubyObject self,
IRubyObject[] aArgs, final Block block) {
final Ruby runtime = context.runtime;
final IRubyObject[] args = zipCommonConvert(runtime, aArgs);

return zipCommonAry(context, self, args, block);
@Deprecated
public static IRubyObject zipCommon19(ThreadContext context, IRubyObject self, IRubyObject[] args, final Block block) {
return zipCommon(context, self, args, block);
}

public static IRubyObject zipCommon19(ThreadContext context, IRubyObject self,
IRubyObject[] args, final Block block) {
public static IRubyObject zipCommon(ThreadContext context, IRubyObject self, IRubyObject[] args, final Block block) {
final Ruby runtime = context.runtime;
RubyClass array = runtime.getArray();
final RubyClass Array = runtime.getArray();

final IRubyObject[] newArgs = new IRubyObject[args.length];

boolean hasUncoercible = false;
for (int i = 0; i < args.length; i++) {
newArgs[i] = TypeConverter.convertToType(args[i], array, "to_ary", false);
newArgs[i] = TypeConverter.convertToType(args[i], Array, "to_ary", false);
if (newArgs[i].isNil()) {
hasUncoercible = true;
break; // since we will overwrite newArgs[]
}
}

// Handle uncoercibles by trying to_enum conversion
if (hasUncoercible) {
RubySymbol each = runtime.newSymbol("each");
final RubySymbol each = runtime.newSymbol("each");
for (int i = 0; i < args.length; i++) {
newArgs[i] = args[i].callMethod(context, "to_enum", each);
}
}

if (hasUncoercible) {
return zipCommonEnum(context, self, newArgs, block);
} else {
return zipCommonAry(context, self, newArgs, block);
}

return zipCommonAry(context, self, newArgs, block);
}

// TODO: Eliminate duplication here and zipCommonEnum
@@ -1687,7 +1686,7 @@ public static IRubyObject zipCommonAry(ThreadContext context, IRubyObject self,

if (block.isGiven()) {
callEach(runtime, context, self, block.getSignature(), new BlockCallback() {
AtomicInteger ix = new AtomicInteger(0);
final AtomicInteger ix = new AtomicInteger(0);

public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
IRubyObject larg = packEnumValues(ctx, largs);
@@ -1698,14 +1697,14 @@ public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
array.append(((RubyArray) args[i]).entry(myIx));
}
block.yield(ctx, array);
return runtime.getNil();
return ctx.nil;
}
});
return runtime.getNil();
return context.nil;
} else {
final RubyArray zip = runtime.newArray();
callEach(runtime, context, self, Signature.ONE_REQUIRED, new BlockCallback() {
AtomicInteger ix = new AtomicInteger(0);
final AtomicInteger ix = new AtomicInteger(0);

public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
IRubyObject larg = packEnumValues(ctx, largs);
@@ -1715,10 +1714,8 @@ public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
for (int i = 0, j = args.length; i < j; i++) {
array.append(((RubyArray) args[i]).entry(myIx));
}
synchronized (zip) {
zip.append(array);
}
return runtime.getNil();
synchronized (zip) { zip.append(array); }
return ctx.nil;
}
});
return zip;
@@ -1734,38 +1731,36 @@ public static IRubyObject zipCommonEnum(ThreadContext context, IRubyObject self,

if (block.isGiven()) {
callEach(runtime, context, self, block.getSignature(), new BlockCallback() {
AtomicInteger ix = new AtomicInteger(0);
//final AtomicInteger ix = new AtomicInteger(0);

public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
IRubyObject larg = packEnumValues(ctx, largs);
RubyArray array = runtime.newArray(len);
int myIx = ix.getAndIncrement();
//int myIx = ix.getAndIncrement();
array.append(larg);
for (int i = 0, j = args.length; i < j; i++) {
array.append(zipEnumNext(ctx, args[i]));
}
block.yield(ctx, array);
return runtime.getNil();
return ctx.nil;
}
});
return runtime.getNil();
return context.nil;
} else {
final RubyArray zip = runtime.newArray();
callEach(runtime, context, self, Signature.ONE_REQUIRED, new BlockCallback() {
AtomicInteger ix = new AtomicInteger(0);
//final AtomicInteger ix = new AtomicInteger(0);

public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
IRubyObject larg = packEnumValues(ctx, largs);
RubyArray array = runtime.newArray(len);
array.append(larg);
int myIx = ix.getAndIncrement();
//int myIx = ix.getAndIncrement();
for (int i = 0, j = args.length; i < j; i++) {
array.append(zipEnumNext(ctx, args[i]));
}
synchronized (zip) {
zip.append(array);
}
return runtime.getNil();
synchronized (zip) { zip.append(array); }
return ctx.nil;
}
});
return zip;
@@ -1797,22 +1792,18 @@ public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
}

public static IRubyObject zipEnumNext(ThreadContext context, IRubyObject arg) {
Ruby runtime = context.runtime;
if (arg.isNil()) return context.nil;

if (arg.isNil()) {
return context.nil;
} else {
IRubyObject oldExc = runtime.getGlobalVariables().get("$!");
try {
return arg.callMethod(context, "next");
} catch (RaiseException re) {
if (re.getException().getMetaClass() == runtime.getStopIteration()) {
runtime.getGlobalVariables().set("$!", oldExc);
return context.nil;
} else {
throw re;
}
final Ruby runtime = context.runtime;
IRubyObject oldExc = runtime.getGlobalVariables().get("$!");
try {
return arg.callMethod(context, "next");
} catch (RaiseException re) {
if (re.getException().getMetaClass() == runtime.getStopIteration()) {
runtime.getGlobalVariables().set("$!", oldExc);
return context.nil;
}
throw re;
}
}

@@ -1837,7 +1828,7 @@ public IRubyObject call(ThreadContext ctx, IRubyObject[] largs, Block blk) {
}
curr.append(larg);
}
return runtime.getNil();
return ctx.nil;
}
});

@@ -1880,9 +1871,9 @@ public IRubyObject size(IRubyObject[] args) {
};
}

private static class ChunkArg {
private static final class ChunkArg {

private ChunkArg(final ThreadContext context) {
ChunkArg(final ThreadContext context) {
this.prev_elts = this.prev_value = context.nil;
}

@@ -1971,7 +1962,7 @@ public static final class AppendBlockCallback implements BlockCallback {

private final RubyArray result;

// @Deprecated
@Deprecated
public AppendBlockCallback(Ruby runtime, RubyArray result) {
this.result = result;
}
@@ -1988,15 +1979,21 @@ public IRubyObject call(ThreadContext context, IRubyObject[] largs, Block blk) {
}

public static final class PutKeyValueCallback implements BlockCallback {
private Ruby runtime;
private RubyHash result;

private final RubyHash result;

@Deprecated
public PutKeyValueCallback(Ruby runtime, RubyHash result) {
this.runtime = runtime;
this.result = result;
}

PutKeyValueCallback(RubyHash result) {
this.result = result;
}

public IRubyObject call(ThreadContext context, IRubyObject[] largs, Block blk) {
final Ruby runtime = context.runtime;

IRubyObject value;

switch (largs.length) {
39 changes: 19 additions & 20 deletions core/src/main/java/org/jruby/anno/AnnotationBinder.java
Original file line number Diff line number Diff line change
@@ -53,7 +53,6 @@
public class AnnotationBinder extends AbstractProcessor {

public static final String POPULATOR_SUFFIX = "$POPULATOR";
private static final Logger LOG = Logger.getLogger("AnnotationBinder");
public static final String SRC_GEN_DIR = "target/generated-sources/org/jruby/gen/";
private final List<CharSequence> classNames = new ArrayList<CharSequence>();
private PrintStream out;
@@ -72,7 +71,9 @@ public boolean process(Set<? extends TypeElement> typeElements, RoundEnvironment
fw.write('\n');
}
fw.close();
} catch (Exception e) {
}
catch (Exception e) {
if (e instanceof RuntimeException) throw (RuntimeException) e;
throw new RuntimeException(e);
}

@@ -239,24 +240,10 @@ public void processType(TypeElement cd) {
// write out a static initializer for frame names, so it only fires once
out.println(" static {");
if (!frameAwareMethods.isEmpty()) {
StringBuffer frameMethodsString = new StringBuffer();
boolean first = true;
for (CharSequence name : frameAwareMethods) {
if (!first) frameMethodsString.append(',');
first = false;
frameMethodsString.append('"').append(name).append('"');
}
out.println(" MethodIndex.addFrameAwareMethods(" + frameMethodsString + ");");
out.println(" MethodIndex.addFrameAwareMethods(" + join(frameAwareMethods) + ");");
}
if (!scopeAwareMethods.isEmpty()) {
StringBuffer scopeMethodsString = new StringBuffer();
boolean first = true;
for (CharSequence name : scopeAwareMethods) {
if (!first) scopeMethodsString.append(',');
first = false;
scopeMethodsString.append('"').append(name).append('"');
}
out.println(" MethodIndex.addScopeAwareMethods(" + scopeMethodsString + ");");
out.println(" MethodIndex.addScopeAwareMethods(" + join(scopeAwareMethods) + ");");
}
out.println(" }");

@@ -268,12 +255,24 @@ public void processType(TypeElement cd) {
FileOutputStream fos = new FileOutputStream(SRC_GEN_DIR + qualifiedName + POPULATOR_SUFFIX + ".java");
fos.write(bytes.toByteArray());
fos.close();
} catch (IOException ioe) {
LOG.severe("FAILED TO GENERATE: " + ioe);
}
catch (IOException ex) {
ex.printStackTrace(System.err);
System.exit(1);
}
}

private static StringBuilder join(final Iterable<String> names) {
final StringBuilder str = new StringBuilder();
boolean first = true;
for (String name : names) {
if (!first) str.append(',');
first = false;
str.append('"').append(name).append('"');
}
return str;
}

public void processMethodDeclarations(Map<CharSequence, List<ExecutableElement>> declarations) {
for (Map.Entry<CharSequence, List<ExecutableElement>> entry : declarations.entrySet()) {
List<ExecutableElement> list = entry.getValue();
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/anno/IndyBinder.java
Original file line number Diff line number Diff line change
@@ -76,7 +76,6 @@
public class IndyBinder extends AbstractProcessor {

public static final String POPULATOR_SUFFIX = "$POPULATOR";
private static final Logger LOG = Logger.getLogger("IndyBinder");
public static final String SRC_GEN_DIR = "target/classes/org/jruby/gen/";
public static final int CLASS = 1;
public static final int BASEMETHOD = 3;
@@ -311,8 +310,9 @@ public void processType(TypeElement cd) {
FileOutputStream fos = new FileOutputStream(SRC_GEN_DIR + qualifiedName + POPULATOR_SUFFIX + ".class");
fos.write(cw.toByteArray());
fos.close();
} catch (IOException ioe) {
LOG.severe("FAILED TO GENERATE: " + ioe);
}
catch (IOException ex) {
ex.printStackTrace(System.err);
System.exit(1);
}
}
Loading