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: 1b3111eeb162
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 9edd069b4594
Choose a head ref

Commits on Jul 19, 2016

  1. First pass at making dyncalls from Java use call site caching.

    This introduces a new class, JavaCallSites, which holds per-
    runtime call sites and function objects that cache better than our
    per-class caches. This improves the performance of core methods
    implemented with Java that need to make dynamic calls. This is a
    first step toward eventually getting those calls to use
    invokedynamic, which will require bytecode manpulation.
    
    This first commit also reworks Ruby.safeRecurse to accept a richer
    function object that also receives context and a generic state
    object. This will allow most safe-recursion guards to work without
    any allocation.
    headius committed Jul 19, 2016
    Copy the full SHA
    0a4aa21 View commit details
  2. Implement fully-cached "checked" methods and type conversions.

    This batch of changes implements cached logic for the "checked"
    type conversions and calls, and wires that logic up for many
    places in core. CheckedSites is introduced into JavaSites as a
    carrier for the four call site types needed to do a checked
    invocation. With this change, checked calls can now be fully
    cached.
    
    This also introduces a few new cached unchecked paths and wires
    them up in a few places as well. I will let this bake and then
    ensure all places using the old logic now use the new logic in an
    uncoming commit.
    headius committed Jul 19, 2016
    Copy the full SHA
    44e9d92 View commit details

Commits on Jul 20, 2016

  1. Copy the full SHA
    71b5898 View commit details
  2. Remaining cold calls from RubyBasicObject.

    Also added a Ruby !~ to allow for specialization and better
    caching.
    headius committed Jul 20, 2016
    Copy the full SHA
    b3c7afa View commit details
  3. Copy the full SHA
    c40e112 View commit details
  4. Copy the full SHA
    80ce35a View commit details
  5. Inline caching for interesting bits of RubyKernel.

    This also adds initialize_dup and initialize_clone in Ruby to be
    specialized with better caching.
    headius committed Jul 20, 2016
    Copy the full SHA
    46ab758 View commit details
  6. Restructure sites into namespaces.

    This introduces an extra hop to get to a given call site, but it
    reduces the naming cruft for call sites.
    headius committed Jul 20, 2016
    Copy the full SHA
    9169ae0 View commit details

Commits on Jul 21, 2016

  1. Copy the full SHA
    2f4f417 View commit details
  2. Copy the full SHA
    2f8b532 View commit details
  3. Copy the full SHA
    d092793 View commit details

Commits on Jul 25, 2016

  1. Copy the full SHA
    5acd4ca View commit details
  2. Missed one in RubyNumeric.

    headius committed Jul 25, 2016
    Copy the full SHA
    1a3f259 View commit details
  3. Copy the full SHA
    b3f930a View commit details
  4. Copy the full SHA
    8e4317a View commit details

Commits on Jul 26, 2016

  1. Fix bad coercion mistake.

    Called against wrong self with no argument.
    headius committed Jul 26, 2016
    Copy the full SHA
    221c6a9 View commit details
  2. Call site caching for Fixnum.

    headius committed Jul 26, 2016
    Copy the full SHA
    11b3d79 View commit details
  3. Copy the full SHA
    cc7cd9a View commit details
  4. Use new call site caching for builtin check. Fixes #3976.

    This allows us to use short-circuited logic without calling <=>
    without hardcoding a particular <=> implementation.
    headius committed Jul 26, 2016
    Copy the full SHA
    d2e6c5b View commit details
  5. Call site caching for String.

    headius committed Jul 26, 2016
    Copy the full SHA
    30691a9 View commit details
  6. Copy the full SHA
    49bbe5e View commit details
  7. Copy the full SHA
    bf60762 View commit details
  8. Copy the full SHA
    aa1f5df View commit details
  9. Copy the full SHA
    52ef5b2 View commit details
  10. Copy the full SHA
    e85a8d2 View commit details
  11. Copy the full SHA
    fb31d66 View commit details

Commits on Jul 29, 2016

  1. Copy the full SHA
    188517c View commit details
  2. Call site caching for Hash.

    headius committed Jul 29, 2016
    Copy the full SHA
    ec4e1fe View commit details

Commits on Jul 30, 2016

  1. Call site caching for IO.

    headius committed Jul 30, 2016
    Copy the full SHA
    9167f3a View commit details

Commits on Aug 1, 2016

  1. Call site caching for File.

    headius committed Aug 1, 2016
    Copy the full SHA
    2101092 View commit details
  2. Copy the full SHA
    149a52e View commit details
  3. Call site caching for Float.

    headius committed Aug 1, 2016
    Copy the full SHA
    7b14eb7 View commit details

Commits on Aug 5, 2016

  1. Copy the full SHA
    9edd069 View commit details
Showing with 1,730 additions and 683 deletions.
  1. +29 −11 core/src/main/java/org/jruby/Ruby.java
  2. +126 −69 core/src/main/java/org/jruby/RubyArray.java
  3. +101 −26 core/src/main/java/org/jruby/RubyBasicObject.java
  4. +22 −15 core/src/main/java/org/jruby/RubyBignum.java
  5. +108 −0 core/src/main/java/org/jruby/RubyClass.java
  6. +46 −15 core/src/main/java/org/jruby/RubyComparable.java
  7. +11 −6 core/src/main/java/org/jruby/RubyComplex.java
  8. +7 −1 core/src/main/java/org/jruby/RubyEnumerable.java
  9. +2 −0 core/src/main/java/org/jruby/RubyEnumerator.java
  10. +14 −7 core/src/main/java/org/jruby/RubyFile.java
  11. +45 −33 core/src/main/java/org/jruby/RubyFixnum.java
  12. +27 −21 core/src/main/java/org/jruby/RubyFloat.java
  13. +28 −34 core/src/main/java/org/jruby/RubyHash.java
  14. +40 −66 core/src/main/java/org/jruby/RubyIO.java
  15. +24 −20 core/src/main/java/org/jruby/RubyInteger.java
  16. +47 −28 core/src/main/java/org/jruby/RubyKernel.java
  17. +123 −46 core/src/main/java/org/jruby/RubyNumeric.java
  18. +36 −24 core/src/main/java/org/jruby/RubyObject.java
  19. +1 −1 core/src/main/java/org/jruby/RubyRandom.java
  20. +34 −2 core/src/main/java/org/jruby/RubyRange.java
  21. +13 −8 core/src/main/java/org/jruby/RubyRational.java
  22. +75 −54 core/src/main/java/org/jruby/RubyString.java
  23. +7 −8 core/src/main/java/org/jruby/RubyStruct.java
  24. +10 −3 core/src/main/java/org/jruby/RubyTime.java
  25. +0 −57 core/src/main/java/org/jruby/ast/util/ArgsUtil.java
  26. +25 −20 core/src/main/java/org/jruby/ext/bigdecimal/RubyBigDecimal.java
  27. +3 −0 core/src/main/java/org/jruby/ir/operands/UndefinedValue.java
  28. +6 −1 core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java
  29. +1 −1 core/src/main/java/org/jruby/java/proxies/MapJavaProxy.java
  30. +17 −29 core/src/main/java/org/jruby/runtime/Helpers.java
  31. +379 −0 core/src/main/java/org/jruby/runtime/JavaSites.java
  32. +3 −1 core/src/main/java/org/jruby/runtime/ThreadContext.java
  33. +5 −0 core/src/main/java/org/jruby/runtime/builtin/IRubyObject.java
  34. +9 −0 core/src/main/java/org/jruby/runtime/callsite/CachingCallSite.java
  35. +52 −2 core/src/main/java/org/jruby/runtime/callsite/RespondToCallSite.java
  36. +46 −41 core/src/main/java/org/jruby/util/Numeric.java
  37. +8 −10 core/src/main/java/org/jruby/util/RecursiveComparator.java
  38. +185 −22 core/src/main/java/org/jruby/util/TypeConverter.java
  39. +1 −1 core/src/main/java/org/jruby/util/io/EncodingUtils.java
  40. +4 −0 core/src/main/ruby/jruby/kernel/basicobject.rb
  41. +10 −0 core/src/main/ruby/jruby/kernel/kernel.rb
40 changes: 29 additions & 11 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@
import org.jruby.javasupport.JavaSupportImpl;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.JavaSites;
import org.jruby.runtime.invokedynamic.InvokeDynamicSupport;
import org.jruby.util.ClassDefiningClassLoader;
import org.objectweb.asm.util.TraceClassVisitor;
@@ -159,7 +160,6 @@
import org.objectweb.asm.ClassReader;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;
@@ -4310,7 +4310,11 @@ public void unregisterInspecting(Object obj) {
if (val != null ) val.remove(obj);
}

public static interface RecursiveFunction {
public interface RecursiveFunctionEx<T> {
IRubyObject call(ThreadContext context, T state, IRubyObject obj, boolean recur);
}

public interface RecursiveFunction {
IRubyObject call(IRubyObject obj, boolean recur);
}

@@ -4467,7 +4471,7 @@ private IRubyObject execRecursiveInternal(RecursiveFunction func, IRubyObject ob

ThreadLocal<Map<String, Map<IRubyObject, IRubyObject>>> symMap = new ThreadLocal<>();

public IRubyObject safeRecurse(RecursiveFunction func, IRubyObject obj, String name, boolean outer) {
public <T> IRubyObject safeRecurse(RecursiveFunctionEx<T> func, ThreadContext context, T state, IRubyObject obj, String name, boolean outer) {
Map<IRubyObject, IRubyObject> guards = safeRecurseGetGuards(name);

boolean outermost = outer && !guards.containsKey(recursiveKey);
@@ -4477,29 +4481,29 @@ public IRubyObject safeRecurse(RecursiveFunction func, IRubyObject obj, String n
if (outer && !outermost) {
throw new RecursiveError(guards);
}
return func.call(obj, true);
return func.call(context, state, obj, true);
} else {
if (outermost) {
return safeRecurseOutermost(func, obj, guards);
return safeRecurseOutermost(func, context, state, obj, guards);
} else {
return safeRecurseInner(func, obj, guards);
return safeRecurseInner(func, context, state, obj, guards);
}
}
}

private IRubyObject safeRecurseOutermost(RecursiveFunction func, IRubyObject obj, Map<IRubyObject, IRubyObject> guards) {
private <T> IRubyObject safeRecurseOutermost(RecursiveFunctionEx<T> func, ThreadContext context, T state, IRubyObject obj, Map<IRubyObject, IRubyObject> guards) {
boolean recursed = false;
guards.put(recursiveKey, recursiveKey);

try {
return safeRecurseInner(func, obj, guards);
return safeRecurseInner(func, context, state, obj, guards);
} catch (RecursiveError re) {
if (re.tag != guards) {
throw re;
}
recursed = true;
guards.remove(recursiveKey);
return func.call(obj, true);
return func.call(context, state, obj, true);
} finally {
if (!recursed) guards.remove(recursiveKey);
}
@@ -4519,10 +4523,10 @@ private Map<IRubyObject, IRubyObject> safeRecurseGetGuards(String name) {
} return guards;
}

private IRubyObject safeRecurseInner(RecursiveFunction func, IRubyObject obj, Map<IRubyObject, IRubyObject> guards) {
private <T> IRubyObject safeRecurseInner(RecursiveFunctionEx<T> func, ThreadContext context, T state, IRubyObject obj, Map<IRubyObject, IRubyObject> guards) {
try {
guards.put(obj, obj);
return func.call(obj, false);
return func.call(context, state, obj, false);
} finally {
guards.remove(obj);
}
@@ -5087,6 +5091,18 @@ public FilenoUtil getFilenoUtil() {
return filenoUtil;
}

@Deprecated
public IRubyObject safeRecurse(RecursiveFunction func, IRubyObject obj, String name, boolean outer) {
return safeRecurse(LEGACY_RECURSE, getCurrentContext(), func, obj, name, outer);
}

private static final RecursiveFunctionEx<RecursiveFunction> LEGACY_RECURSE = new RecursiveFunctionEx<RecursiveFunction>() {
@Override
public IRubyObject call(ThreadContext context, RecursiveFunction func, IRubyObject obj, boolean recur) {
return func.call(obj, recur);
}
};

private final ConcurrentHashMap<String, Invalidator> constantNameInvalidators =
new ConcurrentHashMap<String, Invalidator>(
16 /* default initial capacity */,
@@ -5417,4 +5433,6 @@ protected TypePopulator computeValue(Class<?> type) {
return RubyModule.loadPopulatorFor(type);
}
};

public final JavaSites sites = new JavaSites();
}
Loading