annotate src/share/vm/runtime/vframeArray.hpp @ 3979:4dfb2df418f2

6484982: G1: process references during evacuation pauses Summary: G1 now uses two reference processors - one is used by concurrent marking and the other is used by STW GCs (both full and incremental evacuation pauses). In an evacuation pause, the reference processor is embedded into the closures used to scan objects. Doing so causes causes reference objects to be 'discovered' by the reference processor. At the end of the evacuation pause, these discovered reference objects are processed - preserving (and copying) referent objects (and their reachable graphs) as appropriate. Reviewed-by: ysr, jwilhelm, brutisso, stefank, tonyp
author johnc
date Thu, 22 Sep 2011 10:57:37 -0700
parents f6f3bb0ee072
children d2a62e0f25eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3369
diff changeset
2 * Copyright (c) 1997, 2011, 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: 948
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 948
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: 948
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_VFRAMEARRAY_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_RUNTIME_VFRAMEARRAY_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 "oops/arrayOop.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "runtime/deoptimization.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "runtime/frame.inline.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "runtime/monitorChunk.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 #include "utilities/growableArray.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33
0
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // A vframeArray is an array used for momentarily storing off stack Java method activations
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // during deoptimization. Essentially it is an array of vframes where each vframe
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // data is stored off stack. This structure will never exist across a safepoint so
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // there is no need to gc any oops that are stored in the structure.
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 class LocalsClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 class ExpressionStackClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 class MonitorStackClosure;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class MonitorArrayElement;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 class StackValueCollection;
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // A vframeArrayElement is an element of a vframeArray. Each element
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // represent an interpreter frame which will eventually be created.
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 class vframeArrayElement : public _ValueObj {
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3369
diff changeset
50 friend class VMStructs;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3369
diff changeset
51
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 frame _frame; // the interpreter frame we will unpack into
900
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 0
diff changeset
55 int _bci; // raw bci for this vframe
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 0
diff changeset
56 bool _reexecute; // whether sould we reexecute this bytecode
0
a61af66fc99e Initial load
duke
parents:
diff changeset
57 methodOop _method; // the method for this vframe
a61af66fc99e Initial load
duke
parents:
diff changeset
58 MonitorChunk* _monitors; // active monitors for this vframe
a61af66fc99e Initial load
duke
parents:
diff changeset
59 StackValueCollection* _locals;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 StackValueCollection* _expressions;
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 frame* iframe(void) { return &_frame; }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 int bci(void) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 int raw_bci(void) const { return _bci; }
900
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 0
diff changeset
69 bool should_reexecute(void) const { return _reexecute; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 methodOop method(void) const { return _method; }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 MonitorChunk* monitors(void) const { return _monitors; }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 void free_monitors(JavaThread* jt);
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 StackValueCollection* locals(void) const { return _locals; }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 StackValueCollection* expressions(void) const { return _expressions; }
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 void fill_in(compiledVFrame* vf);
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // Formerly part of deoptimizedVFrame
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Returns the on stack word size for this frame
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // callee_parameters is the number of callee locals residing inside this frame
3369
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 1972
diff changeset
88 int on_stack_size(int caller_actual_parameters,
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 1972
diff changeset
89 int callee_parameters,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
90 int callee_locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
91 bool is_top_frame,
a61af66fc99e Initial load
duke
parents:
diff changeset
92 int popframe_extra_stack_expression_els) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // Unpacks the element to skeletal interpreter frame
3369
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 1972
diff changeset
95 void unpack_on_stack(int caller_actual_parameters,
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 1972
diff changeset
96 int callee_parameters,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
97 int callee_locals,
a61af66fc99e Initial load
duke
parents:
diff changeset
98 frame* caller,
a61af66fc99e Initial load
duke
parents:
diff changeset
99 bool is_top_frame,
a61af66fc99e Initial load
duke
parents:
diff changeset
100 int exec_mode);
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
103 void print(outputStream* st);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 #endif /* PRODUCT */
a61af66fc99e Initial load
duke
parents:
diff changeset
105 };
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // this can be a ResourceObj if we don't save the last one...
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // but it does make debugging easier even if we can't look
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // at the data in each vframeElement
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 class vframeArray: public CHeapObj {
3939
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3369
diff changeset
112 friend class VMStructs;
f6f3bb0ee072 7088955: add C2 IR support to the SA
never
parents: 3369
diff changeset
113
0
a61af66fc99e Initial load
duke
parents:
diff changeset
114 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // Here is what a vframeArray looks like in memory
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
120 fixed part
a61af66fc99e Initial load
duke
parents:
diff changeset
121 description of the original frame
a61af66fc99e Initial load
duke
parents:
diff changeset
122 _frames - number of vframes in this array
a61af66fc99e Initial load
duke
parents:
diff changeset
123 adapter info
a61af66fc99e Initial load
duke
parents:
diff changeset
124 callee register save area
a61af66fc99e Initial load
duke
parents:
diff changeset
125 variable part
a61af66fc99e Initial load
duke
parents:
diff changeset
126 vframeArrayElement [ 0 ]
a61af66fc99e Initial load
duke
parents:
diff changeset
127 ...
a61af66fc99e Initial load
duke
parents:
diff changeset
128 vframeArrayElement [_frames - 1]
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 */
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 JavaThread* _owner_thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 vframeArray* _next;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 frame _original; // the original frame of the deoptee
a61af66fc99e Initial load
duke
parents:
diff changeset
135 frame _caller; // caller of root frame in vframeArray
a61af66fc99e Initial load
duke
parents:
diff changeset
136 frame _sender;
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 Deoptimization::UnrollBlock* _unroll_block;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 int _frame_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 int _frames; // number of javavframes in the array (does not count any adapter)
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 intptr_t _callee_registers[RegisterMap::reg_count];
a61af66fc99e Initial load
duke
parents:
diff changeset
144 unsigned char _valid[RegisterMap::reg_count];
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 vframeArrayElement _elements[1]; // First variable section.
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148 void fill_in_element(int index, compiledVFrame* vf);
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 bool is_location_valid(int i) const { return _valid[i] != 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 void set_location_valid(int i, bool valid) { _valid[i] = valid; }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 // Tells whether index is within bounds.
a61af66fc99e Initial load
duke
parents:
diff changeset
157 bool is_within_bounds(int index) const { return 0 <= index && index < frames(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // Accessores for instance variable
a61af66fc99e Initial load
duke
parents:
diff changeset
160 int frames() const { return _frames; }
a61af66fc99e Initial load
duke
parents:
diff changeset
161
a61af66fc99e Initial load
duke
parents:
diff changeset
162 static vframeArray* allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
a61af66fc99e Initial load
duke
parents:
diff changeset
163 RegisterMap* reg_map, frame sender, frame caller, frame self);
a61af66fc99e Initial load
duke
parents:
diff changeset
164
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 vframeArrayElement* element(int index) { assert(is_within_bounds(index), "Bad index"); return &_elements[index]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
167
a61af66fc99e Initial load
duke
parents:
diff changeset
168 // Allocates a new vframe in the array and fills the array with vframe information in chunk
a61af66fc99e Initial load
duke
parents:
diff changeset
169 void fill_in(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk, const RegisterMap *reg_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // Returns the owner of this vframeArray
a61af66fc99e Initial load
duke
parents:
diff changeset
172 JavaThread* owner_thread() const { return _owner_thread; }
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // Accessors for next
a61af66fc99e Initial load
duke
parents:
diff changeset
175 vframeArray* next() const { return _next; }
a61af66fc99e Initial load
duke
parents:
diff changeset
176 void set_next(vframeArray* value) { _next = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
177
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // Accessors for sp
a61af66fc99e Initial load
duke
parents:
diff changeset
179 intptr_t* sp() const { return _original.sp(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
180
a61af66fc99e Initial load
duke
parents:
diff changeset
181 intptr_t* unextended_sp() const { return _original.unextended_sp(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 address original_pc() const { return _original.pc(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 frame original() const { return _original; }
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 frame caller() const { return _caller; }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 frame sender() const { return _sender; }
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // Accessors for unroll block
a61af66fc99e Initial load
duke
parents:
diff changeset
192 Deoptimization::UnrollBlock* unroll_block() const { return _unroll_block; }
a61af66fc99e Initial load
duke
parents:
diff changeset
193 void set_unroll_block(Deoptimization::UnrollBlock* block) { _unroll_block = block; }
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // Returns the size of the frame that got deoptimized
a61af66fc99e Initial load
duke
parents:
diff changeset
196 int frame_size() const { return _frame_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 // Unpack the array on the stack passed in stack interval
3369
3d2ab563047a 7043461: VM crashes in void LinkResolver::runtime_resolve_virtual_method
never
parents: 1972
diff changeset
199 void unpack_to_stack(frame &unpack_frame, int exec_mode, int caller_actual_parameters);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // Deallocates monitor chunks allocated during deoptimization.
a61af66fc99e Initial load
duke
parents:
diff changeset
202 // This should be called when the array is not used anymore.
a61af66fc99e Initial load
duke
parents:
diff changeset
203 void deallocate_monitor_chunks();
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // Accessor for register map
a61af66fc99e Initial load
duke
parents:
diff changeset
208 address register_location(int i) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 void print_on_2(outputStream* st) PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
211 void print_value_on(outputStream* st) const PRODUCT_RETURN;
a61af66fc99e Initial load
duke
parents:
diff changeset
212
a61af66fc99e Initial load
duke
parents:
diff changeset
213 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
214 // Comparing
a61af66fc99e Initial load
duke
parents:
diff changeset
215 bool structural_compare(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk);
a61af66fc99e Initial load
duke
parents:
diff changeset
216 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
217
a61af66fc99e Initial load
duke
parents:
diff changeset
218 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
219
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
220 #endif // SHARE_VM_RUNTIME_VFRAMEARRAY_HPP