annotate src/share/vm/compiler/oopMap.hpp @ 113:ba764ed4b6f2

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author coleenp
date Sun, 13 Apr 2008 17:43:42 -0400
parents c7c777385a15
children d1605aabd0a1 524eca34ea76
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 1998-2007 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 // Interface for generating the frame map for compiled code. A frame map
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // describes for a specific pc whether each register and frame stack slot is:
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // Oop - A GC root for current frame
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // Value - Live non-oop, non-float value: int, either half of double
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // Dead - Dead; can be Zapped for debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // CalleeXX - Callee saved; also describes which caller register is saved
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // DerivedXX - A derived oop; original oop is described.
a61af66fc99e Initial load
duke
parents:
diff changeset
32 //
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // OopMapValue describes a single OopMap entry
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 class frame;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 class RegisterMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 class DerivedPointerEntry;
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class OopMapValue: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
42 short _value;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 int value() const { return _value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
44 void set_value(int value) { _value = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
45 short _content_reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Constants
a61af66fc99e Initial load
duke
parents:
diff changeset
49 enum { type_bits = 6,
a61af66fc99e Initial load
duke
parents:
diff changeset
50 register_bits = BitsPerShort - type_bits };
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 enum { type_shift = 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
53 register_shift = type_bits };
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 enum { type_mask = right_n_bits(type_bits),
a61af66fc99e Initial load
duke
parents:
diff changeset
56 type_mask_in_place = type_mask << type_shift,
a61af66fc99e Initial load
duke
parents:
diff changeset
57 register_mask = right_n_bits(register_bits),
a61af66fc99e Initial load
duke
parents:
diff changeset
58 register_mask_in_place = register_mask << register_shift };
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 enum oop_types { // must fit in type_bits
a61af66fc99e Initial load
duke
parents:
diff changeset
61 unused_value =0, // powers of 2, for masking OopMapStream
a61af66fc99e Initial load
duke
parents:
diff changeset
62 oop_value = 1,
a61af66fc99e Initial load
duke
parents:
diff changeset
63 value_value = 2,
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
64 narrowoop_value = 4,
0
a61af66fc99e Initial load
duke
parents:
diff changeset
65 callee_saved_value = 8,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 derived_oop_value= 16,
a61af66fc99e Initial load
duke
parents:
diff changeset
67 stack_obj = 32 };
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Constructors
a61af66fc99e Initial load
duke
parents:
diff changeset
70 OopMapValue () { set_value(0); set_content_reg(VMRegImpl::Bad()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 OopMapValue (VMReg reg, oop_types t) { set_reg_type(reg,t); }
a61af66fc99e Initial load
duke
parents:
diff changeset
72 OopMapValue (VMReg reg, oop_types t, VMReg reg2) { set_reg_type(reg,t); set_content_reg(reg2); }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 OopMapValue (CompressedReadStream* stream) { read_from(stream); }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // Archiving
a61af66fc99e Initial load
duke
parents:
diff changeset
76 void write_on(CompressedWriteStream* stream) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 stream->write_int(value());
a61af66fc99e Initial load
duke
parents:
diff changeset
78 if(is_callee_saved() || is_derived_oop()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
79 stream->write_int(content_reg()->value());
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 void read_from(CompressedReadStream* stream) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 set_value(stream->read_int());
a61af66fc99e Initial load
duke
parents:
diff changeset
85 if(is_callee_saved() || is_derived_oop()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 set_content_reg(VMRegImpl::as_VMReg(stream->read_int(), true));
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // Querying
a61af66fc99e Initial load
duke
parents:
diff changeset
91 bool is_oop() { return mask_bits(value(), type_mask_in_place) == oop_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 bool is_value() { return mask_bits(value(), type_mask_in_place) == value_value; }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
93 bool is_narrowoop() { return mask_bits(value(), type_mask_in_place) == narrowoop_value; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
94 bool is_callee_saved() { return mask_bits(value(), type_mask_in_place) == callee_saved_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 bool is_derived_oop() { return mask_bits(value(), type_mask_in_place) == derived_oop_value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
96 bool is_stack_obj() { return mask_bits(value(), type_mask_in_place) == stack_obj; }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 void set_oop() { set_value((value() & register_mask_in_place) | oop_value); }
a61af66fc99e Initial load
duke
parents:
diff changeset
99 void set_value() { set_value((value() & register_mask_in_place) | value_value); }
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
100 void set_narrowoop() { set_value((value() & register_mask_in_place) | narrowoop_value); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101 void set_callee_saved() { set_value((value() & register_mask_in_place) | callee_saved_value); }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 void set_derived_oop() { set_value((value() & register_mask_in_place) | derived_oop_value); }
a61af66fc99e Initial load
duke
parents:
diff changeset
103 void set_stack_obj() { set_value((value() & register_mask_in_place) | stack_obj); }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 VMReg reg() const { return VMRegImpl::as_VMReg(mask_bits(value(), register_mask_in_place) >> register_shift); }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 oop_types type() const { return (oop_types)mask_bits(value(), type_mask_in_place); }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 static bool legal_vm_reg_name(VMReg p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 return (p->value() == (p->value() & register_mask));
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 void set_reg_type(VMReg p, oop_types t) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 set_value((p->value() << register_shift) | t);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 assert(reg() == p, "sanity check" );
a61af66fc99e Initial load
duke
parents:
diff changeset
115 assert(type() == t, "sanity check" );
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 VMReg content_reg() const { return VMRegImpl::as_VMReg(_content_reg, true); }
a61af66fc99e Initial load
duke
parents:
diff changeset
120 void set_content_reg(VMReg r) { _content_reg = r->value(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // Physical location queries
a61af66fc99e Initial load
duke
parents:
diff changeset
123 bool is_register_loc() { return reg()->is_reg(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
124 bool is_stack_loc() { return reg()->is_stack(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // Returns offset from sp.
a61af66fc99e Initial load
duke
parents:
diff changeset
127 int stack_offset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
128 assert(is_stack_loc(), "must be stack location");
a61af66fc99e Initial load
duke
parents:
diff changeset
129 return reg()->reg2stack();
a61af66fc99e Initial load
duke
parents:
diff changeset
130 }
a61af66fc99e Initial load
duke
parents:
diff changeset
131
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
132 void print_on(outputStream* st) const;
25
c5cbd367e4d1 6621094: PrintOptoAssembly is broken for oops information in DebugInfo
kvn
parents: 0
diff changeset
133 void print() const { print_on(tty); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
134 };
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136
a61af66fc99e Initial load
duke
parents:
diff changeset
137 class OopMap: public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 friend class OopMapStream;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
140 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
141 int _pc_offset;
a61af66fc99e Initial load
duke
parents:
diff changeset
142 int _omv_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
143 int _omv_data_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 unsigned char* _omv_data;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 CompressedWriteStream* _write_stream;
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 debug_only( OopMapValue::oop_types* _locs_used; int _locs_length;)
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 // Accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
150 unsigned char* omv_data() const { return _omv_data; }
a61af66fc99e Initial load
duke
parents:
diff changeset
151 void set_omv_data(unsigned char* value) { _omv_data = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 int omv_data_size() const { return _omv_data_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 void set_omv_data_size(int value) { _omv_data_size = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 int omv_count() const { return _omv_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
155 void set_omv_count(int value) { _omv_count = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 void increment_count() { _omv_count++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
157 CompressedWriteStream* write_stream() const { return _write_stream; }
a61af66fc99e Initial load
duke
parents:
diff changeset
158 void set_write_stream(CompressedWriteStream* value) { _write_stream = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
159
a61af66fc99e Initial load
duke
parents:
diff changeset
160 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
161 enum DeepCopyToken { _deep_copy_token };
a61af66fc99e Initial load
duke
parents:
diff changeset
162 OopMap(DeepCopyToken, OopMap* source); // used only by deep_copy
a61af66fc99e Initial load
duke
parents:
diff changeset
163
a61af66fc99e Initial load
duke
parents:
diff changeset
164 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
165 OopMap(int frame_size, int arg_count);
a61af66fc99e Initial load
duke
parents:
diff changeset
166
a61af66fc99e Initial load
duke
parents:
diff changeset
167 // pc-offset handling
a61af66fc99e Initial load
duke
parents:
diff changeset
168 int offset() const { return _pc_offset; }
a61af66fc99e Initial load
duke
parents:
diff changeset
169 void set_offset(int o) { _pc_offset = o; }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 // Check to avoid double insertion
a61af66fc99e Initial load
duke
parents:
diff changeset
172 debug_only(OopMapValue::oop_types locs_used( int indx ) { return _locs_used[indx]; })
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // Construction
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // frame_size units are stack-slots (4 bytes) NOT intptr_t; we can name odd
a61af66fc99e Initial load
duke
parents:
diff changeset
176 // slots to hold 4-byte values like ints and floats in the LP64 build.
a61af66fc99e Initial load
duke
parents:
diff changeset
177 void set_oop ( VMReg local);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 void set_value( VMReg local);
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
179 void set_narrowoop(VMReg local);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
180 void set_dead ( VMReg local);
a61af66fc99e Initial load
duke
parents:
diff changeset
181 void set_callee_saved( VMReg local, VMReg caller_machine_register );
a61af66fc99e Initial load
duke
parents:
diff changeset
182 void set_derived_oop ( VMReg local, VMReg derived_from_local_register );
a61af66fc99e Initial load
duke
parents:
diff changeset
183 void set_stack_obj( VMReg local);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 void set_xxx(VMReg reg, OopMapValue::oop_types x, VMReg optional);
a61af66fc99e Initial load
duke
parents:
diff changeset
185
a61af66fc99e Initial load
duke
parents:
diff changeset
186 int heap_size() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 void copy_to(address addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
188 OopMap* deep_copy();
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190 bool has_derived_pointer() const PRODUCT_RETURN0;
a61af66fc99e Initial load
duke
parents:
diff changeset
191
a61af66fc99e Initial load
duke
parents:
diff changeset
192 bool legal_vm_reg_name(VMReg local) {
a61af66fc99e Initial load
duke
parents:
diff changeset
193 return OopMapValue::legal_vm_reg_name(local);
a61af66fc99e Initial load
duke
parents:
diff changeset
194 }
a61af66fc99e Initial load
duke
parents:
diff changeset
195
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // Printing
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
197 void print_on(outputStream* st) const;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
198 void print() const { print_on(tty); }
a61af66fc99e Initial load
duke
parents:
diff changeset
199 };
a61af66fc99e Initial load
duke
parents:
diff changeset
200
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 class OopMapSet : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
204 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
205 int _om_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
206 int _om_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
207 OopMap** _om_data;
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 int om_count() const { return _om_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
210 void set_om_count(int value) { _om_count = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
211 void increment_count() { _om_count++; }
a61af66fc99e Initial load
duke
parents:
diff changeset
212 int om_size() const { return _om_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
213 void set_om_size(int value) { _om_size = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
214 OopMap** om_data() const { return _om_data; }
a61af66fc99e Initial load
duke
parents:
diff changeset
215 void set_om_data(OopMap** value) { _om_data = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
216 void grow_om_data();
a61af66fc99e Initial load
duke
parents:
diff changeset
217 void set(int index,OopMap* value) { assert((index == 0) || ((index > 0) && (index < om_size())),"bad index"); _om_data[index] = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
218
a61af66fc99e Initial load
duke
parents:
diff changeset
219 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
220 OopMapSet();
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 // returns the number of OopMaps in this OopMapSet
a61af66fc99e Initial load
duke
parents:
diff changeset
223 int size() const { return _om_count; }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // returns the OopMap at a given index
a61af66fc99e Initial load
duke
parents:
diff changeset
225 OopMap* at(int index) const { assert((index >= 0) && (index <= om_count()),"bad index"); return _om_data[index]; }
a61af66fc99e Initial load
duke
parents:
diff changeset
226
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // Collect OopMaps.
a61af66fc99e Initial load
duke
parents:
diff changeset
228 void add_gc_map(int pc, OopMap* map);
a61af66fc99e Initial load
duke
parents:
diff changeset
229
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // Returns the only oop map. Used for reconstructing
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // Adapter frames during deoptimization
a61af66fc99e Initial load
duke
parents:
diff changeset
232 OopMap* singular_oop_map();
a61af66fc99e Initial load
duke
parents:
diff changeset
233
a61af66fc99e Initial load
duke
parents:
diff changeset
234 // returns OopMap in that is anchored to the pc
a61af66fc99e Initial load
duke
parents:
diff changeset
235 OopMap* find_map_at_offset(int pc_offset) const;
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 int heap_size() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
238 void copy_to(address addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
239
a61af66fc99e Initial load
duke
parents:
diff changeset
240 // Iterates through frame for a compiled method
a61af66fc99e Initial load
duke
parents:
diff changeset
241 static void oops_do (const frame* fr,
a61af66fc99e Initial load
duke
parents:
diff changeset
242 const RegisterMap* reg_map, OopClosure* f);
a61af66fc99e Initial load
duke
parents:
diff changeset
243 static void update_register_map(const frame* fr, RegisterMap *reg_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
244
a61af66fc99e Initial load
duke
parents:
diff changeset
245 // Iterates through frame for a compiled method for dead ones and values, too
a61af66fc99e Initial load
duke
parents:
diff changeset
246 static void all_do(const frame* fr, const RegisterMap* reg_map,
a61af66fc99e Initial load
duke
parents:
diff changeset
247 OopClosure* oop_fn,
a61af66fc99e Initial load
duke
parents:
diff changeset
248 void derived_oop_fn(oop* base, oop* derived),
113
ba764ed4b6f2 6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents: 100
diff changeset
249 OopClosure* value_fn);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
250
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // Printing
100
c7c777385a15 6667042: PrintAssembly option does not work without special plugin
jrose
parents: 25
diff changeset
252 void print_on(outputStream* st) const;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
253 void print() const { print_on(tty); }
a61af66fc99e Initial load
duke
parents:
diff changeset
254 };
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257 class OopMapStream : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
258 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
259 CompressedReadStream* _stream;
a61af66fc99e Initial load
duke
parents:
diff changeset
260 int _mask;
a61af66fc99e Initial load
duke
parents:
diff changeset
261 int _size;
a61af66fc99e Initial load
duke
parents:
diff changeset
262 int _position;
a61af66fc99e Initial load
duke
parents:
diff changeset
263 bool _valid_omv;
a61af66fc99e Initial load
duke
parents:
diff changeset
264 OopMapValue _omv;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 void find_next();
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
268 OopMapStream(OopMap* oop_map);
a61af66fc99e Initial load
duke
parents:
diff changeset
269 OopMapStream(OopMap* oop_map, int oop_types_mask);
a61af66fc99e Initial load
duke
parents:
diff changeset
270 bool is_done() { if(!_valid_omv) { find_next(); } return !_valid_omv; }
a61af66fc99e Initial load
duke
parents:
diff changeset
271 void next() { find_next(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
272 OopMapValue current() { return _omv; }
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 // Derived pointer support. This table keeps track of all derived points on a
a61af66fc99e Initial load
duke
parents:
diff changeset
277 // stack. It is cleared before each scavenge/GC. During the traversal of all
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // oops, it is filled in with references to all locations that contains a
a61af66fc99e Initial load
duke
parents:
diff changeset
279 // derived oop (assumed to be very few). When the GC is complete, the derived
a61af66fc99e Initial load
duke
parents:
diff changeset
280 // pointers are updated based on their base pointers new value and an offset.
a61af66fc99e Initial load
duke
parents:
diff changeset
281 #ifdef COMPILER2
a61af66fc99e Initial load
duke
parents:
diff changeset
282 class DerivedPointerTable : public AllStatic {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
284 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
285 static GrowableArray<DerivedPointerEntry*>* _list;
a61af66fc99e Initial load
duke
parents:
diff changeset
286 static bool _active; // do not record pointers for verify pass etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
287 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
288 static void clear(); // Called before scavenge/GC
a61af66fc99e Initial load
duke
parents:
diff changeset
289 static void add(oop *derived, oop *base); // Called during scavenge/GC
a61af66fc99e Initial load
duke
parents:
diff changeset
290 static void update_pointers(); // Called after scavenge/GC
a61af66fc99e Initial load
duke
parents:
diff changeset
291 static bool is_empty() { return _list == NULL || _list->is_empty(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
292 static bool is_active() { return _active; }
a61af66fc99e Initial load
duke
parents:
diff changeset
293 static void set_active(bool value) { _active = value; }
a61af66fc99e Initial load
duke
parents:
diff changeset
294 };
a61af66fc99e Initial load
duke
parents:
diff changeset
295
a61af66fc99e Initial load
duke
parents:
diff changeset
296 // A utility class to temporarily "deactivate" the DerivedPointerTable.
a61af66fc99e Initial load
duke
parents:
diff changeset
297 // (Note: clients are responsible for any MT-safety issues)
a61af66fc99e Initial load
duke
parents:
diff changeset
298 class DerivedPointerTableDeactivate: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
299 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
300 bool _active;
a61af66fc99e Initial load
duke
parents:
diff changeset
301 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
302 DerivedPointerTableDeactivate() {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 _active = DerivedPointerTable::is_active();
a61af66fc99e Initial load
duke
parents:
diff changeset
304 if (_active) {
a61af66fc99e Initial load
duke
parents:
diff changeset
305 DerivedPointerTable::set_active(false);
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307 }
a61af66fc99e Initial load
duke
parents:
diff changeset
308
a61af66fc99e Initial load
duke
parents:
diff changeset
309 ~DerivedPointerTableDeactivate() {
a61af66fc99e Initial load
duke
parents:
diff changeset
310 assert(!DerivedPointerTable::is_active(),
a61af66fc99e Initial load
duke
parents:
diff changeset
311 "Inconsistency: not MT-safe");
a61af66fc99e Initial load
duke
parents:
diff changeset
312 if (_active) {
a61af66fc99e Initial load
duke
parents:
diff changeset
313 DerivedPointerTable::set_active(true);
a61af66fc99e Initial load
duke
parents:
diff changeset
314 }
a61af66fc99e Initial load
duke
parents:
diff changeset
315 }
a61af66fc99e Initial load
duke
parents:
diff changeset
316 };
a61af66fc99e Initial load
duke
parents:
diff changeset
317 #endif // COMPILER2