ART: Add wrappers for membarrier and memfd_create()

Adds art::membarrer() and art::memfd_create() as wrappers around the
similarly named linux syscalls. These wrappers can fail due to missing
OS support so code that uses them needs to deal with this.

Updates the JIT code cache to use art::membarrer().

Bug: 111199492
Test: art/test.py --host
Change-Id: I122746e6293e7201077e834d8a5ed7bbba45e283
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index bcbdc3b..191795b 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -23,6 +23,7 @@
 #include "base/enums.h"
 #include "base/histogram-inl.h"
 #include "base/logging.h"  // For VLOG.
+#include "base/membarrier.h"
 #include "base/mem_map.h"
 #include "base/quasi_atomic.h"
 #include "base/stl_util.h"
@@ -187,6 +188,11 @@
     return nullptr;
   }
 
+  // Register for membarrier expedited sync core if JIT will be generating code.
+  if (!used_only_for_profile_data) {
+    art::membarrier(art::MembarrierCommand::kRegisterPrivateExpeditedSyncCore);
+  }
+
   // Decide how we should map the code and data sections.
   // If we use the code cache just for profiling we do not need to map the code section as
   // executable.
@@ -809,9 +815,8 @@
     // shootdown (incidentally invalidating the CPU pipelines by sending an IPI to all cores to
     // notify them of the TLB invalidation). Some architectures, notably ARM and ARM64, have
     // hardware support that broadcasts TLB invalidations and so their kernels have no software
-    // based TLB shootdown. FlushInstructionPipeline() is a wrapper around the Linux
-    // membarrier(MEMBARRIER_CMD_PRIVATE_EXPEDITED) syscall which does the appropriate flushing.
-    FlushInstructionPipeline();
+    // based TLB shootdown.
+    art::membarrier(art::MembarrierCommand::kPrivateExpeditedSyncCore);
 
     DCHECK(!Runtime::Current()->IsAotCompiler());
     if (has_should_deoptimize_flag) {