src/os_cpu/bsd_x86/vm/thread_bsd_x86.cpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/os_cpu/bsd_x86/vm/thread_bsd_x86.cpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,90 @@
     1.4 +/*
     1.5 + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#include "precompiled.hpp"
    1.29 +#include "runtime/frame.inline.hpp"
    1.30 +#include "runtime/thread.inline.hpp"
    1.31 +
    1.32 +// For Forte Analyzer AsyncGetCallTrace profiling support - thread is
    1.33 +// currently interrupted by SIGPROF
    1.34 +bool JavaThread::pd_get_top_frame_for_signal_handler(frame* fr_addr,
    1.35 +  void* ucontext, bool isInJava) {
    1.36 +  assert(Thread::current() == this, "caller must be current thread");
    1.37 +  return pd_get_top_frame(fr_addr, ucontext, isInJava);
    1.38 +}
    1.39 +
    1.40 +bool JavaThread::pd_get_top_frame_for_profiling(frame* fr_addr, void* ucontext, bool isInJava) {
    1.41 +  return pd_get_top_frame(fr_addr, ucontext, isInJava);
    1.42 +}
    1.43 +
    1.44 +bool JavaThread::pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava) {
    1.45 +  assert(this->is_Java_thread(), "must be JavaThread");
    1.46 +  JavaThread* jt = (JavaThread *)this;
    1.47 +
    1.48 +  // If we have a last_Java_frame, then we should use it even if
    1.49 +  // isInJava == true.  It should be more reliable than ucontext info.
    1.50 +  if (jt->has_last_Java_frame()) {
    1.51 +    *fr_addr = jt->pd_last_frame();
    1.52 +    return true;
    1.53 +  }
    1.54 +
    1.55 +  // At this point, we don't have a last_Java_frame, so
    1.56 +  // we try to glean some information out of the ucontext
    1.57 +  // if we were running Java code when SIGPROF came in.
    1.58 +  if (isInJava) {
    1.59 +    ucontext_t* uc = (ucontext_t*) ucontext;
    1.60 +
    1.61 +    intptr_t* ret_fp;
    1.62 +    intptr_t* ret_sp;
    1.63 +    ExtendedPC addr = os::Bsd::fetch_frame_from_ucontext(this, uc,
    1.64 +      &ret_sp, &ret_fp);
    1.65 +    if (addr.pc() == NULL || ret_sp == NULL ) {
    1.66 +      // ucontext wasn't useful
    1.67 +      return false;
    1.68 +    }
    1.69 +
    1.70 +    frame ret_frame(ret_sp, ret_fp, addr.pc());
    1.71 +    if (!ret_frame.safe_for_sender(jt)) {
    1.72 +#ifdef COMPILER2
    1.73 +      // C2 uses ebp as a general register see if NULL fp helps
    1.74 +      frame ret_frame2(ret_sp, NULL, addr.pc());
    1.75 +      if (!ret_frame2.safe_for_sender(jt)) {
    1.76 +        // nothing else to try if the frame isn't good
    1.77 +        return false;
    1.78 +      }
    1.79 +      ret_frame = ret_frame2;
    1.80 +#else
    1.81 +      // nothing else to try if the frame isn't good
    1.82 +      return false;
    1.83 +#endif /* COMPILER2 */
    1.84 +    }
    1.85 +    *fr_addr = ret_frame;
    1.86 +    return true;
    1.87 +  }
    1.88 +
    1.89 +  // nothing else to try
    1.90 +  return false;
    1.91 +}
    1.92 +
    1.93 +void JavaThread::cache_global_variables() { }

mercurial