hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp
changeset 38190 ff9ac612c723
parent 38174 f611c50b8703
child 38209 b2a58604e046
--- a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp	Wed May 04 17:47:05 2016 +0300
+++ b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp	Wed May 04 15:32:26 2016 -0400
@@ -226,6 +226,23 @@
 extern "C" void FetchNResume () ;
 #endif
 
+// An operation in Unsafe has faulted.  We're going to return to the
+// instruction after the faulting load or store.  We also set
+// pending_unsafe_access_error so that at some point in the future our
+// user will get a helpful message.
+static address handle_unsafe_access(JavaThread* thread, address pc) {
+  // pc is the instruction which we must emulate
+  // doing a no-op is fine:  return garbage from the load
+  // therefore, compute npc
+  address npc = pc + NativeCall::instruction_size;
+
+  // request an async exception
+  thread->set_pending_unsafe_access_error();
+
+  // return address of next instruction to execute
+  return npc;
+}
+
 extern "C" JNIEXPORT int
 JVM_handle_linux_signal(int sig,
                         siginfo_t* info,
@@ -370,8 +387,7 @@
         CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
         CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
         if (nm != NULL && nm->has_unsafe_access()) {
-          address next_pc = pc + NativeCall::instruction_size;
-          stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
+          stub = handle_unsafe_access(thread, pc);
         }
       }
       else
@@ -392,8 +408,7 @@
     } else if (thread->thread_state() == _thread_in_vm &&
                sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
                thread->doing_unsafe_access()) {
-      address next_pc = pc + NativeCall::instruction_size;
-      stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
+        stub = handle_unsafe_access(thread, pc);
     }
 
     // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in