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