duke@435: /* trims@2708: * Copyright (c) 2002, 2011, Oracle and/or its affiliates. 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: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ stefank@2314: stefank@2314: #ifndef SHARE_VM_RUNTIME_JAVAFRAMEANCHOR_HPP stefank@2314: #define SHARE_VM_RUNTIME_JAVAFRAMEANCHOR_HPP stefank@2314: stefank@2314: #include "utilities/globalDefinitions.hpp" goetz@6911: #include "runtime/orderAccess.inline.hpp" never@3156: duke@435: // duke@435: // An object for encapsulating the machine/os dependent part of a JavaThread frame state duke@435: // duke@435: class JavaThread; duke@435: duke@435: class JavaFrameAnchor VALUE_OBJ_CLASS_SPEC { duke@435: // Too many friends... duke@435: friend class CallNativeDirectNode; duke@435: friend class OptoRuntime; duke@435: friend class Runtime1; duke@435: friend class StubAssembler; duke@435: friend class CallRuntimeDirectNode; duke@435: friend class MacroAssembler; duke@435: friend class InterpreterGenerator; duke@435: friend class LIR_Assembler; duke@435: friend class GraphKit; duke@435: friend class StubGenerator; duke@435: friend class JavaThread; duke@435: friend class frame; duke@435: friend class VMStructs; duke@435: friend class BytecodeInterpreter; duke@435: friend class JavaCallWrapper; duke@435: duke@435: private: duke@435: // duke@435: // Whenever _last_Java_sp != NULL other anchor fields MUST be valid! duke@435: // The stack may not be walkable [check with walkable() ] but the values must be valid. duke@435: // The profiler apparently depends on this. duke@435: // duke@435: intptr_t* volatile _last_Java_sp; duke@435: duke@435: // Whenever we call from Java to native we can not be assured that the return duke@435: // address that composes the last_Java_frame will be in an accessible location duke@435: // so calls from Java to native store that pc (or one good enough to locate duke@435: // the oopmap) in the frame anchor. Since the frames that call from Java to duke@435: // native are never deoptimized we never need to patch the pc and so this duke@435: // is acceptable. duke@435: volatile address _last_Java_pc; duke@435: duke@435: // tells whether the last Java frame is set duke@435: // It is important that when last_Java_sp != NULL that the rest of the frame duke@435: // anchor (including platform specific) all be valid. duke@435: duke@435: bool has_last_Java_frame() const { return _last_Java_sp != NULL; } duke@435: // This is very dangerous unless sp == NULL duke@435: // Invalidate the anchor so that has_last_frame is false duke@435: // and no one should look at the other fields. duke@435: void zap(void) { _last_Java_sp = NULL; } duke@435: stefank@2314: #ifdef TARGET_ARCH_x86 stefank@2314: # include "javaFrameAnchor_x86.hpp" stefank@2314: #endif stefank@2314: #ifdef TARGET_ARCH_sparc stefank@2314: # include "javaFrameAnchor_sparc.hpp" stefank@2314: #endif stefank@2314: #ifdef TARGET_ARCH_zero stefank@2314: # include "javaFrameAnchor_zero.hpp" stefank@2314: #endif bobv@2508: #ifdef TARGET_ARCH_arm bobv@2508: # include "javaFrameAnchor_arm.hpp" bobv@2508: #endif bobv@2508: #ifdef TARGET_ARCH_ppc bobv@2508: # include "javaFrameAnchor_ppc.hpp" bobv@2508: #endif stefank@2314: duke@435: duke@435: public: duke@435: JavaFrameAnchor() { clear(); } duke@435: JavaFrameAnchor(JavaFrameAnchor *src) { copy(src); } duke@435: duke@435: void set_last_Java_pc(address pc) { _last_Java_pc = pc; } duke@435: duke@435: // Assembly stub generation helpers duke@435: duke@435: static ByteSize last_Java_sp_offset() { return byte_offset_of(JavaFrameAnchor, _last_Java_sp); } duke@435: static ByteSize last_Java_pc_offset() { return byte_offset_of(JavaFrameAnchor, _last_Java_pc); } duke@435: duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_RUNTIME_JAVAFRAMEANCHOR_HPP