Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a flag to turn off dynopt guards (experimental)

  • Loading branch information...
commit 60f553cd7cab9c205b7ba1b0695d271e2502eb5c 1 parent 53013d6
@headius headius authored
View
2  src/org/jruby/RubyInstanceConfig.java
@@ -211,6 +211,8 @@ public boolean shouldPrecompileAll() {
= SafePropertyAccessor.getBoolean("jruby.compile.peephole", true);
public static boolean DYNOPT_COMPILE_ENABLED
= SafePropertyAccessor.getBoolean("jruby.compile.dynopt");
+ public static boolean NOGUARDS_COMPILE_ENABLED
+ = SafePropertyAccessor.getBoolean("jruby.compile.noguards");
public static boolean FASTEST_COMPILE_ENABLED
= SafePropertyAccessor.getBoolean("jruby.compile.fastest");
public static boolean FASTOPS_COMPILE_ENABLED
View
85 src/org/jruby/compiler/impl/StandardInvocationCompiler.java
@@ -428,13 +428,15 @@ public void invokeFixnumLong(String rubyName, int moduleGeneration, CompilerCall
final int tmp = methodCompiler.getVariableCompiler().grabTempLocal();
method.astore(tmp);
- method.aload(tmp);
- method.ldc(moduleGeneration);
- methodCompiler.invokeUtilityMethod("isGenerationEqual", sig(boolean.class, IRubyObject.class, int.class));
-
Label slow = new Label();
Label after = new Label();
- method.ifne(slow);
+ if (!RubyInstanceConfig.NOGUARDS_COMPILE_ENABLED) {
+ method.aload(tmp);
+ method.ldc(moduleGeneration);
+ methodCompiler.invokeUtilityMethod("isGenerationEqual", sig(boolean.class, IRubyObject.class, int.class));
+
+ method.ifne(slow);
+ }
method.aload(tmp);
method.checkcast(p(RubyFixnum.class));
@@ -443,16 +445,19 @@ public void invokeFixnumLong(String rubyName, int moduleGeneration, CompilerCall
method.invokevirtual(p(RubyFixnum.class), methodName, sig(IRubyObject.class, ThreadContext.class, long.class));
- method.go_to(after);
- method.label(slow);
+ if (!RubyInstanceConfig.NOGUARDS_COMPILE_ENABLED) {
+ method.go_to(after);
+ method.label(slow);
- invokeBinaryFixnumRHS(rubyName, new CompilerCallback() {
- public void call(BodyCompiler context) {
- method.aload(tmp);
- }
- }, fixnum);
+ invokeBinaryFixnumRHS(rubyName, new CompilerCallback() {
+ public void call(BodyCompiler context) {
+ method.aload(tmp);
+ }
+ }, fixnum);
- method.label(after);
+ method.label(after);
+ }
+ methodCompiler.getVariableCompiler().releaseTempLocal();
}
public void invokeFloatDouble(String rubyName, int moduleGeneration, CompilerCallback receiverCallback, String methodName, double flote) {
@@ -488,13 +493,15 @@ public void call(BodyCompiler context) {
}
public void invokeRecursive(String name, int moduleGeneration, ArgumentsCallback argsCallback, CompilerCallback closure, CallType callType, boolean iterator) {
- methodCompiler.loadSelf();
- method.ldc(moduleGeneration);
- methodCompiler.invokeUtilityMethod("isGenerationEqual", sig(boolean.class, IRubyObject.class, int.class));
-
Label slow = new Label();
Label after = new Label();
- method.ifne(slow);
+ if (!RubyInstanceConfig.NOGUARDS_COMPILE_ENABLED) {
+ methodCompiler.loadSelf();
+ method.ldc(moduleGeneration);
+ methodCompiler.invokeUtilityMethod("isGenerationEqual", sig(boolean.class, IRubyObject.class, int.class));
+
+ method.ifne(slow);
+ }
method.aload(0);
methodCompiler.loadThreadContext();
@@ -506,12 +513,14 @@ public void invokeRecursive(String name, int moduleGeneration, ArgumentsCallback
method.invokestatic(methodCompiler.getScriptCompiler().getClassname(), methodCompiler.getNativeMethodName(), methodCompiler.getSignature());
- method.go_to(after);
- method.label(slow);
+ if (!RubyInstanceConfig.NOGUARDS_COMPILE_ENABLED) {
+ method.go_to(after);
+ method.label(slow);
- invokeDynamic(name, null, argsCallback, callType, closure, iterator);
+ invokeDynamic(name, null, argsCallback, callType, closure, iterator);
- method.label(after);
+ method.label(after);
+ }
}
public void invokeNative(String name, DynamicMethod.NativeCall nativeCall,
@@ -525,14 +534,16 @@ public void invokeNative(String name, DynamicMethod.NativeCall nativeCall,
method.astore(tmp);
// validate generation
- method.aload(tmp);
- method.ldc(moduleGeneration);
- methodCompiler.invokeUtilityMethod("isGenerationEqual", sig(boolean.class, IRubyObject.class, int.class));
-
Label slow = new Label();
Label after = new Label();
- method.ifne(slow);
-
+ if (!RubyInstanceConfig.NOGUARDS_COMPILE_ENABLED) {
+ method.aload(tmp);
+ method.ldc(moduleGeneration);
+ methodCompiler.invokeUtilityMethod("isGenerationEqual", sig(boolean.class, IRubyObject.class, int.class));
+
+ method.ifne(slow);
+ }
+
if (nativeCall.isStatic()) {
if (nativeSignature.length > 0 && nativeSignature[0] == ThreadContext.class) {
methodCompiler.loadThreadContext();
@@ -579,16 +590,18 @@ public void invokeNative(String name, DynamicMethod.NativeCall nativeCall,
method.invokevirtual(p(nativeCall.getNativeTarget()), nativeCall.getNativeName(), sig(nativeCall.getNativeReturn(), nativeSignature));
}
- method.go_to(after);
- method.label(slow);
+ if (!RubyInstanceConfig.NOGUARDS_COMPILE_ENABLED) {
+ method.go_to(after);
+ method.label(slow);
- invokeDynamic(name, new CompilerCallback() {
- public void call(BodyCompiler context) {
- method.aload(tmp);
- }
- }, args, callType, closure, iterator);
+ invokeDynamic(name, new CompilerCallback() {
+ public void call(BodyCompiler context) {
+ method.aload(tmp);
+ }
+ }, args, callType, closure, iterator);
- method.label(after);
+ method.label(after);
+ }
methodCompiler.getVariableCompiler().releaseTempLocal();
}
Please sign in to comment.
Something went wrong with that request. Please try again.