summaryrefslogtreecommitdiff
path: root/src/object_utils.h
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2012-09-18 08:57:04 -0700
committer Mathieu Chartier <mathieuc@google.com> 2012-09-21 17:32:56 -0700
commit66f19258f9728d4ffe026074d8fd429d639802fa (patch)
treefd94009774c6cbbb1528ea096e606133bd35f104 /src/object_utils.h
parenta5e1e3d153990845d80cb8d013157210f11a473c (diff)
Change dex cache to be java object instead of array, add pointer to dex file in dex cache.
Generic clean up to facilitate having GDB macros for Pretty* helper functions. Improved cleanliness of DexCache since having it as an object array was not the best solution. Fixed a bug in InOrderWalk caused by ResolveType sometimes allocating classes. Rename C++ Method to AbstractMethod and add two new classes Constructor, Method which both inherit from AbstractMethod. Rename done to have the C++ code be closer to the java code. Change-Id: I4995b4c5e47a3822192b08afa24a639d3b1f4da9
Diffstat (limited to 'src/object_utils.h')
-rw-r--r--src/object_utils.h30
1 files changed, 12 insertions, 18 deletions
diff --git a/src/object_utils.h b/src/object_utils.h
index f6158f3b9e..035f689ae5 100644
--- a/src/object_utils.h
+++ b/src/object_utils.h
@@ -199,13 +199,10 @@ class ClassHelper {
}
const DexFile& GetDexFile() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- const DexFile* result = dex_file_;
- if (result == NULL) {
- const DexCache* dex_cache = GetDexCache();
- result = &GetClassLinker()->FindDexFile(dex_cache);
- dex_file_ = result;
+ if (dex_file_ == NULL) {
+ dex_file_ = GetDexCache()->GetDexFile();
}
- return *result;
+ return *dex_file_;
}
DexCache* GetDexCache() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -366,13 +363,10 @@ class FieldHelper {
return result;
}
const DexFile& GetDexFile() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- const DexFile* result = dex_file_;
- if (result == NULL) {
- const DexCache* dex_cache = GetDexCache();
- result = &GetClassLinker()->FindDexFile(dex_cache);
- dex_file_ = result;
+ if (dex_file_ == NULL) {
+ dex_file_ = GetDexCache()->GetDexFile();
}
- return *result;
+ return *dex_file_;
}
ClassLinker* class_linker_;
@@ -390,21 +384,21 @@ class MethodHelper {
: class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL),
shorty_len_(0) {}
- explicit MethodHelper(const Method* m)
+ explicit MethodHelper(const AbstractMethod* m)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
: class_linker_(NULL), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL),
shorty_len_(0) {
SetMethod(m);
}
- MethodHelper(const Method* m, ClassLinker* l)
+ MethodHelper(const AbstractMethod* m, ClassLinker* l)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
: class_linker_(l), dex_cache_(NULL), dex_file_(NULL), method_(NULL), shorty_(NULL),
shorty_len_(0) {
SetMethod(m);
}
- void ChangeMethod(Method* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+ void ChangeMethod(AbstractMethod* new_m) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
DCHECK(new_m != NULL);
if (dex_cache_ != NULL) {
Class* klass = new_m->GetDeclaringClass();
@@ -675,12 +669,12 @@ class MethodHelper {
private:
// Set the method_ field, for proxy methods looking up the interface method via the resolved
// methods table.
- void SetMethod(const Method* method)
+ void SetMethod(const AbstractMethod* method)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
if (method != NULL) {
Class* klass = method->GetDeclaringClass();
if (klass->IsProxyClass()) {
- Method* interface_method =
+ AbstractMethod* interface_method =
method->GetDexCacheResolvedMethods()->Get(method->GetDexMethodIndex());
CHECK(interface_method != NULL);
CHECK(interface_method == GetClassLinker()->FindMethodForProxy(klass, method));
@@ -702,7 +696,7 @@ class MethodHelper {
ClassLinker* class_linker_;
DexCache* dex_cache_;
const DexFile* dex_file_;
- const Method* method_;
+ const AbstractMethod* method_;
const char* shorty_;
uint32_t shorty_len_;