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

Commits on Mar 23, 2015

  1. Copy the full SHA
    e8f296a View commit details
  2. Copy the full SHA
    cc3b196 View commit details
  3. Copy the full SHA
    002d38b View commit details
5 changes: 4 additions & 1 deletion core/src/main/java/org/jruby/compiler/JITCompiler.java
Original file line number Diff line number Diff line change
@@ -250,7 +250,10 @@ public void run() {
|| config.getExcludedMethods().contains(excludeModuleName + "#" + methodName)
|| config.getExcludedMethods().contains(methodName))) {
method.setCallCount(-1);
log(method.getImplementationClass(), method.getFile(), method.getLine(), methodName, "skipping method: " + excludeModuleName + "#" + methodName);

if (config.isJitLogging()) {
log(method.getImplementationClass(), method.getFile(), method.getLine(), methodName, "skipping method: " + excludeModuleName + "#" + methodName);
}
return;
}
}
54 changes: 33 additions & 21 deletions core/src/main/java/org/jruby/util/Sprintf.java
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@
import org.jruby.common.IRubyWarnings.ID;
import org.jruby.runtime.ClassIndex;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.io.EncodingUtils;


/**
@@ -485,29 +486,40 @@ private static boolean rubySprintfToBuffer(ByteList buf, CharSequence charFormat
}

int c = 0;
// MRI 1.8.5-p12 doesn't support 1-char strings, but
// YARV 0.4.1 does. I don't think it hurts to include
// this; sprintf('%c','a') is nicer than sprintf('%c','a'[0])
if (arg instanceof RubyString) {
ByteList bytes = ((RubyString)arg).getByteList();
if (bytes.length() == 1) {
c = bytes.getUnsafeBytes()[bytes.begin()];
} else {
raiseArgumentError(args,"%c requires a character");
int n = 0;
IRubyObject tmp = arg.checkStringType19();
if (!tmp.isNil()) {
if (((RubyString)tmp).strLength() != 1) {
throw runtime.newArgumentError("%c requires a character");
}
} else {
c = args.intValue(arg);
ByteList bl = ((RubyString)tmp).getByteList();
c = StringSupport.codePoint(runtime, encoding, bl.unsafeBytes(), bl.begin(), bl.begin() + bl.realSize());
n = StringSupport.codeLength(runtime, bl.getEncoding(), c);
}
if ((flags & FLAG_WIDTH) != 0 && width > 1) {
if ((flags & FLAG_MINUS) != 0) {
buf.append(c);
buf.fill(' ', width-1);
} else {
buf.fill(' ',width-1);
buf.append(c);
}
} else {
buf.append(c);
else {
// unsigned bits
c = (int)arg.convertToInteger().getLongValue() & 0xFFFFFFFF;
n = StringSupport.codeLength(runtime, encoding, c);
}
if (n <= 0) {
throw runtime.newArgumentError("invalid character");
}
if ((flags & FLAG_WIDTH) == 0) {
buf.ensure(buf.length() + n);
EncodingUtils.encMbcput(c, buf.unsafeBytes(), buf.realSize(), encoding);
buf.realSize(buf.realSize() + n);
}
else if ((flags & FLAG_MINUS) != 0) {
buf.ensure(buf.length() + n);
EncodingUtils.encMbcput(c, buf.unsafeBytes(), buf.realSize(), encoding);
buf.realSize(buf.realSize() + n);
buf.fill(' ', width - 1);
}
else {
buf.fill(' ', width - 1);
buf.ensure(buf.length() + n);
EncodingUtils.encMbcput(c, buf.unsafeBytes(), buf.realSize(), encoding);
buf.realSize(buf.realSize() + n);
}
offset++;
incomplete = false;
10 changes: 8 additions & 2 deletions core/src/main/java/org/jruby/util/StringSupport.java
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@
import org.jcodings.Encoding;
import org.jcodings.ascii.AsciiTables;
import org.jcodings.constants.CharacterType;
import org.jcodings.exception.EncodingException;
import org.jcodings.specific.ASCIIEncoding;
import org.jcodings.specific.UTF8Encoding;
import org.jcodings.util.IntHash;
@@ -379,8 +380,13 @@ public static int codePoint(Ruby runtime, Encoding enc, byte[]bytes, int p, int
}

public static int codeLength(Ruby runtime, Encoding enc, int c) {
int n = enc.codeToMbcLength(c);
if (n == 0) throw runtime.newRangeError("invalid codepoint " + String.format("0x%x in ", c) + enc.getName());
int n = 0;
try {
n = enc.codeToMbcLength(c);
} catch (EncodingException ee) {
// raise as ArgumentError below
}
if (n == 0) throw runtime.newArgumentError("invalid codepoint " + String.format("0x%x in ", c) + enc.getName());
return n;
}

2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/util/cli/Options.java
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ public class Options {
public static final Option<Boolean> JIT_LOGGING_VERBOSE = bool(JIT, "jit.logging.verbose", false, "Enable verbose JIT logging (reports failed compilation).");
public static final Option<Boolean> JIT_DUMPING = bool(JIT, "jit.dumping", false, "Enable stdout dumping of JITed bytecode.");
public static final Option<Integer> JIT_LOGEVERY = integer(JIT, "jit.logEvery", 0, "Log a message every n methods JIT compiled.");
public static final Option<String> JIT_EXCLUDE = string(JIT, "jit.exclude", new String[]{"ClsOrMod","ClsOrMod::method_name","-::method_name"}, "", "Exclude methods from JIT. Comma delimited.");
public static final Option<String> JIT_EXCLUDE = string(JIT, "jit.exclude", "", "Exclude methods from JIT. <ModClsName or '-'>::<method_name>, comma-delimited.");
public static final Option<String> JIT_CODECACHE = string(JIT, "jit.codeCache", new String[]{"dir"}, "Save jitted methods to <dir> as they're compiled, for future runs.");
public static final Option<Boolean> JIT_DEBUG = bool(JIT, "jit.debug", false, "Log loading of JITed bytecode.");
public static final Option<Boolean> JIT_BACKGROUND = bool(JIT, "jit.background", true, "Run the JIT compiler in a background thread.");