Skip to content

Commit

Permalink
Modifications for JRUBY-2679, to allow excluding specific methods fro…
Browse files Browse the repository at this point in the history
…m being jitted.

git-svn-id: http://svn.codehaus.org/jruby/trunk/jruby@7174 961051c9-f516-0410-bf72-c9f7e237a7b7
  • Loading branch information
headius committed Jul 15, 2008
1 parent a3bb4a2 commit e37e721
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
21 changes: 20 additions & 1 deletion src/org/jruby/RubyInstanceConfig.java
Expand Up @@ -37,9 +37,12 @@
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

import java.util.Set;
import java.util.StringTokenizer;
import org.jruby.ast.executable.Script;
import org.jruby.exceptions.MainExitException;
import org.jruby.runtime.Constants;
Expand Down Expand Up @@ -135,6 +138,7 @@ public boolean shouldPrecompileAll() {

// from CommandlineParser
private List<String> loadPaths = new ArrayList<String>();
private Set<String> excludedMethods = new HashSet<String>();
private StringBuffer inlineScript = new StringBuffer();
private boolean hasInlineScript = false;
private String scriptFileName = null;
Expand Down Expand Up @@ -206,6 +210,8 @@ public boolean shouldPrecompileAll() {
public static boolean FULL_TRACE_ENABLED
= SafePropertyAccessor.getBoolean("jruby.debug.fullTrace", false);

public static final String COMPILE_EXCLUDE
= SafePropertyAccessor.getProperty("jruby.jit.exclude");
public static boolean nativeEnabled = true;


Expand Down Expand Up @@ -277,7 +283,12 @@ public RubyInstanceConfig() {
String threshold = SafePropertyAccessor.getProperty("jruby.jit.threshold");
String max = SafePropertyAccessor.getProperty("jruby.jit.max");
String maxSize = SafePropertyAccessor.getProperty("jruby.jit.maxsize");


if (COMPILE_EXCLUDE != null) {
String[] elements = COMPILE_EXCLUDE.split(",");
for (String element : elements) excludedMethods.add(element);
}

managementEnabled = SafePropertyAccessor.getBoolean("jruby.management.enabled", true);
runRubyInProcess = SafePropertyAccessor.getBoolean("jruby.launch.inproc", true);
boolean jitProperty = SafePropertyAccessor.getProperty("jruby.jit.enabled") != null;
Expand Down Expand Up @@ -430,6 +441,9 @@ public String getPropertyHelp() {
.append(" Enable verbose JIT logging (reports failed compilation). Default is false\n")
.append(" jruby.jit.logEvery=<method count>\n")
.append(" Log a message every n methods JIT compiled. Default is 0 (off).\n")
.append(" jruby.jit.exclude=<ClsOrMod,ClsOrMod::method_name,-::method_name>\n")
.append(" Exclude methods from JIT by class/module short name, c/m::method_name,\n")
.append(" or -::method_name for anon/singleton classes/modules. Comma-delimited.\n")
.append("\nNATIVE SUPPORT:\n")
.append(" jruby.native.enabled=true|false\n")
.append(" Enable/disable native extensions (like JNA for non-Java APIs; Default is true\n")
Expand Down Expand Up @@ -1203,4 +1217,9 @@ public Map getOptionGlobals() {
public boolean isManagementEnabled() {
return managementEnabled;
}

public Set getExcludedMethods() {
return excludedMethods;
}

}
11 changes: 10 additions & 1 deletion src/org/jruby/compiler/JITCompiler.java
Expand Up @@ -85,7 +85,16 @@ public void runJIT(final DefaultMethod method, final ThreadContext context, fina
method.setCallCount(-1);
return;
}


// Check if the method has been explicitly excluded
String moduleName = method.getImplementationClass().getName();
moduleName = moduleName.replaceAll("#<.*>", "-");
if (instanceConfig.getExcludedMethods().contains(moduleName) ||
instanceConfig.getExcludedMethods().contains(moduleName+"::"+name)) {
method.setCallCount(-1);
return;
}

JITClassGenerator generator = new JITClassGenerator(name, method, context);

String key = SexpMaker.create(name, method.getArgsNode(), method.getBodyNode());
Expand Down
4 changes: 4 additions & 0 deletions src/org/jruby/management/Config.java
Expand Up @@ -171,4 +171,8 @@ public boolean isLazyHandlesEnabled() {
public boolean isShowBytecode() {
return ruby.getInstanceConfig().isShowBytecode();
}

public String getExcludedMethods() {
return ruby.getInstanceConfig().getExcludedMethods().toString();
}
}
1 change: 1 addition & 0 deletions src/org/jruby/management/ConfigMBean.java
Expand Up @@ -41,4 +41,5 @@ public interface ConfigMBean {
public boolean isFullTraceEnabled();
public boolean isLazyHandlesEnabled();
public boolean isShowBytecode();
public String getExcludedMethods();
}

0 comments on commit e37e721

Please sign in to comment.