Move ArtField to native
Add linear alloc. Moved ArtField to be native object. Changed image
writer to put ArtFields after the mirror section.
Savings:
2MB on low ram devices
4MB on normal devices
Total PSS measurements before (normal N5, 95s after shell start):
Image size: 7729152 bytes
23112 kB: .NonMoving
23212 kB: .NonMoving
22868 kB: .NonMoving
23072 kB: .NonMoving
22836 kB: .NonMoving
19618 kB: .Zygote
19850 kB: .Zygote
19623 kB: .Zygote
19924 kB: .Zygote
19612 kB: .Zygote
Avg: 42745.4 kB
After:
Image size: 7462912 bytes
17440 kB: .NonMoving
16776 kB: .NonMoving
16804 kB: .NonMoving
17812 kB: .NonMoving
16820 kB: .NonMoving
18788 kB: .Zygote
18856 kB: .Zygote
19064 kB: .Zygote
18841 kB: .Zygote
18629 kB: .Zygote
3499 kB: .LinearAlloc
3408 kB: .LinearAlloc
3424 kB: .LinearAlloc
3600 kB: .LinearAlloc
3436 kB: .LinearAlloc
Avg: 39439.4 kB
No reflection performance changes.
Bug: 19264997
Bug: 17643507
Change-Id: I10c73a37913332080aeb978c7c94713bdfe4fe1c
diff --git a/runtime/check_jni.cc b/runtime/check_jni.cc
index 2b0167d..f94ebea 100644
--- a/runtime/check_jni.cc
+++ b/runtime/check_jni.cc
@@ -19,6 +19,7 @@
#include <sys/mman.h>
#include <zlib.h>
+#include "art_field-inl.h"
#include "base/logging.h"
#include "base/to_str.h"
#include "class_linker.h"
@@ -27,7 +28,6 @@
#include "gc/space/space.h"
#include "java_vm_ext.h"
#include "jni_internal.h"
-#include "mirror/art_field-inl.h"
#include "mirror/art_method-inl.h"
#include "mirror/class-inl.h"
#include "mirror/object-inl.h"
@@ -169,7 +169,7 @@
return false;
}
- mirror::ArtField* f = CheckFieldID(soa, fid);
+ ArtField* f = CheckFieldID(soa, fid);
if (f == nullptr) {
return false;
}
@@ -248,7 +248,7 @@
bool CheckStaticFieldID(ScopedObjectAccess& soa, jclass java_class, jfieldID fid)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
mirror::Class* c = soa.Decode<mirror::Class*>(java_class);
- mirror::ArtField* f = CheckFieldID(soa, fid);
+ ArtField* f = CheckFieldID(soa, fid);
if (f == nullptr) {
return false;
}
@@ -565,7 +565,7 @@
if (!is_static && !CheckInstanceFieldID(soa, obj, fid)) {
return false;
}
- mirror::ArtField* field = soa.DecodeField(fid);
+ ArtField* field = soa.DecodeField(fid);
DCHECK(field != nullptr); // Already checked by Check.
if (is_static != field->IsStatic()) {
AbortF("attempt to access %s field %s: %p",
@@ -817,7 +817,7 @@
}
case 'f': { // jfieldID
jfieldID fid = arg.f;
- mirror::ArtField* f = soa.DecodeField(fid);
+ ArtField* f = soa.DecodeField(fid);
*msg += PrettyField(f);
if (!entry) {
StringAppendF(msg, " (%p)", fid);
@@ -986,14 +986,15 @@
return true;
}
- mirror::ArtField* CheckFieldID(ScopedObjectAccess& soa, jfieldID fid)
+ ArtField* CheckFieldID(ScopedObjectAccess& soa, jfieldID fid)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
if (fid == nullptr) {
AbortF("jfieldID was NULL");
return nullptr;
}
- mirror::ArtField* f = soa.DecodeField(fid);
- if (!Runtime::Current()->GetHeap()->IsValidObjectAddress(f) || !f->IsArtField()) {
+ ArtField* f = soa.DecodeField(fid);
+ // TODO: Better check here.
+ if (!Runtime::Current()->GetHeap()->IsValidObjectAddress(f->GetDeclaringClass())) {
Runtime::Current()->GetHeap()->DumpSpaces(LOG(ERROR));
AbortF("invalid jfieldID: %p", fid);
return nullptr;