Remove CHECK and don't free code/data in zygote space.
jvmti can redefine classes and request free-ing code generated
by the zygote. In this case, don't free the memory, as that would
actually lead to dirty memory, which is opposite the idea of
saving memory.
bug: 120653173
Test: com.android.server.wifi.test
Change-Id: I8552f075e68e6646f06842a8abf7ec65da6be292
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 1d53a58..fdb6b86 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -2072,7 +2072,10 @@
}
void JitCodeCache::FreeCode(uint8_t* code) {
- CHECK(!IsInZygoteExecSpace(code));
+ if (IsInZygoteExecSpace(code)) {
+ // No need to free, this is shared memory.
+ return;
+ }
used_memory_for_code_ -= mspace_usable_size(code);
mspace_free(exec_mspace_, code);
}
@@ -2084,7 +2087,10 @@
}
void JitCodeCache::FreeData(uint8_t* data) {
- CHECK(!IsInZygoteDataSpace(data));
+ if (IsInZygoteDataSpace(data)) {
+ // No need to free, this is shared memory.
+ return;
+ }
used_memory_for_data_ -= mspace_usable_size(data);
mspace_free(data_mspace_, data);
}