summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2017-05-30 18:41:34 -0700
committer Andreas Gampe <agampe@google.com> 2017-05-30 20:44:33 -0700
commitd49012909625c3bf87bf51138fe79315ce1b1bdc (patch)
tree349ef2cdcb7255d042244046601bd0fd5eb3a092
parent726e1793d3f54470705e5b84e7860074e029b0ed (diff)
ART: Clean up heap headers
Use more forward declarations for accounting structures and spaces. Factor out structs to reduce header surface. Remove heap include where unnecessary. Fix up transitive users. Move some debug-only code out of line. Test: m test-art-host Change-Id: I16db4aaa803f39e155ce6e1b0778b7e393dcbb17
-rw-r--r--compiler/debug/elf_debug_writer.cc1
-rw-r--r--compiler/image_writer.h5
-rw-r--r--compiler/optimizing/code_generator_arm64.cc1
-rw-r--r--compiler/optimizing/code_generator_x86.cc1
-rw-r--r--compiler/optimizing/code_generator_x86_64.cc1
-rw-r--r--runtime/art_field-inl.h5
-rw-r--r--runtime/art_field.h4
-rw-r--r--runtime/art_method-inl.h1
-rw-r--r--runtime/asm_support.h1
-rw-r--r--runtime/base/arena_allocator.cc5
-rw-r--r--runtime/base/timing_logger.cc1
-rw-r--r--runtime/cha.h3
-rw-r--r--runtime/dex_file_test.cc2
-rw-r--r--runtime/gc/accounting/card_table.cc2
-rw-r--r--runtime/gc/accounting/card_table.h8
-rw-r--r--runtime/gc/collector/concurrent_copying-inl.h3
-rw-r--r--runtime/gc/collector/concurrent_copying.h4
-rw-r--r--runtime/gc/collector/garbage_collector.h81
-rw-r--r--runtime/gc/collector/immune_spaces_test.cc2
-rw-r--r--runtime/gc/collector/iteration.h100
-rw-r--r--runtime/gc/collector/object_byte_pair.h44
-rw-r--r--runtime/gc/collector/sticky_mark_sweep.cc5
-rw-r--r--runtime/gc/heap-inl.h1
-rw-r--r--runtime/gc/heap.cc3
-rw-r--r--runtime/gc/heap.h16
-rw-r--r--runtime/gc/space/bump_pointer_space-inl.h12
-rw-r--r--runtime/gc/space/bump_pointer_space.cc8
-rw-r--r--runtime/gc/space/image_space.h1
-rw-r--r--runtime/gc/space/large_object_space.cc7
-rw-r--r--runtime/gc/space/region_space-inl.h14
-rw-r--r--runtime/gc/space/region_space.cc15
-rw-r--r--runtime/gc/space/region_space.h6
-rw-r--r--runtime/gc/space/rosalloc_space-inl.h36
-rw-r--r--runtime/gc/space/rosalloc_space.cc33
-rw-r--r--runtime/gc/space/space.cc1
-rw-r--r--runtime/gc/space/space.h3
-rw-r--r--runtime/indirect_reference_table-inl.h4
-rw-r--r--runtime/java_vm_ext.cc1
-rw-r--r--runtime/mem_map_test.cc2
-rw-r--r--runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc1
-rw-r--r--runtime/read_barrier-inl.h1
-rw-r--r--runtime/thread-inl.h6
-rw-r--r--runtime/thread.cc12
-rw-r--r--runtime/thread_list.cc1
-rw-r--r--runtime/thread_pool.cc1
-rw-r--r--test/597-deopt-new-string/deopt.cc1
46 files changed, 288 insertions, 178 deletions
diff --git a/compiler/debug/elf_debug_writer.cc b/compiler/debug/elf_debug_writer.cc
index d1c10a9246..7fa6e146c5 100644
--- a/compiler/debug/elf_debug_writer.cc
+++ b/compiler/debug/elf_debug_writer.cc
@@ -30,6 +30,7 @@
#include "debug/method_debug_info.h"
#include "elf_builder.h"
#include "linker/vector_output_stream.h"
+#include "oat.h"
namespace art {
namespace debug {
diff --git a/compiler/image_writer.h b/compiler/image_writer.h
index 39113c8143..a12d849f02 100644
--- a/compiler/image_writer.h
+++ b/compiler/image_writer.h
@@ -34,7 +34,6 @@
#include "base/length_prefixed_array.h"
#include "base/macros.h"
#include "driver/compiler_driver.h"
-#include "gc/space/space.h"
#include "image.h"
#include "lock_word.h"
#include "mem_map.h"
@@ -47,6 +46,10 @@
namespace art {
namespace gc {
+namespace accounting {
+template <size_t kAlignment> class SpaceBitmap;
+typedef SpaceBitmap<kObjectAlignment> ContinuousSpaceBitmap;
+} // namespace accounting
namespace space {
class ImageSpace;
} // namespace space
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc
index 096eb07074..7d9c61b76c 100644
--- a/compiler/optimizing/code_generator_arm64.cc
+++ b/compiler/optimizing/code_generator_arm64.cc
@@ -29,6 +29,7 @@
#include "linker/arm64/relative_patcher_arm64.h"
#include "mirror/array-inl.h"
#include "mirror/class-inl.h"
+#include "lock_word.h"
#include "offsets.h"
#include "thread.h"
#include "utils/arm64/assembler_arm64.h"
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc
index f3ec112548..317ca71136 100644
--- a/compiler/optimizing/code_generator_x86.cc
+++ b/compiler/optimizing/code_generator_x86.cc
@@ -26,6 +26,7 @@
#include "intrinsics_x86.h"
#include "mirror/array-inl.h"
#include "mirror/class-inl.h"
+#include "lock_word.h"
#include "thread.h"
#include "utils/assembler.h"
#include "utils/stack_checks.h"
diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc
index bf1c42ae8e..6b5e4d602d 100644
--- a/compiler/optimizing/code_generator_x86_64.cc
+++ b/compiler/optimizing/code_generator_x86_64.cc
@@ -23,6 +23,7 @@
#include "gc/accounting/card_table.h"
#include "intrinsics.h"
#include "intrinsics_x86_64.h"
+#include "lock_word.h"
#include "mirror/array-inl.h"
#include "mirror/class-inl.h"
#include "mirror/object_reference.h"
diff --git a/runtime/art_field-inl.h b/runtime/art_field-inl.h
index 0de0f02f9b..98002aed31 100644
--- a/runtime/art_field-inl.h
+++ b/runtime/art_field-inl.h
@@ -352,11 +352,6 @@ inline ObjPtr<mirror::String> ArtField::GetStringName(Thread* self, bool resolve
return name;
}
-template<typename RootVisitorType>
-inline void ArtField::VisitRoots(RootVisitorType& visitor) {
- visitor.VisitRoot(declaring_class_.AddressWithoutBarrier());
-}
-
template <typename Visitor>
inline void ArtField::UpdateObjects(const Visitor& visitor) {
ObjPtr<mirror::Class> old_class = DeclaringClassRoot().Read<kWithoutReadBarrier>();
diff --git a/runtime/art_field.h b/runtime/art_field.h
index 3789b0ce2f..5114578933 100644
--- a/runtime/art_field.h
+++ b/runtime/art_field.h
@@ -171,7 +171,9 @@ class ArtField FINAL {
// NO_THREAD_SAFETY_ANALYSIS since we don't know what the callback requires.
template<typename RootVisitorType>
- void VisitRoots(RootVisitorType& visitor) NO_THREAD_SAFETY_ANALYSIS;
+ ALWAYS_INLINE inline void VisitRoots(RootVisitorType& visitor) NO_THREAD_SAFETY_ANALYSIS {
+ visitor.VisitRoot(declaring_class_.AddressWithoutBarrier());
+ }
bool IsVolatile() REQUIRES_SHARED(Locks::mutator_lock_) {
return (GetAccessFlags() & kAccVolatile) != 0;
diff --git a/runtime/art_method-inl.h b/runtime/art_method-inl.h
index 59cd978a66..9d0bfdee5d 100644
--- a/runtime/art_method-inl.h
+++ b/runtime/art_method-inl.h
@@ -36,7 +36,6 @@
#include "oat.h"
#include "obj_ptr-inl.h"
#include "quick/quick_method_frame_info.h"
-#include "read_barrier-inl.h"
#include "runtime-inl.h"
#include "scoped_thread_state_change-inl.h"
#include "thread-inl.h"
diff --git a/runtime/asm_support.h b/runtime/asm_support.h
index 6d271ed380..fce6da4718 100644
--- a/runtime/asm_support.h
+++ b/runtime/asm_support.h
@@ -20,6 +20,7 @@
#if defined(__cplusplus)
#include "art_method.h"
#include "base/bit_utils.h"
+#include "gc/accounting/card_table.h"
#include "gc/allocator/rosalloc.h"
#include "gc/heap.h"
#include "jit/jit.h"
diff --git a/runtime/base/arena_allocator.cc b/runtime/base/arena_allocator.cc
index f672882254..99c310af8c 100644
--- a/runtime/base/arena_allocator.cc
+++ b/runtime/base/arena_allocator.cc
@@ -14,12 +14,15 @@
* limitations under the License.
*/
+#include "arena_allocator-inl.h"
+
+#include <sys/mman.h>
+
#include <algorithm>
#include <cstddef>
#include <iomanip>
#include <numeric>
-#include "arena_allocator-inl.h"
#include "logging.h"
#include "mem_map.h"
#include "mutex.h"
diff --git a/runtime/base/timing_logger.cc b/runtime/base/timing_logger.cc
index 9a0e0d02a6..06e2526294 100644
--- a/runtime/base/timing_logger.cc
+++ b/runtime/base/timing_logger.cc
@@ -24,6 +24,7 @@
#include "base/histogram-inl.h"
#include "base/systrace.h"
#include "base/time_utils.h"
+#include "gc/heap.h"
#include "thread-inl.h"
#include <cmath>
diff --git a/runtime/cha.h b/runtime/cha.h
index d9692a684e..81458db601 100644
--- a/runtime/cha.h
+++ b/runtime/cha.h
@@ -17,7 +17,6 @@
#ifndef ART_RUNTIME_CHA_H_
#define ART_RUNTIME_CHA_H_
-#include "art_method.h"
#include "base/enums.h"
#include "base/mutex.h"
#include "handle.h"
@@ -28,6 +27,8 @@
namespace art {
+class ArtMethod;
+
/**
* Class Hierarchy Analysis (CHA) tries to devirtualize virtual calls into
* direct calls based on the info generated by analyzing class hierarchies.
diff --git a/runtime/dex_file_test.cc b/runtime/dex_file_test.cc
index 6627550574..1d4507a9d6 100644
--- a/runtime/dex_file_test.cc
+++ b/runtime/dex_file_test.cc
@@ -16,6 +16,8 @@
#include "dex_file.h"
+#include <sys/mman.h>
+
#include <memory>
#include "base/stl_util.h"
diff --git a/runtime/gc/accounting/card_table.cc b/runtime/gc/accounting/card_table.cc
index 450659791d..01b5896650 100644
--- a/runtime/gc/accounting/card_table.cc
+++ b/runtime/gc/accounting/card_table.cc
@@ -16,6 +16,8 @@
#include "card_table.h"
+#include <sys/mman.h>
+
#include "base/logging.h"
#include "base/systrace.h"
#include "card_table-inl.h"
diff --git a/runtime/gc/accounting/card_table.h b/runtime/gc/accounting/card_table.h
index c3dd21f113..17acc763d1 100644
--- a/runtime/gc/accounting/card_table.h
+++ b/runtime/gc/accounting/card_table.h
@@ -155,6 +155,14 @@ class CardTable {
};
} // namespace accounting
+
+class AgeCardVisitor {
+ public:
+ uint8_t operator()(uint8_t card) const {
+ return (card == accounting::CardTable::kCardDirty) ? card - 1 : 0;
+ }
+};
+
} // namespace gc
} // namespace art
diff --git a/runtime/gc/collector/concurrent_copying-inl.h b/runtime/gc/collector/concurrent_copying-inl.h
index 3503973321..85a656ec51 100644
--- a/runtime/gc/collector/concurrent_copying-inl.h
+++ b/runtime/gc/collector/concurrent_copying-inl.h
@@ -19,11 +19,12 @@
#include "concurrent_copying.h"
+#include "gc/accounting/atomic_stack.h"
#include "gc/accounting/space_bitmap-inl.h"
#include "gc/heap.h"
#include "gc/space/region_space.h"
-#include "mirror/object-readbarrier-inl.h"
#include "lock_word.h"
+#include "mirror/object-readbarrier-inl.h"
namespace art {
namespace gc {
diff --git a/runtime/gc/collector/concurrent_copying.h b/runtime/gc/collector/concurrent_copying.h
index 377f4d30ba..f8ca8dba42 100644
--- a/runtime/gc/collector/concurrent_copying.h
+++ b/runtime/gc/collector/concurrent_copying.h
@@ -23,7 +23,6 @@
#include "jni.h"
#include "object_callbacks.h"
#include "offsets.h"
-#include "gc/accounting/space_bitmap.h"
#include "mirror/object.h"
#include "mirror/object_reference.h"
#include "safe_map.h"
@@ -40,6 +39,7 @@ namespace gc {
namespace accounting {
template<typename T> class AtomicStack;
typedef AtomicStack<mirror::Object> ObjectStack;
+ template <size_t kAlignment> class SpaceBitmap;
typedef SpaceBitmap<kObjectAlignment> ContinuousSpaceBitmap;
class HeapBitmap;
class ReadBarrierTable;
@@ -284,7 +284,7 @@ class ConcurrentCopying : public GarbageCollector {
bool is_active_; // True while the collection is ongoing.
bool is_asserting_to_space_invariant_; // True while asserting the to-space invariant.
ImmuneSpaces immune_spaces_;
- accounting::SpaceBitmap<kObjectAlignment>* region_space_bitmap_;
+ accounting::ContinuousSpaceBitmap* region_space_bitmap_;
// A cache of Heap::GetMarkBitmap().
accounting::HeapBitmap* heap_mark_bitmap_;
size_t live_stack_freeze_size_;
diff --git a/runtime/gc/collector/garbage_collector.h b/runtime/gc/collector/garbage_collector.h
index 14d049971f..dec206be30 100644
--- a/runtime/gc/collector/garbage_collector.h
+++ b/runtime/gc/collector/garbage_collector.h
@@ -27,6 +27,8 @@
#include "gc/gc_cause.h"
#include "gc_root.h"
#include "gc_type.h"
+#include "iteration.h"
+#include "object_byte_pair.h"
#include "object_callbacks.h"
namespace art {
@@ -43,85 +45,6 @@ class Heap;
namespace collector {
-struct ObjectBytePair {
- explicit ObjectBytePair(uint64_t num_objects = 0, int64_t num_bytes = 0)
- : objects(num_objects), bytes(num_bytes) {}
- void Add(const ObjectBytePair& other) {
- objects += other.objects;
- bytes += other.bytes;
- }
- // Number of objects which were freed.
- uint64_t objects;
- // Freed bytes are signed since the GC can free negative bytes if it promotes objects to a space
- // which has a larger allocation size.
- int64_t bytes;
-};
-
-// A information related single garbage collector iteration. Since we only ever have one GC running
-// at any given time, we can have a single iteration info.
-class Iteration {
- public:
- Iteration();
- // Returns how long the mutators were paused in nanoseconds.
- const std::vector<uint64_t>& GetPauseTimes() const {
- return pause_times_;
- }
- TimingLogger* GetTimings() {
- return &timings_;
- }
- // Returns how long the GC took to complete in nanoseconds.
- uint64_t GetDurationNs() const {
- return duration_ns_;
- }
- int64_t GetFreedBytes() const {
- return freed_.bytes;
- }
- int64_t GetFreedLargeObjectBytes() const {
- return freed_los_.bytes;
- }
- uint64_t GetFreedObjects() const {
- return freed_.objects;
- }
- uint64_t GetFreedLargeObjects() const {
- return freed_los_.objects;
- }
- uint64_t GetFreedRevokeBytes() const {
- return freed_bytes_revoke_;
- }
- void SetFreedRevoke(uint64_t freed) {
- freed_bytes_revoke_ = freed;
- }
- void Reset(GcCause gc_cause, bool clear_soft_references);
- // Returns the estimated throughput of the iteration.
- uint64_t GetEstimatedThroughput() const;
- bool GetClearSoftReferences() const {
- return clear_soft_references_;
- }
- void SetClearSoftReferences(bool clear_soft_references) {
- clear_soft_references_ = clear_soft_references;
- }
- GcCause GetGcCause() const {
- return gc_cause_;
- }
-
- private:
- void SetDurationNs(uint64_t duration) {
- duration_ns_ = duration;
- }
-
- GcCause gc_cause_;
- bool clear_soft_references_;
- uint64_t duration_ns_;
- TimingLogger timings_;
- ObjectBytePair freed_;
- ObjectBytePair freed_los_;
- uint64_t freed_bytes_revoke_; // see Heap::num_bytes_freed_revoke_.
- std::vector<uint64_t> pause_times_;
-
- friend class GarbageCollector;
- DISALLOW_COPY_AND_ASSIGN(Iteration);
-};
-
class GarbageCollector : public RootVisitor, public IsMarkedVisitor, public MarkObjectVisitor {
public:
class SCOPED_LOCKABLE ScopedPause {
diff --git a/runtime/gc/collector/immune_spaces_test.cc b/runtime/gc/collector/immune_spaces_test.cc
index cf93ec614d..acb4f575c8 100644
--- a/runtime/gc/collector/immune_spaces_test.cc
+++ b/runtime/gc/collector/immune_spaces_test.cc
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#include <sys/mman.h>
+
#include "common_runtime_test.h"
#include "gc/collector/immune_spaces.h"
#include "gc/space/image_space.h"
diff --git a/runtime/gc/collector/iteration.h b/runtime/gc/collector/iteration.h
new file mode 100644
index 0000000000..fbe41664f7
--- /dev/null
+++ b/runtime/gc/collector/iteration.h
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#ifndef ART_RUNTIME_GC_COLLECTOR_ITERATION_H_
+#define ART_RUNTIME_GC_COLLECTOR_ITERATION_H_
+
+#include <inttypes.h>
+#include <vector>
+
+#include "android-base/macros.h"
+#include "base/timing_logger.h"
+#include "object_byte_pair.h"
+
+namespace art {
+namespace gc {
+namespace collector {
+
+// A information related single garbage collector iteration. Since we only ever have one GC running
+// at any given time, we can have a single iteration info.
+class Iteration {
+ public:
+ Iteration();
+ // Returns how long the mutators were paused in nanoseconds.
+ const std::vector<uint64_t>& GetPauseTimes() const {
+ return pause_times_;
+ }
+ TimingLogger* GetTimings() {
+ return &timings_;
+ }
+ // Returns how long the GC took to complete in nanoseconds.
+ uint64_t GetDurationNs() const {
+ return duration_ns_;
+ }
+ int64_t GetFreedBytes() const {
+ return freed_.bytes;
+ }
+ int64_t GetFreedLargeObjectBytes() const {
+ return freed_los_.bytes;
+ }
+ uint64_t GetFreedObjects() const {
+ return freed_.objects;
+ }
+ uint64_t GetFreedLargeObjects() const {
+ return freed_los_.objects;
+ }
+ uint64_t GetFreedRevokeBytes() const {
+ return freed_bytes_revoke_;
+ }
+ void SetFreedRevoke(uint64_t freed) {
+ freed_bytes_revoke_ = freed;
+ }
+ void Reset(GcCause gc_cause, bool clear_soft_references);
+ // Returns the estimated throughput of the iteration.
+ uint64_t GetEstimatedThroughput() const;
+ bool GetClearSoftReferences() const {
+ return clear_soft_references_;
+ }
+ void SetClearSoftReferences(bool clear_soft_references) {
+ clear_soft_references_ = clear_soft_references;
+ }
+ GcCause GetGcCause() const {
+ return gc_cause_;
+ }
+
+ private:
+ void SetDurationNs(uint64_t duration) {
+ duration_ns_ = duration;
+ }
+
+ GcCause gc_cause_;
+ bool clear_soft_references_;
+ uint64_t duration_ns_;
+ TimingLogger timings_;
+ ObjectBytePair freed_;
+ ObjectBytePair freed_los_;
+ uint64_t freed_bytes_revoke_; // see Heap::num_bytes_freed_revoke_.
+ std::vector<uint64_t> pause_times_;
+
+ friend class GarbageCollector;
+ DISALLOW_COPY_AND_ASSIGN(Iteration);
+};
+
+} // namespace collector
+} // namespace gc
+} // namespace art
+
+#endif // ART_RUNTIME_GC_COLLECTOR_ITERATION_H_
diff --git a/runtime/gc/collector/object_byte_pair.h b/runtime/gc/collector/object_byte_pair.h
new file mode 100644
index 0000000000..16ef06b6dd
--- /dev/null
+++ b/runtime/gc/collector/object_byte_pair.h
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2012 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.
+ */
+
+#ifndef ART_RUNTIME_GC_COLLECTOR_OBJECT_BYTE_PAIR_H_
+#define ART_RUNTIME_GC_COLLECTOR_OBJECT_BYTE_PAIR_H_
+
+#include <inttypes.h>
+
+namespace art {
+namespace gc {
+namespace collector {
+
+struct ObjectBytePair {
+ explicit ObjectBytePair(uint64_t num_objects = 0, int64_t num_bytes = 0)
+ : objects(num_objects), bytes(num_bytes) {}
+ void Add(const ObjectBytePair& other) {
+ objects += other.objects;
+ bytes += other.bytes;
+ }
+ // Number of objects which were freed.
+ uint64_t objects;
+ // Freed bytes are signed since the GC can free negative bytes if it promotes objects to a space
+ // which has a larger allocation size.
+ int64_t bytes;
+};
+
+} // namespace collector
+} // namespace gc
+} // namespace art
+
+#endif // ART_RUNTIME_GC_COLLECTOR_OBJECT_BYTE_PAIR_H_
diff --git a/runtime/gc/collector/sticky_mark_sweep.cc b/runtime/gc/collector/sticky_mark_sweep.cc
index a2dbe3f7a0..428e387c21 100644
--- a/runtime/gc/collector/sticky_mark_sweep.cc
+++ b/runtime/gc/collector/sticky_mark_sweep.cc
@@ -14,10 +14,13 @@
* limitations under the License.
*/
+#include "sticky_mark_sweep.h"
+
+#include "gc/accounting/atomic_stack.h"
+#include "gc/accounting/card_table.h"
#include "gc/heap.h"
#include "gc/space/large_object_space.h"
#include "gc/space/space-inl.h"
-#include "sticky_mark_sweep.h"
#include "thread-inl.h"
namespace art {
diff --git a/runtime/gc/heap-inl.h b/runtime/gc/heap-inl.h
index 79086da703..060f12db33 100644
--- a/runtime/gc/heap-inl.h
+++ b/runtime/gc/heap-inl.h
@@ -21,6 +21,7 @@
#include "allocation_listener.h"
#include "base/time_utils.h"
+#include "gc/accounting/atomic_stack.h"
#include "gc/accounting/card_table-inl.h"
#include "gc/allocation_record.h"
#include "gc/collector/semi_space.h"
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index df097a0e60..1af3b57830 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -37,10 +37,10 @@
#include "cutils/sched_policy.h"
#include "debugger.h"
#include "dex_file-inl.h"
-#include "gc/accounting/atomic_stack.h"
#include "gc/accounting/card_table-inl.h"
#include "gc/accounting/heap_bitmap-inl.h"
#include "gc/accounting/mod_union_table-inl.h"
+#include "gc/accounting/read_barrier_table.h"
#include "gc/accounting/remembered_set.h"
#include "gc/accounting/space_bitmap-inl.h"
#include "gc/collector/concurrent_copying.h"
@@ -63,6 +63,7 @@
#include "gc/verification.h"
#include "entrypoints/quick/quick_alloc_entrypoints.h"
#include "gc_pause_listener.h"
+#include "gc_root.h"
#include "heap-inl.h"
#include "image.h"
#include "intern_table.h"
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 72871785e5..24f4ce29e2 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -26,11 +26,9 @@
#include "arch/instruction_set.h"
#include "atomic.h"
#include "base/time_utils.h"
-#include "gc/accounting/atomic_stack.h"
-#include "gc/accounting/card_table.h"
-#include "gc/accounting/read_barrier_table.h"
#include "gc/gc_cause.h"
#include "gc/collector/gc_type.h"
+#include "gc/collector/iteration.h"
#include "gc/collector_type.h"
#include "gc/space/large_object_space.h"
#include "globals.h"
@@ -46,6 +44,7 @@ namespace art {
class ConditionVariable;
class Mutex;
+class RootVisitor;
class StackVisitor;
class Thread;
class ThreadPool;
@@ -67,8 +66,12 @@ class TaskProcessor;
class Verification;
namespace accounting {
+ template <typename T> class AtomicStack;
+ typedef AtomicStack<mirror::Object> ObjectStack;
+ class CardTable;
class HeapBitmap;
class ModUnionTable;
+ class ReadBarrierTable;
class RememberedSet;
} // namespace accounting
@@ -99,13 +102,6 @@ namespace space {
class ZygoteSpace;
} // namespace space
-class AgeCardVisitor {
- public:
- uint8_t operator()(uint8_t card) const {
- return (card == accounting::CardTable::kCardDirty) ? card - 1 : 0;
- }
-};
-
enum HomogeneousSpaceCompactResult {
// Success.
kSuccess,
diff --git a/runtime/gc/space/bump_pointer_space-inl.h b/runtime/gc/space/bump_pointer_space-inl.h
index 45cea5a48c..1509bb027d 100644
--- a/runtime/gc/space/bump_pointer_space-inl.h
+++ b/runtime/gc/space/bump_pointer_space-inl.h
@@ -17,9 +17,10 @@
#ifndef ART_RUNTIME_GC_SPACE_BUMP_POINTER_SPACE_INL_H_
#define ART_RUNTIME_GC_SPACE_BUMP_POINTER_SPACE_INL_H_
-#include "base/bit_utils.h"
#include "bump_pointer_space.h"
+#include "base/bit_utils.h"
+
namespace art {
namespace gc {
namespace space {
@@ -86,15 +87,6 @@ inline mirror::Object* BumpPointerSpace::AllocNonvirtual(size_t num_bytes) {
return ret;
}
-inline size_t BumpPointerSpace::AllocationSizeNonvirtual(mirror::Object* obj, size_t* usable_size)
- REQUIRES_SHARED(Locks::mutator_lock_) {
- size_t num_bytes = obj->SizeOf();
- if (usable_size != nullptr) {
- *usable_size = RoundUp(num_bytes, kAlignment);
- }
- return num_bytes;
-}
-
} // namespace space
} // namespace gc
} // namespace art
diff --git a/runtime/gc/space/bump_pointer_space.cc b/runtime/gc/space/bump_pointer_space.cc
index 426b33218c..bb1ede15f2 100644
--- a/runtime/gc/space/bump_pointer_space.cc
+++ b/runtime/gc/space/bump_pointer_space.cc
@@ -271,6 +271,14 @@ void BumpPointerSpace::LogFragmentationAllocFailure(std::ostream& os,
// Caller's job to print failed_alloc_bytes.
}
+size_t BumpPointerSpace::AllocationSizeNonvirtual(mirror::Object* obj, size_t* usable_size) {
+ size_t num_bytes = obj->SizeOf();
+ if (usable_size != nullptr) {
+ *usable_size = RoundUp(num_bytes, kAlignment);
+ }
+ return num_bytes;
+}
+
} // namespace space
} // namespace gc
} // namespace art
diff --git a/runtime/gc/space/image_space.h b/runtime/gc/space/image_space.h
index a4065bf6d6..3383d6b383 100644
--- a/runtime/gc/space/image_space.h
+++ b/runtime/gc/space/image_space.h
@@ -19,6 +19,7 @@
#include "arch/instruction_set.h"
#include "gc/accounting/space_bitmap.h"
+#include "image.h"
#include "space.h"
namespace art {
diff --git a/runtime/gc/space/large_object_space.cc b/runtime/gc/space/large_object_space.cc
index 3988073de8..0f856b8ecc 100644
--- a/runtime/gc/space/large_object_space.cc
+++ b/runtime/gc/space/large_object_space.cc
@@ -16,14 +16,17 @@
#include "large_object_space.h"
+#include <sys/mman.h>
+
#include <memory>
-#include "gc/accounting/heap_bitmap-inl.h"
-#include "gc/accounting/space_bitmap-inl.h"
#include "base/logging.h"
#include "base/memory_tool.h"
#include "base/mutex-inl.h"
#include "base/stl_util.h"
+#include "gc/accounting/heap_bitmap-inl.h"
+#include "gc/accounting/space_bitmap-inl.h"
+#include "gc/heap.h"
#include "image.h"
#include "os.h"
#include "scoped_thread_state_change-inl.h"
diff --git a/runtime/gc/space/region_space-inl.h b/runtime/gc/space/region_space-inl.h
index 3910a03342..61161602ce 100644
--- a/runtime/gc/space/region_space-inl.h
+++ b/runtime/gc/space/region_space-inl.h
@@ -138,20 +138,6 @@ inline mirror::Object* RegionSpace::Region::Alloc(size_t num_bytes, size_t* byte
return reinterpret_cast<mirror::Object*>(old_top);
}
-inline size_t RegionSpace::AllocationSizeNonvirtual(mirror::Object* obj, size_t* usable_size) {
- size_t num_bytes = obj->SizeOf();
- if (usable_size != nullptr) {
- if (LIKELY(num_bytes <= kRegionSize)) {
- DCHECK(RefToRegion(obj)->IsAllocated());
- *usable_size = RoundUp(num_bytes, kAlignment);
- } else {
- DCHECK(RefToRegion(obj)->IsLarge());
- *usable_size = RoundUp(num_bytes, kRegionSize);
- }
- }
- return num_bytes;
-}
-
template<RegionSpace::RegionType kRegionType>
uint64_t RegionSpace::GetBytesAllocatedInternal() {
uint64_t bytes = 0;
diff --git a/runtime/gc/space/region_space.cc b/runtime/gc/space/region_space.cc
index 09b4a3a183..27f30e0719 100644
--- a/runtime/gc/space/region_space.cc
+++ b/runtime/gc/space/region_space.cc
@@ -16,6 +16,7 @@
#include "bump_pointer_space.h"
#include "bump_pointer_space-inl.h"
+#include "gc/accounting/read_barrier_table.h"
#include "mirror/object-inl.h"
#include "mirror/class-inl.h"
#include "thread_list.h"
@@ -511,6 +512,20 @@ void RegionSpace::Region::Dump(std::ostream& os) const {
<< " is_newly_allocated=" << is_newly_allocated_ << " is_a_tlab=" << is_a_tlab_ << " thread=" << thread_ << "\n";
}
+size_t RegionSpace::AllocationSizeNonvirtual(mirror::Object* obj, size_t* usable_size) {
+ size_t num_bytes = obj->SizeOf();
+ if (usable_size != nullptr) {
+ if (LIKELY(num_bytes <= kRegionSize)) {
+ DCHECK(RefToRegion(obj)->IsAllocated());
+ *usable_size = RoundUp(num_bytes, kAlignment);
+ } else {
+ DCHECK(RefToRegion(obj)->IsLarge());
+ *usable_size = RoundUp(num_bytes, kRegionSize);
+ }
+ }
+ return num_bytes;
+}
+
} // namespace space
} // namespace gc
} // namespace art
diff --git a/runtime/gc/space/region_space.h b/runtime/gc/space/region_space.h
index 80eeccaf42..1d1d27e0f4 100644
--- a/runtime/gc/space/region_space.h
+++ b/runtime/gc/space/region_space.h
@@ -17,13 +17,17 @@
#ifndef ART_RUNTIME_GC_SPACE_REGION_SPACE_H_
#define ART_RUNTIME_GC_SPACE_REGION_SPACE_H_
-#include "gc/accounting/read_barrier_table.h"
#include "object_callbacks.h"
#include "space.h"
#include "thread.h"
namespace art {
namespace gc {
+
+namespace accounting {
+class ReadBarrierTable;
+} // namespace accounting
+
namespace space {
// A space that consists of equal-sized regions.
diff --git a/runtime/gc/space/rosalloc_space-inl.h b/runtime/gc/space/rosalloc_space-inl.h
index 8bff2b4c0f..09aa7cf8a3 100644
--- a/runtime/gc/space/rosalloc_space-inl.h
+++ b/runtime/gc/space/rosalloc_space-inl.h
@@ -17,49 +17,17 @@
#ifndef ART_RUNTIME_GC_SPACE_ROSALLOC_SPACE_INL_H_
#define ART_RUNTIME_GC_SPACE_ROSALLOC_SPACE_INL_H_
+#include "rosalloc_space.h"
+
#include "base/memory_tool.h"
#include "gc/allocator/rosalloc-inl.h"
#include "gc/space/memory_tool_settings.h"
-#include "rosalloc_space.h"
#include "thread.h"
namespace art {
namespace gc {
namespace space {
-template<bool kMaybeIsRunningOnMemoryTool>
-inline size_t RosAllocSpace::AllocationSizeNonvirtual(mirror::Object* obj, size_t* usable_size) {
- // obj is a valid object. Use its class in the header to get the size.
- // Don't use verification since the object may be dead if we are sweeping.
- size_t size = obj->SizeOf<kVerifyNone>();
- bool add_redzones = false;
- if (kMaybeIsRunningOnMemoryTool) {
- add_redzones = RUNNING_ON_MEMORY_TOOL ? kMemoryToolAddsRedzones : 0;
- if (add_redzones) {
- size += 2 * kDefaultMemoryToolRedZoneBytes;
- }
- } else {
- DCHECK_EQ(RUNNING_ON_MEMORY_TOOL, 0U);
- }
- size_t size_by_size = rosalloc_->UsableSize(size);
- if (kIsDebugBuild) {
- // On memory tool, the red zone has an impact...
- const uint8_t* obj_ptr = reinterpret_cast<const uint8_t*>(obj);
- size_t size_by_ptr = rosalloc_->UsableSize(
- obj_ptr - (add_redzones ? kDefaultMemoryToolRedZoneBytes : 0));
- if (size_by_size != size_by_ptr) {
- LOG(INFO) << "Found a bad sized obj of size " << size
- << " at " << std::hex << reinterpret_cast<intptr_t>(obj_ptr) << std::dec
- << " size_by_size=" << size_by_size << " size_by_ptr=" << size_by_ptr;
- }
- DCHECK_EQ(size_by_size, size_by_ptr);
- }
- if (usable_size != nullptr) {
- *usable_size = size_by_size;
- }
- return size_by_size;
-}
-
template<bool kThreadSafe>
inline mirror::Object* RosAllocSpace::AllocCommon(Thread* self, size_t num_bytes,
size_t* bytes_allocated, size_t* usable_size,
diff --git a/runtime/gc/space/rosalloc_space.cc b/runtime/gc/space/rosalloc_space.cc
index 8ccbfaa7a3..8d8b745b71 100644
--- a/runtime/gc/space/rosalloc_space.cc
+++ b/runtime/gc/space/rosalloc_space.cc
@@ -373,6 +373,39 @@ void RosAllocSpace::DumpStats(std::ostream& os) {
rosalloc_->DumpStats(os);
}
+template<bool kMaybeIsRunningOnMemoryTool>
+size_t RosAllocSpace::AllocationSizeNonvirtual(mirror::Object* obj, size_t* usable_size) {
+ // obj is a valid object. Use its class in the header to get the size.
+ // Don't use verification since the object may be dead if we are sweeping.
+ size_t size = obj->SizeOf<kVerifyNone>();
+ bool add_redzones = false;
+ if (kMaybeIsRunningOnMemoryTool) {
+ add_redzones = RUNNING_ON_MEMORY_TOOL ? kMemoryToolAddsRedzones : 0;
+ if (add_redzones) {
+ size += 2 * kDefaultMemoryToolRedZoneBytes;
+ }
+ } else {
+ DCHECK_EQ(RUNNING_ON_MEMORY_TOOL, 0U);
+ }
+ size_t size_by_size = rosalloc_->UsableSize(size);
+ if (kIsDebugBuild) {
+ // On memory tool, the red zone has an impact...
+ const uint8_t* obj_ptr = reinterpret_cast<const uint8_t*>(obj);
+ size_t size_by_ptr = rosalloc_->UsableSize(
+ obj_ptr - (add_redzones ? kDefaultMemoryToolRedZoneBytes : 0));
+ if (size_by_size != size_by_ptr) {
+ LOG(INFO) << "Found a bad sized obj of size " << size
+ << " at " << std::hex << reinterpret_cast<intptr_t>(obj_ptr) << std::dec
+ << " size_by_size=" << size_by_size << " size_by_ptr=" << size_by_ptr;
+ }
+ DCHECK_EQ(size_by_size, size_by_ptr);
+ }
+ if (usable_size != nullptr) {
+ *usable_size = size_by_size;
+ }
+ return size_by_size;
+}
+
} // namespace space
namespace allocator {
diff --git a/runtime/gc/space/space.cc b/runtime/gc/space/space.cc
index a2e2c1c7fb..4a078b8f49 100644
--- a/runtime/gc/space/space.cc
+++ b/runtime/gc/space/space.cc
@@ -19,6 +19,7 @@
#include "base/logging.h"
#include "gc/accounting/heap_bitmap.h"
#include "gc/accounting/space_bitmap-inl.h"
+#include "gc/heap.h"
#include "runtime.h"
#include "thread-inl.h"
diff --git a/runtime/gc/space/space.h b/runtime/gc/space/space.h
index fc558cf8e4..2a4f830843 100644
--- a/runtime/gc/space/space.h
+++ b/runtime/gc/space/space.h
@@ -24,9 +24,8 @@
#include "base/macros.h"
#include "base/mutex.h"
#include "gc/accounting/space_bitmap.h"
-#include "gc/collector/garbage_collector.h"
+#include "gc/collector/object_byte_pair.h"
#include "globals.h"
-#include "image.h"
#include "mem_map.h"
namespace art {
diff --git a/runtime/indirect_reference_table-inl.h b/runtime/indirect_reference_table-inl.h
index 2128f8cde8..9673bd9728 100644
--- a/runtime/indirect_reference_table-inl.h
+++ b/runtime/indirect_reference_table-inl.h
@@ -111,12 +111,12 @@ inline void IrtEntry::Add(ObjPtr<mirror::Object> obj) {
if (serial_ == kIRTPrevCount) {
serial_ = 0;
}
- references_[serial_] = GcRoot<mirror::Object>(obj);
+ references_[serial_] = GcRoot<mirror::Object>(obj.Ptr());
}
inline void IrtEntry::SetReference(ObjPtr<mirror::Object> obj) {
DCHECK_LT(serial_, kIRTPrevCount);
- references_[serial_] = GcRoot<mirror::Object>(obj);
+ references_[serial_] = GcRoot<mirror::Object>(obj.Ptr());
}
} // namespace art
diff --git a/runtime/java_vm_ext.cc b/runtime/java_vm_ext.cc
index 6d3118e4aa..bd0f8420aa 100644
--- a/runtime/java_vm_ext.cc
+++ b/runtime/java_vm_ext.cc
@@ -28,6 +28,7 @@
#include "check_jni.h"
#include "dex_file-inl.h"
#include "fault_handler.h"
+#include "gc_root-inl.h"
#include "indirect_reference_table-inl.h"
#include "mirror/class-inl.h"
#include "mirror/class_loader.h"
diff --git a/runtime/mem_map_test.cc b/runtime/mem_map_test.cc
index aa306ac337..5f027b1105 100644
--- a/runtime/mem_map_test.cc
+++ b/runtime/mem_map_test.cc
@@ -16,6 +16,8 @@
#include "mem_map.h"
+#include <sys/mman.h>
+
#include <memory>
#include "common_runtime_test.h"
diff --git a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
index ac504ccaf6..71c5b50216 100644
--- a/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
+++ b/runtime/native/org_apache_harmony_dalvik_ddmc_DdmVmInternal.cc
@@ -21,6 +21,7 @@
#include "base/logging.h"
#include "base/mutex.h"
#include "debugger.h"
+#include "gc/heap.h"
#include "jni_internal.h"
#include "scoped_fast_native_object_access-inl.h"
#include "ScopedLocalRef.h"
diff --git a/runtime/read_barrier-inl.h b/runtime/read_barrier-inl.h
index dbe7f5c957..db774909dd 100644
--- a/runtime/read_barrier-inl.h
+++ b/runtime/read_barrier-inl.h
@@ -19,6 +19,7 @@
#include "read_barrier.h"
+#include "gc/accounting/read_barrier_table.h"
#include "gc/collector/concurrent_copying-inl.h"
#include "gc/heap.h"
#include "mirror/object_reference.h"
diff --git a/runtime/thread-inl.h b/runtime/thread-inl.h
index aa769fa23d..5c65da6d41 100644
--- a/runtime/thread-inl.h
+++ b/runtime/thread-inl.h
@@ -27,7 +27,7 @@
#include "base/casts.h"
#include "base/mutex-inl.h"
-#include "gc/heap.h"
+#include "base/time_utils.h"
#include "jni_env_ext.h"
#include "obj_ptr.h"
#include "runtime.h"
@@ -297,9 +297,7 @@ inline ThreadState Thread::TransitionFromSuspendedToRunnable() {
inline void Thread::VerifyStack() {
if (kVerifyStack) {
- if (Runtime::Current()->GetHeap()->IsObjectValidationEnabled()) {
- VerifyStackImpl();
- }
+ VerifyStackImpl();
}
}
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 6848686e5d..c849a126ae 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -3442,11 +3442,13 @@ class VerifyRootVisitor : public SingleRootVisitor {
};
void Thread::VerifyStackImpl() {
- VerifyRootVisitor visitor;
- std::unique_ptr<Context> context(Context::Create());
- RootCallbackVisitor visitor_to_callback(&visitor, GetThreadId());
- ReferenceMapVisitor<RootCallbackVisitor> mapper(this, context.get(), visitor_to_callback);
- mapper.WalkStack();
+ if (Runtime::Current()->GetHeap()->IsObjectValidationEnabled()) {
+ VerifyRootVisitor visitor;
+ std::unique_ptr<Context> context(Context::Create());
+ RootCallbackVisitor visitor_to_callback(&visitor, GetThreadId());
+ ReferenceMapVisitor<RootCallbackVisitor> mapper(this, context.get(), visitor_to_callback);
+ mapper.WalkStack();
+ }
}
// Set the stack end to that to be used during a stack overflow
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index dc2af2ae34..ca8f7b648c 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -35,6 +35,7 @@
#include "debugger.h"
#include "gc/collector/concurrent_copying.h"
#include "gc/gc_pause_listener.h"
+#include "gc/heap.h"
#include "gc/reference_processor.h"
#include "jni_internal.h"
#include "lock_word.h"
diff --git a/runtime/thread_pool.cc b/runtime/thread_pool.cc
index d24a5e5c4a..e051e7647f 100644
--- a/runtime/thread_pool.cc
+++ b/runtime/thread_pool.cc
@@ -18,6 +18,7 @@
#include <pthread.h>
+#include <sys/mman.h>
#include <sys/time.h>
#include <sys/resource.h>
diff --git a/test/597-deopt-new-string/deopt.cc b/test/597-deopt-new-string/deopt.cc
index 844a786e1e..0f02efea90 100644
--- a/test/597-deopt-new-string/deopt.cc
+++ b/test/597-deopt-new-string/deopt.cc
@@ -21,6 +21,7 @@
#include "thread_state.h"
#include "gc/gc_cause.h"
#include "gc/scoped_gc_critical_section.h"
+#include "scoped_thread_state_change-inl.h"
namespace art {