1 /*
   2  * Copyright 2000-2007 Sun Microsystems, Inc.  All Rights Reserved.
   3  * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  21  * CA 95054 USA or visit www.sun.com if you need additional information or
  22  * have any questions.
  23  *
  24  */
  25 
  26  private:
  27   ZeroStack  _zero_stack;
  28   ZeroFrame* _top_zero_frame;
  29 
  30   void pd_initialize() {
  31     _top_zero_frame = NULL;
  32   }
  33 
  34  public:
  35   ZeroStack *zero_stack() {
  36     return &_zero_stack;
  37   }
  38 
  39  public:
  40   ZeroFrame *top_zero_frame() {
  41     return _top_zero_frame;
  42   }
  43   void push_zero_frame(ZeroFrame *frame) {
  44     *(ZeroFrame **) frame = _top_zero_frame;
  45     _top_zero_frame = frame;
  46   }
  47   void pop_zero_frame() {
  48     zero_stack()->set_sp((intptr_t *) _top_zero_frame + 1);
  49     _top_zero_frame = *(ZeroFrame **) _top_zero_frame;
  50   }
  51 
  52  public:
  53   static ByteSize zero_stack_offset() {
  54     return byte_offset_of(JavaThread, _zero_stack);
  55   }
  56   static ByteSize top_zero_frame_offset() {
  57     return byte_offset_of(JavaThread, _top_zero_frame);
  58   }
  59 
  60  public:
  61   void record_base_of_stack_pointer() {
  62     assert(top_zero_frame() == NULL, "junk on stack prior to Java call");
  63   }
  64   void set_base_of_stack_pointer(intptr_t* base_sp) {
  65     assert(base_sp == NULL, "should be");
  66     assert(top_zero_frame() == NULL, "junk on stack after Java call");
  67   }
  68 
  69  public:
  70   void set_last_Java_frame() {
  71     set_last_Java_frame(top_zero_frame(), zero_stack()->sp());
  72   }
  73   void reset_last_Java_frame() {
  74     frame_anchor()->zap();
  75   }
  76   void set_last_Java_frame(ZeroFrame* fp, intptr_t* sp) {
  77     frame_anchor()->set(sp, NULL, fp);
  78   }
  79 
  80  public:
  81   ZeroFrame* last_Java_fp() {
  82     return frame_anchor()->last_Java_fp();
  83   }
  84 
  85  private:
  86   frame pd_last_frame() {
  87     assert(has_last_Java_frame(), "must have last_Java_sp() when suspended");
  88     return frame(last_Java_fp(), last_Java_sp());
  89   }
  90 
  91  public:
  92   // Check for pending suspend requests and pending asynchronous
  93   // exceptions.  There are separate accessors for these, but
  94   // _suspend_flags is volatile so using them would be unsafe.
  95   bool has_special_condition_for_native_trans() {
  96     return _suspend_flags != 0;
  97   }
  98 
  99  public:
 100   bool pd_get_top_frame_for_signal_handler(frame* fr_addr,
 101                                            void* ucontext,
 102                                            bool isInJava) {
 103     ShouldNotCallThis();
 104   }
 105 
 106   // These routines are only used on cpu architectures that
 107   // have separate register stacks (Itanium).
 108   static bool register_stack_overflow() { return false; }
 109   static void enable_register_stack_guard() {}
 110   static void disable_register_stack_guard() {}