/* Only flush the part in the code cache that is being used now */
dvmCompilerCacheFlush((intptr_t) gDvmJit.codeCache,
(intptr_t) gDvmJit.codeCache + templateSize, 0);
-
- int result = mprotect(gDvmJit.codeCache, gDvmJit.codeCacheSize,
- PROTECT_CODE_CACHE_ATTRS);
-
- if (result == -1) {
- ALOGE("Failed to remove the write permission for the code cache");
- dvmAbort();
- }
#else
gDvmJit.codeCacheByteUsed = 0;
stream = (char*)gDvmJit.codeCache + gDvmJit.codeCacheByteUsed;
ALOGV("stream = %p after initJIT", stream);
#endif
+ int result = mprotect(gDvmJit.codeCache, gDvmJit.codeCacheSize,
+ PROTECT_CODE_CACHE_ATTRS);
+
+ if (result == -1) {
+ ALOGE("Failed to remove the write permission for the code cache");
+ dvmAbort();
+ }
+
return true;
}
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 */
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 {
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;
}
}
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;
}
}
*/
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;
}
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;
}
*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) {