Merge "Delete pin table" into lmp-dev
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index afbd5cb..8e3680c 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -61,9 +61,6 @@
static const size_t kLocalsInitial = 64; // Arbitrary.
static const size_t kLocalsMax = 512; // Arbitrary sanity check.
-static const size_t kPinTableInitial = 16; // Arbitrary.
-static const size_t kPinTableMax = 1024; // Arbitrary sanity check.
-
static size_t gGlobalsInitial = 512; // Arbitrary.
static size_t gGlobalsMax = 51200; // Arbitrary sanity check. (Must fit in 16 bits.)
@@ -243,20 +240,6 @@
return soa.EncodeField(field);
}
-static void PinPrimitiveArray(const ScopedObjectAccess& soa, mirror::Array* array)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- JavaVMExt* vm = soa.Vm();
- MutexLock mu(soa.Self(), vm->pins_lock);
- vm->pin_table.Add(array);
-}
-
-static void UnpinPrimitiveArray(const ScopedObjectAccess& soa, mirror::Array* array)
- SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- JavaVMExt* vm = soa.Vm();
- MutexLock mu(soa.Self(), vm->pins_lock);
- vm->pin_table.Remove(array);
-}
-
static void ThrowAIOOBE(ScopedObjectAccess& soa, mirror::Array* array, jsize start,
jsize length, const char* identifier)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
@@ -1996,7 +1979,6 @@
ScopedObjectAccess soa(env);
mirror::String* s = soa.Decode<mirror::String*>(java_string);
mirror::CharArray* chars = s->GetCharArray();
- PinPrimitiveArray(soa, chars);
gc::Heap* heap = Runtime::Current()->GetHeap();
if (heap->IsMovableObject(chars)) {
if (is_copy != nullptr) {
@@ -2025,7 +2007,6 @@
if (chars != (s_chars->GetData() + s->GetOffset())) {
delete[] chars;
}
- UnpinPrimitiveArray(soa, s->GetCharArray());
}
static const jchar* GetStringCritical(JNIEnv* env, jstring java_string, jboolean* is_copy) {
@@ -2034,7 +2015,6 @@
mirror::String* s = soa.Decode<mirror::String*>(java_string);
mirror::CharArray* chars = s->GetCharArray();
int32_t offset = s->GetOffset();
- PinPrimitiveArray(soa, chars);
gc::Heap* heap = Runtime::Current()->GetHeap();
if (heap->IsMovableObject(chars)) {
StackHandleScope<1> hs(soa.Self());
@@ -2050,7 +2030,6 @@
static void ReleaseStringCritical(JNIEnv* env, jstring java_string, const jchar* chars) {
CHECK_NON_NULL_ARGUMENT_RETURN_VOID(java_string);
ScopedObjectAccess soa(env);
- UnpinPrimitiveArray(soa, soa.Decode<mirror::String*>(java_string)->GetCharArray());
gc::Heap* heap = Runtime::Current()->GetHeap();
mirror::String* s = soa.Decode<mirror::String*>(java_string);
mirror::CharArray* s_chars = s->GetCharArray();
@@ -2204,7 +2183,6 @@
// Re-decode in case the object moved since IncrementDisableGC waits for GC to complete.
array = soa.Decode<mirror::Array*>(java_array);
}
- PinPrimitiveArray(soa, array);
if (is_copy != nullptr) {
*is_copy = JNI_FALSE;
}
@@ -2631,7 +2609,6 @@
if (UNLIKELY(array == nullptr)) {
return nullptr;
}
- PinPrimitiveArray(soa, array);
// Only make a copy if necessary.
if (Runtime::Current()->GetHeap()->IsMovableObject(array)) {
if (is_copy != nullptr) {
@@ -2693,7 +2670,6 @@
// Non copy to a movable object must means that we had disabled the moving GC.
heap->DecrementDisableMovingGC(soa.Self());
}
- UnpinPrimitiveArray(soa, array);
}
}
@@ -3145,8 +3121,6 @@
check_jni(false),
force_copy(false), // TODO: add a way to enable this
trace(options->jni_trace_),
- pins_lock("JNI pin table lock", kPinTableLock),
- pin_table("pin table", kPinTableInitial, kPinTableMax),
globals_lock("JNI global reference table lock"),
globals(gGlobalsInitial, gGlobalsMax, kGlobal),
libraries_lock("JNI shared libraries map lock", kLoadLibraryLock),
@@ -3197,10 +3171,6 @@
}
Thread* self = Thread::Current();
{
- MutexLock mu(self, pins_lock);
- os << "; pins=" << pin_table.Size();
- }
- {
ReaderMutexLock mu(self, globals_lock);
os << "; globals=" << globals.Capacity();
}
@@ -3248,10 +3218,6 @@
MutexLock mu(self, weak_globals_lock_);
weak_globals_.Dump(os);
}
- {
- MutexLock mu(self, pins_lock);
- pin_table.Dump(os);
- }
}
bool JavaVMExt::LoadNativeLibrary(const std::string& path,
@@ -3446,10 +3412,6 @@
globals.VisitRoots(callback, arg, 0, kRootJNIGlobal);
}
{
- MutexLock mu(self, pins_lock);
- pin_table.VisitRoots(callback, arg, 0, kRootVMInternal);
- }
- {
MutexLock mu(self, libraries_lock);
// Libraries contains shared libraries which hold a pointer to a class loader.
libraries->VisitRoots(callback, arg);
diff --git a/runtime/jni_internal.h b/runtime/jni_internal.h
index ac502e6..25ed2f6 100644
--- a/runtime/jni_internal.h
+++ b/runtime/jni_internal.h
@@ -112,10 +112,6 @@
// Extra diagnostics.
std::string trace;
- // Used to hold references to pinned primitive arrays.
- Mutex pins_lock DEFAULT_MUTEX_ACQUIRED_AFTER;
- ReferenceTable pin_table GUARDED_BY(pins_lock);
-
// JNI global references.
ReaderWriterMutex globals_lock DEFAULT_MUTEX_ACQUIRED_AFTER;
// Not guarded by globals_lock since we sometimes use SynchronizedGet in Thread::DecodeJObject.