summaryrefslogtreecommitdiff
path: root/runtime/class_table.h
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2016-03-02 16:08:31 -0800
committer Mathieu Chartier <mathieuc@google.com> 2016-03-04 13:32:28 -0800
commit88027bd6810b9a5b785dba5396eec5301e4540b2 (patch)
tree5e385f663cfbe85c7db7eeb48d6f9645c1850d65 /runtime/class_table.h
parent7f459f5859e5f01c92c3711e7d63c062f510b416 (diff)
Only visit app image classes in class loader
Only update dex cache arrays of added classes since the declaring class is in image DCHECK fails for other classes in the class loader. Also some cleanup to prevent app images leaving invalid state if they get rejected. Bug: 22858531 Bug: 27431418 (cherry picked from commit 6973100705716bffce3768a8a0908d7ca1d02ec1) Change-Id: Ib05364c44f2b943e3341ef2b1dd43337833de143
Diffstat (limited to 'runtime/class_table.h')
-rw-r--r--runtime/class_table.h61
1 files changed, 33 insertions, 28 deletions
diff --git a/runtime/class_table.h b/runtime/class_table.h
index 5f2eb48d55..0e0e860b4f 100644
--- a/runtime/class_table.h
+++ b/runtime/class_table.h
@@ -39,6 +39,34 @@ namespace mirror {
// Each loader has a ClassTable
class ClassTable {
public:
+ class ClassDescriptorHashEquals {
+ public:
+ // uint32_t for cross compilation.
+ uint32_t operator()(const GcRoot<mirror::Class>& root) const NO_THREAD_SAFETY_ANALYSIS;
+ // Same class loader and descriptor.
+ bool operator()(const GcRoot<mirror::Class>& a, const GcRoot<mirror::Class>& b) const
+ NO_THREAD_SAFETY_ANALYSIS;;
+ // Same descriptor.
+ bool operator()(const GcRoot<mirror::Class>& a, const char* descriptor) const
+ NO_THREAD_SAFETY_ANALYSIS;
+ // uint32_t for cross compilation.
+ uint32_t operator()(const char* descriptor) const NO_THREAD_SAFETY_ANALYSIS;
+ };
+ class GcRootEmptyFn {
+ public:
+ void MakeEmpty(GcRoot<mirror::Class>& item) const {
+ item = GcRoot<mirror::Class>();
+ }
+ bool IsEmpty(const GcRoot<mirror::Class>& item) const {
+ return item.IsNull();
+ }
+ };
+ // hash set which hashes class descriptor, and compares descriptors and class loaders. Results
+ // should be compared for a matching Class descriptor and class loader.
+ typedef HashSet<GcRoot<mirror::Class>, GcRootEmptyFn, ClassDescriptorHashEquals,
+ ClassDescriptorHashEquals, TrackingAllocator<GcRoot<mirror::Class>, kAllocatorTagClassTable>>
+ ClassSet;
+
ClassTable();
// Used by image writer for checking.
@@ -112,35 +140,12 @@ class ClassTable {
REQUIRES(Locks::classlinker_classes_lock_)
SHARED_REQUIRES(Locks::mutator_lock_);
- private:
- class ClassDescriptorHashEquals {
- public:
- // uint32_t for cross compilation.
- uint32_t operator()(const GcRoot<mirror::Class>& root) const NO_THREAD_SAFETY_ANALYSIS;
- // Same class loader and descriptor.
- bool operator()(const GcRoot<mirror::Class>& a, const GcRoot<mirror::Class>& b) const
- NO_THREAD_SAFETY_ANALYSIS;;
- // Same descriptor.
- bool operator()(const GcRoot<mirror::Class>& a, const char* descriptor) const
- NO_THREAD_SAFETY_ANALYSIS;
- // uint32_t for cross compilation.
- uint32_t operator()(const char* descriptor) const NO_THREAD_SAFETY_ANALYSIS;
- };
- class GcRootEmptyFn {
- public:
- void MakeEmpty(GcRoot<mirror::Class>& item) const {
- item = GcRoot<mirror::Class>();
- }
- bool IsEmpty(const GcRoot<mirror::Class>& item) const {
- return item.IsNull();
- }
- };
- // hash set which hashes class descriptor, and compares descriptors and class loaders. Results
- // should be compared for a matching Class descriptor and class loader.
- typedef HashSet<GcRoot<mirror::Class>, GcRootEmptyFn, ClassDescriptorHashEquals,
- ClassDescriptorHashEquals, TrackingAllocator<GcRoot<mirror::Class>, kAllocatorTagClassTable>>
- ClassSet;
+ // Add a class set to the front of classes.
+ void AddClassSet(ClassSet&& set)
+ REQUIRES(Locks::classlinker_classes_lock_)
+ SHARED_REQUIRES(Locks::mutator_lock_);
+ private:
// TODO: shard lock to have one per class loader.
// We have a vector to help prevent dirty pages after the zygote forks by calling FreezeSnapshot.
std::vector<ClassSet> classes_ GUARDED_BY(Locks::classlinker_classes_lock_);