summaryrefslogtreecommitdiffstats
path: root/vm/compiler/codegen
diff options
context:
space:
mode:
authorJun Tian <jun.j.tian@intel.com>2013-08-06 15:03:15 +0800
committerJun Tian <jun.j.tian@intel.com>2013-08-09 08:56:31 +0800
commit74a62214ef262380371bc21be2a1c42295046fb2 (patch)
tree9cf7d0431a1ce2a6320e09a5fe29895f9172895f /vm/compiler/codegen
parentcec783df5a51233dab94f2fa4506f677d45132e8 (diff)
downloadandroid_dalvik-74a62214ef262380371bc21be2a1c42295046fb2.tar.gz
android_dalvik-74a62214ef262380371bc21be2a1c42295046fb2.tar.bz2
android_dalvik-74a62214ef262380371bc21be2a1c42295046fb2.zip
Fix the protection of code cache for x86 JIT
During generation of code into code cache an unprotected region of memory does not correspond to protected one, The patch fixes that. Author: Katkov Serguei <serguei.i.katkov@intel.com> Change-Id: Ia363f27099891244f760c457bdad8c51cfcc394c
Diffstat (limited to 'vm/compiler/codegen')
-rw-r--r--vm/compiler/codegen/x86/CodegenInterface.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/vm/compiler/codegen/x86/CodegenInterface.cpp b/vm/compiler/codegen/x86/CodegenInterface.cpp
index 46f097971..3027929a1 100644
--- a/vm/compiler/codegen/x86/CodegenInterface.cpp
+++ b/vm/compiler/codegen/x86/CodegenInterface.cpp
@@ -1081,14 +1081,14 @@ void dvmCompilerMIR2LIR(CompilationUnit *cUnit, JitTranslationInfo *info)
info->codeAddress = NULL;
stream = (char*)gDvmJit.codeCache + gDvmJit.codeCacheByteUsed;
+ streamStart = stream; /* trace start before alignment */
// TODO: compile into a temporary buffer and then copy into the code cache.
// That would let us leave the code cache unprotected for a shorter time.
size_t unprotected_code_cache_bytes =
- gDvmJit.codeCacheSize - gDvmJit.codeCacheByteUsed - CODE_CACHE_PADDING;
- UNPROTECT_CODE_CACHE(stream, unprotected_code_cache_bytes);
+ gDvmJit.codeCacheSize - gDvmJit.codeCacheByteUsed;
+ UNPROTECT_CODE_CACHE(streamStart, unprotected_code_cache_bytes);
- streamStart = stream; /* trace start before alignment */
stream += EXTRA_BYTES_FOR_CHAINING; /* This is needed for chaining. Add the bytes before the alignment */
stream = (char*)(((unsigned int)stream + 0xF) & ~0xF); /* Align trace to 16-bytes */
streamMethodStart = stream; /* code start */
@@ -1248,7 +1248,7 @@ void dvmCompilerMIR2LIR(CompilationUnit *cUnit, JitTranslationInfo *info)
if(cg_ret < 0) {
endOfTrace(true/*freeOnly*/);
cUnit->baseAddr = NULL;
- PROTECT_CODE_CACHE(stream, unprotected_code_cache_bytes);
+ PROTECT_CODE_CACHE(streamStart, unprotected_code_cache_bytes);
return;
}
} else {
@@ -1289,7 +1289,7 @@ void dvmCompilerMIR2LIR(CompilationUnit *cUnit, JitTranslationInfo *info)
gDvmJit.codeCacheFull = true;
cUnit->baseAddr = NULL;
endOfTrace(true/*freeOnly*/);
- PROTECT_CODE_CACHE(stream, unprotected_code_cache_bytes);
+ PROTECT_CODE_CACHE(streamStart, unprotected_code_cache_bytes);
return;
}
}
@@ -1383,7 +1383,7 @@ gen_fallthrough:
gDvmJit.codeCacheFull = true;
cUnit->baseAddr = NULL;
endOfTrace(true); /* need to free structures */
- PROTECT_CODE_CACHE(stream, unprotected_code_cache_bytes);
+ PROTECT_CODE_CACHE(streamStart, unprotected_code_cache_bytes);
return;
}
}
@@ -1399,7 +1399,7 @@ gen_fallthrough:
*/
ALOGI("JIT code cache full after endOfTrace (trace uses %uB)", (stream - streamStart));
cUnit->baseAddr = NULL;
- PROTECT_CODE_CACHE(stream, unprotected_code_cache_bytes);
+ PROTECT_CODE_CACHE(streamStart, unprotected_code_cache_bytes);
return;
}
@@ -1421,7 +1421,7 @@ gen_fallthrough:
ALOGI("JIT code cache full after ChainingCellCounts (trace uses %uB)", (stream - streamStart));
gDvmJit.codeCacheFull = true;
cUnit->baseAddr = NULL;
- PROTECT_CODE_CACHE(stream, unprotected_code_cache_bytes);
+ PROTECT_CODE_CACHE(streamStart, unprotected_code_cache_bytes);
return;
}
@@ -1430,7 +1430,7 @@ gen_fallthrough:
*pOffset = streamCountStart - streamMethodStart; /* from codeAddr */
pOffset[1] = streamChainingStart - streamMethodStart;
- PROTECT_CODE_CACHE(stream, unprotected_code_cache_bytes);
+ PROTECT_CODE_CACHE(streamStart, unprotected_code_cache_bytes);
gDvmJit.codeCacheByteUsed += (stream - streamStart);
if (cUnit->printMe) {