fix perf bug with xor promotion

This commit is contained in:
Robert Muir 2016-06-14 19:19:50 -04:00
parent d0e4485d42
commit cd4f4594d6
2 changed files with 19 additions and 0 deletions

View File

@ -826,6 +826,10 @@ public final class AnalyzerCaster {
final Sort sort0 = from0.sort;
final Sort sort1 = from1.sort;
if (sort0 == Sort.DEF || sort1 == Sort.DEF) {
return Definition.DEF_TYPE;
}
if (sort0.bool || sort1.bool) {
return Definition.BOOLEAN_TYPE;
}

View File

@ -343,7 +343,22 @@ public class DefOptimizationTests extends ScriptTestCase {
assertBytecodeExists("def x = 1; def y = 2; double d = x ^ y",
"INVOKEDYNAMIC xor(Ljava/lang/Object;Ljava/lang/Object;)D");
}
public void testBooleanXorOptLHS() {
assertBytecodeExists("boolean x = true; def y = true; return x ^ y",
"INVOKEDYNAMIC xor(ZLjava/lang/Object;)Ljava/lang/Object;");
}
public void testBooleanXorOptRHS() {
assertBytecodeExists("def x = true; boolean y = true; return x ^ y",
"INVOKEDYNAMIC xor(Ljava/lang/Object;Z)Ljava/lang/Object;");
}
public void testBooleanXorOptRet() {
assertBytecodeExists("def x = true; def y = true; boolean v = x ^ y",
"INVOKEDYNAMIC xor(Ljava/lang/Object;Ljava/lang/Object;)Z");
}
public void testLtOptLHS() {
assertBytecodeExists("int x = 1; def y = 2; return x < y",
"INVOKEDYNAMIC lt(ILjava/lang/Object;)Z");