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

Commits on Nov 5, 2014

  1. Copy the full SHA
    9a0cf9a View commit details
  2. Fixes plus partial refactor of SelectExecutor.

    * Eliminate fds array, since we already have an object and fields.
      First step to reducing allocation.
    * Attach list of fds to key to allow both read and write to reg.
    * Update (rather than replace) key ops with additional operations.
    * Use SelectorPool to acquire/release selectors.
    * Misc cleanup of dead code.
    
    Fixes #2102
    Fixes #2106
    headius committed Nov 5, 2014
    Copy the full SHA
    f79d6c3 View commit details
  3. Copy the full SHA
    950f82e View commit details
  4. Copy the full SHA
    1cfcd34 View commit details
  5. Pass enumerator method name through for chars, codepoints, bytes.

    Eliminates spurious warnings when doing e.g. str.chars.any? {}.
    headius committed Nov 5, 2014
    Copy the full SHA
    0898d32 View commit details
  6. Copy the full SHA
    bc0485c View commit details
30 changes: 15 additions & 15 deletions core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -5728,14 +5728,14 @@ public IRubyObject lines(ThreadContext context, IRubyObject arg, Block block) {

@JRubyMethod(name = "lines")
public IRubyObject lines20(ThreadContext context, Block block) {
// Inefficient; build array manually rather than via Enumerator
// FIXME: Inefficient; build array manually rather than via Enumerator
return block.isGiven() ? each_lineCommon19(context, block) :
enumeratorize(context.runtime, this, "lines").callMethod(context, "to_a");
}

@JRubyMethod(name = "lines")
public IRubyObject lines20(ThreadContext context, IRubyObject arg, Block block) {
// Inefficient; build array manually rather than via Enumerator
// FIXME: Inefficient; build array manually rather than via Enumerator
return block.isGiven() ? each_lineCommon19(context, arg, block) :
enumeratorize(context.runtime, this, "lines", arg).callMethod(context, "to_a");
}
@@ -5832,22 +5832,22 @@ public RubyString each_byte(ThreadContext context, Block block) {

@JRubyMethod(name = "each_byte")
public IRubyObject each_byte19(ThreadContext context, Block block) {
return enumerateBytes(context, block, false);
return enumerateBytes(context, "each_bytes", block, false);
}

@JRubyMethod
public IRubyObject bytes(ThreadContext context, Block block) {
return enumerateBytes(context, block, true);
return enumerateBytes(context, "bytes", block, true);
}

@JRubyMethod(name = "each_char")
public IRubyObject each_char19(ThreadContext context, Block block) {
return enumerateChars(context, block, false);
return enumerateChars(context, "each_char", block, false);
}

@JRubyMethod(name = "chars")
public IRubyObject chars19(ThreadContext context, Block block) {
return enumerateChars(context, block, true);
return enumerateChars(context, "chars", block, true);
}

private SizeFn eachCharSizeFn() {
@@ -5865,16 +5865,16 @@ public IRubyObject size(IRubyObject[] args) {
*/
@JRubyMethod
public IRubyObject each_codepoint(ThreadContext context, Block block) {
return enumerateCodepoints(context, block, false);
return enumerateCodepoints(context, "each_codepoint", block, false);
}

@JRubyMethod
public IRubyObject codepoints(ThreadContext context, Block block) {
return enumerateCodepoints(context, block, true);
return enumerateCodepoints(context, "codepoints", block, true);
}

// MRI: rb_str_enumerate_chars
private IRubyObject enumerateChars(ThreadContext context, Block block, boolean wantarray) {
private IRubyObject enumerateChars(ThreadContext context, String name, Block block, boolean wantarray) {
Ruby runtime = context.runtime;
RubyString str = this;
IRubyObject orig = str;
@@ -5908,7 +5908,7 @@ private IRubyObject enumerateChars(ThreadContext context, Block block, boolean w
if (wantarray)
ary = RubyArray.newArray(runtime, str.length().getLongValue());
else
return enumeratorizeWithSize(context, this, "chars", eachCharSizeFn());
return enumeratorizeWithSize(context, this, name, eachCharSizeFn());
}

switch (getCodeRange()) {
@@ -5940,7 +5940,7 @@ private IRubyObject enumerateChars(ThreadContext context, Block block, boolean w
}

// MRI: rb_str_enumerate_codepoints
private IRubyObject enumerateCodepoints(ThreadContext context, Block block, boolean wantarray) {
private IRubyObject enumerateCodepoints(ThreadContext context, String name, Block block, boolean wantarray) {
Ruby runtime = context.runtime;
RubyString str = this;
IRubyObject orig = str;
@@ -5952,7 +5952,7 @@ private IRubyObject enumerateCodepoints(ThreadContext context, Block block, bool
RubyArray ary = null;

if (singleByteOptimizable())
return enumerateBytes(context, block, wantarray);
return enumerateBytes(context, name, block, wantarray);

str = RubyString.newString(runtime, str.getByteList().dup());
ByteList strByteList = str.getByteList();
@@ -5977,7 +5977,7 @@ private IRubyObject enumerateCodepoints(ThreadContext context, Block block, bool
if (wantarray)
ary = RubyArray.newArray(runtime, str.length().getLongValue());
else
return enumeratorizeWithSize(context, str, "codepoints", eachCodepointSizeFn());
return enumeratorizeWithSize(context, str, name, eachCodepointSizeFn());
}

while (ptr < end) {
@@ -5995,7 +5995,7 @@ private IRubyObject enumerateCodepoints(ThreadContext context, Block block, bool
return orig;
}

private IRubyObject enumerateBytes(ThreadContext context, Block block, boolean wantarray) {
private IRubyObject enumerateBytes(ThreadContext context, String name, Block block, boolean wantarray) {
Ruby runtime = context.runtime;
RubyString str = this;
int i;
@@ -6017,7 +6017,7 @@ private IRubyObject enumerateBytes(ThreadContext context, Block block, boolean w
if (wantarray)
ary = RubyArray.newArray(runtime, str.size());
else
return enumeratorizeWithSize(context, str, "bytes", eachByteSizeFn());
return enumeratorizeWithSize(context, str, name, eachByteSizeFn());
}

for (i=0; i<str.size(); i++) {
14 changes: 9 additions & 5 deletions core/src/main/java/org/jruby/ir/Compiler.java
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
import org.jruby.ast.executable.ScriptAndCode;
import org.jruby.compiler.NotCompilableException;
import org.jruby.exceptions.JumpException;
import org.jruby.exceptions.RaiseException;
import org.jruby.ir.targets.JVMVisitor;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Block;
@@ -72,11 +73,14 @@ public IRubyObject __file__(ThreadContext context, IRubyObject self, IRubyObject
return (IRubyObject) compiledMethod.invoke(null,
runtime.getCurrentContext(), scope.getStaticScope(), runtimeTopSelf, IRubyObject.NULL_ARRAY, block, runtimeTopSelf.getMetaClass());
} catch (InvocationTargetException ite) {
if (ite.getCause() instanceof JumpException) {
throw (JumpException) ite.getCause();
} else {
throw new RuntimeException(ite);
}
Throwable cause = ite.getCause();

// can this happen?
if (cause == null) throw runtime.newRuntimeError(ite.getMessage());

Helpers.throwException(cause);
return null; // not reached

} catch (Exception e) {
throw new RuntimeException(e);
}
Loading