Tue, 07 Jul 2009 14:23:00 -0400
6855834: G1: minimize the output when -XX:+PrintHeapAtGC is set
Summary: Changing the behavior of -XX:+PrintHeapAtGC for G1 from printing lengthy, per-region information to instead printing a concise summary.
Reviewed-by: ysr, apetrusenko, jcoomes
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 2002-2007 Sun Microsystems, Inc. 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 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | class JavaThread; |
duke@435 | 26 | |
duke@435 | 27 | // |
duke@435 | 28 | // RegisterMap |
duke@435 | 29 | // |
duke@435 | 30 | // A companion structure used for stack traversal. The RegisterMap contains |
duke@435 | 31 | // misc. information needed in order to do correct stack traversal of stack |
duke@435 | 32 | // frames. Hence, it must always be passed in as an argument to |
duke@435 | 33 | // frame::sender(RegisterMap*). |
duke@435 | 34 | // |
duke@435 | 35 | // In particular, |
duke@435 | 36 | // 1) It provides access to the thread for which the stack belongs. The |
duke@435 | 37 | // thread object is needed in order to get sender of a deoptimized frame. |
duke@435 | 38 | // |
duke@435 | 39 | // 2) It is used to pass information from a callee frame to its caller |
duke@435 | 40 | // frame about how the frame should be traversed. This is used to let |
duke@435 | 41 | // the caller frame take care of calling oops-do of out-going |
duke@435 | 42 | // arguments, when the callee frame is not instantiated yet. This |
duke@435 | 43 | // happens, e.g., when a compiled frame calls into |
duke@435 | 44 | // resolve_virtual_call. (Hence, it is critical that the same |
duke@435 | 45 | // RegisterMap object is used for the entire stack walk. Normally, |
duke@435 | 46 | // this is hidden by using the StackFrameStream.) This is used when |
duke@435 | 47 | // doing follow_oops and oops_do. |
duke@435 | 48 | // |
duke@435 | 49 | // 3) The RegisterMap keeps track of the values of callee-saved registers |
duke@435 | 50 | // from frame to frame (hence, the name). For some stack traversal the |
duke@435 | 51 | // values of the callee-saved registers does not matter, e.g., if you |
duke@435 | 52 | // only need the static properies such as frame type, pc, and such. |
duke@435 | 53 | // Updating of the RegisterMap can be turned off by instantiating the |
duke@435 | 54 | // register map as: RegisterMap map(thread, false); |
duke@435 | 55 | |
duke@435 | 56 | class RegisterMap : public StackObj { |
duke@435 | 57 | public: |
duke@435 | 58 | typedef julong LocationValidType; |
duke@435 | 59 | enum { |
duke@435 | 60 | reg_count = ConcreteRegisterImpl::number_of_registers, |
duke@435 | 61 | location_valid_type_size = sizeof(LocationValidType)*8, |
duke@435 | 62 | location_valid_size = (reg_count+location_valid_type_size-1)/location_valid_type_size |
duke@435 | 63 | }; |
duke@435 | 64 | private: |
duke@435 | 65 | intptr_t* _location[reg_count]; // Location of registers (intptr_t* looks better than address in the debugger) |
duke@435 | 66 | LocationValidType _location_valid[location_valid_size]; |
duke@435 | 67 | bool _include_argument_oops; // Should include argument_oop marked locations for compiler |
duke@435 | 68 | JavaThread* _thread; // Reference to current thread |
duke@435 | 69 | bool _update_map; // Tells if the register map need to be |
duke@435 | 70 | // updated when traversing the stack |
duke@435 | 71 | |
duke@435 | 72 | #ifdef ASSERT |
duke@435 | 73 | void check_location_valid(); |
duke@435 | 74 | #else |
duke@435 | 75 | void check_location_valid() {} |
duke@435 | 76 | #endif |
duke@435 | 77 | |
duke@435 | 78 | public: |
duke@435 | 79 | debug_only(intptr_t* _update_for_id;) // Assert that RegisterMap is not updated twice for same frame |
duke@435 | 80 | RegisterMap(JavaThread *thread, bool update_map = true); |
duke@435 | 81 | RegisterMap(const RegisterMap* map); |
duke@435 | 82 | |
duke@435 | 83 | address location(VMReg reg) const { |
duke@435 | 84 | int index = reg->value() / location_valid_type_size; |
duke@435 | 85 | assert(0 <= reg->value() && reg->value() < reg_count, "range check"); |
duke@435 | 86 | assert(0 <= index && index < location_valid_size, "range check"); |
duke@435 | 87 | if (_location_valid[index] & ((LocationValidType)1 << (reg->value() % location_valid_type_size))) { |
duke@435 | 88 | return (address) _location[reg->value()]; |
duke@435 | 89 | } else { |
duke@435 | 90 | return pd_location(reg); |
duke@435 | 91 | } |
duke@435 | 92 | } |
duke@435 | 93 | |
duke@435 | 94 | void set_location(VMReg reg, address loc) { |
duke@435 | 95 | int index = reg->value() / location_valid_type_size; |
duke@435 | 96 | assert(0 <= reg->value() && reg->value() < reg_count, "range check"); |
duke@435 | 97 | assert(0 <= index && index < location_valid_size, "range check"); |
duke@435 | 98 | assert(_update_map, "updating map that does not need updating"); |
duke@435 | 99 | _location[reg->value()] = (intptr_t*) loc; |
duke@435 | 100 | _location_valid[index] |= ((LocationValidType)1 << (reg->value() % location_valid_type_size)); |
duke@435 | 101 | check_location_valid(); |
duke@435 | 102 | } |
duke@435 | 103 | |
duke@435 | 104 | // Called by an entry frame. |
duke@435 | 105 | void clear(); |
duke@435 | 106 | |
duke@435 | 107 | bool include_argument_oops() const { return _include_argument_oops; } |
duke@435 | 108 | void set_include_argument_oops(bool f) { _include_argument_oops = f; } |
duke@435 | 109 | |
duke@435 | 110 | JavaThread *thread() const { return _thread; } |
duke@435 | 111 | bool update_map() const { return _update_map; } |
duke@435 | 112 | |
duke@435 | 113 | void print_on(outputStream* st) const; |
duke@435 | 114 | void print() const; |
duke@435 | 115 | |
duke@435 | 116 | // the following contains the definition of pd_xxx methods |
duke@435 | 117 | # include "incls/_registerMap_pd.hpp.incl" |
duke@435 | 118 | }; |