diff options
author | Bill Buzbee <buzbee@android.com> | 2014-01-10 14:25:53 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-01-10 14:25:54 +0000 |
commit | dff2448094b7f7413f866f744f4381a97ba35bd2 (patch) | |
tree | 527e23ee9d0ed182a0fe98dcc7a0ad4d80f128fa | |
parent | d907de554036cc37444b914725510b458ed545b3 (diff) | |
parent | 522811d183e5cc7d5ac3e1bce1baa16e0d9a7170 (diff) | |
download | android_dalvik-dff2448094b7f7413f866f744f4381a97ba35bd2.tar.gz android_dalvik-dff2448094b7f7413f866f744f4381a97ba35bd2.tar.bz2 android_dalvik-dff2448094b7f7413f866f744f4381a97ba35bd2.zip |
Merge "Protect JIT Code cache modifications with version check"
-rw-r--r-- | vm/compiler/Frontend.cpp | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/vm/compiler/Frontend.cpp b/vm/compiler/Frontend.cpp index 47c1898a0..916915d01 100644 --- a/vm/compiler/Frontend.cpp +++ b/vm/compiler/Frontend.cpp @@ -1579,16 +1579,23 @@ static bool compileLoop(CompilationUnit *cUnit, unsigned int startOffset, dvmCompilerCodegenDump(cUnit); } - /* - * If this trace uses class objects as constants, - * dvmJitInstallClassObjectPointers will switch the thread state - * to running and look up the class pointers using the descriptor/loader - * tuple stored in the callsite info structure. We need to make this window - * as short as possible since it is blocking GC. - */ - if (cUnit->hasClassLiterals && info->codeAddress) { - dvmJitInstallClassObjectPointers(cUnit, (char *) info->codeAddress); + dvmLockMutex(&gDvmJit.compilerLock); + if (info->cacheVersion == gDvmJit.cacheVersion) { + /* + * If this trace uses class objects as constants, + * dvmJitInstallClassObjectPointers will switch the thread state + * to running and look up the class pointers using the descriptor/loader + * tuple stored in the callsite info structure. We need to make this window + * as short as possible since it is blocking GC. + */ + if (cUnit->hasClassLiterals && info->codeAddress) { + dvmJitInstallClassObjectPointers(cUnit, (char *) info->codeAddress); + } + } else { + ALOGD("JIT CC reset. New version: %d / trace version: %d", + gDvmJit.cacheVersion, info->cacheVersion); } + dvmUnlockMutex(&gDvmJit.compilerLock); /* * Since callsiteinfo is allocated from the arena, delay the reset until @@ -2151,16 +2158,23 @@ bool dvmCompileTrace(JitTraceDescription *desc, int numMaxInsts, optHints); } - /* - * If this trace uses class objects as constants, - * dvmJitInstallClassObjectPointers will switch the thread state - * to running and look up the class pointers using the descriptor/loader - * tuple stored in the callsite info structure. We need to make this window - * as short as possible since it is blocking GC. - */ - if (cUnit.hasClassLiterals && info->codeAddress) { - dvmJitInstallClassObjectPointers(&cUnit, (char *) info->codeAddress); + dvmLockMutex(&gDvmJit.compilerLock); + if (info->cacheVersion == gDvmJit.cacheVersion) { + /* + * If this trace uses class objects as constants, + * dvmJitInstallClassObjectPointers will switch the thread state + * to running and look up the class pointers using the descriptor/loader + * tuple stored in the callsite info structure. We need to make this window + * as short as possible since it is blocking GC. + */ + if (cUnit.hasClassLiterals && info->codeAddress) { + dvmJitInstallClassObjectPointers(&cUnit, (char *) info->codeAddress); + } + } else { + ALOGD("JIT CC reset. New version: %d / trace version: %d", + gDvmJit.cacheVersion, info->cacheVersion); } + dvmUnlockMutex(&gDvmJit.compilerLock); /* * Since callsiteinfo is allocated from the arena, delay the reset until |