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: */ duke@435: stefank@2314: #ifndef SHARE_VM_RUNTIME_REGISTERMAP_HPP stefank@2314: #define SHARE_VM_RUNTIME_REGISTERMAP_HPP stefank@2314: stefank@2314: #include "code/vmreg.hpp" stefank@2314: #include "utilities/globalDefinitions.hpp" stefank@2314: #ifdef TARGET_ARCH_x86 stefank@2314: # include "register_x86.hpp" stefank@2314: #endif stefank@2314: #ifdef TARGET_ARCH_sparc stefank@2314: # include "register_sparc.hpp" stefank@2314: #endif stefank@2314: #ifdef TARGET_ARCH_zero stefank@2314: # include "register_zero.hpp" stefank@2314: #endif bobv@2508: #ifdef TARGET_ARCH_arm bobv@2508: # include "register_arm.hpp" bobv@2508: #endif bobv@2508: #ifdef TARGET_ARCH_ppc bobv@2508: # include "register_ppc.hpp" bobv@2508: #endif stefank@2314: duke@435: class JavaThread; duke@435: duke@435: // duke@435: // RegisterMap duke@435: // duke@435: // A companion structure used for stack traversal. The RegisterMap contains duke@435: // misc. information needed in order to do correct stack traversal of stack duke@435: // frames. Hence, it must always be passed in as an argument to duke@435: // frame::sender(RegisterMap*). duke@435: // duke@435: // In particular, duke@435: // 1) It provides access to the thread for which the stack belongs. The duke@435: // thread object is needed in order to get sender of a deoptimized frame. duke@435: // duke@435: // 2) It is used to pass information from a callee frame to its caller duke@435: // frame about how the frame should be traversed. This is used to let duke@435: // the caller frame take care of calling oops-do of out-going duke@435: // arguments, when the callee frame is not instantiated yet. This duke@435: // happens, e.g., when a compiled frame calls into duke@435: // resolve_virtual_call. (Hence, it is critical that the same duke@435: // RegisterMap object is used for the entire stack walk. Normally, duke@435: // this is hidden by using the StackFrameStream.) This is used when duke@435: // doing follow_oops and oops_do. duke@435: // duke@435: // 3) The RegisterMap keeps track of the values of callee-saved registers duke@435: // from frame to frame (hence, the name). For some stack traversal the duke@435: // values of the callee-saved registers does not matter, e.g., if you duke@435: // only need the static properies such as frame type, pc, and such. duke@435: // Updating of the RegisterMap can be turned off by instantiating the duke@435: // register map as: RegisterMap map(thread, false); duke@435: duke@435: class RegisterMap : public StackObj { duke@435: public: duke@435: typedef julong LocationValidType; duke@435: enum { duke@435: reg_count = ConcreteRegisterImpl::number_of_registers, duke@435: location_valid_type_size = sizeof(LocationValidType)*8, duke@435: location_valid_size = (reg_count+location_valid_type_size-1)/location_valid_type_size duke@435: }; duke@435: private: duke@435: intptr_t* _location[reg_count]; // Location of registers (intptr_t* looks better than address in the debugger) duke@435: LocationValidType _location_valid[location_valid_size]; duke@435: bool _include_argument_oops; // Should include argument_oop marked locations for compiler duke@435: JavaThread* _thread; // Reference to current thread duke@435: bool _update_map; // Tells if the register map need to be duke@435: // updated when traversing the stack duke@435: duke@435: #ifdef ASSERT duke@435: void check_location_valid(); duke@435: #else duke@435: void check_location_valid() {} duke@435: #endif duke@435: duke@435: public: duke@435: debug_only(intptr_t* _update_for_id;) // Assert that RegisterMap is not updated twice for same frame duke@435: RegisterMap(JavaThread *thread, bool update_map = true); duke@435: RegisterMap(const RegisterMap* map); duke@435: duke@435: address location(VMReg reg) const { duke@435: int index = reg->value() / location_valid_type_size; duke@435: assert(0 <= reg->value() && reg->value() < reg_count, "range check"); duke@435: assert(0 <= index && index < location_valid_size, "range check"); duke@435: if (_location_valid[index] & ((LocationValidType)1 << (reg->value() % location_valid_type_size))) { duke@435: return (address) _location[reg->value()]; duke@435: } else { duke@435: return pd_location(reg); duke@435: } duke@435: } duke@435: duke@435: void set_location(VMReg reg, address loc) { duke@435: int index = reg->value() / location_valid_type_size; duke@435: assert(0 <= reg->value() && reg->value() < reg_count, "range check"); duke@435: assert(0 <= index && index < location_valid_size, "range check"); duke@435: assert(_update_map, "updating map that does not need updating"); duke@435: _location[reg->value()] = (intptr_t*) loc; duke@435: _location_valid[index] |= ((LocationValidType)1 << (reg->value() % location_valid_type_size)); duke@435: check_location_valid(); duke@435: } duke@435: duke@435: // Called by an entry frame. duke@435: void clear(); duke@435: duke@435: bool include_argument_oops() const { return _include_argument_oops; } duke@435: void set_include_argument_oops(bool f) { _include_argument_oops = f; } duke@435: duke@435: JavaThread *thread() const { return _thread; } duke@435: bool update_map() const { return _update_map; } duke@435: duke@435: void print_on(outputStream* st) const; duke@435: void print() const; duke@435: duke@435: // the following contains the definition of pd_xxx methods stefank@2314: #ifdef TARGET_ARCH_x86 stefank@2314: # include "registerMap_x86.hpp" stefank@2314: #endif stefank@2314: #ifdef TARGET_ARCH_sparc stefank@2314: # include "registerMap_sparc.hpp" stefank@2314: #endif stefank@2314: #ifdef TARGET_ARCH_zero stefank@2314: # include "registerMap_zero.hpp" stefank@2314: #endif bobv@2508: #ifdef TARGET_ARCH_arm bobv@2508: # include "registerMap_arm.hpp" bobv@2508: #endif bobv@2508: #ifdef TARGET_ARCH_ppc bobv@2508: # include "registerMap_ppc.hpp" bobv@2508: #endif stefank@2314: duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_RUNTIME_REGISTERMAP_HPP