Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
More improvement and refactoring of indy binding.
* Install call site caching policies from JRuby 1.7.
* Clean up super sites by storing more in the site object.
* Add failure path to invocation sites.
* Remove switchpoint flag; we always use it now.
* Remove unused RubyInstanceConfig fields related to indy.
  • Loading branch information
headius committed Oct 27, 2014
1 parent 088e62c commit 11205fa
Show file tree
Hide file tree
Showing 13 changed files with 273 additions and 160 deletions.
44 changes: 0 additions & 44 deletions core/src/main/java/org/jruby/RubyInstanceConfig.java
Expand Up @@ -1912,48 +1912,4 @@ public boolean isCextEnabled() {
return false;
}

/**
* In Java integration, allow upper case name for a Java package;
* e.g., com.example.UpperCase.Class
*/
@Deprecated
public static final boolean UPPER_CASE_PACKAGE_NAME_ALLOWED = Options.JI_UPPER_CASE_PACKAGE_NAME_ALLOWED.load();

@Deprecated public static final boolean USE_INVOKEDYNAMIC = Options.COMPILE_INVOKEDYNAMIC.load();

// max times an indy call site can fail before it goes to simple IC
@Deprecated public static final int MAX_FAIL_COUNT = Options.INVOKEDYNAMIC_MAXFAIL.load();

// max polymorphism at a call site to build a chained method handle PIC
@Deprecated public static final int MAX_POLY_COUNT = Options.INVOKEDYNAMIC_MAXPOLY.load();

// logging of various indy aspects
@Deprecated public static final boolean LOG_INDY_BINDINGS = Options.INVOKEDYNAMIC_LOG_BINDING.load();
@Deprecated public static final boolean LOG_INDY_CONSTANTS = Options.INVOKEDYNAMIC_LOG_CONSTANTS.load();

// properties enabling or disabling certain uses of invokedynamic
@Deprecated public static final boolean INVOKEDYNAMIC_ALL = USE_INVOKEDYNAMIC && Options.INVOKEDYNAMIC_ALL.load();
@Deprecated public static final boolean INVOKEDYNAMIC_SAFE = USE_INVOKEDYNAMIC && Options.INVOKEDYNAMIC_SAFE.load();

@Deprecated private static final boolean invokedynamicOn = INVOKEDYNAMIC_ALL || INVOKEDYNAMIC_SAFE || USE_INVOKEDYNAMIC;

@Deprecated public static final boolean INVOKEDYNAMIC_INVOCATION = invokedynamicOn && Options.INVOKEDYNAMIC_INVOCATION.load();

@Deprecated private static final boolean invokedynamicInvocation = invokedynamicOn && INVOKEDYNAMIC_INVOCATION;

@Deprecated public static final boolean INVOKEDYNAMIC_INVOCATION_SWITCHPOINT = invokedynamicInvocation && Options.INVOKEDYNAMIC_INVOCATION_SWITCHPOINT.load();
@Deprecated public static final boolean INVOKEDYNAMIC_INDIRECT = invokedynamicInvocation && Options.INVOKEDYNAMIC_INVOCATION_INDIRECT.load();
@Deprecated public static final boolean INVOKEDYNAMIC_JAVA = invokedynamicInvocation && Options.INVOKEDYNAMIC_INVOCATION_JAVA.load();
@Deprecated public static final boolean INVOKEDYNAMIC_ATTR = invokedynamicInvocation && Options.INVOKEDYNAMIC_INVOCATION_ATTR.load();
@Deprecated public static final boolean INVOKEDYNAMIC_FFI = invokedynamicInvocation && Options.INVOKEDYNAMIC_INVOCATION_FFI.load();
@Deprecated public static final boolean INVOKEDYNAMIC_FASTOPS = invokedynamicInvocation && Options.INVOKEDYNAMIC_INVOCATION_FASTOPS.load();

@Deprecated public static final boolean INVOKEDYNAMIC_CACHE = invokedynamicOn && Options.INVOKEDYNAMIC_CACHE.load();

@Deprecated private static final boolean invokedynamicCache = invokedynamicOn && INVOKEDYNAMIC_CACHE;

@Deprecated public static final boolean INVOKEDYNAMIC_CONSTANTS = invokedynamicCache && Options.INVOKEDYNAMIC_CACHE_CONSTANTS.load();
@Deprecated public static final boolean INVOKEDYNAMIC_LITERALS = invokedynamicCache&& Options.INVOKEDYNAMIC_CACHE_LITERALS.load();
@Deprecated public static final boolean INVOKEDYNAMIC_IVARS = invokedynamicCache&& Options.INVOKEDYNAMIC_CACHE_IVARS.load();

}
Expand Up @@ -48,9 +48,14 @@ public InterpretedIRMethod(IRScope method, Visibility visibility, RubyModule imp
this.method = method;
this.method.getStaticScope().determineModule();
this.arity = calculateArity();
if (!implementationClass.getRuntime().getInstanceConfig().getCompileMode().shouldJIT()) {

// disable JIT for anything that's not an IRMethod, or if JIT is turned off
// FIXME: kinda hacky, but I use IRMethod data in JITCompiler, and module/class/script bodies generally only run once
if (!(method instanceof IRMethod) ||
!implementationClass.getRuntime().getInstanceConfig().getCompileMode().shouldJIT()) {
this.box.callCount = -1;
}

isSynthetic = method instanceof IRModuleBody;
}

Expand Down
Expand Up @@ -12,13 +12,17 @@
* Created by headius on 10/23/14.
*/
public class ClassSuperInvokeSite extends SuperInvokeSite {
public ClassSuperInvokeSite(MethodType type, String name) {
super(type, name);
public ClassSuperInvokeSite(MethodType type, String name, String splatmapString) {
super(type, name, splatmapString);
}

public IRubyObject invoke(String methodName, boolean[] splatMap, ThreadContext context, IRubyObject caller, IRubyObject self, RubyClass definingModule, IRubyObject[] args, Block block) throws Throwable {
public IRubyObject invoke(ThreadContext context, IRubyObject caller, IRubyObject self, RubyClass definingModule, IRubyObject[] args, Block block) throws Throwable {
// TODO: get rid of caller
// TODO: caching
return IRRuntimeHelpers.classSuperSplatArgs(context, self, methodName, definingModule.getMetaClass(), args, block, splatMap);
}

public IRubyObject fail(ThreadContext context, IRubyObject caller, IRubyObject self, RubyClass definingModule, IRubyObject[] args, Block block) throws Throwable {
return invoke(context, caller, self, definingModule, args, block);
}
}
Expand Up @@ -12,13 +12,17 @@
* Created by headius on 10/23/14.
*/
public class InstanceSuperInvokeSite extends SuperInvokeSite {
public InstanceSuperInvokeSite(MethodType type, String name) {
super(type, name);
public InstanceSuperInvokeSite(MethodType type, String name, String splatmapString) {
super(type, name, splatmapString);
}

public IRubyObject invoke(String methodName, boolean[] splatMap, ThreadContext context, IRubyObject caller, IRubyObject self, RubyClass definingModule, IRubyObject[] args, Block block) throws Throwable {
public IRubyObject invoke(ThreadContext context, IRubyObject caller, IRubyObject self, RubyClass definingModule, IRubyObject[] args, Block block) throws Throwable {
// TODO: get rid of caller
// TODO: caching
return IRRuntimeHelpers.instanceSuperSplatArgs(context, self, methodName, definingModule, args, block, splatMap);
}

public IRubyObject fail(ThreadContext context, IRubyObject caller, IRubyObject self, RubyClass definingModule, IRubyObject[] args, Block block) throws Throwable {
return invoke(context, caller, self, definingModule, args, block);
}
}

0 comments on commit 11205fa

Please sign in to comment.