Skip to content

Commit

Permalink
Showing 3 changed files with 15 additions and 14 deletions.
2 changes: 2 additions & 0 deletions core/pom.rb
Original file line number Diff line number Diff line change
@@ -73,6 +73,8 @@
jar 'org.jruby:joda-timezones:${tzdata.version}', :scope => '${tzdata.scope}'
jar 'joda-time:joda-time:${joda.time.version}'

jar 'com.boundary:high-scale-lib:1.0.6'

plugin_management do
plugin( 'org.eclipse.m2e:lifecycle-mapping:1.0.0',
'lifecycleMappingMetadata' => {
5 changes: 5 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -263,6 +263,11 @@ DO NOT MODIFIY - GENERATED CODE
<artifactId>joda-time</artifactId>
<version>${joda.time.version}</version>
</dependency>
<dependency>
<groupId>com.boundary</groupId>
<artifactId>high-scale-lib</artifactId>
<version>1.0.6</version>
</dependency>
</dependencies>
<build>
<defaultGoal>package</defaultGoal>
22 changes: 8 additions & 14 deletions core/src/main/java/org/jruby/java/invokers/RubyToJavaInvoker.java
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
import java.lang.reflect.Modifier;
import java.util.ArrayList;

import org.cliffc.high_scale_lib.NonBlockingHashMapLong;
import org.jruby.Ruby;
import org.jruby.RubyModule;
import org.jruby.exceptions.RaiseException;
@@ -27,16 +28,15 @@

public abstract class RubyToJavaInvoker<T extends JavaCallable> extends JavaMethod {

static final IntHashMap NULL_CACHE = IntHashMap.nullMap();
static final NonBlockingHashMapLong NULL_CACHE = new NonBlockingHashMapLong();

protected final T javaCallable; /* null if multiple callable members */
protected final T[][] javaCallables; /* != null if javaCallable == null */
protected final T[] javaVarargsCallables; /* != null if any var args callables */

// in case multiple callables (overloaded Java method - same name different args)
// for the invoker exists CallableSelector caches resolution based on args here
final IntHashMap<T> writeCache;
volatile IntHashMap<T> readCache;
final NonBlockingHashMapLong<T> cache;

private final Ruby runtime;

@@ -55,8 +55,7 @@ public abstract class RubyToJavaInvoker<T extends JavaCallable> extends JavaMeth
minVarArgsArity = getMemberArity(member) - 1;
}

writeCache = NULL_CACHE; // if there's a single callable - matching (and thus the cache) won't be used
readCache = writeCache;
cache = NULL_CACHE; // if there's a single callable - matching (and thus the cache) won't be used

this.javaCallable = callable;
this.javaCallables = null;
@@ -86,8 +85,7 @@ public abstract class RubyToJavaInvoker<T extends JavaCallable> extends JavaMeth
}
callables = null;

writeCache = NULL_CACHE; // if there's a single callable - matching (and thus the cache) won't be used
readCache = writeCache;
cache = NULL_CACHE; // if there's a single callable - matching (and thus the cache) won't be used
}
else {
callable = null; maxArity = -1; minArity = Integer.MAX_VALUE;
@@ -142,8 +140,7 @@ public abstract class RubyToJavaInvoker<T extends JavaCallable> extends JavaMeth
varargsCallables = varArgs.toArray( createCallableArray(varArgs.size()) );
}

writeCache = newCallableCache();
readCache = (IntHashMap<T>)writeCache.clone();
cache = new NonBlockingHashMapLong<>(8);
}

this.javaCallable = callable;
@@ -196,14 +193,11 @@ private boolean setNativeCallIfPublic(final Method method) {
}

public T getSignature(int signatureCode) {
return readCache.get(signatureCode);
return cache.get(signatureCode);
}

public void putSignature(int signatureCode, T callable) {
synchronized (writeCache) {
writeCache.put(signatureCode, callable);
readCache = (IntHashMap<T>)writeCache.clone();
}
cache.put(signatureCode, callable);
}

protected abstract T createCallable(Ruby runtime, Member member);

0 comments on commit 22be3c6

Please sign in to comment.