Don't force-allocate a profiling info when we cannot.

Shared memory cannot allocate profiling infos.

Test: art/test/run-test --always-clean --dex2oat-jobs 4 --host --prebuild --compact-dex-level fast --jit --runtime-option -Xjitthreshold:0 --no-relocate --runtime-option -Xcheck:jni 689-zygote-jit-deopt
Change-Id: Ib09b9989fb398a12af29501e72b9acd22c3e51ec
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 4288097..382b333 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -939,10 +939,10 @@
 
 void Jit::MethodEntered(Thread* thread, ArtMethod* method) {
   Runtime* runtime = Runtime::Current();
-  if (UNLIKELY(runtime->UseJitCompilation() && runtime->GetJit()->JitAtFirstUse())) {
+  if (UNLIKELY(runtime->UseJitCompilation() && JitAtFirstUse())) {
     ArtMethod* np_method = method->GetInterfaceMethodIfProxy(kRuntimePointerSize);
     if (np_method->IsCompilable()) {
-      if (!np_method->IsNative()) {
+      if (!np_method->IsNative() && GetCodeCache()->CanAllocateProfilingInfo()) {
         // The compiler requires a ProfilingInfo object for non-native methods.
         ProfilingInfo::Create(thread, np_method, /* retry_allocation= */ true);
       }