changeset 29575:437742bd5a1b

Merge
author dcubed
date Fri, 13 Mar 2015 09:18:28 -0700
parents 82f545c6572b ab0121071f54
children bb06d25e302d 0d3bd11f9e02
files hotspot/src/share/vm/prims/whitebox.cpp hotspot/src/share/vm/runtime/stubRoutines.hpp
diffstat 43 files changed, 308 insertions(+), 220 deletions(-) [+]
line wrap: on
line diff
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/ppc64/PPC64Frame.java	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,10 +63,6 @@
   // Entry frames
   private static int ENTRY_FRAME_CALL_WRAPPER_OFFSET;
 
-  // Native frames
-  private static int NATIVE_FRAME_INITIAL_PARAM_OFFSET;
-
-
   static {
     VM.registerVMInitializedObserver(new Observer() {
       public void update(Observable o, Object data) {
@@ -76,10 +72,8 @@
   }
 
   private static synchronized void initialize(TypeDataBase db) {
-    int abi_minframe_size = db.lookupIntConstant("frame::abi_minframe_size").intValue();
     int entry_frame_locals_size = db.lookupIntConstant("frame::entry_frame_locals_size").intValue();
     int wordLength = (int) VM.getVM().getAddressSize();
-    NATIVE_FRAME_INITIAL_PARAM_OFFSET = -abi_minframe_size/wordLength;
     ENTRY_FRAME_CALL_WRAPPER_OFFSET = -entry_frame_locals_size/wordLength;
   }
 
@@ -389,13 +383,6 @@
   // Return address:
   public Address getSenderPC()     { return getSenderSP().getAddressAt(2 * VM.getVM().getAddressSize()); }
 
-  // return address of param, zero origin index.
-  // MPJ note:   Appears to be unused.
-  public Address getNativeParamAddr(int idx) {
-    return null;
-    // return addressOfStackSlot(NATIVE_FRAME_INITIAL_PARAM_OFFSET + idx);
-  }
-
   public Address getSenderSP()     { return getFP(); }
   public Address addressOfInterpreterFrameLocals() {
     return addressOfStackSlot(INTERPRETER_FRAME_LOCALS_OFFSET);
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/x86/X86Frame.java	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -63,9 +63,6 @@
   // Entry frames
   private static       int ENTRY_FRAME_CALL_WRAPPER_OFFSET;
 
-  // Native frames
-  private static final int NATIVE_FRAME_INITIAL_PARAM_OFFSET =  2;
-
   private static VMReg rbp;
 
   static {
@@ -423,20 +420,12 @@
     return addressOfStackSlot(LINK_OFFSET).getAddressAt(0);
   }
 
-  // FIXME: not implementable yet
-  //inline void      frame::set_link(intptr_t* addr)  { *(intptr_t **)addr_at(link_offset) = addr; }
-
   public Address getUnextendedSP() { return raw_unextendedSP; }
 
   // Return address:
   public Address getSenderPCAddr() { return addressOfStackSlot(RETURN_ADDR_OFFSET); }
   public Address getSenderPC()     { return getSenderPCAddr().getAddressAt(0);      }
 
-  // return address of param, zero origin index.
-  public Address getNativeParamAddr(int idx) {
-    return addressOfStackSlot(NATIVE_FRAME_INITIAL_PARAM_OFFSET + idx);
-  }
-
   public Address getSenderSP()     { return addressOfStackSlot(SENDER_SP_OFFSET); }
 
   public Address addressOfInterpreterFrameLocals() {
--- a/hotspot/make/linux/Makefile	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/make/linux/Makefile	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -233,7 +233,7 @@
 # Solaris 2.5.1, 2.6).
 # Disable this check by setting DISABLE_HOTSPOT_OS_VERSION_CHECK=ok.
 
-SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 3%
+SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 3% 4%
 OS_VERSION := $(shell uname -r)
 EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION))
 
--- a/hotspot/make/windows/makefiles/projectcreator.make	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/make/windows/makefiles/projectcreator.make	Fri Mar 13 09:18:28 2015 -0700
@@ -69,6 +69,7 @@
         -ignorePath ppc \
         -ignorePath zero \
         -ignorePath aix \
+        -ignorePath aarch64 \
         -hidePath .hg
 
 
--- a/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -136,12 +136,7 @@
     entry_frame_call_wrapper_offset                  = -8,
 
     // we don't need a save area
-    arg_reg_save_area_bytes                          =  0,
-
-    // TODO - check that this is still correct
-    // Native frames
-
-    native_frame_initial_param_offset                =  2
+    arg_reg_save_area_bytes                          =  0
 
   };
 
@@ -195,9 +190,6 @@
 
   inline address* sender_pc_addr() const;
 
-  // return address of param, zero origin index.
-  inline address* native_param_addr(int idx) const;
-
   // expression stack tos if we are nested in a java call
   intptr_t* interpreter_frame_last_sp() const;
 
--- a/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -166,7 +166,6 @@
 
 
 inline intptr_t* frame::link() const              { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }
-inline void      frame::set_link(intptr_t* addr)  { *(intptr_t **)addr_at(link_offset) = addr; }
 
 
 inline intptr_t* frame::unextended_sp() const     { return _unextended_sp; }
@@ -176,9 +175,6 @@
 inline address* frame::sender_pc_addr()      const { return (address*) addr_at( return_addr_offset); }
 inline address  frame::sender_pc()           const { return *sender_pc_addr(); }
 
-// return address of param, zero origin index.
-inline address* frame::native_param_addr(int idx) const { return (address*) addr_at( native_frame_initial_param_offset+idx); }
-
 #ifdef CC_INTERP
 
 inline interpreterState frame::get_interpreterState() const {
--- a/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,8 +69,6 @@
 
 inline intptr_t* frame::link() const { return (intptr_t *)(fp()[FP->sp_offset_in_saved_window()] + STACK_BIAS); }
 
-inline void frame::set_link(intptr_t* addr) { assert(link()==addr, "frame nesting is controlled by hardware"); }
-
 inline intptr_t* frame::unextended_sp() const { return sp() + _sp_adjustment_by_callee; }
 
 // return address:
--- a/hotspot/src/cpu/x86/vm/frame_x86.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/cpu/x86/vm/frame_x86.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -128,21 +128,16 @@
     entry_frame_after_call_words                     =  28,
     entry_frame_call_wrapper_offset                  =  2,
 
-    arg_reg_save_area_bytes                          = 32, // Register argument save area
+    arg_reg_save_area_bytes                          = 32 // Register argument save area
 #else
     entry_frame_after_call_words                     = 13,
     entry_frame_call_wrapper_offset                  = -6,
 
-    arg_reg_save_area_bytes                          =  0,
+    arg_reg_save_area_bytes                          =  0
 #endif // _WIN64
 #else
-    entry_frame_call_wrapper_offset                  =  2,
+    entry_frame_call_wrapper_offset                  =  2
 #endif // AMD64
-
-    // Native frames
-
-    native_frame_initial_param_offset                =  2
-
   };
 
   intptr_t ptr_at(int offset) const {
@@ -195,9 +190,6 @@
 
   inline address* sender_pc_addr() const;
 
-  // return address of param, zero origin index.
-  inline address* native_param_addr(int idx) const;
-
   // expression stack tos if we are nested in a java call
   intptr_t* interpreter_frame_last_sp() const;
 
--- a/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -139,8 +139,6 @@
 
 
 inline intptr_t* frame::link() const              { return (intptr_t*) *(intptr_t **)addr_at(link_offset); }
-inline void      frame::set_link(intptr_t* addr)  { *(intptr_t **)addr_at(link_offset) = addr; }
-
 
 inline intptr_t* frame::unextended_sp() const     { return _unextended_sp; }
 
@@ -149,9 +147,6 @@
 inline address* frame::sender_pc_addr()      const { return (address*) addr_at( return_addr_offset); }
 inline address  frame::sender_pc()           const { return *sender_pc_addr(); }
 
-// return address of param, zero origin index.
-inline address* frame::native_param_addr(int idx) const { return (address*) addr_at( native_frame_initial_param_offset+idx); }
-
 #ifdef CC_INTERP
 
 inline interpreterState frame::get_interpreterState() const {
--- a/hotspot/src/os/aix/vm/vmError_aix.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os/aix/vm/vmError_aix.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -109,7 +109,15 @@
   }
   sigthreadmask(SIG_UNBLOCK, &newset, NULL);
 
-  VMError err(NULL, sig, NULL, info, ucVoid);
+  // support safefetch faults in error handling
+  ucontext_t* const uc = (ucontext_t*) ucVoid;
+  address const pc = uc ? os::Aix::ucontext_get_pc(uc) : NULL;
+  if (uc && pc && StubRoutines::is_safefetch_fault(pc)) {
+    os::Aix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
+    return;
+  }
+
+  VMError err(NULL, sig, pc, info, ucVoid);
   err.report_and_die();
 }
 
--- a/hotspot/src/os/bsd/vm/os_bsd.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os/bsd/vm/os_bsd.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -99,6 +99,7 @@
   static void set_page_size(int val)                                { _page_size = val; }
 
   static address   ucontext_get_pc(ucontext_t* uc);
+  static void ucontext_set_pc(ucontext_t* uc, address pc);
   static intptr_t* ucontext_get_sp(ucontext_t* uc);
   static intptr_t* ucontext_get_fp(ucontext_t* uc);
 
--- a/hotspot/src/os/bsd/vm/vmError_bsd.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os/bsd/vm/vmError_bsd.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -112,7 +112,16 @@
   }
   pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
 
-  VMError err(NULL, sig, NULL, info, ucVoid);
+  // support safefetch faults in error handling
+  ucontext_t* const uc = (ucontext_t*) ucVoid;
+  address const pc = uc ? os::Bsd::ucontext_get_pc(uc) : NULL;
+
+  if (uc && pc && StubRoutines::is_safefetch_fault(pc)) {
+    os::Bsd::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
+    return;
+  }
+
+  VMError err(NULL, sig, pc, info, ucVoid);
   err.report_and_die();
 }
 
--- a/hotspot/src/os/linux/vm/os_linux.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os/linux/vm/os_linux.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -143,6 +143,7 @@
   static int vm_default_page_size(void)                             { return _vm_default_page_size; }
 
   static address   ucontext_get_pc(ucontext_t* uc);
+  static void ucontext_set_pc(ucontext_t* uc, address pc);
   static intptr_t* ucontext_get_sp(ucontext_t* uc);
   static intptr_t* ucontext_get_fp(ucontext_t* uc);
 
--- a/hotspot/src/os/linux/vm/vmError_linux.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os/linux/vm/vmError_linux.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -112,7 +112,16 @@
   }
   pthread_sigmask(SIG_UNBLOCK, &newset, NULL);
 
-  VMError err(NULL, sig, NULL, info, ucVoid);
+  // support safefetch faults in error handling
+  ucontext_t* const uc = (ucontext_t*) ucVoid;
+  address const pc = uc ? os::Linux::ucontext_get_pc(uc) : NULL;
+
+  if (uc && pc && StubRoutines::is_safefetch_fault(pc)) {
+    os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
+    return;
+  }
+
+  VMError err(NULL, sig, pc, info, ucVoid);
   err.report_and_die();
 }
 
--- a/hotspot/src/os/solaris/vm/os_solaris.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os/solaris/vm/os_solaris.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -137,6 +137,7 @@
   // ucontext_get_fp() is only used by Solaris X86 (see note below)
   static intptr_t*   ucontext_get_fp(ucontext_t* uc);
   static address    ucontext_get_pc(ucontext_t* uc);
+  static void ucontext_set_pc(ucontext_t* uc, address pc);
 
   // For Analyzer Forte AsyncGetCallTrace profiling support:
   // Parameter ret_fp is only used by Solaris X86.
--- a/hotspot/src/os/solaris/vm/vmError_solaris.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os/solaris/vm/vmError_solaris.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -109,7 +109,15 @@
   }
   thr_sigsetmask(SIG_UNBLOCK, &newset, NULL);
 
-  VMError err(NULL, sig, NULL, info, ucVoid);
+  // support safefetch faults in error handling
+  ucontext_t* const uc = (ucontext_t*) ucVoid;
+  address const pc = uc ? os::Solaris::ucontext_get_pc(uc) : NULL;
+  if (uc && pc && StubRoutines::is_safefetch_fault(pc)) {
+    os::Solaris::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
+    return;
+  }
+
+  VMError err(NULL, sig, pc, info, ucVoid);
   err.report_and_die();
 }
 
--- a/hotspot/src/os_cpu/aix_ppc/vm/globals_aix_ppc.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os_cpu/aix_ppc/vm/globals_aix_ppc.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012, 2013 SAP AG. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012, 2015 SAP AG. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,7 +48,5 @@
 
 // Only used on 64 bit platforms
 define_pd_global(uintx,HeapBaseMinAddress,       2*G);
-// Only used on 64 bit Windows platforms
-define_pd_global(bool, UseVectoredExceptions,    false);
 
 #endif // OS_CPU_AIX_OJDKPPC_VM_GLOBALS_AIX_PPC_HPP
--- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -397,7 +397,7 @@
           // continue at the next instruction after the faulting read. Returning
           // garbage from this read is ok.
           thread->set_pending_unsafe_access_error();
-          uc->uc_mcontext.jmp_context.iar = ((unsigned long)pc) + 4;
+          os::Aix::ucontext_set_pc(uc, pc + 4);
           return 1;
         }
       }
@@ -420,7 +420,7 @@
         // continue at the next instruction after the faulting read. Returning
         // garbage from this read is ok.
         thread->set_pending_unsafe_access_error();
-        uc->uc_mcontext.jmp_context.iar = ((unsigned long)pc) + 4;
+        os::Aix::ucontext_set_pc(uc, pc + 4);
         return 1;
       }
     }
@@ -445,7 +445,7 @@
   if (stub != NULL) {
     // Save all thread context in case we need to restore it.
     if (thread != NULL) thread->set_saved_exception_pc(pc);
-    uc->uc_mcontext.jmp_context.iar = (unsigned long)stub;
+    os::Aix::ucontext_set_pc(uc, stub);
     return 1;
   }
 
--- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -309,6 +309,10 @@
   return (address)uc->context_pc;
 }
 
+void os::Bsd::ucontext_set_pc(ucontext_t * uc, address pc) {
+  uc->context_pc = (intptr_t)pc ;
+}
+
 intptr_t* os::Bsd::ucontext_get_sp(ucontext_t * uc) {
   return (intptr_t*)uc->context_sp;
 }
@@ -463,7 +467,7 @@
     pc = (address) os::Bsd::ucontext_get_pc(uc);
 
     if (StubRoutines::is_safefetch_fault(pc)) {
-      uc->context_pc = intptr_t(StubRoutines::continuation_for_safefetch_fault(pc));
+      os::Bsd::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
       return 1;
     }
 
@@ -703,7 +707,7 @@
     // save all thread context in case we need to restore it
     if (thread != NULL) thread->set_saved_exception_pc(pc);
 
-    uc->context_pc = (intptr_t)stub;
+    os::Bsd::ucontext_set_pc(uc, stub);
     return true;
   }
 
--- a/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -107,6 +107,10 @@
   return NULL;
 }
 
+void os::Bsd::ucontext_set_pc(ucontext_t * uc, address pc) {
+  ShouldNotCallThis();
+}
+
 ExtendedPC os::fetch_frame_from_context(void* ucVoid,
                                         intptr_t** ret_sp,
                                         intptr_t** ret_fp) {
--- a/hotspot/src/os_cpu/linux_ppc/vm/globals_linux_ppc.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os_cpu/linux_ppc/vm/globals_linux_ppc.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2012, 2013 SAP AG. All rights reserved.
+ * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012, 2015 SAP AG. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,7 +48,5 @@
 
 // Only used on 64 bit platforms
 define_pd_global(uintx,HeapBaseMinAddress,       2*G);
-// Only used on 64 bit Windows platforms
-define_pd_global(bool, UseVectoredExceptions,    false);
 
 #endif // OS_CPU_LINUX_PPC_VM_GLOBALS_LINUX_PPC_HPP
--- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -113,6 +113,14 @@
   return (address)uc->uc_mcontext.regs->nip;
 }
 
+// modify PC in ucontext.
+// Note: Only use this for an ucontext handed down to a signal handler. See comment
+// in ucontext_get_pc.
+void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
+  guarantee(uc->uc_mcontext.regs != NULL, "only use ucontext_set_pc in sigaction context");
+  uc->uc_mcontext.regs->nip = (unsigned long)pc;
+}
+
 intptr_t* os::Linux::ucontext_get_sp(ucontext_t * uc) {
   return (intptr_t*)uc->uc_mcontext.regs->gpr[1/*REG_SP*/];
 }
@@ -213,7 +221,7 @@
   if (uc) {
     address const pc = os::Linux::ucontext_get_pc(uc);
     if (pc && StubRoutines::is_safefetch_fault(pc)) {
-      uc->uc_mcontext.regs->nip = (unsigned long)StubRoutines::continuation_for_safefetch_fault(pc);
+      os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
       return true;
     }
   }
@@ -360,7 +368,7 @@
           // continue at the next instruction after the faulting read. Returning
           // garbage from this read is ok.
           thread->set_pending_unsafe_access_error();
-          uc->uc_mcontext.regs->nip = ((unsigned long)pc) + 4;
+          os::Linux::ucontext_set_pc(uc, pc + 4);
           return true;
         }
       }
@@ -379,7 +387,7 @@
         // continue at the next instruction after the faulting read. Returning
         // garbage from this read is ok.
         thread->set_pending_unsafe_access_error();
-        uc->uc_mcontext.regs->nip = ((unsigned long)pc) + 4;
+        os::Linux::ucontext_set_pc(uc, pc + 4);
         return true;
       }
     }
@@ -402,7 +410,7 @@
   if (stub != NULL) {
     // Save all thread context in case we need to restore it.
     if (thread != NULL) thread->set_saved_exception_pc(pc);
-    uc->uc_mcontext.regs->nip = (unsigned long)stub;
+    os::Linux::ucontext_set_pc(uc, stub);
     return true;
   }
 
--- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -85,11 +85,6 @@
   CON_O7,
 };
 
-static inline void set_cont_address(sigcontext* ctx, address addr) {
-  SIG_PC(ctx)  = (intptr_t)addr;
-  SIG_NPC(ctx) = (intptr_t)(addr+4);
-}
-
 // For Forte Analyzer AsyncGetCallTrace profiling support - thread is
 // currently interrupted by SIGPROF.
 // os::Solaris::fetch_frame_from_ucontext() tries to skip nested
@@ -351,6 +346,12 @@
   return (address) SIG_PC((sigcontext*)uc);
 }
 
+void os::Linux::ucontext_set_pc(ucontext_t* uc, address pc) {
+  sigcontext_t* ctx = (sigcontext_t*) uc;
+  SIG_PC(ctx)  = (intptr_t)addr;
+  SIG_NPC(ctx) = (intptr_t)(addr+4);
+}
+
 intptr_t* os::Linux::ucontext_get_sp(ucontext_t *uc) {
   return (intptr_t*)
     ((intptr_t)SIG_REGS((sigcontext*)uc).u_regs[CON_O6] + STACK_BIAS);
@@ -366,7 +367,7 @@
 
 inline static bool checkPrefetch(sigcontext* uc, address pc) {
   if (StubRoutines::is_safefetch_fault(pc)) {
-    set_cont_address(uc, address(StubRoutines::continuation_for_safefetch_fault(pc)));
+    os::Linux::ucontext_set_pc((ucontext_t*)uc, StubRoutines::continuation_for_safefetch_fault(pc));
     return true;
   }
   return false;
@@ -666,7 +667,7 @@
       // save all thread context in case we need to restore it
       thread->set_saved_exception_pc(pc);
       thread->set_saved_exception_npc(npc);
-      set_cont_address(uc, stub);
+      os::Linux::ucontext_set_pc((ucontext_t*)uc, stub);
       return true;
     }
   }
--- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -122,6 +122,10 @@
   return (address)uc->uc_mcontext.gregs[REG_PC];
 }
 
+void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
+  uc->uc_mcontext.gregs[REG_PC] = (intptr_t)pc;
+}
+
 intptr_t* os::Linux::ucontext_get_sp(ucontext_t * uc) {
   return (intptr_t*)uc->uc_mcontext.gregs[REG_SP];
 }
@@ -279,7 +283,7 @@
     pc = (address) os::Linux::ucontext_get_pc(uc);
 
     if (StubRoutines::is_safefetch_fault(pc)) {
-      uc->uc_mcontext.gregs[REG_PC] = intptr_t(StubRoutines::continuation_for_safefetch_fault(pc));
+      os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
       return 1;
     }
 
@@ -514,7 +518,7 @@
     // save all thread context in case we need to restore it
     if (thread != NULL) thread->set_saved_exception_pc(pc);
 
-    uc->uc_mcontext.gregs[REG_PC] = (greg_t)stub;
+    os::Linux::ucontext_set_pc(uc, stub);
     return true;
   }
 
--- a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -100,6 +100,10 @@
   ShouldNotCallThis();
 }
 
+void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
+  ShouldNotCallThis();
+}
+
 ExtendedPC os::fetch_frame_from_context(void* ucVoid,
                                         intptr_t** ret_sp,
                                         intptr_t** ret_fp) {
--- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -184,6 +184,11 @@
   return ExtendedPC(pc);
 }
 
+void os::Solaris::ucontext_set_pc(ucontext_t* uc, address pc) {
+  uc->uc_mcontext.gregs [REG_PC]  = (greg_t) pc;
+  uc->uc_mcontext.gregs [REG_nPC] = (greg_t) (pc + 4);
+}
+
 // Assumes ucontext is valid
 intptr_t* os::Solaris::ucontext_get_sp(ucontext_t *uc) {
   return (intptr_t*)((intptr_t)uc->uc_mcontext.gregs[REG_SP] + STACK_BIAS);
@@ -355,8 +360,7 @@
 
     // SafeFetch() support
     if (StubRoutines::is_safefetch_fault(pc)) {
-      uc->uc_mcontext.gregs[REG_PC] = intptr_t(StubRoutines::continuation_for_safefetch_fault(pc));
-      uc->uc_mcontext.gregs[REG_nPC] = uc->uc_mcontext.gregs[REG_PC] + 4;
+      os::Solaris::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
       return 1;
     }
 
@@ -494,8 +498,7 @@
 
     // simulate a branch to the stub (a "call" in the safepoint stub case)
     // factor me: setPC
-    uc->uc_mcontext.gregs[REG_PC ] = (greg_t)stub;
-    uc->uc_mcontext.gregs[REG_nPC] = (greg_t)(stub + 4);
+    os::Solaris::ucontext_set_pc(uc, stub);
 
 #ifndef PRODUCT
     if (TraceJumps) thread->record_jump(stub, NULL, __FILE__, __LINE__);
--- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -174,6 +174,10 @@
   return ExtendedPC((address)uc->uc_mcontext.gregs[REG_PC]);
 }
 
+void os::Solaris::ucontext_set_pc(ucontext_t* uc, address pc) {
+  uc->uc_mcontext.gregs [REG_PC]  = (greg_t) pc;
+}
+
 // Assumes ucontext is valid
 intptr_t* os::Solaris::ucontext_get_sp(ucontext_t *uc) {
   return (intptr_t*)uc->uc_mcontext.gregs[REG_SP];
@@ -411,7 +415,7 @@
     pc = (address) uc->uc_mcontext.gregs[REG_PC];
 
     if (StubRoutines::is_safefetch_fault(pc)) {
-      uc->uc_mcontext.gregs[REG_PC] = intptr_t(StubRoutines::continuation_for_safefetch_fault(pc));
+      os::Solaris::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
       return true;
     }
 
@@ -614,8 +618,7 @@
     if (thread != NULL) thread->set_saved_exception_pc(pc);
     // 12/02/99: On Sparc it appears that the full context is also saved
     // but as yet, no one looks at or restores that saved context
-    // factor me: setPC
-    uc->uc_mcontext.gregs[REG_PC] = (greg_t)stub;
+    os::Solaris::ucontext_set_pc(uc, stub);
     return true;
   }
 
--- a/hotspot/src/share/vm/prims/whitebox.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/prims/whitebox.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -364,10 +364,6 @@
   os::release_memory((char *)(uintptr_t)addr, size);
 WB_END
 
-WB_ENTRY(jboolean, WB_NMTIsDetailSupported(JNIEnv* env))
-  return MemTracker::tracking_level() == NMT_detail;
-WB_END
-
 WB_ENTRY(jboolean, WB_NMTChangeTrackingLevel(JNIEnv* env))
   // Test that we can downgrade NMT levels but not upgrade them.
   if (MemTracker::tracking_level() == NMT_off) {
@@ -1321,7 +1317,6 @@
   {CC"NMTCommitMemory",     CC"(JJ)V",                (void*)&WB_NMTCommitMemory    },
   {CC"NMTUncommitMemory",   CC"(JJ)V",                (void*)&WB_NMTUncommitMemory  },
   {CC"NMTReleaseMemory",    CC"(JJ)V",                (void*)&WB_NMTReleaseMemory   },
-  {CC"NMTIsDetailSupported",CC"()Z",                  (void*)&WB_NMTIsDetailSupported},
   {CC"NMTChangeTrackingLevel", CC"()Z",               (void*)&WB_NMTChangeTrackingLevel},
   {CC"NMTGetHashSize",      CC"()I",                  (void*)&WB_NMTGetHashSize     },
 #endif // INCLUDE_NMT
--- a/hotspot/src/share/vm/runtime/frame.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/runtime/frame.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -194,7 +194,6 @@
  public:
   // Link (i.e., the pointer to the previous frame)
   intptr_t* link() const;
-  void set_link(intptr_t* addr);
 
   // Return address
   address  sender_pc() const;
--- a/hotspot/src/share/vm/runtime/globals.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -921,6 +921,9 @@
           "If > 0, provokes an error inside VM error handler (a secondary " \
           "crash). see test_error_handler() in debug.cpp.")                 \
                                                                             \
+  notproduct(bool, TestSafeFetchInErrorHandler, false,                      \
+          "If true, tests SafeFetch inside error handler.")                 \
+                                                                            \
   develop(bool, Verbose, false,                                             \
           "Print additional debugging information from other modes")        \
                                                                             \
--- a/hotspot/src/share/vm/runtime/stubRoutines.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/runtime/stubRoutines.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -210,8 +210,36 @@
     assert(fbuffer[i] == v && fbuffer2[i] == v2, "shouldn't have copied anything");
   }
 }
+
+// simple test for SafeFetch32
+static void test_safefetch32() {
+  int dummy = 17;
+  int* const p_invalid = (int*) get_segfault_address();
+  int* const p_valid = &dummy;
+  int result_invalid = SafeFetch32(p_invalid, 0xABC);
+  assert(result_invalid == 0xABC, "SafeFetch32 error");
+  int result_valid = SafeFetch32(p_valid, 0xABC);
+  assert(result_valid == 17, "SafeFetch32 error");
+}
+
+// simple test for SafeFetchN
+static void test_safefetchN() {
+#ifdef _LP64
+  const intptr_t v1 = UCONST64(0xABCD00000000ABCD);
+  const intptr_t v2 = UCONST64(0xDEFD00000000DEFD);
+#else
+  const intptr_t v1 = 0xABCDABCD;
+  const intptr_t v2 = 0xDEFDDEFD;
 #endif
-
+  intptr_t dummy = v1;
+  intptr_t* const p_invalid = (intptr_t*) get_segfault_address();
+  intptr_t* const p_valid = &dummy;
+  intptr_t result_invalid = SafeFetchN(p_invalid, v2);
+  assert(result_invalid == v2, "SafeFetchN error");
+  intptr_t result_valid = SafeFetchN(p_valid, v2);
+  assert(result_valid == v1, "SafeFetchN error");
+}
+#endif
 
 void StubRoutines::initialize2() {
   if (_code2 == NULL) {
@@ -300,6 +328,13 @@
   test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::aligned_conjoint_words), sizeof(jlong));
   test_arraycopy_func(CAST_FROM_FN_PTR(address, Copy::aligned_disjoint_words), sizeof(jlong));
 
+  // test safefetch routines
+  // Not on Windows 32bit until 8074860 is fixed
+#if ! (defined(_WIN32) && defined(_M_IX86))
+  test_safefetch32();
+  test_safefetchN();
+#endif
+
 #endif
 }
 
--- a/hotspot/src/share/vm/runtime/stubRoutines.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/runtime/stubRoutines.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -448,4 +448,9 @@
   return StubRoutines::SafeFetchN_stub()(adr, errValue);
 }
 
+
+// returns true if SafeFetch32 and SafeFetchN can be used safely (stubroutines are already generated)
+inline bool CanUseSafeFetch32() { return StubRoutines::SafeFetch32_stub() ? true : false; }
+inline bool CanUseSafeFetchN()  { return StubRoutines::SafeFetchN_stub() ? true : false; }
+
 #endif // SHARE_VM_RUNTIME_STUBROUTINES_HPP
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -2584,7 +2584,6 @@
   /**********************/                                                \
   /* frame              */                                                \
   /**********************/                                                \
-  NOT_ZERO(PPC64_ONLY(declare_constant(frame::abi_minframe_size)))        \
   NOT_ZERO(PPC64_ONLY(declare_constant(frame::entry_frame_locals_size)))  \
                                                                           \
   NOT_ZERO(X86_ONLY(declare_constant(frame::entry_frame_call_wrapper_offset)))      \
--- a/hotspot/src/share/vm/services/memTracker.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/services/memTracker.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,11 +53,7 @@
     if (strcmp(nmt_option, "summary") == 0) {
       level = NMT_summary;
     } else if (strcmp(nmt_option, "detail") == 0) {
-#if PLATFORM_NATIVE_STACK_WALKING_SUPPORTED
       level = NMT_detail;
-#else
-      level = NMT_summary;
-#endif // PLATFORM_NATIVE_STACK_WALKING_SUPPORTED
     } else if (strcmp(nmt_option, "off") != 0) {
       // The option value is invalid
       _is_nmt_env_valid = false;
@@ -95,17 +91,9 @@
 
 bool MemTracker::check_launcher_nmt_support(const char* value) {
   if (strcmp(value, "=detail") == 0) {
-#if !PLATFORM_NATIVE_STACK_WALKING_SUPPORTED
-      jio_fprintf(defaultStream::error_stream(),
-        "NMT detail is not supported on this platform.  Using NMT summary instead.\n");
-    if (MemTracker::tracking_level() != NMT_summary) {
-    return false;
-  }
-#else
     if (MemTracker::tracking_level() != NMT_detail) {
       return false;
     }
-#endif
   } else if (strcmp(value, "=summary") == 0) {
     if (MemTracker::tracking_level() != NMT_summary) {
       return false;
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp	Fri Mar 13 09:18:28 2015 -0700
@@ -446,15 +446,6 @@
 # include "globalDefinitions_aarch64.hpp"
 #endif
 
-/*
- * If a platform does not support native stack walking
- * the platform specific globalDefinitions (above)
- * can set PLATFORM_NATIVE_STACK_WALKING_SUPPORTED to 0
- */
-#ifndef PLATFORM_NATIVE_STACK_WALKING_SUPPORTED
-#define PLATFORM_NATIVE_STACK_WALKING_SUPPORTED 1
-#endif
-
 // To assure the IRIW property on processors that are not multiple copy
 // atomic, sync instructions must be issued between volatile reads to
 // assure their ordering, instead of after volatile stores.
--- a/hotspot/src/share/vm/utilities/nativeCallStack.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/utilities/nativeCallStack.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,10 +32,6 @@
 NativeCallStack::NativeCallStack(int toSkip, bool fillStack) :
   _hash_value(0) {
 
-#if !PLATFORM_NATIVE_STACK_WALKING_SUPPORTED
-  fillStack = false;
-#endif
-
   if (fillStack) {
     os::get_native_stack(_stack, NMT_TrackingStackDepth, toSkip);
   } else {
@@ -95,11 +91,7 @@
   int     offset;
   if (is_empty()) {
     for (int index = 0; index < indent; index ++) out->print(" ");
-#if PLATFORM_NATIVE_STACK_WALKING_SUPPORTED
     out->print("[BOOTSTRAP]");
-#else
-    out->print("[No stack]");
-#endif
   } else {
     for (int frame = 0; frame < NMT_TrackingStackDepth; frame ++) {
       pc = get_frame(frame);
--- a/hotspot/src/share/vm/utilities/vmError.cpp	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/src/share/vm/utilities/vmError.cpp	Fri Mar 13 09:18:28 2015 -0700
@@ -358,19 +358,39 @@
 
   // test secondary error handling. Test it twice, to test that resetting
   // error handler after a secondary crash works.
-  STEP(13, "(test secondary crash 1)")
+  STEP(11, "(test secondary crash 1)")
     if (_verbose && TestCrashInErrorHandler != 0) {
       st->print_cr("Will crash now (TestCrashInErrorHandler=%d)...",
         TestCrashInErrorHandler);
       controlled_crash(TestCrashInErrorHandler);
     }
 
-  STEP(14, "(test secondary crash 2)")
+  STEP(12, "(test secondary crash 2)")
     if (_verbose && TestCrashInErrorHandler != 0) {
       st->print_cr("Will crash now (TestCrashInErrorHandler=%d)...",
         TestCrashInErrorHandler);
       controlled_crash(TestCrashInErrorHandler);
     }
+
+  STEP(13, "(test safefetch in error handler)")
+    // test whether it is safe to use SafeFetch32 in Crash Handler. Test twice
+    // to test that resetting the signal handler works correctly.
+    if (_verbose && TestSafeFetchInErrorHandler) {
+      st->print_cr("Will test SafeFetch...");
+      if (CanUseSafeFetch32()) {
+        int* const invalid_pointer = (int*) get_segfault_address();
+        const int x = 0x76543210;
+        int i1 = SafeFetch32(invalid_pointer, x);
+        int i2 = SafeFetch32(invalid_pointer, x);
+        if (i1 == x && i2 == x) {
+          st->print_cr("SafeFetch OK."); // Correctly deflected and returned default pattern
+        } else {
+          st->print_cr("??");
+        }
+      } else {
+        st->print_cr("not possible; skipped.");
+      }
+    }
 #endif // PRODUCT
 
   STEP(15, "(printing type of error)")
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java	Fri Mar 13 09:18:28 2015 -0700
@@ -0,0 +1,92 @@
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.regex.Pattern;
+
+import com.oracle.java.testlibrary.OutputAnalyzer;
+import com.oracle.java.testlibrary.Platform;
+import com.oracle.java.testlibrary.ProcessTools;
+
+/*
+ * @test
+ * @bug 8074552
+ * @summary SafeFetch32 and SafeFetchN do not work in error handling
+ * @library /testlibrary
+ * @author Thomas Stuefe (SAP)
+ */
+
+public class SafeFetchInErrorHandlingTest {
+
+
+  public static void main(String[] args) throws Exception {
+
+    if (!Platform.isDebugBuild()) {
+      return;
+    }
+
+    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+        "-XX:+UnlockDiagnosticVMOptions",
+        "-Xmx100M",
+        "-XX:ErrorHandlerTest=14",
+        "-XX:+TestSafeFetchInErrorHandler",
+        "-version");
+
+    OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
+
+    // we should have crashed with a SIGSEGV
+    output_detail.shouldMatch("# A fatal error has been detected by the Java Runtime Environment:.*");
+    output_detail.shouldMatch("# +(?:SIGSEGV|EXCEPTION_ACCESS_VIOLATION).*");
+
+    // extract hs-err file
+    String hs_err_file = output_detail.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
+    if (hs_err_file == null) {
+      throw new RuntimeException("Did not find hs-err file in output.\n");
+    }
+
+    File f = new File(hs_err_file);
+    if (!f.exists()) {
+      throw new RuntimeException("hs-err file missing at "
+          + f.getAbsolutePath() + ".\n");
+    }
+
+    System.out.println("Found hs_err file. Scanning...");
+
+    FileInputStream fis = new FileInputStream(f);
+    BufferedReader br = new BufferedReader(new InputStreamReader(fis));
+    String line = null;
+
+    Pattern [] pattern = new Pattern[] {
+        Pattern.compile("Will test SafeFetch..."),
+        Pattern.compile("SafeFetch OK."),
+    };
+    int currentPattern = 0;
+
+    String lastLine = null;
+    while ((line = br.readLine()) != null) {
+      if (currentPattern < pattern.length) {
+        if (pattern[currentPattern].matcher(line).matches()) {
+          System.out.println("Found: " + line + ".");
+          currentPattern ++;
+        }
+      }
+      lastLine = line;
+    }
+    br.close();
+
+    if (currentPattern < pattern.length) {
+      throw new RuntimeException("hs-err file incomplete (first missing pattern: " +  currentPattern + ")");
+    }
+
+    if (!lastLine.equals("END.")) {
+      throw new RuntimeException("hs-err file incomplete (missing END marker.)");
+    } else {
+      System.out.println("End marker found.");
+    }
+
+    System.out.println("OK.");
+
+  }
+
+}
+
--- a/hotspot/test/runtime/NMT/ChangeTrackingLevel.java	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/test/runtime/NMT/ChangeTrackingLevel.java	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
  * @summary Test that you can decrease NMT tracking level but not increase it.
  * @key nmt
  * @library /testlibrary /../../test/lib
- * @ignore 8067167
  * @build ChangeTrackingLevel
  * @run main ClassFileInstaller sun.hotspot.WhiteBox
  *                              sun.hotspot.WhiteBox$WhiteBoxPermission
--- a/hotspot/test/runtime/NMT/PrintNMTStatistics.java	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/test/runtime/NMT/PrintNMTStatistics.java	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,6 @@
  * @bug 8005936 8058606
  * @summary Verify PrintNMTStatistics on normal JVM exit for detail and summary tracking level
  * @library /testlibrary
- * @ignore 8067167
  */
 
 import com.oracle.java.testlibrary.*;
--- a/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -46,13 +46,6 @@
     String pid = Integer.toString(ProcessTools.getProcessId());
     ProcessBuilder pb = new ProcessBuilder();
 
-    boolean has_nmt_detail = wb.NMTIsDetailSupported();
-    if (has_nmt_detail) {
-      System.out.println("NMT detail support detected.");
-    } else {
-      System.out.println("NMT detail support not detected.");
-    }
-
     Thread reserveThread = new Thread() {
       public void run() {
         addr = wb.NMTReserveMemory(reserveSize);
@@ -64,9 +57,7 @@
     pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"});
     output = new OutputAnalyzer(pb.start());
     output.shouldContain("Test (reserved=512KB, committed=0KB)");
-    if (has_nmt_detail) {
-      output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved 512KB for Test");
-    }
+    output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved 512KB for Test");
 
     Thread commitThread = new Thread() {
       public void run() {
@@ -78,9 +69,7 @@
 
     output = new OutputAnalyzer(pb.start());
     output.shouldContain("Test (reserved=512KB, committed=128KB)");
-    if (has_nmt_detail) {
-      output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed 128KB");
-    }
+    output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed 128KB");
 
     Thread uncommitThread = new Thread() {
       public void run() {
@@ -107,4 +96,4 @@
     output.shouldNotContain("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved");
   }
 
-    }
+}
--- a/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -49,13 +49,6 @@
         String pid = Integer.toString(ProcessTools.getProcessId());
         ProcessBuilder pb = new ProcessBuilder();
 
-        boolean has_nmt_detail = wb.NMTIsDetailSupported();
-        if (has_nmt_detail) {
-            System.out.println("NMT detail support detected.");
-        } else {
-            System.out.println("NMT detail support not detected.");
-        }
-
         // reserve
         addr = wb.NMTReserveMemory(reserveSize);
         pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid,
@@ -63,11 +56,9 @@
 
         output = new OutputAnalyzer(pb.start());
         output.shouldContain("Test (reserved=4096KB, committed=0KB)");
-        if (has_nmt_detail) {
-            output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
-                    + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 4096KB for Test");
-        }
+        output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
+                           + Long.toHexString(addr + reserveSize)
+                           + "\\] reserved 4096KB for Test");
 
         long addrA = addr;
         long addrB = addr + commitSize;
@@ -85,11 +76,9 @@
         output = new OutputAnalyzer(pb.start());
         output.shouldContain("Test (reserved=4096KB, committed=512KB)");
 
-        if (has_nmt_detail) {
-            output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
-                    + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 4096KB for Test");
-        }
+        output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
+                           + Long.toHexString(addr + reserveSize)
+                           + "\\] reserved 4096KB for Test");
         // uncommit BC
         wb.NMTUncommitMemory(addrB, commitSize);
         wb.NMTUncommitMemory(addrC, commitSize);
@@ -97,11 +86,9 @@
         output = new OutputAnalyzer(pb.start());
         output.shouldContain("Test (reserved=4096KB, committed=256KB)");
 
-        if (has_nmt_detail) {
-            output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
-                    + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 4096KB for Test");
-        }
+        output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
+                            + Long.toHexString(addr + reserveSize)
+                            + "\\] reserved 4096KB for Test");
 
         // commit EF
         wb.NMTCommitMemory(addrE, commitSize);
@@ -109,22 +96,18 @@
 
         output = new OutputAnalyzer(pb.start());
         output.shouldContain("Test (reserved=4096KB, committed=512KB)");
-        if (has_nmt_detail) {
-            output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
-                    + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 4096KB for Test");
-        }
+        output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
+                           + Long.toHexString(addr + reserveSize)
+                           + "\\] reserved 4096KB for Test");
 
         // uncommit A
         wb.NMTUncommitMemory(addrA, commitSize);
 
         output = new OutputAnalyzer(pb.start());
         output.shouldContain("Test (reserved=4096KB, committed=384KB)");
-        if (has_nmt_detail) {
-            output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
-                    + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 4096KB for Test");
-        }
+        output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
+                           + Long.toHexString(addr + reserveSize)
+                           + "\\] reserved 4096KB for Test");
 
         // commit ABC
         wb.NMTCommitMemory(addrA, commitSize);
@@ -133,11 +116,9 @@
 
         output = new OutputAnalyzer(pb.start());
         output.shouldContain("Test (reserved=4096KB, committed=768KB)");
-        if (has_nmt_detail) {
-            output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
-                    + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 4096KB for Test");
-        }
+        output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
+                           + Long.toHexString(addr + reserveSize)
+                           + "\\] reserved 4096KB for Test");
 
         // uncommit ABCDEF
         wb.NMTUncommitMemory(addrA, commitSize);
@@ -149,11 +130,9 @@
 
         output = new OutputAnalyzer(pb.start());
         output.shouldContain("Test (reserved=4096KB, committed=0KB)");
-        if (has_nmt_detail) {
-            output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
-                    + Long.toHexString(addr + reserveSize)
-                    + "\\] reserved 4096KB for Test");
-        }
+        output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*"
+                           + Long.toHexString(addr + reserveSize)
+                           + "\\] reserved 4096KB for Test");
 
         // release
         wb.NMTReleaseMemory(addr, reserveSize);
--- a/hotspot/test/runtime/NMT/VirtualAllocTestType.java	Thu Mar 12 15:51:12 2015 -0700
+++ b/hotspot/test/runtime/NMT/VirtualAllocTestType.java	Fri Mar 13 09:18:28 2015 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -47,30 +47,19 @@
     String pid = Integer.toString(ProcessTools.getProcessId());
     ProcessBuilder pb = new ProcessBuilder();
 
-    boolean has_nmt_detail = wb.NMTIsDetailSupported();
-    if (has_nmt_detail) {
-      System.out.println("NMT detail support detected.");
-    } else {
-      System.out.println("NMT detail support not detected.");
-    }
-
     addr = wb.NMTReserveMemory(reserveSize);
     pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "detail"});
 
     output = new OutputAnalyzer(pb.start());
     output.shouldContain("Test (reserved=256KB, committed=0KB)");
-    if (has_nmt_detail) {
-      output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved 256KB for Test");
-    }
+    output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved 256KB for Test");
 
     wb.NMTCommitMemory(addr, commitSize);
 
 
     output = new OutputAnalyzer(pb.start());
     output.shouldContain("Test (reserved=256KB, committed=128KB)");
-    if (has_nmt_detail) {
-      output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed 128KB");
-    }
+    output.shouldMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + commitSize) + "\\] committed 128KB");
 
     wb.NMTUncommitMemory(addr, commitSize);
 
@@ -85,4 +74,4 @@
     output.shouldNotContain("Test (reserved=");
     output.shouldNotMatch("\\[0x[0]*" + Long.toHexString(addr) + " - 0x[0]*" + Long.toHexString(addr + reserveSize) + "\\] reserved");
   }
-    }
+}