src/share/vm/runtime/registerMap.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 1
2d8a650513c2
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_RUNTIME_REGISTERMAP_HPP
aoqi@0 26 #define SHARE_VM_RUNTIME_REGISTERMAP_HPP
aoqi@0 27
aoqi@0 28 #include "code/vmreg.hpp"
aoqi@0 29 #include "utilities/globalDefinitions.hpp"
aoqi@0 30 #ifdef TARGET_ARCH_x86
aoqi@0 31 # include "register_x86.hpp"
aoqi@0 32 #endif
aoqi@0 33 #ifdef TARGET_ARCH_sparc
aoqi@0 34 # include "register_sparc.hpp"
aoqi@0 35 #endif
aoqi@0 36 #ifdef TARGET_ARCH_zero
aoqi@0 37 # include "register_zero.hpp"
aoqi@0 38 #endif
aoqi@0 39 #ifdef TARGET_ARCH_arm
aoqi@0 40 # include "register_arm.hpp"
aoqi@0 41 #endif
aoqi@0 42 #ifdef TARGET_ARCH_ppc
aoqi@0 43 # include "register_ppc.hpp"
aoqi@0 44 #endif
aoqi@0 45
aoqi@0 46 class JavaThread;
aoqi@0 47
aoqi@0 48 //
aoqi@0 49 // RegisterMap
aoqi@0 50 //
aoqi@0 51 // A companion structure used for stack traversal. The RegisterMap contains
aoqi@0 52 // misc. information needed in order to do correct stack traversal of stack
aoqi@0 53 // frames. Hence, it must always be passed in as an argument to
aoqi@0 54 // frame::sender(RegisterMap*).
aoqi@0 55 //
aoqi@0 56 // In particular,
aoqi@0 57 // 1) It provides access to the thread for which the stack belongs. The
aoqi@0 58 // thread object is needed in order to get sender of a deoptimized frame.
aoqi@0 59 //
aoqi@0 60 // 2) It is used to pass information from a callee frame to its caller
aoqi@0 61 // frame about how the frame should be traversed. This is used to let
aoqi@0 62 // the caller frame take care of calling oops-do of out-going
aoqi@0 63 // arguments, when the callee frame is not instantiated yet. This
aoqi@0 64 // happens, e.g., when a compiled frame calls into
aoqi@0 65 // resolve_virtual_call. (Hence, it is critical that the same
aoqi@0 66 // RegisterMap object is used for the entire stack walk. Normally,
aoqi@0 67 // this is hidden by using the StackFrameStream.) This is used when
aoqi@0 68 // doing follow_oops and oops_do.
aoqi@0 69 //
aoqi@0 70 // 3) The RegisterMap keeps track of the values of callee-saved registers
aoqi@0 71 // from frame to frame (hence, the name). For some stack traversal the
aoqi@0 72 // values of the callee-saved registers does not matter, e.g., if you
aoqi@0 73 // only need the static properies such as frame type, pc, and such.
aoqi@0 74 // Updating of the RegisterMap can be turned off by instantiating the
aoqi@0 75 // register map as: RegisterMap map(thread, false);
aoqi@0 76
aoqi@0 77 class RegisterMap : public StackObj {
aoqi@0 78 public:
aoqi@0 79 typedef julong LocationValidType;
aoqi@0 80 enum {
aoqi@0 81 reg_count = ConcreteRegisterImpl::number_of_registers,
aoqi@0 82 location_valid_type_size = sizeof(LocationValidType)*8,
aoqi@0 83 location_valid_size = (reg_count+location_valid_type_size-1)/location_valid_type_size
aoqi@0 84 };
aoqi@0 85 private:
aoqi@0 86 intptr_t* _location[reg_count]; // Location of registers (intptr_t* looks better than address in the debugger)
aoqi@0 87 LocationValidType _location_valid[location_valid_size];
aoqi@0 88 bool _include_argument_oops; // Should include argument_oop marked locations for compiler
aoqi@0 89 JavaThread* _thread; // Reference to current thread
aoqi@0 90 bool _update_map; // Tells if the register map need to be
aoqi@0 91 // updated when traversing the stack
aoqi@0 92
aoqi@0 93 #ifdef ASSERT
aoqi@0 94 void check_location_valid();
aoqi@0 95 #else
aoqi@0 96 void check_location_valid() {}
aoqi@0 97 #endif
aoqi@0 98
aoqi@0 99 public:
aoqi@0 100 debug_only(intptr_t* _update_for_id;) // Assert that RegisterMap is not updated twice for same frame
aoqi@0 101 RegisterMap(JavaThread *thread, bool update_map = true);
aoqi@0 102 RegisterMap(const RegisterMap* map);
aoqi@0 103
aoqi@0 104 address location(VMReg reg) const {
aoqi@0 105 int index = reg->value() / location_valid_type_size;
aoqi@0 106 assert(0 <= reg->value() && reg->value() < reg_count, "range check");
aoqi@0 107 assert(0 <= index && index < location_valid_size, "range check");
aoqi@0 108 if (_location_valid[index] & ((LocationValidType)1 << (reg->value() % location_valid_type_size))) {
aoqi@0 109 return (address) _location[reg->value()];
aoqi@0 110 } else {
aoqi@0 111 return pd_location(reg);
aoqi@0 112 }
aoqi@0 113 }
aoqi@0 114
aoqi@0 115 void set_location(VMReg reg, address loc) {
aoqi@0 116 int index = reg->value() / location_valid_type_size;
aoqi@0 117 assert(0 <= reg->value() && reg->value() < reg_count, "range check");
aoqi@0 118 assert(0 <= index && index < location_valid_size, "range check");
aoqi@0 119 assert(_update_map, "updating map that does not need updating");
aoqi@0 120 _location[reg->value()] = (intptr_t*) loc;
aoqi@0 121 _location_valid[index] |= ((LocationValidType)1 << (reg->value() % location_valid_type_size));
aoqi@0 122 check_location_valid();
aoqi@0 123 }
aoqi@0 124
aoqi@0 125 // Called by an entry frame.
aoqi@0 126 void clear();
aoqi@0 127
aoqi@0 128 bool include_argument_oops() const { return _include_argument_oops; }
aoqi@0 129 void set_include_argument_oops(bool f) { _include_argument_oops = f; }
aoqi@0 130
aoqi@0 131 JavaThread *thread() const { return _thread; }
aoqi@0 132 bool update_map() const { return _update_map; }
aoqi@0 133
aoqi@0 134 void print_on(outputStream* st) const;
aoqi@0 135 void print() const;
aoqi@0 136
aoqi@0 137 // the following contains the definition of pd_xxx methods
aoqi@0 138 #ifdef TARGET_ARCH_x86
aoqi@0 139 # include "registerMap_x86.hpp"
aoqi@0 140 #endif
aoqi@0 141 #ifdef TARGET_ARCH_sparc
aoqi@0 142 # include "registerMap_sparc.hpp"
aoqi@0 143 #endif
aoqi@0 144 #ifdef TARGET_ARCH_zero
aoqi@0 145 # include "registerMap_zero.hpp"
aoqi@0 146 #endif
aoqi@0 147 #ifdef TARGET_ARCH_arm
aoqi@0 148 # include "registerMap_arm.hpp"
aoqi@0 149 #endif
aoqi@0 150 #ifdef TARGET_ARCH_ppc
aoqi@0 151 # include "registerMap_ppc.hpp"
aoqi@0 152 #endif
aoqi@0 153
aoqi@0 154 };
aoqi@0 155
aoqi@0 156 #endif // SHARE_VM_RUNTIME_REGISTERMAP_HPP

mercurial