diff options
| author | 2017-08-04 21:10:10 +0000 | |
|---|---|---|
| committer | 2017-08-04 21:10:10 +0000 | |
| commit | 443dbfcf39743f4fd5f1c517a28326ceb97136af (patch) | |
| tree | 758d932e55737edebbe9f65dc1475b2524fa5b51 | |
| parent | 2aa1d0b4b3eb4805ddaf6516015b9d2393707000 (diff) | |
| parent | 47863bbf4ffe4c52bbe68076706f421b3a873814 (diff) | |
Merge "Fix CC handling for no large object space case"
| -rw-r--r-- | runtime/gc/collector/concurrent_copying.cc | 27 | ||||
| -rw-r--r-- | test/1338-gc-no-los/expected.txt | 1 | ||||
| -rw-r--r-- | test/1338-gc-no-los/info.txt | 1 | ||||
| -rwxr-xr-x | test/1338-gc-no-los/run | 16 | ||||
| -rw-r--r-- | test/1338-gc-no-los/src-art/Main.java | 39 |
5 files changed, 74 insertions, 10 deletions
diff --git a/runtime/gc/collector/concurrent_copying.cc b/runtime/gc/collector/concurrent_copying.cc index 9d672b1d34..9b24885f53 100644 --- a/runtime/gc/collector/concurrent_copying.cc +++ b/runtime/gc/collector/concurrent_copying.cc @@ -2431,24 +2431,31 @@ mirror::Object* ConcurrentCopying::IsMarked(mirror::Object* from_ref) { // Non-immune non-moving space. Use the mark bitmap. accounting::ContinuousSpaceBitmap* mark_bitmap = heap_mark_bitmap_->GetContinuousSpaceBitmap(from_ref); - accounting::LargeObjectBitmap* los_bitmap = - heap_mark_bitmap_->GetLargeObjectBitmap(from_ref); - CHECK(los_bitmap != nullptr) << "LOS bitmap covers the entire address range"; bool is_los = mark_bitmap == nullptr; if (!is_los && mark_bitmap->Test(from_ref)) { // Already marked. to_ref = from_ref; - } else if (is_los && los_bitmap->Test(from_ref)) { - // Already marked in LOS. - to_ref = from_ref; } else { - // Not marked. - if (IsOnAllocStack(from_ref)) { - // If on the allocation stack, it's considered marked. + accounting::LargeObjectBitmap* los_bitmap = + heap_mark_bitmap_->GetLargeObjectBitmap(from_ref); + // We may not have a large object space for dex2oat, don't assume it exists. + if (los_bitmap == nullptr) { + CHECK(heap_->GetLargeObjectsSpace() == nullptr) + << "LOS bitmap covers the entire address range " << from_ref + << " " << heap_->DumpSpaces(); + } + if (los_bitmap != nullptr && is_los && los_bitmap->Test(from_ref)) { + // Already marked in LOS. to_ref = from_ref; } else { // Not marked. - to_ref = nullptr; + if (IsOnAllocStack(from_ref)) { + // If on the allocation stack, it's considered marked. + to_ref = from_ref; + } else { + // Not marked. + to_ref = nullptr; + } } } } diff --git a/test/1338-gc-no-los/expected.txt b/test/1338-gc-no-los/expected.txt new file mode 100644 index 0000000000..36bec43b8b --- /dev/null +++ b/test/1338-gc-no-los/expected.txt @@ -0,0 +1 @@ +131072 200 true diff --git a/test/1338-gc-no-los/info.txt b/test/1338-gc-no-los/info.txt new file mode 100644 index 0000000000..2e27357b80 --- /dev/null +++ b/test/1338-gc-no-los/info.txt @@ -0,0 +1 @@ +Test that the GC works with no large object space. Regression test for b/64393515.
\ No newline at end of file diff --git a/test/1338-gc-no-los/run b/test/1338-gc-no-los/run new file mode 100755 index 0000000000..f3c43fbce6 --- /dev/null +++ b/test/1338-gc-no-los/run @@ -0,0 +1,16 @@ +#!/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. +./default-run "$@" --runtime-option -XX:LargeObjectSpace=disabled diff --git a/test/1338-gc-no-los/src-art/Main.java b/test/1338-gc-no-los/src-art/Main.java new file mode 100644 index 0000000000..662fa7e610 --- /dev/null +++ b/test/1338-gc-no-los/src-art/Main.java @@ -0,0 +1,39 @@ +/* + * 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; +import java.lang.ref.WeakReference; +import java.lang.reflect.Method; + +public class Main { + public static void main(String[] args) { + try { + // Allocate a large object. + byte[] arr = new byte[128 * 1024]; + // Allocate a non movable object. + byte[] arr2 = (byte[])VMRuntime.getRuntime().newNonMovableArray(Byte.TYPE, 200); + // Put the array in a weak reference so that IsMarked is called by the GC. + WeakReference weakRef = new WeakReference(arr2); + // Do a GC. + Runtime.getRuntime().gc(); + arr[0] = 1; + arr2[0] = 1; + System.out.println(arr.length + " " + arr2.length + " " + (weakRef.get() != null)); + } catch (Exception e) { + System.out.println(e); + } + } +} |