annotate src/share/vm/oops/generateOopMap.hpp @ 1091:6aa7255741f3

6906727: UseCompressedOops: some card-marking fixes related to object arrays Summary: Introduced a new write_ref_array(HeapWords* start, size_t count) method that does the requisite MemRegion range calculation so (some of the) clients of the erstwhile write_ref_array(MemRegion mr) do not need to worry. This removed all external uses of array_size(), which was also simplified and made private. Asserts were added to catch other possible issues. Further, less essential, fixes stemming from this investigation are deferred to CR 6904516 (to follow shortly in hs17). Reviewed-by: kvn, coleenp, jmasa
author ysr
date Thu, 03 Dec 2009 15:01:57 -0800
parents 98cb887364d3
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // Forward definition
a61af66fc99e Initial load
duke
parents:
diff changeset
26 class MethodOopMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
27 class GenerateOopMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 class BasicBlock;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 class CellTypeState;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 class StackMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // These two should be removed. But requires som code to be cleaned up
a61af66fc99e Initial load
duke
parents:
diff changeset
33 #define MAXARGSIZE 256 // This should be enough
a61af66fc99e Initial load
duke
parents:
diff changeset
34 #define MAX_LOCAL_VARS 65536 // 16-bit entry
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 typedef void (*jmpFct_t)(GenerateOopMap *c, int bcpDelta, int* data);
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 // RetTable
a61af66fc99e Initial load
duke
parents:
diff changeset
40 //
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // Contains maping between jsr targets and there return addresses. One-to-many mapping
a61af66fc99e Initial load
duke
parents:
diff changeset
42 //
a61af66fc99e Initial load
duke
parents:
diff changeset
43 class RetTableEntry : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
45 static int _init_nof_jsrs; // Default size of jsrs list
a61af66fc99e Initial load
duke
parents:
diff changeset
46 int _target_bci; // Target PC address of jump (bytecode index)
a61af66fc99e Initial load
duke
parents:
diff changeset
47 GrowableArray<intptr_t> * _jsrs; // List of return addresses (bytecode index)
a61af66fc99e Initial load
duke
parents:
diff changeset
48 RetTableEntry *_next; // Link to next entry
a61af66fc99e Initial load
duke
parents:
diff changeset
49 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
50 RetTableEntry(int target, RetTableEntry *next) { _target_bci=target; _jsrs = new GrowableArray<intptr_t>(_init_nof_jsrs); _next = next; }
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // Query
a61af66fc99e Initial load
duke
parents:
diff changeset
53 int target_bci() const { return _target_bci; }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 int nof_jsrs() const { return _jsrs->length(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
55 int jsrs(int i) const { assert(i>=0 && i<nof_jsrs(), "Index out of bounds"); return _jsrs->at(i); }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // Update entry
a61af66fc99e Initial load
duke
parents:
diff changeset
58 void add_jsr (int return_bci) { _jsrs->append(return_bci); }
a61af66fc99e Initial load
duke
parents:
diff changeset
59 void add_delta (int bci, int delta);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 RetTableEntry * next() const { return _next; }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 };
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 class RetTable VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
66 RetTableEntry *_first;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 static int _init_nof_entries;
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 void add_jsr(int return_bci, int target_bci); // Adds entry to list
a61af66fc99e Initial load
duke
parents:
diff changeset
70 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
71 RetTable() { _first = NULL; }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 void compute_ret_table(methodHandle method);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 void update_ret_table(int bci, int delta);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 RetTableEntry* find_jsrs_for_target(int targBci);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 };
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 //
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // CellTypeState
a61af66fc99e Initial load
duke
parents:
diff changeset
79 //
a61af66fc99e Initial load
duke
parents:
diff changeset
80 class CellTypeState VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
82 unsigned int _state;
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // Masks for separating the BITS and INFO portions of a CellTypeState
a61af66fc99e Initial load
duke
parents:
diff changeset
85 enum { info_mask = right_n_bits(28),
a61af66fc99e Initial load
duke
parents:
diff changeset
86 bits_mask = (int)(~info_mask) };
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // These constant are used for manipulating the BITS portion of a
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // CellTypeState
a61af66fc99e Initial load
duke
parents:
diff changeset
90 enum { uninit_bit = (int)(nth_bit(31)),
a61af66fc99e Initial load
duke
parents:
diff changeset
91 ref_bit = nth_bit(30),
a61af66fc99e Initial load
duke
parents:
diff changeset
92 val_bit = nth_bit(29),
a61af66fc99e Initial load
duke
parents:
diff changeset
93 addr_bit = nth_bit(28),
a61af66fc99e Initial load
duke
parents:
diff changeset
94 live_bits_mask = (int)(bits_mask & ~uninit_bit) };
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // These constants are used for manipulating the INFO portion of a
a61af66fc99e Initial load
duke
parents:
diff changeset
97 // CellTypeState
a61af66fc99e Initial load
duke
parents:
diff changeset
98 enum { top_info_bit = nth_bit(27),
a61af66fc99e Initial load
duke
parents:
diff changeset
99 not_bottom_info_bit = nth_bit(26),
a61af66fc99e Initial load
duke
parents:
diff changeset
100 info_data_mask = right_n_bits(26),
a61af66fc99e Initial load
duke
parents:
diff changeset
101 info_conflict = info_mask };
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Within the INFO data, these values are used to distinguish different
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // kinds of references.
a61af66fc99e Initial load
duke
parents:
diff changeset
105 enum { ref_not_lock_bit = nth_bit(25), // 0 if this reference is locked as a monitor
a61af66fc99e Initial load
duke
parents:
diff changeset
106 ref_slot_bit = nth_bit(24), // 1 if this reference is a "slot" reference,
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // 0 if it is a "line" reference.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 ref_data_mask = right_n_bits(24) };
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // These values are used to initialize commonly used CellTypeState
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // constants.
a61af66fc99e Initial load
duke
parents:
diff changeset
113 enum { bottom_value = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
114 uninit_value = (int)(uninit_bit | info_conflict),
a61af66fc99e Initial load
duke
parents:
diff changeset
115 ref_value = ref_bit,
a61af66fc99e Initial load
duke
parents:
diff changeset
116 ref_conflict = ref_bit | info_conflict,
a61af66fc99e Initial load
duke
parents:
diff changeset
117 val_value = val_bit | info_conflict,
a61af66fc99e Initial load
duke
parents:
diff changeset
118 addr_value = addr_bit,
a61af66fc99e Initial load
duke
parents:
diff changeset
119 addr_conflict = addr_bit | info_conflict };
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // Since some C++ constructors generate poor code for declarations of the
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // form...
a61af66fc99e Initial load
duke
parents:
diff changeset
125 //
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // CellTypeState vector[length];
a61af66fc99e Initial load
duke
parents:
diff changeset
127 //
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // ...we avoid making a constructor for this class. CellTypeState values
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // should be constructed using one of the make_* methods:
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 static CellTypeState make_any(int state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 CellTypeState s;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 s._state = state;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Causes SS10 warning.
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // assert(s.is_valid_state(), "check to see if CellTypeState is valid");
a61af66fc99e Initial load
duke
parents:
diff changeset
136 return s;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138
a61af66fc99e Initial load
duke
parents:
diff changeset
139 static CellTypeState make_bottom() {
a61af66fc99e Initial load
duke
parents:
diff changeset
140 return make_any(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
141 }
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 static CellTypeState make_top() {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return make_any(AllBits);
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 static CellTypeState make_addr(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
148 assert((bci >= 0) && (bci < info_data_mask), "check to see if ret addr is valid");
a61af66fc99e Initial load
duke
parents:
diff changeset
149 return make_any(addr_bit | not_bottom_info_bit | (bci & info_data_mask));
a61af66fc99e Initial load
duke
parents:
diff changeset
150 }
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 static CellTypeState make_slot_ref(int slot_num) {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 assert(slot_num >= 0 && slot_num < ref_data_mask, "slot out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
154 return make_any(ref_bit | not_bottom_info_bit | ref_not_lock_bit | ref_slot_bit |
a61af66fc99e Initial load
duke
parents:
diff changeset
155 (slot_num & ref_data_mask));
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 static CellTypeState make_line_ref(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 assert(bci >= 0 && bci < ref_data_mask, "line out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
160 return make_any(ref_bit | not_bottom_info_bit | ref_not_lock_bit |
a61af66fc99e Initial load
duke
parents:
diff changeset
161 (bci & ref_data_mask));
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 static CellTypeState make_lock_ref(int bci) {
a61af66fc99e Initial load
duke
parents:
diff changeset
165 assert(bci >= 0 && bci < ref_data_mask, "line out of range");
a61af66fc99e Initial load
duke
parents:
diff changeset
166 return make_any(ref_bit | not_bottom_info_bit | (bci & ref_data_mask));
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169 // Query methods:
a61af66fc99e Initial load
duke
parents:
diff changeset
170 bool is_bottom() const { return _state == 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
171 bool is_live() const { return ((_state & live_bits_mask) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
172 bool is_valid_state() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // Uninitialized and value cells must contain no data in their info field:
a61af66fc99e Initial load
duke
parents:
diff changeset
174 if ((can_be_uninit() || can_be_value()) && !is_info_top()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
176 }
a61af66fc99e Initial load
duke
parents:
diff changeset
177 // The top bit is only set when all info bits are set:
a61af66fc99e Initial load
duke
parents:
diff changeset
178 if (is_info_top() && ((_state & info_mask) != info_mask)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // The not_bottom_bit must be set when any other info bit is set:
a61af66fc99e Initial load
duke
parents:
diff changeset
182 if (is_info_bottom() && ((_state & info_mask) != 0)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
183 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 bool is_address() const { return ((_state & bits_mask) == addr_bit); }
a61af66fc99e Initial load
duke
parents:
diff changeset
189 bool is_reference() const { return ((_state & bits_mask) == ref_bit); }
a61af66fc99e Initial load
duke
parents:
diff changeset
190 bool is_value() const { return ((_state & bits_mask) == val_bit); }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 bool is_uninit() const { return ((_state & bits_mask) == (uint)uninit_bit); }
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 bool can_be_address() const { return ((_state & addr_bit) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
194 bool can_be_reference() const { return ((_state & ref_bit) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
195 bool can_be_value() const { return ((_state & val_bit) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
196 bool can_be_uninit() const { return ((_state & uninit_bit) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
197
a61af66fc99e Initial load
duke
parents:
diff changeset
198 bool is_info_bottom() const { return ((_state & not_bottom_info_bit) == 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
199 bool is_info_top() const { return ((_state & top_info_bit) != 0); }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 int get_info() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 assert((!is_info_top() && !is_info_bottom()),
a61af66fc99e Initial load
duke
parents:
diff changeset
202 "check to make sure top/bottom info is not used");
a61af66fc99e Initial load
duke
parents:
diff changeset
203 return (_state & info_data_mask);
a61af66fc99e Initial load
duke
parents:
diff changeset
204 }
a61af66fc99e Initial load
duke
parents:
diff changeset
205
a61af66fc99e Initial load
duke
parents:
diff changeset
206 bool is_good_address() const { return is_address() && !is_info_top(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
207 bool is_lock_reference() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 return ((_state & (bits_mask | top_info_bit | ref_not_lock_bit)) == ref_bit);
a61af66fc99e Initial load
duke
parents:
diff changeset
209 }
a61af66fc99e Initial load
duke
parents:
diff changeset
210 bool is_nonlock_reference() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
211 return ((_state & (bits_mask | top_info_bit | ref_not_lock_bit)) == (ref_bit | ref_not_lock_bit));
a61af66fc99e Initial load
duke
parents:
diff changeset
212 }
a61af66fc99e Initial load
duke
parents:
diff changeset
213
a61af66fc99e Initial load
duke
parents:
diff changeset
214 bool equal(CellTypeState a) const { return _state == a._state; }
a61af66fc99e Initial load
duke
parents:
diff changeset
215 bool equal_kind(CellTypeState a) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
216 return (_state & bits_mask) == (a._state & bits_mask);
a61af66fc99e Initial load
duke
parents:
diff changeset
217 }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 char to_char() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
220
a61af66fc99e Initial load
duke
parents:
diff changeset
221 // Merge
a61af66fc99e Initial load
duke
parents:
diff changeset
222 CellTypeState merge (CellTypeState cts, int slot) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // Debugging output
a61af66fc99e Initial load
duke
parents:
diff changeset
225 void print(outputStream *os);
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // Default values of common values
a61af66fc99e Initial load
duke
parents:
diff changeset
228 static CellTypeState bottom;
a61af66fc99e Initial load
duke
parents:
diff changeset
229 static CellTypeState uninit;
a61af66fc99e Initial load
duke
parents:
diff changeset
230 static CellTypeState ref;
a61af66fc99e Initial load
duke
parents:
diff changeset
231 static CellTypeState value;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 static CellTypeState refUninit;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 static CellTypeState varUninit;
a61af66fc99e Initial load
duke
parents:
diff changeset
234 static CellTypeState top;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 static CellTypeState addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
236 };
a61af66fc99e Initial load
duke
parents:
diff changeset
237
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 //
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // BasicBlockStruct
a61af66fc99e Initial load
duke
parents:
diff changeset
241 //
a61af66fc99e Initial load
duke
parents:
diff changeset
242 class BasicBlock: ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
244 bool _changed; // Reached a fixpoint or not
a61af66fc99e Initial load
duke
parents:
diff changeset
245 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
246 enum Constants {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 _dead_basic_block = -2,
a61af66fc99e Initial load
duke
parents:
diff changeset
248 _unreached = -1 // Alive but not yet reached by analysis
a61af66fc99e Initial load
duke
parents:
diff changeset
249 // >=0 // Alive and has a merged state
a61af66fc99e Initial load
duke
parents:
diff changeset
250 };
a61af66fc99e Initial load
duke
parents:
diff changeset
251
a61af66fc99e Initial load
duke
parents:
diff changeset
252 int _bci; // Start of basic block
a61af66fc99e Initial load
duke
parents:
diff changeset
253 int _end_bci; // Bci of last instruction in basicblock
a61af66fc99e Initial load
duke
parents:
diff changeset
254 int _max_locals; // Determines split between vars and stack
a61af66fc99e Initial load
duke
parents:
diff changeset
255 int _max_stack; // Determines split between stack and monitors
a61af66fc99e Initial load
duke
parents:
diff changeset
256 CellTypeState* _state; // State (vars, stack) at entry.
a61af66fc99e Initial load
duke
parents:
diff changeset
257 int _stack_top; // -1 indicates bottom stack value.
a61af66fc99e Initial load
duke
parents:
diff changeset
258 int _monitor_top; // -1 indicates bottom monitor stack value.
a61af66fc99e Initial load
duke
parents:
diff changeset
259
a61af66fc99e Initial load
duke
parents:
diff changeset
260 CellTypeState* vars() { return _state; }
a61af66fc99e Initial load
duke
parents:
diff changeset
261 CellTypeState* stack() { return _state + _max_locals; }
a61af66fc99e Initial load
duke
parents:
diff changeset
262
a61af66fc99e Initial load
duke
parents:
diff changeset
263 bool changed() { return _changed; }
a61af66fc99e Initial load
duke
parents:
diff changeset
264 void set_changed(bool s) { _changed = s; }
a61af66fc99e Initial load
duke
parents:
diff changeset
265
a61af66fc99e Initial load
duke
parents:
diff changeset
266 bool is_reachable() const { return _stack_top >= 0; } // Analysis has reached this basicblock
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // All basicblocks that are unreachable are going to have a _stack_top == _dead_basic_block.
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // This info. is setup in a pre-parse before the real abstract interpretation starts.
a61af66fc99e Initial load
duke
parents:
diff changeset
270 bool is_dead() const { return _stack_top == _dead_basic_block; }
a61af66fc99e Initial load
duke
parents:
diff changeset
271 bool is_alive() const { return _stack_top != _dead_basic_block; }
a61af66fc99e Initial load
duke
parents:
diff changeset
272 void mark_as_alive() { assert(is_dead(), "must be dead"); _stack_top = _unreached; }
a61af66fc99e Initial load
duke
parents:
diff changeset
273 };
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275
a61af66fc99e Initial load
duke
parents:
diff changeset
276 //
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // GenerateOopMap
a61af66fc99e Initial load
duke
parents:
diff changeset
278 //
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // Main class used to compute the pointer-maps in a MethodOop
a61af66fc99e Initial load
duke
parents:
diff changeset
280 //
a61af66fc99e Initial load
duke
parents:
diff changeset
281 class GenerateOopMap VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
282 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
283
a61af66fc99e Initial load
duke
parents:
diff changeset
284 // _monitor_top is set to this constant to indicate that a monitor matching
a61af66fc99e Initial load
duke
parents:
diff changeset
285 // problem was encountered prior to this point in control flow.
a61af66fc99e Initial load
duke
parents:
diff changeset
286 enum { bad_monitors = -1 };
a61af66fc99e Initial load
duke
parents:
diff changeset
287
a61af66fc99e Initial load
duke
parents:
diff changeset
288 // Main variables
a61af66fc99e Initial load
duke
parents:
diff changeset
289 methodHandle _method; // The method we are examine
a61af66fc99e Initial load
duke
parents:
diff changeset
290 RetTable _rt; // Contains the return address mappings
a61af66fc99e Initial load
duke
parents:
diff changeset
291 int _max_locals; // Cached value of no. of locals
a61af66fc99e Initial load
duke
parents:
diff changeset
292 int _max_stack; // Cached value of max. stack depth
a61af66fc99e Initial load
duke
parents:
diff changeset
293 int _max_monitors; // Cached value of max. monitor stack depth
a61af66fc99e Initial load
duke
parents:
diff changeset
294 int _has_exceptions; // True, if exceptions exist for method
605
98cb887364d3 6810672: Comment typos
twisti
parents: 342
diff changeset
295 bool _got_error; // True, if an error occurred during interpretation.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
296 Handle _exception; // Exception if got_error is true.
a61af66fc99e Initial load
duke
parents:
diff changeset
297 bool _did_rewriting; // was bytecodes rewritten
a61af66fc99e Initial load
duke
parents:
diff changeset
298 bool _did_relocation; // was relocation neccessary
a61af66fc99e Initial load
duke
parents:
diff changeset
299 bool _monitor_safe; // The monitors in this method have been determined
a61af66fc99e Initial load
duke
parents:
diff changeset
300 // to be safe.
a61af66fc99e Initial load
duke
parents:
diff changeset
301
a61af66fc99e Initial load
duke
parents:
diff changeset
302 // Working Cell type state
a61af66fc99e Initial load
duke
parents:
diff changeset
303 int _state_len; // Size of states
a61af66fc99e Initial load
duke
parents:
diff changeset
304 CellTypeState *_state; // list of states
a61af66fc99e Initial load
duke
parents:
diff changeset
305 char *_state_vec_buf; // Buffer used to print a readable version of a state
a61af66fc99e Initial load
duke
parents:
diff changeset
306 int _stack_top;
a61af66fc99e Initial load
duke
parents:
diff changeset
307 int _monitor_top;
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 // Timing and statistics
a61af66fc99e Initial load
duke
parents:
diff changeset
310 static elapsedTimer _total_oopmap_time; // Holds cumulative oopmap generation time
a61af66fc99e Initial load
duke
parents:
diff changeset
311 static long _total_byte_count; // Holds cumulative number of bytes inspected
a61af66fc99e Initial load
duke
parents:
diff changeset
312
a61af66fc99e Initial load
duke
parents:
diff changeset
313 // Cell type methods
a61af66fc99e Initial load
duke
parents:
diff changeset
314 void init_state();
a61af66fc99e Initial load
duke
parents:
diff changeset
315 void make_context_uninitialized ();
a61af66fc99e Initial load
duke
parents:
diff changeset
316 int methodsig_to_effect (symbolOop signature, bool isStatic, CellTypeState* effect);
a61af66fc99e Initial load
duke
parents:
diff changeset
317 bool merge_local_state_vectors (CellTypeState* cts, CellTypeState* bbts);
a61af66fc99e Initial load
duke
parents:
diff changeset
318 bool merge_monitor_state_vectors(CellTypeState* cts, CellTypeState* bbts);
a61af66fc99e Initial load
duke
parents:
diff changeset
319 void copy_state (CellTypeState *dst, CellTypeState *src);
a61af66fc99e Initial load
duke
parents:
diff changeset
320 void merge_state_into_bb (BasicBlock *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
321 static void merge_state (GenerateOopMap *gom, int bcidelta, int* data);
a61af66fc99e Initial load
duke
parents:
diff changeset
322 void set_var (int localNo, CellTypeState cts);
a61af66fc99e Initial load
duke
parents:
diff changeset
323 CellTypeState get_var (int localNo);
a61af66fc99e Initial load
duke
parents:
diff changeset
324 CellTypeState pop ();
a61af66fc99e Initial load
duke
parents:
diff changeset
325 void push (CellTypeState cts);
a61af66fc99e Initial load
duke
parents:
diff changeset
326 CellTypeState monitor_pop ();
a61af66fc99e Initial load
duke
parents:
diff changeset
327 void monitor_push (CellTypeState cts);
a61af66fc99e Initial load
duke
parents:
diff changeset
328 CellTypeState * vars () { return _state; }
a61af66fc99e Initial load
duke
parents:
diff changeset
329 CellTypeState * stack () { return _state+_max_locals; }
a61af66fc99e Initial load
duke
parents:
diff changeset
330 CellTypeState * monitors () { return _state+_max_locals+_max_stack; }
a61af66fc99e Initial load
duke
parents:
diff changeset
331
a61af66fc99e Initial load
duke
parents:
diff changeset
332 void replace_all_CTS_matches (CellTypeState match,
a61af66fc99e Initial load
duke
parents:
diff changeset
333 CellTypeState replace);
a61af66fc99e Initial load
duke
parents:
diff changeset
334 void print_states (outputStream *os, CellTypeState *vector, int num);
a61af66fc99e Initial load
duke
parents:
diff changeset
335 void print_current_state (outputStream *os,
a61af66fc99e Initial load
duke
parents:
diff changeset
336 BytecodeStream *itr,
a61af66fc99e Initial load
duke
parents:
diff changeset
337 bool detailed);
a61af66fc99e Initial load
duke
parents:
diff changeset
338 void report_monitor_mismatch (const char *msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
339
a61af66fc99e Initial load
duke
parents:
diff changeset
340 // Basicblock info
a61af66fc99e Initial load
duke
parents:
diff changeset
341 BasicBlock * _basic_blocks; // Array of basicblock info
a61af66fc99e Initial load
duke
parents:
diff changeset
342 int _gc_points;
a61af66fc99e Initial load
duke
parents:
diff changeset
343 int _bb_count;
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
344 BitMap _bb_hdr_bits;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
345
a61af66fc99e Initial load
duke
parents:
diff changeset
346 // Basicblocks methods
a61af66fc99e Initial load
duke
parents:
diff changeset
347 void initialize_bb ();
a61af66fc99e Initial load
duke
parents:
diff changeset
348 void mark_bbheaders_and_count_gc_points();
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
349 bool is_bb_header (int bci) const {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
350 return _bb_hdr_bits.at(bci);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
351 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
352 int gc_points () const { return _gc_points; }
a61af66fc99e Initial load
duke
parents:
diff changeset
353 int bb_count () const { return _bb_count; }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
354 void set_bbmark_bit (int bci) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
355 _bb_hdr_bits.at_put(bci, true);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
356 }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
357 void clear_bbmark_bit (int bci) {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
358 _bb_hdr_bits.at_put(bci, false);
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 0
diff changeset
359 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
360 BasicBlock * get_basic_block_at (int bci) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
361 BasicBlock * get_basic_block_containing (int bci) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
362 void interp_bb (BasicBlock *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
363 void restore_state (BasicBlock *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
364 int next_bb_start_pc (BasicBlock *bb);
a61af66fc99e Initial load
duke
parents:
diff changeset
365 void update_basic_blocks (int bci, int delta, int new_method_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
366 static void bb_mark_fct (GenerateOopMap *c, int deltaBci, int *data);
a61af66fc99e Initial load
duke
parents:
diff changeset
367
a61af66fc99e Initial load
duke
parents:
diff changeset
368 // Dead code detection
a61af66fc99e Initial load
duke
parents:
diff changeset
369 void mark_reachable_code();
a61af66fc99e Initial load
duke
parents:
diff changeset
370 static void reachable_basicblock (GenerateOopMap *c, int deltaBci, int *data);
a61af66fc99e Initial load
duke
parents:
diff changeset
371
a61af66fc99e Initial load
duke
parents:
diff changeset
372 // Interpretation methods (primary)
a61af66fc99e Initial load
duke
parents:
diff changeset
373 void do_interpretation ();
a61af66fc99e Initial load
duke
parents:
diff changeset
374 void init_basic_blocks ();
a61af66fc99e Initial load
duke
parents:
diff changeset
375 void setup_method_entry_state ();
a61af66fc99e Initial load
duke
parents:
diff changeset
376 void interp_all ();
a61af66fc99e Initial load
duke
parents:
diff changeset
377
a61af66fc99e Initial load
duke
parents:
diff changeset
378 // Interpretation methods (secondary)
a61af66fc99e Initial load
duke
parents:
diff changeset
379 void interp1 (BytecodeStream *itr);
a61af66fc99e Initial load
duke
parents:
diff changeset
380 void do_exception_edge (BytecodeStream *itr);
a61af66fc99e Initial load
duke
parents:
diff changeset
381 void check_type (CellTypeState expected, CellTypeState actual);
a61af66fc99e Initial load
duke
parents:
diff changeset
382 void ppstore (CellTypeState *in, int loc_no);
a61af66fc99e Initial load
duke
parents:
diff changeset
383 void ppload (CellTypeState *out, int loc_no);
a61af66fc99e Initial load
duke
parents:
diff changeset
384 void ppush1 (CellTypeState in);
a61af66fc99e Initial load
duke
parents:
diff changeset
385 void ppush (CellTypeState *in);
a61af66fc99e Initial load
duke
parents:
diff changeset
386 void ppop1 (CellTypeState out);
a61af66fc99e Initial load
duke
parents:
diff changeset
387 void ppop (CellTypeState *out);
a61af66fc99e Initial load
duke
parents:
diff changeset
388 void ppop_any (int poplen);
a61af66fc99e Initial load
duke
parents:
diff changeset
389 void pp (CellTypeState *in, CellTypeState *out);
a61af66fc99e Initial load
duke
parents:
diff changeset
390 void pp_new_ref (CellTypeState *in, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
391 void ppdupswap (int poplen, const char *out);
a61af66fc99e Initial load
duke
parents:
diff changeset
392 void do_ldc (int idx, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
393 void do_astore (int idx);
a61af66fc99e Initial load
duke
parents:
diff changeset
394 void do_jsr (int delta);
a61af66fc99e Initial load
duke
parents:
diff changeset
395 void do_field (int is_get, int is_static, int idx, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
396 void do_method (int is_static, int is_interface, int idx, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
397 void do_multianewarray (int dims, int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
398 void do_monitorenter (int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
399 void do_monitorexit (int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
400 void do_return_monitor_check ();
a61af66fc99e Initial load
duke
parents:
diff changeset
401 void do_checkcast ();
a61af66fc99e Initial load
duke
parents:
diff changeset
402 CellTypeState *sigchar_to_effect (char sigch, int bci, CellTypeState *out);
a61af66fc99e Initial load
duke
parents:
diff changeset
403 int copy_cts (CellTypeState *dst, CellTypeState *src);
a61af66fc99e Initial load
duke
parents:
diff changeset
404
a61af66fc99e Initial load
duke
parents:
diff changeset
405 // Error handling
a61af66fc99e Initial load
duke
parents:
diff changeset
406 void error_work (const char *format, va_list ap);
a61af66fc99e Initial load
duke
parents:
diff changeset
407 void report_error (const char *format, ...);
a61af66fc99e Initial load
duke
parents:
diff changeset
408 void verify_error (const char *format, ...);
a61af66fc99e Initial load
duke
parents:
diff changeset
409 bool got_error() { return _got_error; }
a61af66fc99e Initial load
duke
parents:
diff changeset
410
a61af66fc99e Initial load
duke
parents:
diff changeset
411 // Create result set
a61af66fc99e Initial load
duke
parents:
diff changeset
412 bool _report_result;
a61af66fc99e Initial load
duke
parents:
diff changeset
413 bool _report_result_for_send; // Unfortunatly, stackmaps for sends are special, so we need some extra
a61af66fc99e Initial load
duke
parents:
diff changeset
414 BytecodeStream *_itr_send; // variables to handle them properly.
a61af66fc99e Initial load
duke
parents:
diff changeset
415
a61af66fc99e Initial load
duke
parents:
diff changeset
416 void report_result ();
a61af66fc99e Initial load
duke
parents:
diff changeset
417
a61af66fc99e Initial load
duke
parents:
diff changeset
418 // Initvars
a61af66fc99e Initial load
duke
parents:
diff changeset
419 GrowableArray<intptr_t> * _init_vars;
a61af66fc99e Initial load
duke
parents:
diff changeset
420
a61af66fc99e Initial load
duke
parents:
diff changeset
421 void initialize_vars ();
a61af66fc99e Initial load
duke
parents:
diff changeset
422 void add_to_ref_init_set (int localNo);
a61af66fc99e Initial load
duke
parents:
diff changeset
423
a61af66fc99e Initial load
duke
parents:
diff changeset
424 // Conflicts rewrite logic
605
98cb887364d3 6810672: Comment typos
twisti
parents: 342
diff changeset
425 bool _conflict; // True, if a conflict occurred during interpretation
0
a61af66fc99e Initial load
duke
parents:
diff changeset
426 int _nof_refval_conflicts; // No. of conflicts that require rewrites
a61af66fc99e Initial load
duke
parents:
diff changeset
427 int * _new_var_map;
a61af66fc99e Initial load
duke
parents:
diff changeset
428
a61af66fc99e Initial load
duke
parents:
diff changeset
429 void record_refval_conflict (int varNo);
a61af66fc99e Initial load
duke
parents:
diff changeset
430 void rewrite_refval_conflicts ();
a61af66fc99e Initial load
duke
parents:
diff changeset
431 void rewrite_refval_conflict (int from, int to);
a61af66fc99e Initial load
duke
parents:
diff changeset
432 bool rewrite_refval_conflict_inst (BytecodeStream *i, int from, int to);
a61af66fc99e Initial load
duke
parents:
diff changeset
433 bool rewrite_load_or_store (BytecodeStream *i, Bytecodes::Code bc, Bytecodes::Code bc0, unsigned int varNo);
a61af66fc99e Initial load
duke
parents:
diff changeset
434
a61af66fc99e Initial load
duke
parents:
diff changeset
435 void expand_current_instr (int bci, int ilen, int newIlen, u_char inst_buffer[]);
a61af66fc99e Initial load
duke
parents:
diff changeset
436 bool is_astore (BytecodeStream *itr, int *index);
a61af66fc99e Initial load
duke
parents:
diff changeset
437 bool is_aload (BytecodeStream *itr, int *index);
a61af66fc99e Initial load
duke
parents:
diff changeset
438
a61af66fc99e Initial load
duke
parents:
diff changeset
439 // List of bci's where a return address is on top of the stack
a61af66fc99e Initial load
duke
parents:
diff changeset
440 GrowableArray<intptr_t> *_ret_adr_tos;
a61af66fc99e Initial load
duke
parents:
diff changeset
441
a61af66fc99e Initial load
duke
parents:
diff changeset
442 bool stack_top_holds_ret_addr (int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
443 void compute_ret_adr_at_TOS ();
a61af66fc99e Initial load
duke
parents:
diff changeset
444 void update_ret_adr_at_TOS (int bci, int delta);
a61af66fc99e Initial load
duke
parents:
diff changeset
445
a61af66fc99e Initial load
duke
parents:
diff changeset
446 int binsToHold (int no) { return ((no+(BitsPerWord-1))/BitsPerWord); }
a61af66fc99e Initial load
duke
parents:
diff changeset
447 char *state_vec_to_string (CellTypeState* vec, int len);
a61af66fc99e Initial load
duke
parents:
diff changeset
448
a61af66fc99e Initial load
duke
parents:
diff changeset
449 // Helper method. Can be used in subclasses to fx. calculate gc_points. If the current instuction
a61af66fc99e Initial load
duke
parents:
diff changeset
450 // is a control transfer, then calls the jmpFct all possible destinations.
a61af66fc99e Initial load
duke
parents:
diff changeset
451 void ret_jump_targets_do (BytecodeStream *bcs, jmpFct_t jmpFct, int varNo,int *data);
a61af66fc99e Initial load
duke
parents:
diff changeset
452 bool jump_targets_do (BytecodeStream *bcs, jmpFct_t jmpFct, int *data);
a61af66fc99e Initial load
duke
parents:
diff changeset
453
a61af66fc99e Initial load
duke
parents:
diff changeset
454 friend class RelocCallback;
a61af66fc99e Initial load
duke
parents:
diff changeset
455 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
456 GenerateOopMap(methodHandle method);
a61af66fc99e Initial load
duke
parents:
diff changeset
457
a61af66fc99e Initial load
duke
parents:
diff changeset
458 // Compute the map.
a61af66fc99e Initial load
duke
parents:
diff changeset
459 void compute_map(TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
460 void result_for_basicblock(int bci); // Do a callback on fill_stackmap_for_opcodes for basicblock containing bci
a61af66fc99e Initial load
duke
parents:
diff changeset
461
a61af66fc99e Initial load
duke
parents:
diff changeset
462 // Query
a61af66fc99e Initial load
duke
parents:
diff changeset
463 int max_locals() const { return _max_locals; }
a61af66fc99e Initial load
duke
parents:
diff changeset
464 methodOop method() const { return _method(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
465 methodHandle method_as_handle() const { return _method; }
a61af66fc99e Initial load
duke
parents:
diff changeset
466
a61af66fc99e Initial load
duke
parents:
diff changeset
467 bool did_rewriting() { return _did_rewriting; }
a61af66fc99e Initial load
duke
parents:
diff changeset
468 bool did_relocation() { return _did_relocation; }
a61af66fc99e Initial load
duke
parents:
diff changeset
469
a61af66fc99e Initial load
duke
parents:
diff changeset
470 static void print_time();
a61af66fc99e Initial load
duke
parents:
diff changeset
471
a61af66fc99e Initial load
duke
parents:
diff changeset
472 // Monitor query
a61af66fc99e Initial load
duke
parents:
diff changeset
473 bool monitor_safe() { return _monitor_safe; }
a61af66fc99e Initial load
duke
parents:
diff changeset
474
a61af66fc99e Initial load
duke
parents:
diff changeset
475 // Specialization methods. Intended use:
a61af66fc99e Initial load
duke
parents:
diff changeset
476 // - possible_gc_point must return true for every bci for which the stackmaps must be returned
a61af66fc99e Initial load
duke
parents:
diff changeset
477 // - fill_stackmap_prolog is called just before the result is reported. The arguments tells the estimated
a61af66fc99e Initial load
duke
parents:
diff changeset
478 // number of gc points
a61af66fc99e Initial load
duke
parents:
diff changeset
479 // - fill_stackmap_for_opcodes is called once for each bytecode index in order (0...code_length-1)
a61af66fc99e Initial load
duke
parents:
diff changeset
480 // - fill_stackmap_epilog is called after all results has been reported. Note: Since the algorithm does not report
a61af66fc99e Initial load
duke
parents:
diff changeset
481 // stackmaps for deadcode, fewer gc_points might have been encounted than assumed during the epilog. It is the
a61af66fc99e Initial load
duke
parents:
diff changeset
482 // responsibility of the subclass to count the correct number.
a61af66fc99e Initial load
duke
parents:
diff changeset
483 // - fill_init_vars are called once with the result of the init_vars computation
a61af66fc99e Initial load
duke
parents:
diff changeset
484 //
a61af66fc99e Initial load
duke
parents:
diff changeset
485 // All these methods are used during a call to: compute_map. Note: Non of the return results are valid
a61af66fc99e Initial load
duke
parents:
diff changeset
486 // after compute_map returns, since all values are allocated as resource objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
487 //
a61af66fc99e Initial load
duke
parents:
diff changeset
488 // All virtual method must be implemented in subclasses
a61af66fc99e Initial load
duke
parents:
diff changeset
489 virtual bool allow_rewrites () const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
490 virtual bool report_results () const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
491 virtual bool report_init_vars () const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
492 virtual bool possible_gc_point (BytecodeStream *bcs) { ShouldNotReachHere(); return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
493 virtual void fill_stackmap_prolog (int nof_gc_points) { ShouldNotReachHere(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
494 virtual void fill_stackmap_epilog () { ShouldNotReachHere(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
495 virtual void fill_stackmap_for_opcodes (BytecodeStream *bcs,
a61af66fc99e Initial load
duke
parents:
diff changeset
496 CellTypeState* vars,
a61af66fc99e Initial load
duke
parents:
diff changeset
497 CellTypeState* stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
498 int stackTop) { ShouldNotReachHere(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
499 virtual void fill_init_vars (GrowableArray<intptr_t> *init_vars) { ShouldNotReachHere();; }
a61af66fc99e Initial load
duke
parents:
diff changeset
500 };
a61af66fc99e Initial load
duke
parents:
diff changeset
501
a61af66fc99e Initial load
duke
parents:
diff changeset
502 //
a61af66fc99e Initial load
duke
parents:
diff changeset
503 // Subclass of the GenerateOopMap Class that just do rewrites of the method, if needed.
a61af66fc99e Initial load
duke
parents:
diff changeset
504 // It does not store any oopmaps.
a61af66fc99e Initial load
duke
parents:
diff changeset
505 //
a61af66fc99e Initial load
duke
parents:
diff changeset
506 class ResolveOopMapConflicts: public GenerateOopMap {
a61af66fc99e Initial load
duke
parents:
diff changeset
507 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
508
a61af66fc99e Initial load
duke
parents:
diff changeset
509 bool _must_clear_locals;
a61af66fc99e Initial load
duke
parents:
diff changeset
510
a61af66fc99e Initial load
duke
parents:
diff changeset
511 virtual bool report_results() const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
512 virtual bool report_init_vars() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
513 virtual bool allow_rewrites() const { return true; }
a61af66fc99e Initial load
duke
parents:
diff changeset
514 virtual bool possible_gc_point (BytecodeStream *bcs) { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
515 virtual void fill_stackmap_prolog (int nof_gc_points) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
516 virtual void fill_stackmap_epilog () {}
a61af66fc99e Initial load
duke
parents:
diff changeset
517 virtual void fill_stackmap_for_opcodes (BytecodeStream *bcs,
a61af66fc99e Initial load
duke
parents:
diff changeset
518 CellTypeState* vars,
a61af66fc99e Initial load
duke
parents:
diff changeset
519 CellTypeState* stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
520 int stack_top) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
521 virtual void fill_init_vars (GrowableArray<intptr_t> *init_vars) { _must_clear_locals = init_vars->length() > 0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
522
a61af66fc99e Initial load
duke
parents:
diff changeset
523 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
524 // Statistics
a61af66fc99e Initial load
duke
parents:
diff changeset
525 static int _nof_invocations;
a61af66fc99e Initial load
duke
parents:
diff changeset
526 static int _nof_rewrites;
a61af66fc99e Initial load
duke
parents:
diff changeset
527 static int _nof_relocations;
a61af66fc99e Initial load
duke
parents:
diff changeset
528 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
529
a61af66fc99e Initial load
duke
parents:
diff changeset
530 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
531 ResolveOopMapConflicts(methodHandle method) : GenerateOopMap(method) { _must_clear_locals = false; };
a61af66fc99e Initial load
duke
parents:
diff changeset
532
a61af66fc99e Initial load
duke
parents:
diff changeset
533 methodHandle do_potential_rewrite(TRAPS);
a61af66fc99e Initial load
duke
parents:
diff changeset
534 bool must_clear_locals() const { return _must_clear_locals; }
a61af66fc99e Initial load
duke
parents:
diff changeset
535 };
a61af66fc99e Initial load
duke
parents:
diff changeset
536
a61af66fc99e Initial load
duke
parents:
diff changeset
537
a61af66fc99e Initial load
duke
parents:
diff changeset
538 //
a61af66fc99e Initial load
duke
parents:
diff changeset
539 // Subclass used by the compiler to generate pairing infomation
a61af66fc99e Initial load
duke
parents:
diff changeset
540 //
a61af66fc99e Initial load
duke
parents:
diff changeset
541 class GeneratePairingInfo: public GenerateOopMap {
a61af66fc99e Initial load
duke
parents:
diff changeset
542 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
543
a61af66fc99e Initial load
duke
parents:
diff changeset
544 virtual bool report_results() const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
545 virtual bool report_init_vars() const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
546 virtual bool allow_rewrites() const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
547 virtual bool possible_gc_point (BytecodeStream *bcs) { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
548 virtual void fill_stackmap_prolog (int nof_gc_points) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
549 virtual void fill_stackmap_epilog () {}
a61af66fc99e Initial load
duke
parents:
diff changeset
550 virtual void fill_stackmap_for_opcodes (BytecodeStream *bcs,
a61af66fc99e Initial load
duke
parents:
diff changeset
551 CellTypeState* vars,
a61af66fc99e Initial load
duke
parents:
diff changeset
552 CellTypeState* stack,
a61af66fc99e Initial load
duke
parents:
diff changeset
553 int stack_top) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
554 virtual void fill_init_vars (GrowableArray<intptr_t> *init_vars) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
555 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
556 GeneratePairingInfo(methodHandle method) : GenerateOopMap(method) {};
a61af66fc99e Initial load
duke
parents:
diff changeset
557
a61af66fc99e Initial load
duke
parents:
diff changeset
558 // Call compute_map(CHECK) to generate info.
a61af66fc99e Initial load
duke
parents:
diff changeset
559 };