diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2017-09-21 05:02:55 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-09-21 05:02:55 +0000 |
commit | 02999bcf7475a82061b076a9ca748d5ae42ea42b (patch) | |
tree | abe9a011d33cbf490d7bb8d1533e97e32c9c7574 | |
parent | fffd063c9750e43921124d97d1874cc6462f6203 (diff) | |
parent | a2047716fba7f844faad68d57b0350a945f06de5 (diff) | |
download | art-02999bcf7475a82061b076a9ca748d5ae42ea42b.tar.gz |
Fix region space when used with SetLengthToUsableSizeVisitor. am: 69ddc6dada
am: a2047716fb
Change-Id: Ic3eaec3645e891eb3e36d5b73c989ace227fa768
-rw-r--r-- | test/659-unpadded-array/src/Main.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/659-unpadded-array/src/Main.java b/test/659-unpadded-array/src/Main.java new file mode 100644 index 0000000000..80fd6e2f6f --- /dev/null +++ b/test/659-unpadded-array/src/Main.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 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. + */ + +import dalvik.system.VMRuntime; + +public class Main { + public static void main(String[] args) { + // Call our optimization API, we used to have a bug in the RegionSpace on large + // objects allocated through it. + Object[] o = (Object[]) VMRuntime.getRuntime().newUnpaddedArray(Object.class, 70000); + + // Make the test run for 30 seconds to be less dependent on GC heuristics. + long time = System.currentTimeMillis(); + int i = 1; + do { + allocateIntArray(i); + for (int j = 0; j < o.length; j++) { + if (o[j] != null) { + // Just print, not throw, to get into "interesting" issues (eg the first + // element that will not be null is the class of the object, the second is + // actually the first element of the int array). + System.out.println("Unexpected value: " + o[j]); + } + } + if (i < 100000) { + i++; + } else { + i = 0; + } + } while (System.currentTimeMillis() - time < 30000); + } + + static void allocateIntArray(int i) { + int[] intArray = new int[i]; + for (int j = 0; j < intArray.length; j++) { + intArray[j] = 1; + } + } +} |