1
|
1 |
/*
|
|
2 |
* Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
|
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
21 |
* have any questions.
|
|
22 |
*
|
|
23 |
*/
|
|
24 |
|
|
25 |
// A vframeArray is an array used for momentarily storing off stack Java method activations
|
|
26 |
// during deoptimization. Essentially it is an array of vframes where each vframe
|
|
27 |
// data is stored off stack. This structure will never exist across a safepoint so
|
|
28 |
// there is no need to gc any oops that are stored in the structure.
|
|
29 |
|
|
30 |
|
|
31 |
class LocalsClosure;
|
|
32 |
class ExpressionStackClosure;
|
|
33 |
class MonitorStackClosure;
|
|
34 |
class MonitorArrayElement;
|
|
35 |
class StackValueCollection;
|
|
36 |
|
|
37 |
// A vframeArrayElement is an element of a vframeArray. Each element
|
|
38 |
// represent an interpreter frame which will eventually be created.
|
|
39 |
|
|
40 |
class vframeArrayElement : public _ValueObj {
|
|
41 |
private:
|
|
42 |
|
|
43 |
frame _frame; // the interpreter frame we will unpack into
|
|
44 |
int _bci; // raw bci for this vframe
|
|
45 |
methodOop _method; // the method for this vframe
|
|
46 |
MonitorChunk* _monitors; // active monitors for this vframe
|
|
47 |
StackValueCollection* _locals;
|
|
48 |
StackValueCollection* _expressions;
|
|
49 |
|
|
50 |
public:
|
|
51 |
|
|
52 |
frame* iframe(void) { return &_frame; }
|
|
53 |
|
|
54 |
int bci(void) const;
|
|
55 |
|
|
56 |
int raw_bci(void) const { return _bci; }
|
|
57 |
|
|
58 |
methodOop method(void) const { return _method; }
|
|
59 |
|
|
60 |
MonitorChunk* monitors(void) const { return _monitors; }
|
|
61 |
|
|
62 |
void free_monitors(JavaThread* jt);
|
|
63 |
|
|
64 |
StackValueCollection* locals(void) const { return _locals; }
|
|
65 |
|
|
66 |
StackValueCollection* expressions(void) const { return _expressions; }
|
|
67 |
|
|
68 |
void fill_in(compiledVFrame* vf);
|
|
69 |
|
|
70 |
// Formerly part of deoptimizedVFrame
|
|
71 |
|
|
72 |
|
|
73 |
// Returns the on stack word size for this frame
|
|
74 |
// callee_parameters is the number of callee locals residing inside this frame
|
|
75 |
int on_stack_size(int callee_parameters,
|
|
76 |
int callee_locals,
|
|
77 |
bool is_top_frame,
|
|
78 |
int popframe_extra_stack_expression_els) const;
|
|
79 |
|
|
80 |
// Unpacks the element to skeletal interpreter frame
|
|
81 |
void unpack_on_stack(int callee_parameters,
|
|
82 |
int callee_locals,
|
|
83 |
frame* caller,
|
|
84 |
bool is_top_frame,
|
|
85 |
int exec_mode);
|
|
86 |
|
|
87 |
#ifndef PRODUCT
|
|
88 |
void print(outputStream* st);
|
|
89 |
#endif /* PRODUCT */
|
|
90 |
};
|
|
91 |
|
|
92 |
// this can be a ResourceObj if we don't save the last one...
|
|
93 |
// but it does make debugging easier even if we can't look
|
|
94 |
// at the data in each vframeElement
|
|
95 |
|
|
96 |
class vframeArray: public CHeapObj {
|
|
97 |
private:
|
|
98 |
|
|
99 |
|
|
100 |
// Here is what a vframeArray looks like in memory
|
|
101 |
|
|
102 |
/*
|
|
103 |
fixed part
|
|
104 |
description of the original frame
|
|
105 |
_frames - number of vframes in this array
|
|
106 |
adapter info
|
|
107 |
callee register save area
|
|
108 |
variable part
|
|
109 |
vframeArrayElement [ 0 ]
|
|
110 |
...
|
|
111 |
vframeArrayElement [_frames - 1]
|
|
112 |
|
|
113 |
*/
|
|
114 |
|
|
115 |
JavaThread* _owner_thread;
|
|
116 |
vframeArray* _next;
|
|
117 |
frame _original; // the original frame of the deoptee
|
|
118 |
frame _caller; // caller of root frame in vframeArray
|
|
119 |
frame _sender;
|
|
120 |
|
|
121 |
Deoptimization::UnrollBlock* _unroll_block;
|
|
122 |
int _frame_size;
|
|
123 |
|
|
124 |
int _frames; // number of javavframes in the array (does not count any adapter)
|
|
125 |
|
|
126 |
intptr_t _callee_registers[RegisterMap::reg_count];
|
|
127 |
unsigned char _valid[RegisterMap::reg_count];
|
|
128 |
|
|
129 |
vframeArrayElement _elements[1]; // First variable section.
|
|
130 |
|
|
131 |
void fill_in_element(int index, compiledVFrame* vf);
|
|
132 |
|
|
133 |
bool is_location_valid(int i) const { return _valid[i] != 0; }
|
|
134 |
void set_location_valid(int i, bool valid) { _valid[i] = valid; }
|
|
135 |
|
|
136 |
public:
|
|
137 |
|
|
138 |
|
|
139 |
// Tells whether index is within bounds.
|
|
140 |
bool is_within_bounds(int index) const { return 0 <= index && index < frames(); }
|
|
141 |
|
|
142 |
// Accessores for instance variable
|
|
143 |
int frames() const { return _frames; }
|
|
144 |
|
|
145 |
static vframeArray* allocate(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk,
|
|
146 |
RegisterMap* reg_map, frame sender, frame caller, frame self);
|
|
147 |
|
|
148 |
|
|
149 |
vframeArrayElement* element(int index) { assert(is_within_bounds(index), "Bad index"); return &_elements[index]; }
|
|
150 |
|
|
151 |
// Allocates a new vframe in the array and fills the array with vframe information in chunk
|
|
152 |
void fill_in(JavaThread* thread, int frame_size, GrowableArray<compiledVFrame*>* chunk, const RegisterMap *reg_map);
|
|
153 |
|
|
154 |
// Returns the owner of this vframeArray
|
|
155 |
JavaThread* owner_thread() const { return _owner_thread; }
|
|
156 |
|
|
157 |
// Accessors for next
|
|
158 |
vframeArray* next() const { return _next; }
|
|
159 |
void set_next(vframeArray* value) { _next = value; }
|
|
160 |
|
|
161 |
// Accessors for sp
|
|
162 |
intptr_t* sp() const { return _original.sp(); }
|
|
163 |
|
|
164 |
intptr_t* unextended_sp() const { return _original.unextended_sp(); }
|
|
165 |
|
|
166 |
address original_pc() const { return _original.pc(); }
|
|
167 |
|
|
168 |
frame original() const { return _original; }
|
|
169 |
|
|
170 |
frame caller() const { return _caller; }
|
|
171 |
|
|
172 |
frame sender() const { return _sender; }
|
|
173 |
|
|
174 |
// Accessors for unroll block
|
|
175 |
Deoptimization::UnrollBlock* unroll_block() const { return _unroll_block; }
|
|
176 |
void set_unroll_block(Deoptimization::UnrollBlock* block) { _unroll_block = block; }
|
|
177 |
|
|
178 |
// Returns the size of the frame that got deoptimized
|
|
179 |
int frame_size() const { return _frame_size; }
|
|
180 |
|
|
181 |
// Unpack the array on the stack passed in stack interval
|
|
182 |
void unpack_to_stack(frame &unpack_frame, int exec_mode);
|
|
183 |
|
|
184 |
// Deallocates monitor chunks allocated during deoptimization.
|
|
185 |
// This should be called when the array is not used anymore.
|
|
186 |
void deallocate_monitor_chunks();
|
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
// Accessor for register map
|
|
191 |
address register_location(int i) const;
|
|
192 |
|
|
193 |
void print_on_2(outputStream* st) PRODUCT_RETURN;
|
|
194 |
void print_value_on(outputStream* st) const PRODUCT_RETURN;
|
|
195 |
|
|
196 |
#ifndef PRODUCT
|
|
197 |
// Comparing
|
|
198 |
bool structural_compare(JavaThread* thread, GrowableArray<compiledVFrame*>* chunk);
|
|
199 |
#endif
|
|
200 |
|
|
201 |
};
|