hotspot/src/os_cpu/bsd_zero/vm/thread_bsd_zero.hpp
author lana
Mon, 16 Jul 2012 14:49:27 -0700
changeset 13239 7bea6829e8d6
parent 10565 dc90c239f4ec
child 19336 ddceb0657500
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10565
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     1
/*
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     2
 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     3
 * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     5
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     8
 * published by the Free Software Foundation.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
     9
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    14
 * accompanied this code).
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    15
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    19
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    22
 * questions.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    23
 *
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    24
 */
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    25
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    26
#ifndef OS_CPU_BSD_ZERO_VM_THREAD_BSD_ZERO_HPP
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    27
#define OS_CPU_BSD_ZERO_VM_THREAD_BSD_ZERO_HPP
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    28
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    29
 private:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    30
  ZeroStack  _zero_stack;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    31
  ZeroFrame* _top_zero_frame;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    32
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    33
  void pd_initialize() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    34
    _top_zero_frame = NULL;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    35
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    36
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    37
 public:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    38
  ZeroStack *zero_stack() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    39
    return &_zero_stack;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    40
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    41
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    42
 public:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    43
  ZeroFrame *top_zero_frame() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    44
    return _top_zero_frame;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    45
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    46
  void push_zero_frame(ZeroFrame *frame) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    47
    *(ZeroFrame **) frame = _top_zero_frame;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    48
    _top_zero_frame = frame;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    49
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    50
  void pop_zero_frame() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    51
    zero_stack()->set_sp((intptr_t *) _top_zero_frame + 1);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    52
    _top_zero_frame = *(ZeroFrame **) _top_zero_frame;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    53
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    54
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    55
 public:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    56
  static ByteSize zero_stack_offset() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    57
    return byte_offset_of(JavaThread, _zero_stack);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    58
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    59
  static ByteSize top_zero_frame_offset() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    60
    return byte_offset_of(JavaThread, _top_zero_frame);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    61
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    62
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    63
 public:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    64
  void record_base_of_stack_pointer() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    65
    assert(top_zero_frame() == NULL, "junk on stack prior to Java call");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    66
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    67
  void set_base_of_stack_pointer(intptr_t* base_sp) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    68
    assert(base_sp == NULL, "should be");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    69
    assert(top_zero_frame() == NULL, "junk on stack after Java call");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    70
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    71
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    72
 public:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    73
  void set_last_Java_frame() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    74
    set_last_Java_frame(top_zero_frame(), zero_stack()->sp());
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    75
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    76
  void reset_last_Java_frame() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    77
    frame_anchor()->zap();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    78
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    79
  void set_last_Java_frame(ZeroFrame* fp, intptr_t* sp) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    80
    frame_anchor()->set(sp, NULL, fp);
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    81
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    82
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    83
 public:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    84
  ZeroFrame* last_Java_fp() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    85
    return frame_anchor()->last_Java_fp();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    86
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    87
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    88
 private:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    89
  frame pd_last_frame() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    90
    assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    91
    return frame(last_Java_fp(), last_Java_sp());
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    92
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    93
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    94
 public:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    95
  static ByteSize last_Java_fp_offset() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    96
    return byte_offset_of(JavaThread, _anchor) +
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    97
      JavaFrameAnchor::last_Java_fp_offset();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    98
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
    99
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   100
 public:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   101
  // Check for pending suspend requests and pending asynchronous
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   102
  // exceptions.  There are separate accessors for these, but
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   103
  // _suspend_flags is volatile so using them would be unsafe.
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   104
  bool has_special_condition_for_native_trans() {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   105
    return _suspend_flags != 0;
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   106
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   107
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   108
 public:
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   109
  bool pd_get_top_frame_for_signal_handler(frame* fr_addr,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   110
                                           void* ucontext,
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   111
                                           bool isInJava) {
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   112
    ShouldNotCallThis();
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   113
  }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   114
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   115
  // These routines are only used on cpu architectures that
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   116
  // have separate register stacks (Itanium).
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   117
  static bool register_stack_overflow() { return false; }
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   118
  static void enable_register_stack_guard() {}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   119
  static void disable_register_stack_guard() {}
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   120
dc90c239f4ec 7089790: integrate bsd-port changes
never
parents:
diff changeset
   121
#endif // OS_CPU_BSD_ZERO_VM_THREAD_BSD_ZERO_HPP