summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/arch/arm/jni_entrypoints_arm.S24
-rw-r--r--runtime/arch/arm64/jni_entrypoints_arm64.S38
-rw-r--r--runtime/arch/mips/jni_entrypoints_mips.S33
-rw-r--r--runtime/check_jni.cc11
-rw-r--r--runtime/indirect_reference_table.cc13
-rw-r--r--runtime/jni_internal.cc19
-rw-r--r--runtime/jni_internal.h10
-rw-r--r--runtime/mirror/art_method.cc21
-rw-r--r--runtime/native/dalvik_system_VMRuntime.cc19
-rw-r--r--runtime/scoped_thread_state_change.h2
-rw-r--r--runtime/thread.cc4
11 files changed, 15 insertions, 179 deletions
diff --git a/runtime/arch/arm/jni_entrypoints_arm.S b/runtime/arch/arm/jni_entrypoints_arm.S
index 4a69644..1be34ba 100644
--- a/runtime/arch/arm/jni_entrypoints_arm.S
+++ b/runtime/arch/arm/jni_entrypoints_arm.S
@@ -41,27 +41,3 @@ ENTRY art_jni_dlsym_lookup_stub
pop {r0, r1, r2, r3, pc} @ restore regs and return to caller to handle exception
.cfi_adjust_cfa_offset -20
END art_jni_dlsym_lookup_stub
-
- /*
- * Entry point of native methods when JNI bug compatibility is enabled.
- */
- .extern artWorkAroundAppJniBugs
-ENTRY art_work_around_app_jni_bugs
- @ save registers that may contain arguments and LR that will be crushed by a call
- push {r0-r3, lr}
- .save {r0-r3, lr}
- .cfi_adjust_cfa_offset 16
- .cfi_rel_offset r0, 0
- .cfi_rel_offset r1, 4
- .cfi_rel_offset r2, 8
- .cfi_rel_offset r3, 12
- sub sp, #12 @ 3 words of space for alignment
- mov r0, r9 @ pass Thread::Current
- mov r1, sp @ pass SP
- bl artWorkAroundAppJniBugs @ (Thread*, SP)
- add sp, #12 @ rewind stack
- mov r12, r0 @ save target address
- pop {r0-r3, lr} @ restore possibly modified argument registers
- .cfi_adjust_cfa_offset -16
- bx r12 @ tail call into JNI routine
-END art_work_around_app_jni_bugs
diff --git a/runtime/arch/arm64/jni_entrypoints_arm64.S b/runtime/arch/arm64/jni_entrypoints_arm64.S
index ba783ab..c59a304 100644
--- a/runtime/arch/arm64/jni_entrypoints_arm64.S
+++ b/runtime/arch/arm64/jni_entrypoints_arm64.S
@@ -55,41 +55,3 @@ ENTRY art_jni_dlsym_lookup_stub
1:
ret // restore regs and return to caller to handle exception.
END art_jni_dlsym_lookup_stub
-
- /*
- * Entry point of native methods when JNI bug compatibility is enabled.
- */
- .extern artWorkAroundAppJniBugs
-ENTRY art_work_around_app_jni_bugs
- // spill regs.
- stp x29, x30, [sp, #-16]!
- mov x29, sp
- stp d6, d7, [sp, #-16]!
- stp d4, d5, [sp, #-16]!
- stp d2, d3, [sp, #-16]!
- stp d0, d1, [sp, #-16]!
- stp x6, x7, [sp, #-16]!
- stp x4, x5, [sp, #-16]!
- stp x2, x3, [sp, #-16]!
- stp x0, x1, [sp, #-16]!
-
- mov x0, x19 // Thread::Current.
- mov x1, sp // SP.
- bl artWorkAroundAppJniBugs // (Thread*, SP).
- mov x17, x0 // save target return.
-
- // load spill regs.
- ldp x0, x1, [sp], #16
- ldp x2, x3, [sp], #16
- ldp x4, x5, [sp], #16
- ldp x6, x7, [sp], #16
- ldp d0, d1, [sp], #16
- ldp d2, d3, [sp], #16
- ldp d4, d5, [sp], #16
- ldp d6, d7, [sp], #16
- ldp x29, x30, [sp], #16
-
- //tail call into JNI routine.
- br x17
-END art_work_around_app_jni_bugs
-
diff --git a/runtime/arch/mips/jni_entrypoints_mips.S b/runtime/arch/mips/jni_entrypoints_mips.S
index f9ca7df..e5f4a79 100644
--- a/runtime/arch/mips/jni_entrypoints_mips.S
+++ b/runtime/arch/mips/jni_entrypoints_mips.S
@@ -54,36 +54,3 @@ ENTRY art_jni_dlsym_lookup_stub
jr $ra
nop
END art_jni_dlsym_lookup_stub
-
- /*
- * Entry point of native methods when JNI bug compatibility is enabled.
- */
- .extern artWorkAroundAppJniBugs
-ENTRY art_work_around_app_jni_bugs
- GENERATE_GLOBAL_POINTER
- # save registers that may contain arguments and LR that will be crushed by a call
- addiu $sp, $sp, -32
- .cfi_adjust_cfa_offset 32
- sw $ra, 28($sp)
- .cfi_rel_offset 31, 28
- sw $a3, 24($sp)
- .cfi_rel_offset 7, 28
- sw $a2, 20($sp)
- .cfi_rel_offset 6, 28
- sw $a1, 16($sp)
- .cfi_rel_offset 5, 28
- sw $a0, 12($sp)
- .cfi_rel_offset 4, 28
- move $a0, rSELF # pass Thread::Current
- jal artWorkAroundAppJniBugs # (Thread*, $sp)
- move $a1, $sp # pass $sp
- move $t9, $v0 # save target address
- lw $a0, 12($sp)
- lw $a1, 16($sp)
- lw $a2, 20($sp)
- lw $a3, 24($sp)
- lw $ra, 28($sp)
- jr $t9 # tail call into JNI routine
- addiu $sp, $sp, 32
- .cfi_adjust_cfa_offset -32
-END art_work_around_app_jni_bugs
diff --git a/runtime/check_jni.cc b/runtime/check_jni.cc
index 960c26d..b52941b 100644
--- a/runtime/check_jni.cc
+++ b/runtime/check_jni.cc
@@ -765,14 +765,9 @@ class ScopedCheck {
// Verify that the current thread is (a) attached and (b) associated with
// this particular instance of JNIEnv.
if (soa_.Env() != threadEnv) {
- if (soa_.Vm()->work_around_app_jni_bugs) {
- // If we're keeping broken code limping along, we need to suppress the abort...
- LOG(ERROR) << "APP BUG DETECTED: thread " << *self << " using JNIEnv* from thread " << *soa_.Self();
- } else {
- JniAbortF(function_name_, "thread %s using JNIEnv* from thread %s",
- ToStr<Thread>(*self).c_str(), ToStr<Thread>(*soa_.Self()).c_str());
- return;
- }
+ JniAbortF(function_name_, "thread %s using JNIEnv* from thread %s",
+ ToStr<Thread>(*self).c_str(), ToStr<Thread>(*soa_.Self()).c_str());
+ return;
}
// Verify that, if this thread previously made a critical "get" call, we
diff --git a/runtime/indirect_reference_table.cc b/runtime/indirect_reference_table.cc
index bbad884..987df91 100644
--- a/runtime/indirect_reference_table.cc
+++ b/runtime/indirect_reference_table.cc
@@ -254,20 +254,11 @@ bool IndirectReferenceTable::Remove(uint32_t cookie, IndirectRef iref) {
int idx = ExtractIndex(iref);
- JavaVMExt* vm = Runtime::Current()->GetJavaVM();
if (GetIndirectRefKind(iref) == kSirtOrInvalid &&
Thread::Current()->SirtContains(reinterpret_cast<jobject>(iref))) {
LOG(WARNING) << "Attempt to remove local SIRT entry from IRT, ignoring";
return true;
}
- if (GetIndirectRefKind(iref) == kSirtOrInvalid && vm->work_around_app_jni_bugs) {
- mirror::Object* direct_pointer = reinterpret_cast<mirror::Object*>(iref);
- idx = Find(direct_pointer, bottomIndex, topIndex, table_);
- if (idx == -1) {
- LOG(WARNING) << "Trying to work around app JNI bugs, but didn't find " << iref << " in table!";
- return false;
- }
- }
if (idx < bottomIndex) {
// Wrong segment.
@@ -285,7 +276,7 @@ bool IndirectReferenceTable::Remove(uint32_t cookie, IndirectRef iref) {
if (idx == topIndex-1) {
// Top-most entry. Scan up and consume holes.
- if (!vm->work_around_app_jni_bugs && !CheckEntry("remove", iref, idx)) {
+ if (!CheckEntry("remove", iref, idx)) {
return false;
}
@@ -321,7 +312,7 @@ bool IndirectReferenceTable::Remove(uint32_t cookie, IndirectRef iref) {
LOG(INFO) << "--- WEIRD: removing null entry " << idx;
return false;
}
- if (!vm->work_around_app_jni_bugs && !CheckEntry("remove", iref, idx)) {
+ if (!CheckEntry("remove", iref, idx)) {
return false;
}
diff --git a/runtime/jni_internal.cc b/runtime/jni_internal.cc
index f7aeffd..38aeaee 100644
--- a/runtime/jni_internal.cc
+++ b/runtime/jni_internal.cc
@@ -2444,23 +2444,6 @@ class JNI {
if (static_cast<JNIEnvExt*>(env)->self->SirtContains(java_object)) {
return JNILocalRefType;
}
-
- if (!static_cast<JNIEnvExt*>(env)->vm->work_around_app_jni_bugs) {
- return JNIInvalidRefType;
- }
-
- // If we're handing out direct pointers, check whether it's a direct pointer to a local
- // reference.
- {
- ScopedObjectAccess soa(env);
- if (soa.Decode<mirror::Object*>(java_object) ==
- reinterpret_cast<mirror::Object*>(java_object)) {
- mirror::Object* object = reinterpret_cast<mirror::Object*>(java_object);
- if (soa.Env()->locals.ContainsDirectPointer(object)) {
- return JNILocalRefType;
- }
- }
- }
return JNIInvalidRefType;
}
LOG(FATAL) << "IndirectRefKind[" << kind << "]";
@@ -2993,7 +2976,6 @@ JavaVMExt::JavaVMExt(Runtime* runtime, ParsedOptions* options)
check_jni(false),
force_copy(false), // TODO: add a way to enable this
trace(options->jni_trace_),
- work_around_app_jni_bugs(false),
pins_lock("JNI pin table lock", kPinTableLock),
pin_table("pin table", kPinTableInitial, kPinTableMax),
globals_lock("JNI global reference table lock"),
@@ -3044,7 +3026,6 @@ void JavaVMExt::DumpForSigQuit(std::ostream& os) {
if (force_copy) {
os << " (with forcecopy)";
}
- os << "; workarounds are " << (work_around_app_jni_bugs ? "on" : "off");
Thread* self = Thread::Current();
{
MutexLock mu(self, pins_lock);
diff --git a/runtime/jni_internal.h b/runtime/jni_internal.h
index 42796db..ec911b2 100644
--- a/runtime/jni_internal.h
+++ b/runtime/jni_internal.h
@@ -110,9 +110,6 @@ class JavaVMExt : public JavaVM {
// Extra diagnostics.
std::string trace;
- // Used to provide compatibility for apps that assumed direct references.
- bool work_around_app_jni_bugs;
-
// Used to hold references to pinned primitive arrays.
Mutex pins_lock DEFAULT_MUTEX_ACQUIRED_AFTER;
ReferenceTable pin_table GUARDED_BY(pins_lock);
@@ -149,7 +146,7 @@ struct JNIEnvExt : public JNIEnv {
void PopFrame();
template<typename T>
- T AddLocalReference(mirror::Object* obj, bool jni_work_arounds)
+ T AddLocalReference(mirror::Object* obj)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
static Offset SegmentStateOffset();
@@ -216,7 +213,7 @@ class ScopedJniEnvLocalRefState {
};
template<typename T>
-inline T JNIEnvExt::AddLocalReference(mirror::Object* obj, bool jni_work_arounds) {
+inline T JNIEnvExt::AddLocalReference(mirror::Object* obj) {
IndirectRef ref = locals.Add(local_ref_cookie, obj);
// TODO: fix this to understand PushLocalFrame, so we can turn it on.
@@ -231,9 +228,6 @@ inline T JNIEnvExt::AddLocalReference(mirror::Object* obj, bool jni_work_arounds
}
}
- if (jni_work_arounds) {
- return reinterpret_cast<T>(obj);
- }
return reinterpret_cast<T>(ref);
}
diff --git a/runtime/mirror/art_method.cc b/runtime/mirror/art_method.cc
index ee5a0a4..c998346 100644
--- a/runtime/mirror/art_method.cc
+++ b/runtime/mirror/art_method.cc
@@ -342,30 +342,15 @@ bool ArtMethod::IsRegistered() {
return native_method != jni_stub;
}
-extern "C" void art_work_around_app_jni_bugs(JNIEnv*, jobject);
void ArtMethod::RegisterNative(Thread* self, const void* native_method, bool is_fast) {
DCHECK(Thread::Current() == self);
CHECK(IsNative()) << PrettyMethod(this);
CHECK(!IsFastNative()) << PrettyMethod(this);
CHECK(native_method != NULL) << PrettyMethod(this);
- if (!self->GetJniEnv()->vm->work_around_app_jni_bugs) {
- if (is_fast) {
- SetAccessFlags(GetAccessFlags() | kAccFastNative);
- }
- SetNativeMethod(native_method);
- } else {
- // We've been asked to associate this method with the given native method but are working
- // around JNI bugs, that include not giving Object** SIRT references to native methods. Direct
- // the native method to runtime support and store the target somewhere runtime support will
- // find it.
-#if defined(__i386__) || defined(__x86_64__)
- UNIMPLEMENTED(FATAL);
-#else
- SetNativeMethod(reinterpret_cast<void*>(art_work_around_app_jni_bugs));
-#endif
- SetFieldPtr<false>(OFFSET_OF_OBJECT_MEMBER(ArtMethod, gc_map_),
- reinterpret_cast<const uint8_t*>(native_method), false);
+ if (is_fast) {
+ SetAccessFlags(GetAccessFlags() | kAccFastNative);
}
+ SetNativeMethod(native_method);
}
void ArtMethod::UnregisterNative(Thread* self) {
diff --git a/runtime/native/dalvik_system_VMRuntime.cc b/runtime/native/dalvik_system_VMRuntime.cc
index 5c5eaa1..76c5866 100644
--- a/runtime/native/dalvik_system_VMRuntime.cc
+++ b/runtime/native/dalvik_system_VMRuntime.cc
@@ -164,23 +164,12 @@ static jstring VMRuntime_vmLibrary(JNIEnv* env, jobject) {
}
static void VMRuntime_setTargetSdkVersionNative(JNIEnv* env, jobject, jint targetSdkVersion) {
- // This is the target SDK version of the app we're about to run.
+ // This is the target SDK version of the app we're about to run. It is intended that this a place
+ // where workarounds can be enabled.
// Note that targetSdkVersion may be CUR_DEVELOPMENT (10000).
// Note that targetSdkVersion may be 0, meaning "current".
- if (targetSdkVersion > 0 && targetSdkVersion <= 13 /* honeycomb-mr2 */) {
- Runtime* runtime = Runtime::Current();
- JavaVMExt* vm = runtime->GetJavaVM();
- if (vm->check_jni) {
- LOG(INFO) << "CheckJNI enabled: not enabling JNI app bug workarounds.";
- } else {
- LOG(INFO) << "Turning on JNI app bug workarounds for target SDK version "
- << targetSdkVersion << "...";
-
- vm->work_around_app_jni_bugs = true;
- LOG(WARNING) << "Permenantly disabling heap compaction due to jni workarounds";
- Runtime::Current()->GetHeap()->DisableCompaction();
- }
- }
+ UNUSED(env);
+ UNUSED(targetSdkVersion);
}
static void VMRuntime_registerNativeAllocation(JNIEnv* env, jobject, jint bytes) {
diff --git a/runtime/scoped_thread_state_change.h b/runtime/scoped_thread_state_change.h
index ebc5452..404c616 100644
--- a/runtime/scoped_thread_state_change.h
+++ b/runtime/scoped_thread_state_change.h
@@ -171,7 +171,7 @@ class ScopedObjectAccessUnchecked : public ScopedThreadStateChange {
DCHECK_NE((reinterpret_cast<uintptr_t>(obj) & 0xffff0000), 0xebad0000);
- return Env()->AddLocalReference<T>(obj, Vm()->work_around_app_jni_bugs);
+ return Env()->AddLocalReference<T>(obj);
}
template<typename T>
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 8691dec..eae5507 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -1248,10 +1248,6 @@ mirror::Object* Thread::DecodeJObject(jobject obj) const {
// Read from SIRT.
result = reinterpret_cast<StackReference<mirror::Object>*>(obj)->AsMirrorPtr();
VerifyObject(result);
- } else if (Runtime::Current()->GetJavaVM()->work_around_app_jni_bugs) {
- // Assume an invalid local reference is actually a direct pointer.
- result = reinterpret_cast<mirror::Object*>(obj);
- VerifyObject(result);
} else {
result = kInvalidIndirectRefObject;
}