Flatten interface entries into the iftable.
Avoid an indirection when scanning the iftable by inlining the interface
entry into the iftable.
Copy the iftable for marker interfaces from parents to their children
(for example for exceptions).
Don't allocate method arrays for 0 element interface method tables.
Change-Id: I8402960d4ddbe4b1ffd335ed4ce4b4825210fd0d
diff --git a/src/object.cc b/src/object.cc
index e8381db..5fdea71 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -474,10 +474,9 @@
} else {
MethodHelper mh(this);
MethodHelper interface_mh;
- ObjectArray<InterfaceEntry>* iftable = GetDeclaringClass()->GetIfTable();
- for (int32_t i = 0; i < iftable->GetLength() && result == NULL; i++) {
- InterfaceEntry* entry = iftable->Get(i);
- Class* interface = entry->GetInterface();
+ IfTable* iftable = GetDeclaringClass()->GetIfTable();
+ for (size_t i = 0; i < iftable->Count() && result == NULL; i++) {
+ Class* interface = iftable->GetInterface(i);
for (size_t j = 0; j < interface->NumVirtualMethods(); ++j) {
AbstractMethod* interface_method = interface->GetVirtualMethod(j);
interface_mh.ChangeMethod(interface_method);
@@ -881,9 +880,9 @@
// recursively all super-interfaces of those interfaces, are listed
// in iftable_, so we can just do a linear scan through that.
int32_t iftable_count = GetIfTableCount();
- ObjectArray<InterfaceEntry>* iftable = GetIfTable();
+ IfTable* iftable = GetIfTable();
for (int32_t i = 0; i < iftable_count; i++) {
- if (iftable->Get(i)->GetInterface() == klass) {
+ if (iftable->GetInterface(i) == klass) {
return true;
}
}
@@ -1007,11 +1006,10 @@
DCHECK(declaring_class->IsInterface()) << PrettyMethod(method);
// TODO cache to improve lookup speed
int32_t iftable_count = GetIfTableCount();
- ObjectArray<InterfaceEntry>* iftable = GetIfTable();
+ IfTable* iftable = GetIfTable();
for (int32_t i = 0; i < iftable_count; i++) {
- InterfaceEntry* interface_entry = iftable->Get(i);
- if (interface_entry->GetInterface() == declaring_class) {
- return interface_entry->GetMethodArray()->Get(method->GetMethodIndex());
+ if (iftable->GetInterface(i) == declaring_class) {
+ return iftable->GetMethodArray(i)->Get(method->GetMethodIndex());
}
}
return NULL;
@@ -1025,9 +1023,9 @@
}
int32_t iftable_count = GetIfTableCount();
- ObjectArray<InterfaceEntry>* iftable = GetIfTable();
+ IfTable* iftable = GetIfTable();
for (int32_t i = 0; i < iftable_count; i++) {
- method = iftable->Get(i)->GetInterface()->FindVirtualMethod(name, signature);
+ method = iftable->GetInterface(i)->FindVirtualMethod(name, signature);
if (method != NULL) {
return method;
}
@@ -1043,9 +1041,9 @@
}
int32_t iftable_count = GetIfTableCount();
- ObjectArray<InterfaceEntry>* iftable = GetIfTable();
+ IfTable* iftable = GetIfTable();
for (int32_t i = 0; i < iftable_count; i++) {
- method = iftable->Get(i)->GetInterface()->FindVirtualMethod(dex_cache, dex_method_idx);
+ method = iftable->GetInterface(i)->FindVirtualMethod(dex_cache, dex_method_idx);
if (method != NULL) {
return method;
}