diff options
author | 2017-06-23 13:58:58 -0700 | |
---|---|---|
committer | 2017-06-26 14:07:24 +0000 | |
commit | bd44132f680430d44790015b42edffc05797e19c (patch) | |
tree | 0663bda2c6e5d06f588e0949b1117bb53d9c39f7 | |
parent | 3b9aee84472d9b45fef8654de875463c14c5fbcf (diff) |
test: Fix 4 checker tests to pass with javac/dx
Acts as a partial revert of commit f02c3cf66c2c24533f6da43970e7b766b2ca9938.
Revert only the failing javac/dx checker tests. Update files to match
new checker syntax
(e.g. constant_folding_after_inling -> constant_folding$after_inlining).
Add build scripts to force these tests to use javac/dx even if
the platform build was using jack.
Fixes following tests:
* 442-checker-constant-folding
* 450-checker-types
* 463-checker-boolean-simplifier
* 537-checker-inline-and-unverified
Bug: 62950048
Bug: 36902714
Change-Id: I89dc039e3746b4b9f7d3eced43d1e0113662e812
-rwxr-xr-x | test/442-checker-constant-folding/build | 23 | ||||
-rw-r--r-- | test/442-checker-constant-folding/src/Main.java | 540 | ||||
-rwxr-xr-x | test/450-checker-types/build | 23 | ||||
-rw-r--r-- | test/450-checker-types/smali/SmaliTests.smali | 120 | ||||
-rw-r--r-- | test/450-checker-types/src/Main.java | 56 | ||||
-rwxr-xr-x | test/463-checker-boolean-simplifier/build | 23 | ||||
-rw-r--r-- | test/463-checker-boolean-simplifier/smali/BooleanNotDx.smali | 65 | ||||
-rw-r--r-- | test/463-checker-boolean-simplifier/src/Main.java | 64 | ||||
-rwxr-xr-x | test/537-checker-inline-and-unverified/build | 23 | ||||
-rw-r--r-- | test/537-checker-inline-and-unverified/src/Main.java | 6 |
10 files changed, 430 insertions, 513 deletions
diff --git a/test/442-checker-constant-folding/build b/test/442-checker-constant-folding/build new file mode 100755 index 0000000000..49292c9ac1 --- /dev/null +++ b/test/442-checker-constant-folding/build @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Copyright 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This checker test is incompatible with jack bytecode output, +# so force it to use javac/dx. +export USE_JACK=false +# Also disable desugar because it is missing in jack platform builds. +export DESUGAR=false + +./default-build "$@" diff --git a/test/442-checker-constant-folding/src/Main.java b/test/442-checker-constant-folding/src/Main.java index 64180d5273..eba5137f6f 100644 --- a/test/442-checker-constant-folding/src/Main.java +++ b/test/442-checker-constant-folding/src/Main.java @@ -27,12 +27,6 @@ public class Main { } } - public static void assertTrue(boolean condition) { - if (!condition) { - throw new Error(); - } - } - public static void assertIntEquals(int expected, int result) { if (expected != result) { throw new Error("Expected: " + expected + ", found: " + result); @@ -57,21 +51,6 @@ public class Main { } } - private static int $inline$int(int x) { - return x; - } - - private static long $inline$long(long x) { - return x; - } - - private static float $inline$float(float x) { - return x; - } - - private static double $inline$double(double x) { - return x; - } // Wrappers around methods located in file TestCmp.smali. @@ -215,119 +194,121 @@ public class Main { return y; } + /** * Exercise constant folding on addition. */ - /// CHECK-START: int Main.IntAddition1() constant_folding$after_inlining (before) + /// CHECK-START: int Main.IntAddition1() constant_folding (before) /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 /// CHECK-DAG: <<Add:i\d+>> Add [<<Const1>>,<<Const2>>] /// CHECK-DAG: Return [<<Add>>] - /// CHECK-START: int Main.IntAddition1() constant_folding$after_inlining (after) + /// CHECK-START: int Main.IntAddition1() constant_folding (after) /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 /// CHECK-DAG: Return [<<Const3>>] - /// CHECK-START: int Main.IntAddition1() constant_folding$after_inlining (after) + /// CHECK-START: int Main.IntAddition1() constant_folding (after) /// CHECK-NOT: Add public static int IntAddition1() { int a, b, c; - a = $inline$int(1); - b = $inline$int(2); + a = 1; + b = 2; c = a + b; return c; } - /// CHECK-START: int Main.IntAddition2() constant_folding$after_inlining (before) + /// CHECK-START: int Main.IntAddition2() constant_folding (before) /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 /// CHECK-DAG: <<Const5:i\d+>> IntConstant 5 /// CHECK-DAG: <<Const6:i\d+>> IntConstant 6 + /// CHECK-DAG: <<Const11:i\d+>> IntConstant 11 /// CHECK-DAG: <<Add1:i\d+>> Add [<<Const1>>,<<Const2>>] - /// CHECK-DAG: <<Add2:i\d+>> Add [<<Const5>>,<<Const6>>] - /// CHECK-DAG: <<Add3:i\d+>> Add [<<Add1>>,<<Add2>>] + /// CHECK-DAG: Add [<<Const5>>,<<Const6>>] + /// CHECK-DAG: <<Add3:i\d+>> Add [<<Add1>>,<<Const11>>] /// CHECK-DAG: Return [<<Add3>>] - /// CHECK-START: int Main.IntAddition2() constant_folding$after_inlining (after) + /// CHECK-START: int Main.IntAddition2() constant_folding (after) /// CHECK-DAG: <<Const14:i\d+>> IntConstant 14 /// CHECK-DAG: Return [<<Const14>>] - /// CHECK-START: int Main.IntAddition2() constant_folding$after_inlining (after) + /// CHECK-START: int Main.IntAddition2() constant_folding (after) /// CHECK-NOT: Add public static int IntAddition2() { int a, b, c; - a = $inline$int(1); - b = $inline$int(2); + a = 1; + b = 2; a += b; - b = $inline$int(5); - c = $inline$int(6); + b = 5; + c = 6; b += c; c = a + b; return c; } - /// CHECK-START: long Main.LongAddition() constant_folding$after_inlining (before) + /// CHECK-START: long Main.LongAddition() constant_folding (before) /// CHECK-DAG: <<Const1:j\d+>> LongConstant 1 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2 /// CHECK-DAG: <<Add:j\d+>> Add [<<Const1>>,<<Const2>>] /// CHECK-DAG: Return [<<Add>>] - /// CHECK-START: long Main.LongAddition() constant_folding$after_inlining (after) + /// CHECK-START: long Main.LongAddition() constant_folding (after) /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3 /// CHECK-DAG: Return [<<Const3>>] - /// CHECK-START: long Main.LongAddition() constant_folding$after_inlining (after) + /// CHECK-START: long Main.LongAddition() constant_folding (after) /// CHECK-NOT: Add public static long LongAddition() { long a, b, c; - a = $inline$long(1L); - b = $inline$long(2L); + a = 1L; + b = 2L; c = a + b; return c; } - /// CHECK-START: float Main.FloatAddition() constant_folding$after_inlining (before) + /// CHECK-START: float Main.FloatAddition() constant_folding (before) /// CHECK-DAG: <<Const1:f\d+>> FloatConstant 1 /// CHECK-DAG: <<Const2:f\d+>> FloatConstant 2 /// CHECK-DAG: <<Add:f\d+>> Add [<<Const1>>,<<Const2>>] /// CHECK-DAG: Return [<<Add>>] - /// CHECK-START: float Main.FloatAddition() constant_folding$after_inlining (after) + /// CHECK-START: float Main.FloatAddition() constant_folding (after) /// CHECK-DAG: <<Const3:f\d+>> FloatConstant 3 /// CHECK-DAG: Return [<<Const3>>] - /// CHECK-START: float Main.FloatAddition() constant_folding$after_inlining (after) + /// CHECK-START: float Main.FloatAddition() constant_folding (after) /// CHECK-NOT: Add public static float FloatAddition() { float a, b, c; - a = $inline$float(1F); - b = $inline$float(2F); + a = 1F; + b = 2F; c = a + b; return c; } - /// CHECK-START: double Main.DoubleAddition() constant_folding$after_inlining (before) + /// CHECK-START: double Main.DoubleAddition() constant_folding (before) /// CHECK-DAG: <<Const1:d\d+>> DoubleConstant 1 /// CHECK-DAG: <<Const2:d\d+>> DoubleConstant 2 /// CHECK-DAG: <<Add:d\d+>> Add [<<Const1>>,<<Const2>>] /// CHECK-DAG: Return [<<Add>>] - /// CHECK-START: double Main.DoubleAddition() constant_folding$after_inlining (after) + /// CHECK-START: double Main.DoubleAddition() constant_folding (after) /// CHECK-DAG: <<Const3:d\d+>> DoubleConstant 3 /// CHECK-DAG: Return [<<Const3>>] - /// CHECK-START: double Main.DoubleAddition() constant_folding$after_inlining (after) + /// CHECK-START: double Main.DoubleAddition() constant_folding (after) /// CHECK-NOT: Add public static double DoubleAddition() { double a, b, c; - a = $inline$double(1D); - b = $inline$double(2D); + a = 1D; + b = 2D; c = a + b; return c; } @@ -337,86 +318,86 @@ public class Main { * Exercise constant folding on subtraction. */ - /// CHECK-START: int Main.IntSubtraction() constant_folding$after_inlining (before) + /// CHECK-START: int Main.IntSubtraction() constant_folding (before) /// CHECK-DAG: <<Const6:i\d+>> IntConstant 6 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const6>>,<<Const2>>] /// CHECK-DAG: Return [<<Sub>>] - /// CHECK-START: int Main.IntSubtraction() constant_folding$after_inlining (after) + /// CHECK-START: int Main.IntSubtraction() constant_folding (after) /// CHECK-DAG: <<Const4:i\d+>> IntConstant 4 /// CHECK-DAG: Return [<<Const4>>] - /// CHECK-START: int Main.IntSubtraction() constant_folding$after_inlining (after) + /// CHECK-START: int Main.IntSubtraction() constant_folding (after) /// CHECK-NOT: Sub public static int IntSubtraction() { int a, b, c; - a = $inline$int(6); - b = $inline$int(2); + a = 6; + b = 2; c = a - b; return c; } - /// CHECK-START: long Main.LongSubtraction() constant_folding$after_inlining (before) + /// CHECK-START: long Main.LongSubtraction() constant_folding (before) /// CHECK-DAG: <<Const6:j\d+>> LongConstant 6 /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2 /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Const6>>,<<Const2>>] /// CHECK-DAG: Return [<<Sub>>] - /// CHECK-START: long Main.LongSubtraction() constant_folding$after_inlining (after) + /// CHECK-START: long Main.LongSubtraction() constant_folding (after) /// CHECK-DAG: <<Const4:j\d+>> LongConstant 4 /// CHECK-DAG: Return [<<Const4>>] - /// CHECK-START: long Main.LongSubtraction() constant_folding$after_inlining (after) + /// CHECK-START: long Main.LongSubtraction() constant_folding (after) /// CHECK-NOT: Sub public static long LongSubtraction() { long a, b, c; - a = $inline$long(6L); - b = $inline$long(2L); + a = 6L; + b = 2L; c = a - b; return c; } - /// CHECK-START: float Main.FloatSubtraction() constant_folding$after_inlining (before) + /// CHECK-START: float Main.FloatSubtraction() constant_folding (before) /// CHECK-DAG: <<Const6:f\d+>> FloatConstant 6 /// CHECK-DAG: <<Const2:f\d+>> FloatConstant 2 /// CHECK-DAG: <<Sub:f\d+>> Sub [<<Const6>>,<<Const2>>] /// CHECK-DAG: Return [<<Sub>>] - /// CHECK-START: float Main.FloatSubtraction() constant_folding$after_inlining (after) + /// CHECK-START: float Main.FloatSubtraction() constant_folding (after) /// CHECK-DAG: <<Const4:f\d+>> FloatConstant 4 /// CHECK-DAG: Return [<<Const4>>] - /// CHECK-START: float Main.FloatSubtraction() constant_folding$after_inlining (after) + /// CHECK-START: float Main.FloatSubtraction() constant_folding (after) /// CHECK-NOT: Sub public static float FloatSubtraction() { float a, b, c; - a = $inline$float(6F); - b = $inline$float(2F); + a = 6F; + b = 2F; c = a - b; return c; } - /// CHECK-START: double Main.DoubleSubtraction() constant_folding$after_inlining (before) + /// CHECK-START: double Main.DoubleSubtraction() constant_folding (before) /// CHECK-DAG: <<Const6:d\d+>> DoubleConstant 6 /// CHECK-DAG: <<Const2:d\d+>> DoubleConstant 2 /// CHECK-DAG: <<Sub:d\d+>> Sub [<<Const6>>,<<Const2>>] /// CHECK-DAG: Return [<<Sub>>] - /// CHECK-START: double Main.DoubleSubtraction() constant_folding$after_inlining (after) + /// CHECK-START: double Main.DoubleSubtraction() constant_folding (after) /// CHECK-DAG: <<Const4:d\d+>> DoubleConstant 4 /// CHECK-DAG: Return [<<Const4>>] - /// CHECK-START: double Main.DoubleSubtraction() constant_folding$after_inlining (after) + /// CHECK-START: double Main.DoubleSubtraction() constant_folding (after) /// CHECK-NOT: Sub public static double DoubleSubtraction() { double a, b, c; - a = $inline$double(6D); - b = $inline$double(2D); + a = 6D; + b = 2D; c = a - b; return c; } @@ -426,86 +407,86 @@ public class Main { * Exercise constant folding on multiplication. */ - /// CHECK-START: int Main.IntMultiplication() constant_folding$after_inlining (before) + /// CHECK-START: int Main.IntMultiplication() constant_folding (before) /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 /// CHECK-DAG: <<Mul:i\d+>> Mul [<<Const7>>,<<Const3>>] /// CHECK-DAG: Return [<<Mul>>] - /// CHECK-START: int Main.IntMultiplication() constant_folding$after_inlining (after) + /// CHECK-START: int Main.IntMultiplication() constant_folding (after) /// CHECK-DAG: <<Const21:i\d+>> IntConstant 21 /// CHECK-DAG: Return [<<Const21>>] - /// CHECK-START: int Main.IntMultiplication() constant_folding$after_inlining (after) + /// CHECK-START: int Main.IntMultiplication() constant_folding (after) /// CHECK-NOT: Mul public static int IntMultiplication() { int a, b, c; - a = $inline$int(7); - b = $inline$int(3); + a = 7; + b = 3; c = a * b; return c; } - /// CHECK-START: long Main.LongMultiplication() constant_folding$after_inlining (before) + /// CHECK-START: long Main.LongMultiplication() constant_folding (before) /// CHECK-DAG: <<Const7:j\d+>> LongConstant 7 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3 /// CHECK-DAG: <<Mul:j\d+>> Mul [<<Const7>>,<<Const3>>] /// CHECK-DAG: Return [<<Mul>>] - /// CHECK-START: long Main.LongMultiplication() constant_folding$after_inlining (after) + /// CHECK-START: long Main.LongMultiplication() constant_folding (after) /// CHECK-DAG: <<Const21:j\d+>> LongConstant 21 /// CHECK-DAG: Return [<<Const21>>] - /// CHECK-START: long Main.LongMultiplication() constant_folding$after_inlining (after) + /// CHECK-START: long Main.LongMultiplication() constant_folding (after) /// CHECK-NOT: Mul public static long LongMultiplication() { long a, b, c; - a = $inline$long(7L); - b = $inline$long(3L); + a = 7L; + b = 3L; c = a * b; return c; } - /// CHECK-START: float Main.FloatMultiplication() constant_folding$after_inlining (before) + /// CHECK-START: float Main.FloatMultiplication() constant_folding (before) /// CHECK-DAG: <<Const7:f\d+>> FloatConstant 7 /// CHECK-DAG: <<Const3:f\d+>> FloatConstant 3 /// CHECK-DAG: <<Mul:f\d+>> Mul [<<Const7>>,<<Const3>>] /// CHECK-DAG: Return [<<Mul>>] - /// CHECK-START: float Main.FloatMultiplication() constant_folding$after_inlining (after) + /// CHECK-START: float Main.FloatMultiplication() constant_folding (after) /// CHECK-DAG: <<Const21:f\d+>> FloatConstant 21 /// CHECK-DAG: Return [<<Const21>>] - /// CHECK-START: float Main.FloatMultiplication() constant_folding$after_inlining (after) + /// CHECK-START: float Main.FloatMultiplication() constant_folding (after) /// CHECK-NOT: Mul public static float FloatMultiplication() { float a, b, c; - a = $inline$float(7F); - b = $inline$float(3F); + a = 7F; + b = 3F; c = a * b; return c; } - /// CHECK-START: double Main.DoubleMultiplication() constant_folding$after_inlining (before) + /// CHECK-START: double Main.DoubleMultiplication() constant_folding (before) /// CHECK-DAG: <<Const7:d\d+>> DoubleConstant 7 /// CHECK-DAG: <<Const3:d\d+>> DoubleConstant 3 /// CHECK-DAG: <<Mul:d\d+>> Mul [<<Const7>>,<<Const3>>] /// CHECK-DAG: Return [<<Mul>>] - /// CHECK-START: double Main.DoubleMultiplication() constant_folding$after_inlining (after) + /// CHECK-START: double Main.DoubleMultiplication() constant_folding (after) /// CHECK-DAG: <<Const21:d\d+>> DoubleConstant 21 /// CHECK-DAG: Return [<<Const21>>] - /// CHECK-START: double Main.DoubleMultiplication() constant_folding$after_inlining (after) + /// CHECK-START: double Main.DoubleMultiplication() constant_folding (after) /// CHECK-NOT: Mul public static double DoubleMultiplication() { double a, b, c; - a = $inline$double(7D); - b = $inline$double(3D); + a = 7D; + b = 3D; c = a * b; return c; } @@ -515,90 +496,90 @@ public class Main { * Exercise constant folding on division. */ - /// CHECK-START: int Main.IntDivision() constant_folding$after_inlining (before) + /// CHECK-START: int Main.IntDivision() constant_folding (before) /// CHECK-DAG: <<Const8:i\d+>> IntConstant 8 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 /// CHECK-DAG: <<Div0Chk:i\d+>> DivZeroCheck [<<Const3>>] /// CHECK-DAG: <<Div:i\d+>> Div [<<Const8>>,<<Div0Chk>>] /// CHECK-DAG: Return [<<Div>>] - /// CHECK-START: int Main.IntDivision() constant_folding$after_inlining (after) + /// CHECK-START: int Main.IntDivision() constant_folding (after) /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 /// CHECK-DAG: Return [<<Const2>>] - /// CHECK-START: int Main.IntDivision() constant_folding$after_inlining (after) + /// CHECK-START: int Main.IntDivision() constant_folding (after) /// CHECK-NOT: DivZeroCheck /// CHECK-NOT: Div public static int IntDivision() { int a, b, c; - a = $inline$int(8); - b = $inline$int(3); + a = 8; + b = 3; c = a / b; return c; } - /// CHECK-START: long Main.LongDivision() constant_folding$after_inlining (before) + /// CHECK-START: long Main.LongDivision() constant_folding (before) /// CHECK-DAG: <<Const8:j\d+>> LongConstant 8 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3 /// CHECK-DAG: <<Div0Chk:j\d+>> DivZeroCheck [<<Const3>>] /// CHECK-DAG: <<Div:j\d+>> Div [<<Const8>>,<<Div0Chk>>] /// CHECK-DAG: Return [<<Div>>] - /// CHECK-START: long Main.LongDivision() constant_folding$after_inlining (after) + /// CHECK-START: long Main.LongDivision() constant_folding (after) /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2 /// CHECK-DAG: Return [<<Const2>>] - /// CHECK-START: long Main.LongDivision() constant_folding$after_inlining (after) + /// CHECK-START: long Main.LongDivision() constant_folding (after) /// CHECK-NOT: DivZeroCheck /// CHECK-NOT: Div public static long LongDivision() { long a, b, c; - a = $inline$long(8L); - b = $inline$long(3L); + a = 8L; + b = 3L; c = a / b; return c; } - /// CHECK-START: float Main.FloatDivision() constant_folding$after_inlining (before) + /// CHECK-START: float Main.FloatDivision() constant_folding (before) /// CHECK-DAG: <<Const8:f\d+>> FloatConstant 8 /// CHECK-DAG: <<Const2P5:f\d+>> FloatConstant 2.5 /// CHECK-DAG: <<Div:f\d+>> Div [<<Const8>>,<<Const2P5>>] /// CHECK-DAG: Return [<<Div>>] - /// CHECK-START: float Main.FloatDivision() constant_folding$after_inlining (after) + /// CHECK-START: float Main.FloatDivision() constant_folding (after) /// CHECK-DAG: <<Const3P2:f\d+>> FloatConstant 3.2 /// CHECK-DAG: Return [<<Const3P2>>] - /// CHECK-START: float Main.FloatDivision() constant_folding$after_inlining (after) + /// CHECK-START: float Main.FloatDivision() constant_folding (after) /// CHECK-NOT: Div public static float FloatDivision() { float a, b, c; - a = $inline$float(8F); - b = $inline$float(2.5F); + a = 8F; + b = 2.5F; c = a / b; return c; } - /// CHECK-START: double Main.DoubleDivision() constant_folding$after_inlining (before) + /// CHECK-START: double Main.DoubleDivision() constant_folding (before) /// CHECK-DAG: <<Const8:d\d+>> DoubleConstant 8 /// CHECK-DAG: <<Const2P5:d\d+>> DoubleConstant 2.5 /// CHECK-DAG: <<Div:d\d+>> Div [<<Const8>>,<<Const2P5>>] /// CHECK-DAG: Return [<<Div>>] - /// CHECK-START: double Main.DoubleDivision() constant_folding$after_inlining (after) + /// CHECK-START: double Main.DoubleDivision() constant_folding (after) /// CHECK-DAG: <<Const3P2:d\d+>> DoubleConstant 3.2 /// CHECK-DAG: Return [<<Const3P2>>] - /// CHECK-START: double Main.DoubleDivision() constant_folding$after_inlining (after) + /// CHECK-START: double Main.DoubleDivision() constant_folding (after) /// CHECK-NOT: Div public static double DoubleDivision() { double a, b, c; - a = $inline$double(8D); - b = $inline$double(2.5D); + a = 8D; + b = 2.5D; c = a / b; return c; } @@ -608,90 +589,90 @@ public class Main { * Exercise constant folding on remainder. */ - /// CHECK-START: int Main.IntRemainder() constant_folding$after_inlining (before) + /// CHECK-START: int Main.IntRemainder() constant_folding (before) /// CHECK-DAG: <<Const8:i\d+>> IntConstant 8 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 /// CHECK-DAG: <<Div0Chk:i\d+>> DivZeroCheck [<<Const3>>] /// CHECK-DAG: <<Rem:i\d+>> Rem [<<Const8>>,<<Div0Chk>>] /// CHECK-DAG: Return [<<Rem>>] - /// CHECK-START: int Main.IntRemainder() constant_folding$after_inlining (after) + /// CHECK-START: int Main.IntRemainder() constant_folding (after) /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 /// CHECK-DAG: Return [<<Const2>>] - /// CHECK-START: int Main.IntRemainder() constant_folding$after_inlining (after) + /// CHECK-START: int Main.IntRemainder() constant_folding (after) /// CHECK-NOT: DivZeroCheck /// CHECK-NOT: Rem public static int IntRemainder() { int a, b, c; - a = $inline$int(8); - b = $inline$int(3); + a = 8; + b = 3; c = a % b; return c; } - /// CHECK-START: long Main.LongRemainder() constant_folding$after_inlining (before) + /// CHECK-START: long Main.LongRemainder() constant_folding (before) /// CHECK-DAG: <<Const8:j\d+>> LongConstant 8 /// CHECK-DAG: <<Const3:j\d+>> LongConstant 3 /// CHECK-DAG: <<Div0Chk:j\d+>> DivZeroCheck [<<Const3>>] /// CHECK-DAG: <<Rem:j\d+>> Rem [<<Const8>>,<<Div0Chk>>] /// CHECK-DAG: Return [<<Rem>>] - /// CHECK-START: long Main.LongRemainder() constant_folding$after_inlining (after) + /// CHECK-START: long Main.LongRemainder() constant_folding (after) /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2 /// CHECK-DAG: Return [<<Const2>>] - /// CHECK-START: long Main.LongRemainder() constant_folding$after_inlining (after) + /// CHECK-START: long Main.LongRemainder() constant_folding (after) /// CHECK-NOT: DivZeroCheck /// CHECK-NOT: Rem public static long LongRemainder() { long a, b, c; - a = $inline$long(8L); - b = $inline$long(3L); + a = 8L; + b = 3L; c = a % b; return c; } - /// CHECK-START: float Main.FloatRemainder() constant_folding$after_inlining (before) + /// CHECK-START: float Main.FloatRemainder() constant_folding (before) /// CHECK-DAG: <<Const8:f\d+>> FloatConstant 8 /// CHECK-DAG: <<Const2P5:f\d+>> FloatConstant 2.5 /// CHECK-DAG: <<Rem:f\d+>> Rem [<<Const8>>,<<Const2P5>>] /// CHECK-DAG: Return [<<Rem>>] - /// CHECK-START: float Main.FloatRemainder() constant_folding$after_inlining (after) + /// CHECK-START: float Main.FloatRemainder() constant_folding (after) /// CHECK-DAG: <<Const0P5:f\d+>> FloatConstant 0.5 /// CHECK-DAG: Return [<<Const0P5>>] - /// CHECK-START: float Main.FloatRemainder() constant_folding$after_inlining (after) + /// CHECK-START: float Main.FloatRemainder() constant_folding (after) /// CHECK-NOT: Rem public static float FloatRemainder() { float a, b, c; - a = $inline$float(8F); - b = $inline$float(2.5F); + a = 8F; + b = 2.5F; c = a % b; return c; } - /// CHECK-START: double Main.DoubleRemainder() constant_folding$after_inlining (before) + /// CHECK-START: double Main.DoubleRemainder() constant_folding (before) /// CHECK-DAG: <<Const8:d\d+>> DoubleConstant 8 /// CHECK-DAG: <<Const2P5:d\d+>> DoubleConstant 2.5 /// CHECK-DAG: <<Rem:d\d+>> Rem [<<Const8>>,<<Const2P5>>] /// CHECK-DAG: Return [<<Rem>>] - /// CHECK-START: double Main.DoubleRemainder() constant_folding$after_inlining (after) + /// CHECK-START: double Main.DoubleRemainder() constant_folding (after) /// CHECK-DAG: <<Const0P5:d\d+>> DoubleConstant 0.5 /// CHECK-DAG: Return [<<Const0P5>>] - /// CHECK-START: double Main.DoubleRemainder() constant_folding$after_inlining (after) + /// CHECK-START: double Main.DoubleRemainder() constant_folding (after) /// CHECK-NOT: Rem public static double DoubleRemainder() { double a, b, c; - a = $inline$double(8D); - b = $inline$double(2.5D); + a = 8D; + b = 2.5D; c = a % b; return c; } @@ -701,42 +682,42 @@ public class Main { * Exercise constant folding on left shift. */ - /// CHECK-START: int Main.ShlIntLong() constant_folding$after_inlining (before) + /// CHECK-START: int Main.ShlIntLong() constant_folding (before) /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2 /// CHECK-DAG: <<TypeConv:i\d+>> TypeConversion [<<Const2L>>] /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Const1>>,<<TypeConv>>] /// CHECK-DAG: Return [<<Shl>>] - /// CHECK-START: int Main.ShlIntLong() constant_folding$after_inlining (after) + /// CHECK-START: int Main.ShlIntLong() constant_folding (after) /// CHECK-DAG: <<Const4:i\d+>> IntConstant 4 /// CHECK-DAG: Return [<<Const4>>] - /// CHECK-START: int Main.ShlIntLong() constant_folding$after_inlining (after) + /// CHECK-START: int Main.ShlIntLong() constant_folding (after) /// CHECK-NOT: Shl public static int ShlIntLong() { - int lhs = $inline$int(1); - long rhs = $inline$long(2L); + int lhs = 1; + long rhs = 2; return lhs << rhs; } - /// CHECK-START: long Main.ShlLongInt() constant_folding$after_inlining (before) + /// CHECK-START: long Main.ShlLongInt() constant_folding (before) /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Const3L>>,<<Const2>>] /// CHECK-DAG: Return [<<Shl>>] - /// CHECK-START: long Main.ShlLongInt() constant_folding$after_inlining (after) + /// CHECK-START: long Main.ShlLongInt() constant_folding (after) /// CHECK-DAG: <<Const12L:j\d+>> LongConstant 12 /// CHECK-DAG: Return [<<Const12L>>] - /// CHECK-START: long Main.ShlLongInt() constant_folding$after_inlining (after) + /// CHECK-START: long Main.ShlLongInt() constant_folding (after) /// CHECK-NOT: Shl public static long ShlLongInt() { - long lhs = $inline$long(3L); - int rhs = $inline$int(2); + long lhs = 3; + int rhs = 2; return lhs << rhs; } @@ -745,42 +726,42 @@ public class Main { * Exercise constant folding on right shift. */ - /// CHECK-START: int Main.ShrIntLong() constant_folding$after_inlining (before) + /// CHECK-START: int Main.ShrIntLong() constant_folding (before) /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2 /// CHECK-DAG: <<TypeConv:i\d+>> TypeConversion [<<Const2L>>] /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Const7>>,<<TypeConv>>] /// CHECK-DAG: Return [<<Shr>>] - /// CHECK-START: int Main.ShrIntLong() constant_folding$after_inlining (after) + /// CHECK-START: int Main.ShrIntLong() constant_folding (after) /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 /// CHECK-DAG: Return [<<Const1>>] - /// CHECK-START: int Main.ShrIntLong() constant_folding$after_inlining (after) + /// CHECK-START: int Main.ShrIntLong() constant_folding (after) /// CHECK-NOT: Shr public static int ShrIntLong() { - int lhs = $inline$int(7); - long rhs = $inline$long(2L); + int lhs = 7; + long rhs = 2; return lhs >> rhs; } - /// CHECK-START: long Main.ShrLongInt() constant_folding$after_inlining (before) + /// CHECK-START: long Main.ShrLongInt() constant_folding (before) /// CHECK-DAG: <<Const9L:j\d+>> LongConstant 9 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Const9L>>,<<Const2>>] /// CHECK-DAG: Return [<<Shr>>] - /// CHECK-START: long Main.ShrLongInt() constant_folding$after_inlining (after) + /// CHECK-START: long Main.ShrLongInt() constant_folding (after) /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2 /// CHECK-DAG: Return [<<Const2L>>] - /// CHECK-START: long Main.ShrLongInt() constant_folding$after_inlining (after) + /// CHECK-START: long Main.ShrLongInt() constant_folding (after) /// CHECK-NOT: Shr public static long ShrLongInt() { - long lhs = $inline$long(9); - int rhs = $inline$int(2); + long lhs = 9; + int rhs = 2; return lhs >> rhs; } @@ -789,42 +770,42 @@ public class Main { * Exercise constant folding on unsigned right shift. */ - /// CHECK-START: int Main.UShrIntLong() constant_folding$after_inlining (before) + /// CHECK-START: int Main.UShrIntLong() constant_folding (before) /// CHECK-DAG: <<ConstM7:i\d+>> IntConstant -7 /// CHECK-DAG: <<Const2L:j\d+>> LongConstant 2 /// CHECK-DAG: <<TypeConv:i\d+>> TypeConversion [<<Const2L>>] /// CHECK-DAG: <<UShr:i\d+>> UShr [<<ConstM7>>,<<TypeConv>>] /// CHECK-DAG: Return [<<UShr>>] - /// CHECK-START: int Main.UShrIntLong() constant_folding$after_inlining (after) + /// CHECK-START: int Main.UShrIntLong() constant_folding (after) /// CHECK-DAG: <<ConstRes:i\d+>> IntConstant 1073741822 /// CHECK-DAG: Return [<<ConstRes>>] - /// CHECK-START: int Main.UShrIntLong() constant_folding$after_inlining (after) + /// CHECK-START: int Main.UShrIntLong() constant_folding (after) /// CHECK-NOT: UShr public static int UShrIntLong() { - int lhs = $inline$int(-7); - long rhs = $inline$long(2L); + int lhs = -7; + long rhs = 2; return lhs >>> rhs; } - /// CHECK-START: long Main.UShrLongInt() constant_folding$after_inlining (before) + /// CHECK-START: long Main.UShrLongInt() constant_folding (before) /// CHECK-DAG: <<ConstM9L:j\d+>> LongConstant -9 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 /// CHECK-DAG: <<UShr:j\d+>> UShr [<<ConstM9L>>,<<Const2>>] /// CHECK-DAG: Return [<<UShr>>] - /// CHECK-START: long Main.UShrLongInt() constant_folding$after_inlining (after) + /// CHECK-START: long Main.UShrLongInt() constant_folding (after) /// CHECK-DAG: <<ConstRes:j\d+>> LongConstant 4611686018427387901 /// CHECK-DAG: Return [<<ConstRes>>] - /// CHECK-START: long Main.UShrLongInt() constant_folding$after_inlining (after) + /// CHECK-START: long Main.UShrLongInt() constant_folding (after) /// CHECK-NOT: UShr public static long UShrLongInt() { - long lhs = $inline$long(-9); - int rhs = $inline$int(2); + long lhs = -9; + int rhs = 2; return lhs >>> rhs; } @@ -833,43 +814,43 @@ public class Main { * Exercise constant folding on logical and. */ - /// CHECK-START: long Main.AndIntLong() constant_folding$after_inlining (before) + /// CHECK-START: long Main.AndIntLong() constant_folding (before) /// CHECK-DAG: <<Const10:i\d+>> IntConstant 10 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const10>>] /// CHECK-DAG: <<And:j\d+>> And [<<TypeConv>>,<<Const3L>>] /// CHECK-DAG: Return [<<And>>] - /// CHECK-START: long Main.AndIntLong() constant_folding$after_inlining (after) + /// CHECK-START: long Main.AndIntLong() constant_folding (after) /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2 /// CHECK-DAG: Return [<<Const2>>] - /// CHECK-START: long Main.AndIntLong() constant_folding$after_inlining (after) + /// CHECK-START: long Main.AndIntLong() constant_folding (after) /// CHECK-NOT: And public static long AndIntLong() { - int lhs = $inline$int(10); - long rhs = $inline$long(3L); + int lhs = 10; + long rhs = 3; return lhs & rhs; } - /// CHECK-START: long Main.AndLongInt() constant_folding$after_inlining (before) + /// CHECK-START: long Main.AndLongInt() constant_folding (before) /// CHECK-DAG: <<Const10L:j\d+>> LongConstant 10 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const3>>] /// CHECK-DAG: <<And:j\d+>> And [<<TypeConv>>,<<Const10L>>] /// CHECK-DAG: Return [<<And>>] - /// CHECK-START: long Main.AndLongInt() constant_folding$after_inlining (after) + /// CHECK-START: long Main.AndLongInt() constant_folding (after) /// CHECK-DAG: <<Const2:j\d+>> LongConstant 2 /// CHECK-DAG: Return [<<Const2>>] - /// CHECK-START: long Main.AndLongInt() constant_folding$after_inlining (after) + /// CHECK-START: long Main.AndLongInt() constant_folding (after) /// CHECK-NOT: And public static long AndLongInt() { - long lhs = $inline$long(10L); - int rhs = $inline$int(3); + long lhs = 10; + int rhs = 3; return lhs & rhs; } @@ -878,43 +859,43 @@ public class Main { * Exercise constant folding on logical or. */ - /// CHECK-START: long Main.OrIntLong() constant_folding$after_inlining (before) + /// CHECK-START: long Main.OrIntLong() constant_folding (before) /// CHECK-DAG: <<Const10:i\d+>> IntConstant 10 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const10>>] /// CHECK-DAG: <<Or:j\d+>> Or [<<TypeConv>>,<<Const3L>>] /// CHECK-DAG: Return [<<Or>>] - /// CHECK-START: long Main.OrIntLong() constant_folding$after_inlining (after) + /// CHECK-START: long Main.OrIntLong() constant_folding (after) /// CHECK-DAG: <<Const11:j\d+>> LongConstant 11 /// CHECK-DAG: Return [<<Const11>>] - /// CHECK-START: long Main.OrIntLong() constant_folding$after_inlining (after) + /// CHECK-START: long Main.OrIntLong() constant_folding (after) /// CHECK-NOT: Or public static long OrIntLong() { - int lhs = $inline$int(10); - long rhs = $inline$long(3L); + int lhs = 10; + long rhs = 3; return lhs | rhs; } - /// CHECK-START: long Main.OrLongInt() constant_folding$after_inlining (before) + /// CHECK-START: long Main.OrLongInt() constant_folding (before) /// CHECK-DAG: <<Const10L:j\d+>> LongConstant 10 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const3>>] /// CHECK-DAG: <<Or:j\d+>> Or [<<TypeConv>>,<<Const10L>>] /// CHECK-DAG: Return [<<Or>>] - /// CHECK-START: long Main.OrLongInt() constant_folding$after_inlining (after) + /// CHECK-START: long Main.OrLongInt() constant_folding (after) /// CHECK-DAG: <<Const11:j\d+>> LongConstant 11 /// CHECK-DAG: Return [<<Const11>>] - /// CHECK-START: long Main.OrLongInt() constant_folding$after_inlining (after) + /// CHECK-START: long Main.OrLongInt() constant_folding (after) /// CHECK-NOT: Or public static long OrLongInt() { - long lhs = $inline$long(10L); - int rhs = $inline$int(3); + long lhs = 10; + int rhs = 3; return lhs | rhs; } @@ -923,43 +904,43 @@ public class Main { * Exercise constant folding on logical exclusive or. */ - /// CHECK-START: long Main.XorIntLong() constant_folding$after_inlining (before) + /// CHECK-START: long Main.XorIntLong() constant_folding (before) /// CHECK-DAG: <<Const10:i\d+>> IntConstant 10 /// CHECK-DAG: <<Const3L:j\d+>> LongConstant 3 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const10>>] /// CHECK-DAG: <<Xor:j\d+>> Xor [<<TypeConv>>,<<Const3L>>] /// CHECK-DAG: Return [<<Xor>>] - /// CHECK-START: long Main.XorIntLong() constant_folding$after_inlining (after) + /// CHECK-START: long Main.XorIntLong() constant_folding (after) /// CHECK-DAG: <<Const9:j\d+>> LongConstant 9 /// CHECK-DAG: Return [<<Const9>>] - /// CHECK-START: long Main.XorIntLong() constant_folding$after_inlining (after) + /// CHECK-START: long Main.XorIntLong() constant_folding (after) /// CHECK-NOT: Xor public static long XorIntLong() { - int lhs = $inline$int(10); - long rhs = $inline$long(3L); + int lhs = 10; + long rhs = 3; return lhs ^ rhs; } - /// CHECK-START: long Main.XorLongInt() constant_folding$after_inlining (before) + /// CHECK-START: long Main.XorLongInt() constant_folding (before) /// CHECK-DAG: <<Const10L:j\d+>> LongConstant 10 /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 /// CHECK-DAG: <<TypeConv:j\d+>> TypeConversion [<<Const3>>] /// CHECK-DAG: <<Xor:j\d+>> Xor [<<TypeConv>>,<<Const10L>>] /// CHECK-DAG: Return [<<Xor>>] - /// CHECK-START: long Main.XorLongInt() constant_folding$after_inlining (after) + /// CHECK-START: long Main.XorLongInt() constant_folding (after) /// CHECK-DAG: <<Const9:j\d+>> LongConstant 9 /// CHECK-DAG: Return [<<Const9>>] - /// CHECK-START: long Main.XorLongInt() constant_folding$after_inlining (after) + /// CHECK-START: long Main.XorLongInt() constant_folding (after) /// CHECK-NOT: Xor public static long XorLongInt() { - long lhs = $inline$long(10L); - int rhs = $inline$int(3); + long lhs = 10; + int rhs = 3; return lhs ^ rhs; } @@ -968,23 +949,23 @@ public class Main { * Exercise constant folding on constant (static) condition. */ - /// CHECK-START: int Main.StaticCondition() constant_folding$after_inlining (before) + /// CHECK-START: int Main.StaticCondition() constant_folding (before) /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 /// CHECK-DAG: <<Cond:z\d+>> GreaterThanOrEqual [<<Const7>>,<<Const2>>] - /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Cond>>] + /// CHECK-DAG: If [<<Cond>>] - /// CHECK-START: int Main.StaticCondition() constant_folding$after_inlining (after) + /// CHECK-START: int Main.StaticCondition() constant_folding (after) /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 - /// CHECK-DAG: Select [{{i\d+}},{{i\d+}},<<Const1>>] + /// CHECK-DAG: If [<<Const1>>] - /// CHECK-START: int Main.StaticCondition() constant_folding$after_inlining (after) + /// CHECK-START: int Main.StaticCondition() constant_folding (after) /// CHECK-NOT: GreaterThanOrEqual public static int StaticCondition() { int a, b, c; - a = $inline$int(7); - b = $inline$int(2); + a = 7; + b = 2; if (a < b) c = a + b; else @@ -1029,30 +1010,28 @@ public class Main { * (forward) post-order traversal of the the dominator tree. */ - /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding$after_inlining (before) - /// CHECK-DAG: <<Cond:z\d+>> ParameterValue + /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding (before) /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 /// CHECK-DAG: <<Const5:i\d+>> IntConstant 5 /// CHECK-DAG: <<Add:i\d+>> Add [<<Const5>>,<<Const2>>] /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const5>>,<<Const2>>] - /// CHECK-DAG: <<Phi:i\d+>> Select [<<Sub>>,<<Add>>,<<Cond>>] + /// CHECK-DAG: <<Phi:i\d+>> Phi [<<Add>>,<<Sub>>] /// CHECK-DAG: Return [<<Phi>>] - /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding$after_inlining (after) - /// CHECK-DAG: <<Cond:z\d+>> ParameterValue + /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding (after) /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 - /// CHECK-DAG: <<Phi:i\d+>> Select [<<Const3>>,<<Const7>>,<<Cond>>] + /// CHECK-DAG: <<Phi:i\d+>> Phi [<<Const7>>,<<Const3>>] /// CHECK-DAG: Return [<<Phi>>] - /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding$after_inlining (after) + /// CHECK-START: int Main.JumpsAndConditionals(boolean) constant_folding (after) /// CHECK-NOT: Add /// CHECK-NOT: Sub public static int JumpsAndConditionals(boolean cond) { int a, b, c; - a = $inline$int(5); - b = $inline$int(2); + a = 5; + b = 2; if (cond) c = a + b; else @@ -1328,259 +1307,207 @@ public class Main { /** - * Test optimizations of comparisons with null yielding a constant result. - */ - - /// CHECK-START: boolean Main.ConstStringEqualsNull() constant_folding$after_inlining (before) - /// CHECK-DAG: <<ConstStr:l\d+>> LoadString - /// CHECK-DAG: <<Null:l\d+>> NullConstant - /// CHECK-DAG: <<Eq:z\d+>> Equal [<<ConstStr>>,<<Null>>] - /// CHECK-DAG: If [<<Eq>>] - - /// CHECK-START: boolean Main.ConstStringEqualsNull() constant_folding$after_inlining (after) - /// CHECK-DAG: <<False:i\d+>> IntConstant 0 - /// CHECK-DAG: If [<<False>>] - - /// CHECK-START: boolean Main.ConstStringEqualsNull() constant_folding$after_inlining (after) - /// CHECK-NOT: Equal - - public static boolean ConstStringEqualsNull() { - // Due to Jack emitting code using the opposite condition, use != to generate Equal. - if ($inline$ConstString() != null) { - return false; - } else { - return true; - } - } - - /// CHECK-START: boolean Main.ConstStringNotEqualsNull() constant_folding$after_inlining (before) - /// CHECK-DAG: <<ConstStr:l\d+>> LoadString - /// CHECK-DAG: <<Null:l\d+>> NullConstant - /// CHECK-DAG: <<Ne:z\d+>> NotEqual [<<ConstStr>>,<<Null>>] - /// CHECK-DAG: If [<<Ne>>] - - /// CHECK-START: boolean Main.ConstStringNotEqualsNull() constant_folding$after_inlining (after) - /// CHECK-DAG: <<True:i\d+>> IntConstant 1 - /// CHECK-DAG: If [<<True>>] - - /// CHECK-START: boolean Main.ConstStringNotEqualsNull() constant_folding$after_inlining (after) - /// CHECK-NOT: NotEqual - - public static boolean ConstStringNotEqualsNull() { - // Due to Jack emitting code using the opposite condition, use == to generate NotEqual. - if ($inline$ConstString() == null) { - return false; - } else { - return true; - } - } - - public static String $inline$ConstString() { - return ""; - } - - /** * Exercise constant folding on type conversions. */ - /// CHECK-START: int Main.ReturnInt33() constant_folding$after_inlining (before) + /// CHECK-START: int Main.ReturnInt33() constant_folding (before) /// CHECK-DAG: <<Const33:j\d+>> LongConstant 33 /// CHECK-DAG: <<Convert:i\d+>> TypeConversion [<<Const33>>] /// CHECK-DAG: Return [<<Convert>>] - /// CHECK-START: int Main.ReturnInt33() constant_folding$after_inlining (after) + /// CHECK-START: int Main.ReturnInt33() constant_folding (after) /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33 /// CHECK-DAG: Return [<<Const33>>] - /// CHECK-START: int Main.ReturnInt33() constant_folding$after_inlining (after) + /// CHECK-START: int Main.ReturnInt33() constant_folding (after) /// CHECK-NOT: TypeConversion public static int ReturnInt33() { - long imm = $inline$long(33L); + long imm = 33L; return (int) imm; } - /// CHECK-START: int Main.ReturnIntMax() constant_folding$after_inlining (before) + /// CHECK-START: int Main.ReturnIntMax() constant_folding (before) /// CHECK-DAG: <<ConstMax:f\d+>> FloatConstant 1e+34 /// CHECK-DAG: <<Convert:i\d+>> TypeConversion [<<ConstMax>>] /// CHECK-DAG: Return [<<Convert>>] - /// CHECK-START: int Main.ReturnIntMax() constant_folding$after_inlining (after) + /// CHECK-START: int Main.ReturnIntMax() constant_folding (after) /// CHECK-DAG: <<ConstMax:i\d+>> IntConstant 2147483647 /// CHECK-DAG: Return [<<ConstMax>>] - /// CHECK-START: int Main.ReturnIntMax() constant_folding$after_inlining (after) + /// CHECK-START: int Main.ReturnIntMax() constant_folding (after) /// CHECK-NOT: TypeConversion public static int ReturnIntMax() { - float imm = $inline$float(1.0e34f); + float imm = 1.0e34f; return (int) imm; } - /// CHECK-START: int Main.ReturnInt0() constant_folding$after_inlining (before) + /// CHECK-START: int Main.ReturnInt0() constant_folding (before) /// CHECK-DAG: <<ConstNaN:d\d+>> DoubleConstant nan /// CHECK-DAG: <<Convert:i\d+>> TypeConversion [<<ConstNaN>>] /// CHECK-DAG: Return [<<Convert>>] - /// CHECK-START: int Main.ReturnInt0() constant_folding$after_inlining (after) + /// CHECK-START: int Main.ReturnInt0() constant_folding (after) /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 /// CHECK-DAG: Return [<<Const0>>] - /// CHECK-START: int Main.ReturnInt0() constant_folding$after_inlining (after) + /// CHECK-START: int Main.ReturnInt0() constant_folding (after) /// CHECK-NOT: TypeConversion public static int ReturnInt0() { - double imm = $inline$double(Double.NaN); + double imm = Double.NaN; return (int) imm; } - /// CHECK-START: long Main.ReturnLong33() constant_folding$after_inlining (before) + /// CHECK-START: long Main.ReturnLong33() constant_folding (before) /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33 /// CHECK-DAG: <<Convert:j\d+>> TypeConversion [<<Const33>>] /// CHECK-DAG: Return [<<Convert>>] - /// CHECK-START: long Main.ReturnLong33() constant_folding$after_inlining (after) + /// CHECK-START: long Main.ReturnLong33() constant_folding (after) /// CHECK-DAG: <<Const33:j\d+>> LongConstant 33 /// CHECK-DAG: Return [<<Const33>>] - /// CHECK-START: long Main.ReturnLong33() constant_folding$after_inlining (after) + /// CHECK-START: long Main.ReturnLong33() constant_folding (after) /// CHECK-NOT: TypeConversion public static long ReturnLong33() { - int imm = $inline$int(33); + int imm = 33; return (long) imm; } - /// CHECK-START: long Main.ReturnLong34() constant_folding$after_inlining (before) + /// CHECK-START: long Main.ReturnLong34() constant_folding (before) /// CHECK-DAG: <<Const34:f\d+>> FloatConstant 34 /// CHECK-DAG: <<Convert:j\d+>> TypeConversion [<<Const34>>] /// CHECK-DAG: Return [<<Convert>>] - /// CHECK-START: long Main.ReturnLong34() constant_folding$after_inlining (after) + /// CHECK-START: long Main.ReturnLong34() constant_folding (after) /// CHECK-DAG: <<Const34:j\d+>> LongConstant 34 /// CHECK-DAG: Return [<<Const34>>] - /// CHECK-START: long Main.ReturnLong34() constant_folding$after_inlining (after) + /// CHECK-START: long Main.ReturnLong34() constant_folding (after) /// CHECK-NOT: TypeConversion public static long ReturnLong34() { - float imm = $inline$float(34.0f); + float imm = 34.0f; return (long) imm; } - /// CHECK-START: long Main.ReturnLong0() constant_folding$after_inlining (before) + /// CHECK-START: long Main.ReturnLong0() constant_folding (before) /// CHECK-DAG: <<ConstNaN:d\d+>> DoubleConstant nan /// CHECK-DAG: <<Convert:j\d+>> TypeConversion [<<ConstNaN>>] /// CHECK-DAG: Return [<<Convert>>] - /// CHECK-START: long Main.ReturnLong0() constant_folding$after_inlining (after) + /// CHECK-START: long Main.ReturnLong0() constant_folding (after) /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 /// CHECK-DAG: Return [<<Const0>>] - /// CHECK-START: long Main.ReturnLong0() constant_folding$after_inlining (after) + /// CHECK-START: long Main.ReturnLong0() constant_folding (after) /// CHECK-NOT: TypeConversion public static long ReturnLong0() { - double imm = $inline$double(-Double.NaN); + double imm = -Double.NaN; return (long) imm; } - /// CHECK-START: float Main.ReturnFloat33() constant_folding$after_inlining (before) + /// CHECK-START: float Main.ReturnFloat33() constant_folding (before) /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33 /// CHECK-DAG: <<Convert:f\d+>> TypeConversion [<<Const33>>] /// CHECK-DAG: Return [<<Convert>>] - /// CHECK-START: float Main.ReturnFloat33() constant_folding$after_inlining (after) + /// CHECK-START: float Main.ReturnFloat33() constant_folding (after) /// CHECK-DAG: <<Const33:f\d+>> FloatConstant 33 /// CHECK-DAG: Return [<<Const33>>] - /// CHECK-START: float Main.ReturnFloat33() constant_folding$after_inlining (after) + /// CHECK-START: float Main.ReturnFloat33() constant_folding (after) /// CHECK-NOT: TypeConversion public static float ReturnFloat33() { - int imm = $inline$int(33); + int imm = 33; return (float) imm; } - /// CHECK-START: float Main.ReturnFloat34() constant_folding$after_inlining (before) + /// CHECK-START: float Main.ReturnFloat34() constant_folding (before) /// CHECK-DAG: <<Const34:j\d+>> LongConstant 34 /// CHECK-DAG: <<Convert:f\d+>> TypeConversion [<<Const34>>] /// CHECK-DAG: Return [<<Convert>>] - /// CHECK-START: float Main.ReturnFloat34() constant_folding$after_inlining (after) + /// CHECK-START: float Main.ReturnFloat34() constant_folding (after) /// CHECK-DAG: <<Const34:f\d+>> FloatConstant 34 /// CHECK-DAG: Return [<<Const34>>] - /// CHECK-START: float Main.ReturnFloat34() constant_folding$after_inlining (after) + /// CHECK-START: float Main.ReturnFloat34() constant_folding (after) /// CHECK-NOT: TypeConversion public static float ReturnFloat34() { - long imm = $inline$long(34L); + long imm = 34L; return (float) imm; } - /// CHECK-START: float Main.ReturnFloat99P25() constant_folding$after_inlining (before) + /// CHECK-START: float Main.ReturnFloat99P25() constant_folding (before) /// CHECK-DAG: <<Const:d\d+>> DoubleConstant 99.25 /// CHECK-DAG: <<Convert:f\d+>> TypeConversion [<<Const>>] /// CHECK-DAG: Return [<<Convert>>] - /// CHECK-START: float Main.ReturnFloat99P25() constant_folding$after_inlining (after) + /// CHECK-START: float Main.ReturnFloat99P25() constant_folding (after) /// CHECK-DAG: <<Const:f\d+>> FloatConstant 99.25 /// CHECK-DAG: Return [<<Const>>] - /// CHECK-START: float Main.ReturnFloat99P25() constant_folding$after_inlining (after) + /// CHECK-START: float Main.ReturnFloat99P25() constant_folding (after) /// CHECK-NOT: TypeConversion public static float ReturnFloat99P25() { - double imm = $inline$double(99.25); + double imm = 99.25; return (float) imm; } - /// CHECK-START: double Main.ReturnDouble33() constant_folding$after_inlining (before) + /// CHECK-START: double Main.ReturnDouble33() constant_folding (before) /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33 /// CHECK-DAG: <<Convert:d\d+>> TypeConversion [<<Const33>>] /// CHECK-DAG: Return [<<Convert>>] - /// CHECK-START: double Main.ReturnDouble33() constant_folding$after_inlining (after) + /// CHECK-START: double Main.ReturnDouble33() constant_folding (after) /// CHECK-DAG: <<Const33:d\d+>> DoubleConstant 33 /// CHECK-DAG: Return [<<Const33>>] public static double ReturnDouble33() { - int imm = $inline$int(33); + int imm = 33; return (double) imm; } - /// CHECK-START: double Main.ReturnDouble34() constant_folding$after_inlining (before) + /// CHECK-START: double Main.ReturnDouble34() constant_folding (before) /// CHECK-DAG: <<Const34:j\d+>> LongConstant 34 /// CHECK-DAG: <<Convert:d\d+>> TypeConversion [<<Const34>>] /// CHECK-DAG: Return [<<Convert>>] - /// CHECK-START: double Main.ReturnDouble34() constant_folding$after_inlining (after) + /// CHECK-START: double Main.ReturnDouble34() constant_folding (after) /// CHECK-DAG: <<Const34:d\d+>> DoubleConstant 34 /// CHECK-DAG: Return [<<Const34>>] - /// CHECK-START: double Main.ReturnDouble34() constant_folding$after_inlining (after) + /// CHECK-START: double Main.ReturnDouble34() constant_folding (after) /// CHECK-NOT: TypeConversion public static double ReturnDouble34() { - long imm = $inline$long(34L); + long imm = 34L; return (double) imm; } - /// CHECK-START: double Main.ReturnDouble99P25() constant_folding$after_inlining (before) + /// CHECK-START: double Main.ReturnDouble99P25() constant_folding (before) /// CHECK-DAG: <<Const:f\d+>> FloatConstant 99.25 /// CHECK-DAG: <<Convert:d\d+>> TypeConversion [<<Const>>] /// CHECK-DAG: Return [<<Convert>>] - /// CHECK-START: double Main.ReturnDouble99P25() constant_folding$after_inlining (after) + /// CHECK-START: double Main.ReturnDouble99P25() constant_folding (after) /// CHECK-DAG: <<Const:d\d+>> DoubleConstant 99.25 /// CHECK-DAG: Return [<<Const>>] - /// CHECK-START: double Main.ReturnDouble99P25() constant_folding$after_inlining (after) + /// CHECK-START: double Main.ReturnDouble99P25() constant_folding (after) /// CHECK-NOT: TypeConversion public static double ReturnDouble99P25() { - float imm = $inline$float(99.25f); + float imm = 99.25f; return (double) imm; } @@ -1659,9 +1586,6 @@ public class Main { assertFalse(CmpFloatGreaterThanNaN(arbitrary)); assertFalse(CmpDoubleLessThanNaN(arbitrary)); - assertFalse(ConstStringEqualsNull()); - assertTrue(ConstStringNotEqualsNull()); - Main main = new Main(); assertIntEquals(1, main.smaliCmpLongConstants()); assertIntEquals(-1, main.smaliCmpGtFloatConstants()); diff --git a/test/450-checker-types/build b/test/450-checker-types/build new file mode 100755 index 0000000000..49292c9ac1 --- /dev/null +++ b/test/450-checker-types/build @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Copyright 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This checker test is incompatible with jack bytecode output, +# so force it to use javac/dx. +export USE_JACK=false +# Also disable desugar because it is missing in jack platform builds. +export DESUGAR=false + +./default-build "$@" diff --git a/test/450-checker-types/smali/SmaliTests.smali b/test/450-checker-types/smali/SmaliTests.smali deleted file mode 100644 index 6a3122e41b..0000000000 --- a/test/450-checker-types/smali/SmaliTests.smali +++ /dev/null @@ -1,120 +0,0 @@ -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -.class public LSmaliTests; -.super Ljava/lang/Object; - -## CHECK-START: void SmaliTests.testInstanceOf_EQ0_NotInlined(java.lang.Object) builder (after) -## CHECK-DAG: <<Cst0:i\d+>> IntConstant 0 -## CHECK-DAG: <<IOf:z\d+>> InstanceOf -## CHECK-DAG: Equal [<<IOf>>,<<Cst0>>] - -## CHECK-START: void SmaliTests.testInstanceOf_EQ0_NotInlined(java.lang.Object) instruction_simplifier (before) -## CHECK: CheckCast - -## CHECK-START: void SmaliTests.testInstanceOf_EQ0_NotInlined(java.lang.Object) instruction_simplifier (after) -## CHECK-NOT: CheckCast - -.method public static testInstanceOf_EQ0_NotInlined(Ljava/lang/Object;)V - .registers 3 - - const v0, 0x0 - instance-of v1, p0, LSubclassC; - if-eq v1, v0, :return - - check-cast p0, LSubclassC; - invoke-virtual {p0}, LSubclassC;->$noinline$g()V - - :return - return-void - -.end method - -## CHECK-START: void SmaliTests.testInstanceOf_EQ1_NotInlined(java.lang.Object) builder (after) -## CHECK-DAG: <<Cst1:i\d+>> IntConstant 1 -## CHECK-DAG: <<IOf:z\d+>> InstanceOf -## CHECK-DAG: Equal [<<IOf>>,<<Cst1>>] - -## CHECK-START: void SmaliTests.testInstanceOf_EQ1_NotInlined(java.lang.Object) instruction_simplifier (before) -## CHECK: CheckCast - -## CHECK-START: void SmaliTests.testInstanceOf_EQ1_NotInlined(java.lang.Object) instruction_simplifier (after) -## CHECK-NOT: CheckCast - -.method public static testInstanceOf_EQ1_NotInlined(Ljava/lang/Object;)V - .registers 3 - - const v0, 0x1 - instance-of v1, p0, LSubclassC; - if-eq v1, v0, :invoke - return-void - - :invoke - check-cast p0, LSubclassC; - invoke-virtual {p0}, LSubclassC;->$noinline$g()V - return-void - -.end method - -## CHECK-START: void SmaliTests.testInstanceOf_NE0_NotInlined(java.lang.Object) builder (after) -## CHECK-DAG: <<Cst0:i\d+>> IntConstant 0 -## CHECK-DAG: <<IOf:z\d+>> InstanceOf -## CHECK-DAG: NotEqual [<<IOf>>,<<Cst0>>] - -## CHECK-START: void SmaliTests.testInstanceOf_NE0_NotInlined(java.lang.Object) instruction_simplifier (before) -## CHECK: CheckCast - -## CHECK-START: void SmaliTests.testInstanceOf_NE0_NotInlined(java.lang.Object) instruction_simplifier (after) -## CHECK-NOT: CheckCast - -.method public static testInstanceOf_NE0_NotInlined(Ljava/lang/Object;)V - .registers 3 - - const v0, 0x0 - instance-of v1, p0, LSubclassC; - if-ne v1, v0, :invoke - return-void - - :invoke - check-cast p0, LSubclassC; - invoke-virtual {p0}, LSubclassC;->$noinline$g()V - return-void - -.end method - -## CHECK-START: void SmaliTests.testInstanceOf_NE1_NotInlined(java.lang.Object) builder (after) -## CHECK-DAG: <<Cst1:i\d+>> IntConstant 1 -## CHECK-DAG: <<IOf:z\d+>> InstanceOf -## CHECK-DAG: NotEqual [<<IOf>>,<<Cst1>>] - -## CHECK-START: void SmaliTests.testInstanceOf_NE1_NotInlined(java.lang.Object) instruction_simplifier (before) -## CHECK: CheckCast - -## CHECK-START: void SmaliTests.testInstanceOf_NE1_NotInlined(java.lang.Object) instruction_simplifier (after) -## CHECK-NOT: CheckCast - -.method public static testInstanceOf_NE1_NotInlined(Ljava/lang/Object;)V - .registers 3 - - const v0, 0x1 - instance-of v1, p0, LSubclassC; - if-ne v1, v0, :return - - check-cast p0, LSubclassC; - invoke-virtual {p0}, LSubclassC;->$noinline$g()V - - :return - return-void - -.end method diff --git a/test/450-checker-types/src/Main.java b/test/450-checker-types/src/Main.java index ea8609ee5e..ae0fdbe576 100644 --- a/test/450-checker-types/src/Main.java +++ b/test/450-checker-types/src/Main.java @@ -210,6 +210,58 @@ public class Main { public static boolean $inline$InstanceofSubclassB(Object o) { return o instanceof SubclassB; } public static boolean $inline$InstanceofSubclassC(Object o) { return o instanceof SubclassC; } + /// CHECK-START: void Main.testInstanceOf_NotInlined(java.lang.Object) builder (after) + /// CHECK-DAG: <<Cst0:i\d+>> IntConstant 0 + /// CHECK-DAG: <<Cst1:i\d+>> IntConstant 1 + /// CHECK-DAG: <<IOf1:z\d+>> InstanceOf + /// CHECK-DAG: NotEqual [<<IOf1>>,<<Cst1>>] + /// CHECK-DAG: <<IOf2:z\d+>> InstanceOf + /// CHECK-DAG: Equal [<<IOf2>>,<<Cst0>>] + + /// CHECK-START: void Main.testInstanceOf_NotInlined(java.lang.Object) instruction_simplifier (before) + /// CHECK: CheckCast + /// CHECK: CheckCast + /// CHECK-NOT: CheckCast + + /// CHECK-START: void Main.testInstanceOf_NotInlined(java.lang.Object) instruction_simplifier (after) + /// CHECK-NOT: CheckCast + public void testInstanceOf_NotInlined(Object o) { + if ((o instanceof SubclassC) == true) { + ((SubclassC)o).$noinline$g(); + } + if ((o instanceof SubclassB) != false) { + ((SubclassB)o).$noinline$g(); + } + } + + /// CHECK-START: void Main.testNotInstanceOf_NotInlined(java.lang.Object) builder (after) + /// CHECK-DAG: <<Cst0:i\d+>> IntConstant 0 + /// CHECK-DAG: <<Cst1:i\d+>> IntConstant 1 + /// CHECK-DAG: <<IOf1:z\d+>> InstanceOf + /// CHECK-DAG: Equal [<<IOf1>>,<<Cst1>>] + /// CHECK-DAG: <<IOf2:z\d+>> InstanceOf + /// CHECK-DAG: NotEqual [<<IOf2>>,<<Cst0>>] + + /// CHECK-START: void Main.testNotInstanceOf_NotInlined(java.lang.Object) instruction_simplifier (before) + /// CHECK: CheckCast + /// CHECK: CheckCast + /// CHECK-NOT: CheckCast + + /// CHECK-START: void Main.testNotInstanceOf_NotInlined(java.lang.Object) instruction_simplifier (after) + /// CHECK-NOT: CheckCast + public void testNotInstanceOf_NotInlined(Object o) { + if ((o instanceof SubclassC) != true) { + // Empty branch to flip the condition. + } else { + ((SubclassC)o).$noinline$g(); + } + if ((o instanceof SubclassB) == false) { + // Empty branch to flip the condition. + } else { + ((SubclassB)o).$noinline$g(); + } + } + /// CHECK-START: void Main.testInstanceOf_Inlined(java.lang.Object) inliner (after) /// CHECK-DAG: <<IOf:z\d+>> InstanceOf /// CHECK-DAG: If [<<IOf>>] @@ -634,7 +686,7 @@ public class Main { /// CHECK-DAG: <<Null:l\d+>> NullConstant /// CHECK-DAG: <<Phi:l\d+>> Phi [<<Arg>>,<<Null>>] klass:SubclassA /// CHECK-DAG: <<NCPhi:l\d+>> NullCheck [<<Phi>>] - /// CHECK-DAG: InvokeVirtual [<<NCPhi>>] method_name:Super.hashCode + /// CHECK-DAG: InvokeVirtual [<<NCPhi>>] method_name:java.lang.Object.hashCode public void testThisArgumentMoreSpecific(boolean cond) { // Inlining method from Super will build it with `this` typed as Super. @@ -655,7 +707,7 @@ public class Main { /// CHECK-START: void Main.testExplicitArgumentMoreSpecific(SubclassA) inliner (after) /// CHECK-DAG: <<Arg:l\d+>> ParameterValue klass:SubclassA /// CHECK-DAG: <<NCArg:l\d+>> NullCheck [<<Arg>>] klass:SubclassA - /// CHECK-DAG: InvokeVirtual [<<NCArg>>] method_name:Super.hashCode + /// CHECK-DAG: InvokeVirtual [<<NCArg>>] method_name:java.lang.Object.hashCode public void testExplicitArgumentMoreSpecific(SubclassA obj) { // Inlining a method will build it with reference types from its signature, diff --git a/test/463-checker-boolean-simplifier/build b/test/463-checker-boolean-simplifier/build new file mode 100755 index 0000000000..49292c9ac1 --- /dev/null +++ b/test/463-checker-boolean-simplifier/build @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Copyright 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This checker test is incompatible with jack bytecode output, +# so force it to use javac/dx. +export USE_JACK=false +# Also disable desugar because it is missing in jack platform builds. +export DESUGAR=false + +./default-build "$@" diff --git a/test/463-checker-boolean-simplifier/smali/BooleanNotDx.smali b/test/463-checker-boolean-simplifier/smali/BooleanNotDx.smali deleted file mode 100644 index 765d0eb663..0000000000 --- a/test/463-checker-boolean-simplifier/smali/BooleanNotDx.smali +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright (C) 2016 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -.class public LBooleanNotSmali; -.super Ljava/lang/Object; - -# -# Elementary test negating a boolean. Verifies that blocks are merged and -# empty branches removed. -# - -## CHECK-START: boolean BooleanNotSmali.BooleanNot(boolean) select_generator (before) -## CHECK-DAG: <<Param:z\d+>> ParameterValue -## CHECK-DAG: <<Const0:i\d+>> IntConstant 0 -## CHECK-DAG: <<Const1:i\d+>> IntConstant 1 -## CHECK-DAG: If [<<Param>>] -## CHECK-DAG: <<Phi:i\d+>> Phi [<<Const0>>,<<Const1>>] -## CHECK-DAG: Return [<<Phi>>] - -## CHECK-START: boolean BooleanNotSmali.BooleanNot(boolean) select_generator (before) -## CHECK: Goto -## CHECK: Goto -## CHECK: Goto -## CHECK-NOT: Goto - -## CHECK-START: boolean BooleanNotSmali.BooleanNot(boolean) select_generator (after) -## CHECK-DAG: <<Param:z\d+>> ParameterValue -## CHECK-DAG: <<Const0:i\d+>> IntConstant 0 -## CHECK-DAG: <<Const1:i\d+>> IntConstant 1 -## CHECK-DAG: <<NotParam:i\d+>> Select [<<Const1>>,<<Const0>>,<<Param>>] -## CHECK-DAG: Return [<<NotParam>>] - -## CHECK-START: boolean BooleanNotSmali.BooleanNot(boolean) select_generator (after) -## CHECK-NOT: If -## CHECK-NOT: Phi - -## CHECK-START: boolean BooleanNotSmali.BooleanNot(boolean) select_generator (after) -## CHECK: Goto -## CHECK-NOT: Goto - -.method public static BooleanNot(Z)Z - .registers 2 - - if-eqz v1, :true_start - const/4 v0, 0x0 - -:return_start - return v0 - -:true_start - const/4 v0, 0x1 - goto :return_start - -.end method diff --git a/test/463-checker-boolean-simplifier/src/Main.java b/test/463-checker-boolean-simplifier/src/Main.java index 9368488056..d1d02cdfee 100644 --- a/test/463-checker-boolean-simplifier/src/Main.java +++ b/test/463-checker-boolean-simplifier/src/Main.java @@ -32,14 +32,42 @@ public class Main { } } - // Invoke a method written in smali that implements the boolean ! operator. This method - // uses the if/else pattern generated by dx (while Jack generates a different pattern). - // Since this method is in a smali-generated class, we invoke it through reflection. - public static boolean SmaliBooleanNot(boolean x) throws Exception { - Class<?> c = Class.forName("BooleanNotSmali"); - java.lang.reflect.Method method = c.getMethod("BooleanNot", boolean.class); - Object retValue = method.invoke(null, new Object[] { Boolean.valueOf(x) }); - return ((Boolean) retValue).booleanValue(); + /* + * Elementary test negating a boolean. Verifies that blocks are merged and + * empty branches removed. + */ + + /// CHECK-START: boolean Main.BooleanNot(boolean) select_generator (before) + /// CHECK-DAG: <<Param:z\d+>> ParameterValue + /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 + /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 + /// CHECK-DAG: If [<<Param>>] + /// CHECK-DAG: <<Phi:i\d+>> Phi [<<Const1>>,<<Const0>>] + /// CHECK-DAG: Return [<<Phi>>] + + /// CHECK-START: boolean Main.BooleanNot(boolean) select_generator (before) + /// CHECK: Goto + /// CHECK: Goto + /// CHECK: Goto + /// CHECK-NOT: Goto + + /// CHECK-START: boolean Main.BooleanNot(boolean) select_generator (after) + /// CHECK-DAG: <<Param:z\d+>> ParameterValue + /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 + /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 + /// CHECK-DAG: <<NotParam:i\d+>> Select [<<Const1>>,<<Const0>>,<<Param>>] + /// CHECK-DAG: Return [<<NotParam>>] + + /// CHECK-START: boolean Main.BooleanNot(boolean) select_generator (after) + /// CHECK-NOT: If + /// CHECK-NOT: Phi + + /// CHECK-START: boolean Main.BooleanNot(boolean) select_generator (after) + /// CHECK: Goto + /// CHECK-NOT: Goto + + public static boolean BooleanNot(boolean x) { + return !x; } /* @@ -157,7 +185,11 @@ public class Main { /// CHECK-NOT: BooleanNot public static int NegatedCondition(boolean x) { - return (x != false) ? 42 : 43; + if (x != false) { + return 42; + } else { + return 43; + } } /// CHECK-START: int Main.SimpleTrueBlock(boolean, int) select_generator (after) @@ -221,7 +253,13 @@ public class Main { /// CHECK-DAG: Return [<<Select123>>] public static int ThreeBlocks(boolean x, boolean y) { - return x ? 1 : (y ? 2 : 3); + if (x) { + return 1; + } else if (y) { + return 2; + } else { + return 3; + } } /// CHECK-START: int Main.MultiplePhis() select_generator (before) @@ -254,10 +292,8 @@ public class Main { while (y++ < 10) { if (y > 1) { x = 13; - continue; } else { x = 42; - continue; } } return x; @@ -330,8 +366,8 @@ public class Main { } public static void main(String[] args) throws Exception { - assertBoolEquals(false, SmaliBooleanNot(true)); - assertBoolEquals(true, SmaliBooleanNot(false)); + assertBoolEquals(false, BooleanNot(true)); + assertBoolEquals(true, BooleanNot(false)); assertBoolEquals(true, GreaterThan(10, 5)); assertBoolEquals(false, GreaterThan(10, 10)); assertBoolEquals(false, GreaterThan(5, 10)); diff --git a/test/537-checker-inline-and-unverified/build b/test/537-checker-inline-and-unverified/build new file mode 100755 index 0000000000..49292c9ac1 --- /dev/null +++ b/test/537-checker-inline-and-unverified/build @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Copyright 2017 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This checker test is incompatible with jack bytecode output, +# so force it to use javac/dx. +export USE_JACK=false +# Also disable desugar because it is missing in jack platform builds. +export DESUGAR=false + +./default-build "$@" diff --git a/test/537-checker-inline-and-unverified/src/Main.java b/test/537-checker-inline-and-unverified/src/Main.java index b9d5fc98cc..bdc14b027c 100644 --- a/test/537-checker-inline-and-unverified/src/Main.java +++ b/test/537-checker-inline-and-unverified/src/Main.java @@ -45,14 +45,12 @@ public class Main { } public static boolean $opt$noinline$testNoInline() { - boolean result = true; try { - result = (null instanceof InaccessibleClass); - throw new Error("Unreachable"); + return null instanceof InaccessibleClass; } catch (IllegalAccessError e) { // expected } - return result; + return false; } public static boolean $opt$inline$testInline() { |