duke@435: /* duke@435: * Copyright 2002-2005 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: private: duke@435: volatile int _flags; duke@435: duke@435: public: duke@435: duke@435: enum pd_Constants { duke@435: flushed = 1 // winodows have flushed duke@435: }; duke@435: duke@435: int flags(void) { return _flags; } duke@435: void set_flags(int flags) { _flags = flags; } duke@435: duke@435: static ByteSize flags_offset() { return byte_offset_of(JavaFrameAnchor, _flags); } duke@435: duke@435: // Each arch must define clear, copy duke@435: // These are used by objects that only care about: duke@435: // 1 - initializing a new state (thread creation, javaCalls) duke@435: // 2 - saving a current state (javaCalls) duke@435: // 3 - restoring an old state (javaCalls) duke@435: duke@435: void clear(void) { duke@435: // clearing _last_Java_sp must be first duke@435: _last_Java_sp = NULL; duke@435: // fence? duke@435: _flags = 0; duke@435: _last_Java_pc = NULL; duke@435: } duke@435: duke@435: void copy(JavaFrameAnchor* src) { duke@435: // In order to make sure the transition state is valid for "this" duke@435: // We must clear _last_Java_sp before copying the rest of the new data duke@435: // duke@435: // Hack Alert: Temporary bugfix for 4717480/4721647 duke@435: // To act like previous version (pd_cache_state) don't NULL _last_Java_sp duke@435: // unless the value is changing duke@435: // duke@435: if (_last_Java_sp != src->_last_Java_sp) duke@435: _last_Java_sp = NULL; duke@435: duke@435: _flags = src->_flags; duke@435: _last_Java_pc = src->_last_Java_pc; duke@435: // Must be last so profiler will always see valid frame if has_last_frame() is true duke@435: _last_Java_sp = src->_last_Java_sp; duke@435: } duke@435: duke@435: // Is stack walkable duke@435: inline bool walkable( void) { duke@435: return _flags & flushed; duke@435: } duke@435: duke@435: void make_walkable(JavaThread* thread); duke@435: duke@435: void set_last_Java_sp(intptr_t* sp) { _last_Java_sp = sp; } duke@435: duke@435: // These are only used by friends duke@435: private: duke@435: duke@435: intptr_t* last_Java_sp() const { duke@435: // _last_Java_sp will always be a an unbiased stack pointer duke@435: // if is is biased then some setter screwed up. This is duke@435: // deadly. duke@435: #ifdef _LP64 duke@435: assert(((intptr_t)_last_Java_sp & 0xF) == 0, "Biased last_Java_sp"); duke@435: #endif duke@435: return _last_Java_sp; duke@435: } duke@435: duke@435: void capture_last_Java_pc(intptr_t* sp); duke@435: duke@435: void set_window_flushed( void) { duke@435: _flags |= flushed; duke@435: OrderAccess::fence(); duke@435: }