diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2014-11-06 08:59:20 +0000 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2014-11-07 15:32:37 +0000 |
commit | 6f5c41f9e409bc4da53b5d7c385202255e391e72 (patch) | |
tree | bea48b3f23fdac7d566dd3b32dde1f86014b5a02 /test/422-instanceof | |
parent | 86fe4e41720cab85e3e40c45c0436521e56b25d5 (diff) | |
download | art-6f5c41f9e409bc4da53b5d7c385202255e391e72.zip art-6f5c41f9e409bc4da53b5d7c385202255e391e72.tar.gz art-6f5c41f9e409bc4da53b5d7c385202255e391e72.tar.bz2 |
Implement instanceof in optimizing.
- Only fast-path for now: null or same class.
- Use pQuickInstanceofNonTrivial for slow path.
Change-Id: Ic5196b94bef792f081f3cb4d15157058e1381e6b
Diffstat (limited to 'test/422-instanceof')
-rw-r--r-- | test/422-instanceof/expected.txt | 0 | ||||
-rw-r--r-- | test/422-instanceof/info.txt | 1 | ||||
-rw-r--r-- | test/422-instanceof/src/Main.java | 70 |
3 files changed, 71 insertions, 0 deletions
diff --git a/test/422-instanceof/expected.txt b/test/422-instanceof/expected.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/422-instanceof/expected.txt diff --git a/test/422-instanceof/info.txt b/test/422-instanceof/info.txt new file mode 100644 index 0000000..b2f7ff1 --- /dev/null +++ b/test/422-instanceof/info.txt @@ -0,0 +1 @@ +Tests for instanceof bytecode. diff --git a/test/422-instanceof/src/Main.java b/test/422-instanceof/src/Main.java new file mode 100644 index 0000000..307c987 --- /dev/null +++ b/test/422-instanceof/src/Main.java @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2014 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. + */ + +public class Main { + public static Object a; + + public static void assertTrue(boolean value) { + if (!value) { + throw new Error("Wrong result"); + } + } + + public static void assertFalse(boolean value) { + if (value) { + throw new Error("Wrong result"); + } + } + + public static boolean $opt$InstanceOfMain() { + return a instanceof Main; + } + + public static boolean $opt$InstanceOfFinalClass() { + return a instanceof FinalClass; + } + + public static void main(String[] args) { + $opt$TestMain(); + $opt$TestFinalClass(); + } + + public static void $opt$TestMain() { + a = new Main(); + assertTrue($opt$InstanceOfMain()); + a = null; + assertFalse($opt$InstanceOfMain()); + a = new MainChild(); + assertTrue($opt$InstanceOfMain()); + a = new Object(); + assertFalse($opt$InstanceOfMain()); + } + + public static void $opt$TestFinalClass() { + a = new FinalClass(); + assertTrue($opt$InstanceOfFinalClass()); + a = null; + assertFalse($opt$InstanceOfFinalClass()); + a = new Main(); + assertFalse($opt$InstanceOfFinalClass()); + a = new Object(); + assertFalse($opt$InstanceOfFinalClass()); + } + + static class MainChild extends Main {} + + static final class FinalClass {} +} |