annotate src/share/vm/runtime/registerMap.hpp @ 2095:36c186bcc085

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