1 /* 2 * Copyright (c) 2000, 2007, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * 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 static ByteSize last_Java_fp_offset() { 93 return byte_offset_of(JavaThread, _anchor) + 94 JavaFrameAnchor::last_Java_fp_offset(); 95 } 96 97 public: 98 // Check for pending suspend requests and pending asynchronous 99 // exceptions. There are separate accessors for these, but 100 // _suspend_flags is volatile so using them would be unsafe. 101 bool has_special_condition_for_native_trans() { 102 return _suspend_flags != 0; 103 } 104 105 public: 106 bool pd_get_top_frame_for_signal_handler(frame* fr_addr, 107 void* ucontext, 108 bool isInJava) { 109 ShouldNotCallThis(); 110 } 111 112 // These routines are only used on cpu architectures that 113 // have separate register stacks (Itanium). 114 static bool register_stack_overflow() { return false; } 115 static void enable_register_stack_guard() {} 116 static void disable_register_stack_guard() {}