annotate src/os_cpu/linux_zero/vm/thread_linux_zero.hpp @ 1379:f9271ff9d324

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