Revert "Make the JIT zygote memory shared."

This reverts commit 05f87217ddc9b4b9186710c0135b918f456c5aef.

Bug: 119800099
Bug: 136110523

Reason for revert: testWebview flaking

Change-Id: I96afa6bc9c56c4aaf5ed72ae370f6f69c096c559
diff --git a/runtime/jit/jit_memory_region.cc b/runtime/jit/jit_memory_region.cc
index 3438c37..2db5245 100644
--- a/runtime/jit/jit_memory_region.cc
+++ b/runtime/jit/jit_memory_region.cc
@@ -64,14 +64,9 @@
   // File descriptor enabling dual-view mapping of code section.
   unique_fd mem_fd;
 
-  if (is_zygote) {
-    // Because we are not going to GC code generated by the zygote, just use all available.
-    current_capacity_ = max_capacity;
-    mem_fd = unique_fd(CreateZygoteMemory(capacity, error_msg));
-    if (mem_fd.get() < 0) {
-      return false;
-    }
-  } else {
+  // Zygote shouldn't create a shared mapping for JIT, so we cannot use dual view
+  // for it.
+  if (!is_zygote) {
     // Bionic supports memfd_create, but the call may fail on older kernels.
     mem_fd = unique_fd(art::memfd_create("/jit-cache", /* flags= */ 0));
     if (mem_fd.get() < 0) {
@@ -84,14 +79,16 @@
         return false;
       }
       VLOG(jit) << oss.str();
-    } else if (ftruncate(mem_fd, capacity) != 0) {
-      std::ostringstream oss;
-      oss << "Failed to initialize memory file: " << strerror(errno);
-      *error_msg = oss.str();
-      return false;
     }
   }
 
+  if (mem_fd.get() >= 0 && ftruncate(mem_fd, capacity) != 0) {
+    std::ostringstream oss;
+    oss << "Failed to initialize memory file: " << strerror(errno);
+    *error_msg = oss.str();
+    return false;
+  }
+
   std::string data_cache_name = is_zygote ? "zygote-data-code-cache" : "data-code-cache";
   std::string exec_cache_name = is_zygote ? "zygote-jit-code-cache" : "jit-code-cache";
 
@@ -210,13 +207,6 @@
         }
       }
     }
-    if (is_zygote) {
-      // Now that we have created the writable and executable mappings, prevent creating any new
-      // ones.
-      if (!ProtectZygoteMemory(mem_fd.get(), error_msg)) {
-        return false;
-      }
-    }
   } else {
     // Profiling only. No memory for code required.
   }
@@ -244,14 +234,15 @@
     CheckedCall(mprotect, "create code heap", code_heap->Begin(), code_heap->Size(), kProtRW);
     exec_mspace_ = create_mspace_with_base(code_heap->Begin(), exec_end_, false /*locked*/);
     CHECK(exec_mspace_ != nullptr) << "create_mspace_with_base (exec) failed";
-    SetFootprintLimit(current_capacity_);
+    SetFootprintLimit(initial_capacity_);
     // Protect pages containing heap metadata. Updates to the code heap toggle write permission to
     // perform the update and there are no other times write access is required.
     CheckedCall(mprotect, "protect code heap", code_heap->Begin(), code_heap->Size(), kProtR);
   } else {
     exec_mspace_ = nullptr;
-    SetFootprintLimit(current_capacity_);
+    SetFootprintLimit(initial_capacity_);
   }
+
   return true;
 }