aoqi@0: /* aoqi@0: * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_RUNTIME_REGISTERMAP_HPP aoqi@0: #define SHARE_VM_RUNTIME_REGISTERMAP_HPP aoqi@0: aoqi@0: #include "code/vmreg.hpp" aoqi@0: #include "utilities/globalDefinitions.hpp" aoqi@0: #ifdef TARGET_ARCH_x86 aoqi@0: # include "register_x86.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_sparc aoqi@0: # include "register_sparc.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_zero aoqi@0: # include "register_zero.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_arm aoqi@0: # include "register_arm.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_ppc aoqi@0: # include "register_ppc.hpp" aoqi@0: #endif aoqi@0: aoqi@0: class JavaThread; aoqi@0: aoqi@0: // aoqi@0: // RegisterMap aoqi@0: // aoqi@0: // A companion structure used for stack traversal. The RegisterMap contains aoqi@0: // misc. information needed in order to do correct stack traversal of stack aoqi@0: // frames. Hence, it must always be passed in as an argument to aoqi@0: // frame::sender(RegisterMap*). aoqi@0: // aoqi@0: // In particular, aoqi@0: // 1) It provides access to the thread for which the stack belongs. The aoqi@0: // thread object is needed in order to get sender of a deoptimized frame. aoqi@0: // aoqi@0: // 2) It is used to pass information from a callee frame to its caller aoqi@0: // frame about how the frame should be traversed. This is used to let aoqi@0: // the caller frame take care of calling oops-do of out-going aoqi@0: // arguments, when the callee frame is not instantiated yet. This aoqi@0: // happens, e.g., when a compiled frame calls into aoqi@0: // resolve_virtual_call. (Hence, it is critical that the same aoqi@0: // RegisterMap object is used for the entire stack walk. Normally, aoqi@0: // this is hidden by using the StackFrameStream.) This is used when aoqi@0: // doing follow_oops and oops_do. aoqi@0: // aoqi@0: // 3) The RegisterMap keeps track of the values of callee-saved registers aoqi@0: // from frame to frame (hence, the name). For some stack traversal the aoqi@0: // values of the callee-saved registers does not matter, e.g., if you aoqi@0: // only need the static properies such as frame type, pc, and such. aoqi@0: // Updating of the RegisterMap can be turned off by instantiating the aoqi@0: // register map as: RegisterMap map(thread, false); aoqi@0: aoqi@0: class RegisterMap : public StackObj { aoqi@0: public: aoqi@0: typedef julong LocationValidType; aoqi@0: enum { aoqi@0: reg_count = ConcreteRegisterImpl::number_of_registers, aoqi@0: location_valid_type_size = sizeof(LocationValidType)*8, aoqi@0: location_valid_size = (reg_count+location_valid_type_size-1)/location_valid_type_size aoqi@0: }; aoqi@0: private: aoqi@0: intptr_t* _location[reg_count]; // Location of registers (intptr_t* looks better than address in the debugger) aoqi@0: LocationValidType _location_valid[location_valid_size]; aoqi@0: bool _include_argument_oops; // Should include argument_oop marked locations for compiler aoqi@0: JavaThread* _thread; // Reference to current thread aoqi@0: bool _update_map; // Tells if the register map need to be aoqi@0: // updated when traversing the stack aoqi@0: aoqi@0: #ifdef ASSERT aoqi@0: void check_location_valid(); aoqi@0: #else aoqi@0: void check_location_valid() {} aoqi@0: #endif aoqi@0: aoqi@0: public: aoqi@0: debug_only(intptr_t* _update_for_id;) // Assert that RegisterMap is not updated twice for same frame aoqi@0: RegisterMap(JavaThread *thread, bool update_map = true); aoqi@0: RegisterMap(const RegisterMap* map); aoqi@0: aoqi@0: address location(VMReg reg) const { aoqi@0: int index = reg->value() / location_valid_type_size; aoqi@0: assert(0 <= reg->value() && reg->value() < reg_count, "range check"); aoqi@0: assert(0 <= index && index < location_valid_size, "range check"); aoqi@0: if (_location_valid[index] & ((LocationValidType)1 << (reg->value() % location_valid_type_size))) { aoqi@0: return (address) _location[reg->value()]; aoqi@0: } else { aoqi@0: return pd_location(reg); aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: void set_location(VMReg reg, address loc) { aoqi@0: int index = reg->value() / location_valid_type_size; aoqi@0: assert(0 <= reg->value() && reg->value() < reg_count, "range check"); aoqi@0: assert(0 <= index && index < location_valid_size, "range check"); aoqi@0: assert(_update_map, "updating map that does not need updating"); aoqi@0: _location[reg->value()] = (intptr_t*) loc; aoqi@0: _location_valid[index] |= ((LocationValidType)1 << (reg->value() % location_valid_type_size)); aoqi@0: check_location_valid(); aoqi@0: } aoqi@0: aoqi@0: // Called by an entry frame. aoqi@0: void clear(); aoqi@0: aoqi@0: bool include_argument_oops() const { return _include_argument_oops; } aoqi@0: void set_include_argument_oops(bool f) { _include_argument_oops = f; } aoqi@0: aoqi@0: JavaThread *thread() const { return _thread; } aoqi@0: bool update_map() const { return _update_map; } aoqi@0: aoqi@0: void print_on(outputStream* st) const; aoqi@0: void print() const; aoqi@0: aoqi@0: // the following contains the definition of pd_xxx methods aoqi@0: #ifdef TARGET_ARCH_x86 aoqi@0: # include "registerMap_x86.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_sparc aoqi@0: # include "registerMap_sparc.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_zero aoqi@0: # include "registerMap_zero.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_arm aoqi@0: # include "registerMap_arm.hpp" aoqi@0: #endif aoqi@0: #ifdef TARGET_ARCH_ppc aoqi@0: # include "registerMap_ppc.hpp" aoqi@0: #endif aoqi@0: aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_RUNTIME_REGISTERMAP_HPP