INNER CODE UNIT · C++
length
tiann/epic · library/src/main/cpp/epic.cpp:322
jsize length = env->GetArrayLength(code);
jlong cookie = 0;
bool isNougat = api_level >= 24;
if (isNougat) {
// We do thus things:
// 1. modify the code mprotect
// 2. modify the code
// Ideal, this two operation must be atomic. Below N, this is safe, because no one
// modify the code except ourselves;
// But in Android N, When the jit is working, between our step 1 and step 2,
// if we modity the mprotect of the code, and planning to write the code,
// the jit thread may modify the mprotect of the code meanwhile
// we must suspend all thread to ensure the atomic operation.
LOGV("suspend all thread.");
cookie = epic_suspendAll(env, jclazz);