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