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

Commits on Apr 5, 2016

  1. invent a fast string.split (without regexp compiling) for single char…

    … splitings
    
    ... and use it with Java method name mangling for faster backtrace generation
    kares committed Apr 5, 2016
    Copy the full SHA
    16cb9c6 View commit details
  2. Copy the full SHA
    b079462 View commit details
  3. Copy the full SHA
    e5f9f01 View commit details
  4. Copy the full SHA
    6163e00 View commit details
  5. Copy the full SHA
    9927542 View commit details
  6. Copy the full SHA
    91b66dd View commit details
11 changes: 5 additions & 6 deletions core/src/main/java/org/jruby/RubyDir.java
Original file line number Diff line number Diff line change
@@ -799,12 +799,11 @@ public static IRubyObject getHomeDirectoryPath(ThreadContext context, String use
return runtime.getNil();
}

String[] rows = passwd.split("\n");
int rowCount = rows.length;
for (int i = 0; i < rowCount; i++) {
String[] fields = rows[i].split(":");
if (fields[0].equals(user)) {
return runtime.newString(fields[5]);
List<String> rows = StringSupport.split(passwd, '\n');
for (int i = 0; i < rows.size(); i++) {
List<String> fields = StringSupport.split(rows.get(i), ':');
if (fields.get(0).equals(user)) {
return runtime.newString(fields.get(5));
}
}
}
6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/RubyInstanceConfig.java
Original file line number Diff line number Diff line change
@@ -43,11 +43,13 @@
import org.jruby.util.JRubyFile;
import org.jruby.util.KCode;
import org.jruby.util.SafePropertyAccessor;
import org.jruby.util.StringSupport;
import org.jruby.util.UriLikePathHelper;
import org.jruby.util.cli.ArgumentProcessor;
import org.jruby.util.cli.Options;
import org.jruby.util.cli.OutputStrings;
import static org.jruby.util.StringSupport.EMPTY_STRING_ARRAY;

import org.objectweb.asm.Opcodes;

import java.io.BufferedInputStream;
@@ -60,7 +62,6 @@
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -94,8 +95,7 @@ public RubyInstanceConfig() {
managementEnabled = false;
} else {
if (COMPILE_EXCLUDE != null) {
String[] elements = COMPILE_EXCLUDE.split(",");
excludedMethods.addAll(Arrays.asList(elements));
excludedMethods.addAll(StringSupport.split(COMPILE_EXCLUDE, ','));
}

managementEnabled = Options.MANAGEMENT_ENABLED.load();
11 changes: 6 additions & 5 deletions core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java
Original file line number Diff line number Diff line change
@@ -63,6 +63,7 @@
import static org.jruby.runtime.builtin.IRubyObject.NULL_ARRAY;
import org.jruby.util.Numeric;
import org.jruby.util.SafeDoubleParser;
import org.jruby.util.StringSupport;

/**
* @author <a href="mailto:ola.bini@ki.se">Ola Bini</a>
@@ -1626,14 +1627,14 @@ private CharSequence engineeringValue(String arg) {
}

private CharSequence floatingPointValue(String arg) {
String values[] = value.abs().stripTrailingZeros().toPlainString().split("\\.");
String whole = values.length > 0 ? values[0] : "0";
String after = values.length > 1 ? values[1] : "0";
List<String> values = StringSupport.split(value.abs().stripTrailingZeros().toPlainString(), '.');
String whole = values.size() > 0 ? values.get(0) : "0";
String after = values.size() > 1 ? values.get(1) : "0";
StringBuilder build = new StringBuilder().append(sign(arg, value.signum()));

if (groups(arg) == 0) {
build.append(whole);
if (after != null) build.append(".").append(after);
if (after != null) build.append('.').append(after);
} else {
int index = 0;
String sep = "";
@@ -1646,7 +1647,7 @@ private CharSequence floatingPointValue(String arg) {
index += groups(arg);
}
if (null != after) {
build.append(".");
build.append('.');
index = 0;
sep = "";
while (index < after.length()) {
Original file line number Diff line number Diff line change
@@ -28,7 +28,6 @@
package org.jruby.internal.runtime.methods;

import java.lang.invoke.MethodHandle;
import java.util.Arrays;
import java.util.concurrent.Callable;

import org.jruby.RubyModule;
@@ -40,6 +39,9 @@
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;

import static org.jruby.util.StringSupport.EMPTY_STRING_ARRAY;
import static org.jruby.util.StringSupport.split;

/**
* A DynamicMethod backed by one or more java.lang.invoke.MethodHandle objects.
*
@@ -288,10 +290,9 @@ public DynamicMethod dup() {
@Override
public String[] getParameterList() {
if (parameterDesc != null && parameterDesc.length() > 0) {
return parameterDesc.split(";");
} else {
return new String[0];
return split(parameterDesc, ';').toArray(EMPTY_STRING_ARRAY);
}
return EMPTY_STRING_ARRAY;
}

public MethodHandle getHandle(int arity) {
Original file line number Diff line number Diff line change
@@ -34,6 +34,9 @@
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;

import static org.jruby.util.StringSupport.EMPTY_STRING_ARRAY;
import static org.jruby.util.StringSupport.split;

/**
*/
public abstract class JavaMethod extends DynamicMethod implements Cloneable, MethodArgs2, NativeCallMethod {
@@ -232,12 +235,12 @@ public void setParameterList(String[] parameterList) {
public String[] getParameterList() {
if (parameterList == null) {
if (parameterDesc != null && parameterDesc.length() > 0) {
parameterList = parameterDesc.split(";");
} else {
parameterList = new String[0];
parameterList = split(parameterDesc, ';').toArray(EMPTY_STRING_ARRAY);
}
else {
parameterList = EMPTY_STRING_ARRAY;
}
}

return parameterList;
}

6 changes: 3 additions & 3 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -332,7 +332,7 @@ private void emitWithSignatures(IRMethod method, JVMVisitorMethodContext context
}

public Handle emitModuleBodyJIT(IRModuleBody method) {
String name = JavaNameMangler.encodeScopeForBacktrace(method) + "$" + methodIndex++;
String name = JavaNameMangler.encodeScopeForBacktrace(method) + '$' + methodIndex++;

String clsName = jvm.scriptToClass(method.getFileName());
jvm.pushscript(clsName, method.getFileName());
@@ -357,15 +357,15 @@ private void emitClosures(IRScope s, boolean print) {

public Handle emitClosure(IRClosure closure, boolean print) {
/* Compile the closure like a method */
String name = JavaNameMangler.encodeScopeForBacktrace(closure) + "$" + methodIndex++;
String name = JavaNameMangler.encodeScopeForBacktrace(closure) + '$' + methodIndex++;

emitScope(closure, name, CLOSURE_SIGNATURE, false, print);

return new Handle(Opcodes.H_INVOKESTATIC, jvm.clsData().clsName, name, sig(CLOSURE_SIGNATURE.type().returnType(), CLOSURE_SIGNATURE.type().parameterArray()));
}

public Handle emitModuleBody(IRModuleBody method) {
String name = JavaNameMangler.encodeScopeForBacktrace(method) + "$" + methodIndex++;
String name = JavaNameMangler.encodeScopeForBacktrace(method) + '$' + methodIndex++;

Signature signature = signatureFor(method, false);
emitScope(method, name, signature, false, true);
9 changes: 3 additions & 6 deletions core/src/main/java/org/jruby/ir/targets/NormalInvokeSite.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package org.jruby.ir.targets;

import org.jruby.RubyClass;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.runtime.Block;
import org.jruby.runtime.CallType;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.callsite.CacheEntry;
import org.jruby.util.JavaNameMangler;
import org.jruby.util.StringSupport;
import org.objectweb.asm.Handle;
import org.objectweb.asm.Opcodes;

@@ -17,8 +15,6 @@
import java.lang.invoke.MethodType;
import java.lang.invoke.SwitchPoint;

import static org.jruby.runtime.invokedynamic.InvokeDynamicSupport.callMethodMissing;
import static org.jruby.runtime.invokedynamic.InvokeDynamicSupport.methodMissing;
import static org.jruby.util.CodegenUtils.p;
import static org.jruby.util.CodegenUtils.sig;

@@ -35,7 +31,8 @@ public NormalInvokeSite(MethodType type, String name) {
public static Handle BOOTSTRAP = new Handle(Opcodes.H_INVOKESTATIC, p(NormalInvokeSite.class), "bootstrap", sig(CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class));

public static CallSite bootstrap(MethodHandles.Lookup lookup, String name, MethodType type) {
InvokeSite site = new NormalInvokeSite(type, JavaNameMangler.demangleMethodName(name.split(":")[1]));
String methodName = StringSupport.split(name, ':').get(1);
InvokeSite site = new NormalInvokeSite(type, JavaNameMangler.demangleMethodName(methodName));

return InvokeSite.bootstrap(site, lookup);
}
14 changes: 5 additions & 9 deletions core/src/main/java/org/jruby/ir/targets/SelfInvokeSite.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package org.jruby.ir.targets;

import org.jruby.RubyClass;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.runtime.Block;
import org.jruby.runtime.CallType;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.callsite.CacheEntry;
import org.jruby.util.JavaNameMangler;
import org.jruby.util.StringSupport;
import org.objectweb.asm.Handle;
import org.objectweb.asm.Opcodes;

@@ -17,9 +14,8 @@
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.invoke.SwitchPoint;
import java.util.List;

import static org.jruby.runtime.invokedynamic.InvokeDynamicSupport.callMethodMissing;
import static org.jruby.runtime.invokedynamic.InvokeDynamicSupport.methodMissing;
import static org.jruby.util.CodegenUtils.p;
import static org.jruby.util.CodegenUtils.sig;

@@ -34,9 +30,9 @@ public SelfInvokeSite(MethodType type, String name, CallType callType) {
public static Handle BOOTSTRAP = new Handle(Opcodes.H_INVOKESTATIC, p(SelfInvokeSite.class), "bootstrap", sig(CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class));

public static CallSite bootstrap(MethodHandles.Lookup lookup, String name, MethodType type) {
String[] nameComponents = name.split(":");
String methodName = JavaNameMangler.demangleMethodName(nameComponents[1]);
CallType callType = nameComponents[0].equals("callFunctional") ? CallType.FUNCTIONAL : CallType.VARIABLE;
List<String> nameComponents = StringSupport.split(name, ':');
String methodName = JavaNameMangler.demangleMethodName(nameComponents.get(1));
CallType callType = nameComponents.get(0).equals("callFunctional") ? CallType.FUNCTIONAL : CallType.VARIABLE;
InvokeSite site = new SelfInvokeSite(type, methodName, callType);

return InvokeSite.bootstrap(site, lookup);
15 changes: 5 additions & 10 deletions core/src/main/java/org/jruby/ir/targets/SuperInvokeSite.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package org.jruby.ir.targets;

import com.headius.invokebinder.Binder;
import com.headius.invokebinder.SmartBinder;
import org.jruby.RubyClass;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.runtime.Block;
import org.jruby.runtime.CallType;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.callsite.CacheEntry;
import org.jruby.util.JavaNameMangler;
import org.jruby.util.StringSupport;
import org.objectweb.asm.Handle;
import org.objectweb.asm.Opcodes;

@@ -20,9 +16,8 @@
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.invoke.SwitchPoint;
import java.util.List;

import static org.jruby.ir.runtime.IRRuntimeHelpers.splatArguments;
import static org.jruby.runtime.Helpers.arrayOf;
import static org.jruby.util.CodegenUtils.p;
import static org.jruby.util.CodegenUtils.sig;

@@ -43,12 +38,12 @@ public SuperInvokeSite(MethodType type, String superName, String splatmapString)
public static final Handle BOOTSTRAP = new Handle(Opcodes.H_INVOKESTATIC, p(SuperInvokeSite.class), "bootstrap", sig(CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class, String.class));

public static CallSite bootstrap(MethodHandles.Lookup lookup, String name, MethodType type, String splatmapString) {
String[] targetAndMethod = name.split(":");
String superName = JavaNameMangler.demangleMethodName(targetAndMethod[1]);
List<String> targetAndMethod = StringSupport.split(name, ':');
String superName = JavaNameMangler.demangleMethodName(targetAndMethod.get(1));

InvokeSite site;

switch (targetAndMethod[0]) {
switch (targetAndMethod.get(0)) {
case "invokeInstanceSuper":
site = new InstanceSuperInvokeSite(type, superName, splatmapString);
break;
Original file line number Diff line number Diff line change
@@ -130,8 +130,8 @@ private static void buildClassName(StringBuilder nameBuilder, StringBuilder file
nameBuilder.setLength(0);
fileBuilder.setLength(0);
for (int j = i; j < all.length - 1; j++) {
nameBuilder.append(all[j]).append(".");
fileBuilder.append(all[j]).append("/");
nameBuilder.append(all[j]).append('.');
fileBuilder.append(all[j]).append('/');
}
nameBuilder.append(serviceName);
fileBuilder.append(serviceName).append(".class");
Loading