Force inlining on trivial accessors.
Make volatility for GetFieldObject a template parameter.
Move some trivial mirror::String routines to a -inl.h.
Bug: 14285442
Change-Id: Ie23b11d4f18cb15a62c3bbb42837a8aaf6b68f92
diff --git a/runtime/gc/accounting/mod_union_table.cc b/runtime/gc/accounting/mod_union_table.cc
index d744dee..7cddaf4 100644
--- a/runtime/gc/accounting/mod_union_table.cc
+++ b/runtime/gc/accounting/mod_union_table.cc
@@ -101,7 +101,7 @@
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
DCHECK(root != NULL);
ModUnionUpdateObjectReferencesVisitor ref_visitor(callback_, arg_);
- root->VisitReferences<kMovingClasses>(ref_visitor);
+ root->VisitReferences<kMovingClasses>(ref_visitor, VoidFunctor());
}
private:
@@ -153,7 +153,7 @@
// We don't have an early exit since we use the visitor pattern, an early
// exit should significantly speed this up.
AddToReferenceArrayVisitor visitor(mod_union_table_, references_);
- obj->VisitReferences<kMovingClasses>(visitor);
+ obj->VisitReferences<kMovingClasses>(visitor, VoidFunctor());
}
private:
ModUnionTableReferenceCache* const mod_union_table_;
@@ -171,7 +171,7 @@
// Extra parameters are required since we use this same visitor signature for checking objects.
void operator()(Object* obj, MemberOffset offset, bool /*is_static*/) const
SHARED_LOCKS_REQUIRED(Locks::heap_bitmap_lock_, Locks::mutator_lock_) {
- mirror::Object* ref = obj->GetFieldObject<mirror::Object>(offset, false);
+ mirror::Object* ref = obj->GetFieldObject<mirror::Object>(offset);
if (ref != nullptr && mod_union_table_->ShouldAddReference(ref) &&
references_.find(ref) == references_.end()) {
Heap* heap = mod_union_table_->GetHeap();
@@ -205,7 +205,7 @@
void operator()(Object* obj) const NO_THREAD_SAFETY_ANALYSIS {
Locks::heap_bitmap_lock_->AssertSharedHeld(Thread::Current());
CheckReferenceVisitor visitor(mod_union_table_, references_);
- obj->VisitReferences<kMovingClasses>(visitor);
+ obj->VisitReferences<kMovingClasses>(visitor, VoidFunctor());
}
private:
diff --git a/runtime/gc/allocator_type.h b/runtime/gc/allocator_type.h
new file mode 100644
index 0000000..938b0f1
--- /dev/null
+++ b/runtime/gc/allocator_type.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2014 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_ALLOCATOR_TYPE_H_
+#define ART_RUNTIME_GC_ALLOCATOR_TYPE_H_
+
+namespace art {
+namespace gc {
+
+// Different types of allocators.
+enum AllocatorType {
+ kAllocatorTypeBumpPointer, // Use BumpPointer allocator, has entrypoints.
+ kAllocatorTypeTLAB, // Use TLAB allocator, has entrypoints.
+ kAllocatorTypeRosAlloc, // Use RosAlloc allocator, has entrypoints.
+ kAllocatorTypeDlMalloc, // Use dlmalloc allocator, has entrypoints.
+ kAllocatorTypeNonMoving, // Special allocator for non moving objects, doesn't have entrypoints.
+ kAllocatorTypeLOS, // Large object space, also doesn't have entrypoints.
+};
+
+} // namespace gc
+} // namespace art
+
+#endif // ART_RUNTIME_GC_ALLOCATOR_TYPE_H_
diff --git a/runtime/gc/collector/mark_sweep.cc b/runtime/gc/collector/mark_sweep.cc
index 9cd740e..e225d5a 100644
--- a/runtime/gc/collector/mark_sweep.cc
+++ b/runtime/gc/collector/mark_sweep.cc
@@ -596,7 +596,7 @@
void operator()(Object* obj, MemberOffset offset, bool /* static */) const ALWAYS_INLINE
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- mirror::Object* ref = obj->GetFieldObject<mirror::Object>(offset, false);
+ mirror::Object* ref = obj->GetFieldObject<mirror::Object>(offset);
if (ref != nullptr && mark_sweep_->MarkObjectParallel(ref)) {
if (kUseFinger) {
android_memory_barrier();
@@ -1190,7 +1190,7 @@
Locks::mutator_lock_->AssertSharedHeld(Thread::Current());
Locks::heap_bitmap_lock_->AssertExclusiveHeld(Thread::Current());
}
- mark_sweep_->MarkObject(obj->GetFieldObject<mirror::Object>(offset, false));
+ mark_sweep_->MarkObject(obj->GetFieldObject<mirror::Object>(offset));
}
private:
diff --git a/runtime/gc/collector/mark_sweep.h b/runtime/gc/collector/mark_sweep.h
index 0c5a0da..bfc70d1 100644
--- a/runtime/gc/collector/mark_sweep.h
+++ b/runtime/gc/collector/mark_sweep.h
@@ -22,7 +22,7 @@
#include "base/macros.h"
#include "base/mutex.h"
#include "garbage_collector.h"
-#include "gc/accounting/space_bitmap.h"
+#include "gc/accounting/heap_bitmap.h"
#include "immune_region.h"
#include "object_callbacks.h"
#include "offsets.h"
diff --git a/runtime/gc/collector/semi_space.cc b/runtime/gc/collector/semi_space.cc
index 65bbbd2..0b26019 100644
--- a/runtime/gc/collector/semi_space.cc
+++ b/runtime/gc/collector/semi_space.cc
@@ -352,7 +352,7 @@
void operator()(Object* obj, MemberOffset offset, bool /* is_static */) const
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) ALWAYS_INLINE {
- mirror::Object* ref = obj->GetFieldObject<mirror::Object>(offset, false);
+ mirror::Object* ref = obj->GetFieldObject<mirror::Object>(offset);
if (from_space_->HasAddress(ref)) {
Runtime::Current()->GetHeap()->DumpObject(LOG(INFO), obj);
LOG(FATAL) << ref << " found in from space";
@@ -365,7 +365,7 @@
void SemiSpace::VerifyNoFromSpaceReferences(Object* obj) {
DCHECK(!from_space_->HasAddress(obj)) << "Scanning object " << obj << " in from space";
SemiSpaceVerifyNoFromSpaceReferencesVisitor visitor(from_space_);
- obj->VisitReferences<kMovingClasses>(visitor);
+ obj->VisitReferences<kMovingClasses>(visitor, VoidFunctor());
}
class SemiSpaceVerifyNoFromSpaceReferencesObjectVisitor {
diff --git a/runtime/gc/collector/semi_space.h b/runtime/gc/collector/semi_space.h
index d468561..9b6df16 100644
--- a/runtime/gc/collector/semi_space.h
+++ b/runtime/gc/collector/semi_space.h
@@ -21,7 +21,7 @@
#include "base/macros.h"
#include "base/mutex.h"
#include "garbage_collector.h"
-#include "gc/accounting/space_bitmap.h"
+#include "gc/accounting/heap_bitmap.h"
#include "immune_region.h"
#include "object_callbacks.h"
#include "offsets.h"
@@ -191,7 +191,8 @@
void ProcessMarkStack()
EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_, Locks::heap_bitmap_lock_);
- inline mirror::Object* GetForwardingAddressInFromSpace(mirror::Object* obj) const;
+ inline mirror::Object* GetForwardingAddressInFromSpace(mirror::Object* obj) const
+ SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
// Revoke all the thread-local buffers.
void RevokeAllThreadLocalBuffers();
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index b57fc69..4d074f1 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -1136,8 +1136,7 @@
return;
}
CHECK(IsAligned<kObjectAlignment>(obj)) << "Object isn't aligned: " << obj;
- mirror::Class* c = obj->GetFieldObject<mirror::Class, kVerifyNone>(
- mirror::Object::ClassOffset(), false);
+ mirror::Class* c = obj->GetFieldObject<mirror::Class, kVerifyNone>(mirror::Object::ClassOffset());
CHECK(c != nullptr) << "Null class in object " << obj;
CHECK(IsAligned<kObjectAlignment>(c)) << "Class " << c << " not aligned in object " << obj;
CHECK(VerifyClassClass(c));
@@ -1378,13 +1377,13 @@
// TODO: Fix lock analysis to not use NO_THREAD_SAFETY_ANALYSIS, requires support for
// annotalysis on visitors.
void operator()(mirror::Object* o) const NO_THREAD_SAFETY_ANALYSIS {
- o->VisitReferences<true>(*this);
+ o->VisitReferences<true>(*this, VoidFunctor());
}
// For Object::VisitReferences.
void operator()(mirror::Object* obj, MemberOffset offset, bool /* is_static */) const
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- mirror::Object* ref = obj->GetFieldObject<mirror::Object>(offset, false);
+ mirror::Object* ref = obj->GetFieldObject<mirror::Object>(offset);
if (ref == object_ && (max_count_ == 0 || referring_objects_.size() < max_count_)) {
referring_objects_.push_back(obj);
}
@@ -1990,7 +1989,7 @@
void operator()(mirror::Object* obj, MemberOffset offset, bool /*is_static*/) const
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- this->operator()(obj, obj->GetFieldObject<mirror::Object>(offset, false), offset);
+ this->operator()(obj, obj->GetFieldObject<mirror::Object>(offset), offset);
}
// TODO: Fix the no thread safety analysis.
@@ -2182,7 +2181,7 @@
// annotalysis on visitors.
void operator()(mirror::Object* obj, MemberOffset offset, bool is_static) const
NO_THREAD_SAFETY_ANALYSIS {
- mirror::Object* ref = obj->GetFieldObject<mirror::Object>(offset, false);
+ mirror::Object* ref = obj->GetFieldObject<mirror::Object>(offset);
// Filter out class references since changing an object's class does not mark the card as dirty.
// Also handles large objects, since the only reference they hold is a class reference.
if (ref != nullptr && !ref->IsClass()) {
@@ -2252,7 +2251,7 @@
void operator()(mirror::Object* obj) const
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_, Locks::heap_bitmap_lock_) {
VerifyReferenceCardVisitor visitor(heap_, const_cast<bool*>(&failed_));
- obj->VisitReferences<true>(visitor);
+ obj->VisitReferences<true>(visitor, VoidFunctor());
}
bool Failed() const {
diff --git a/runtime/gc/heap.h b/runtime/gc/heap.h
index 631397b..c631372 100644
--- a/runtime/gc/heap.h
+++ b/runtime/gc/heap.h
@@ -21,6 +21,7 @@
#include <string>
#include <vector>
+#include "allocator_type.h"
#include "atomic.h"
#include "base/timing_logger.h"
#include "gc/accounting/atomic_stack.h"
@@ -90,16 +91,6 @@
}
};
-// Different types of allocators.
-enum AllocatorType {
- kAllocatorTypeBumpPointer, // Use BumpPointer allocator, has entrypoints.
- kAllocatorTypeTLAB, // Use TLAB allocator, has entrypoints.
- kAllocatorTypeRosAlloc, // Use RosAlloc allocator, has entrypoints.
- kAllocatorTypeDlMalloc, // Use dlmalloc allocator, has entrypoints.
- kAllocatorTypeNonMoving, // Special allocator for non moving objects, doesn't have entrypoints.
- kAllocatorTypeLOS, // Large object space, also doesn't have entrypoints.
-};
-
// If true, use rosalloc/RosAllocSpace instead of dlmalloc/DlMallocSpace
static constexpr bool kUseRosAlloc = true;
diff --git a/runtime/gc/space/space-inl.h b/runtime/gc/space/space-inl.h
index 3a715ab..3ea68cf 100644
--- a/runtime/gc/space/space-inl.h
+++ b/runtime/gc/space/space-inl.h
@@ -19,6 +19,7 @@
#include "space.h"
+#include "base/casts.h"
#include "dlmalloc_space.h"
#include "image_space.h"
#include "large_object_space.h"