diff options
author | David Brazdil <dbrazdil@google.com> | 2015-06-17 18:20:52 +0100 |
---|---|---|
committer | David Brazdil <dbrazdil@google.com> | 2015-06-18 17:08:13 +0100 |
commit | df75bca6bd100ca9c2c395b1b8d2f8a871ab2c62 (patch) | |
tree | b83e5d90f517e3d70cff4c35a38c4c84608084f5 /test | |
parent | a8b41003a717ecf399b890c18e9b0df49f55472f (diff) | |
download | art-df75bca6bd100ca9c2c395b1b8d2f8a871ab2c62.tar.gz art-df75bca6bd100ca9c2c395b1b8d2f8a871ab2c62.tar.bz2 art-df75bca6bd100ca9c2c395b1b8d2f8a871ab2c62.zip |
ART: Allow PackedSwitch instructions with zero targets
Optimizing and the interpreter wrongly assumed that a PackedSwitch
always has at least one target. This patch removes the corresponding
DCHECKs and adds a regression test case.
This is a resubmission of CL I32b7033ed38de6f1d1a6ee5d5bf12f3a47c9b37e
Bug: 21863783
Change-Id: I04e6e124bdd16591ba27c79490e6ce183c36b691
(cherry picked from commit 2ef645ba50544b879a82ea30e606f18c9af98917)
Diffstat (limited to 'test')
-rw-r--r-- | test/501-regression-packed-switch/expected.txt | 0 | ||||
-rw-r--r-- | test/501-regression-packed-switch/info.txt | 2 | ||||
-rw-r--r-- | test/501-regression-packed-switch/smali/Test.smali | 29 | ||||
-rw-r--r-- | test/501-regression-packed-switch/src/Main.java | 33 |
4 files changed, 64 insertions, 0 deletions
diff --git a/test/501-regression-packed-switch/expected.txt b/test/501-regression-packed-switch/expected.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/501-regression-packed-switch/expected.txt diff --git a/test/501-regression-packed-switch/info.txt b/test/501-regression-packed-switch/info.txt new file mode 100644 index 0000000000..fbd93fa815 --- /dev/null +++ b/test/501-regression-packed-switch/info.txt @@ -0,0 +1,2 @@ +Regression test for the interpreter and optimizing's builder which used +to trip when compiled code contained a packed switch with no targets. diff --git a/test/501-regression-packed-switch/smali/Test.smali b/test/501-regression-packed-switch/smali/Test.smali new file mode 100644 index 0000000000..8756ed5f23 --- /dev/null +++ b/test/501-regression-packed-switch/smali/Test.smali @@ -0,0 +1,29 @@ +# +# Copyright (C) 2015 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 LTest; + +.super Ljava/lang/Object; + +.method public static EmptyPackedSwitch(I)I + .registers 1 + packed-switch v0, :pswitch_data_6a + const/4 v0, 0x5 + return v0 + + :pswitch_data_6a + .packed-switch 0x0 + .end packed-switch +.end method diff --git a/test/501-regression-packed-switch/src/Main.java b/test/501-regression-packed-switch/src/Main.java new file mode 100644 index 0000000000..b80bc62c50 --- /dev/null +++ b/test/501-regression-packed-switch/src/Main.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2015 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. + */ + +import java.lang.reflect.Method; +import java.lang.reflect.Type; + +public class Main { + + // Workaround for b/18051191. + class InnerClass {} + + public static void main(String args[]) throws Exception { + Class<?> c = Class.forName("Test"); + Method m = c.getMethod("EmptyPackedSwitch", new Class[] { int.class }); + Integer result = (Integer) m.invoke(null, new Integer(42)); + if (result != 5) { + throw new Error("Expected 5, got " + result); + } + } +} |