52 int _frame_complete_offset; // instruction offsets in [0.._frame_complete_offset) have |
52 int _frame_complete_offset; // instruction offsets in [0.._frame_complete_offset) have |
53 // not finished setting up their frame. Beware of pc's in |
53 // not finished setting up their frame. Beware of pc's in |
54 // that range. There is a similar range(s) on returns |
54 // that range. There is a similar range(s) on returns |
55 // which we don't detect. |
55 // which we don't detect. |
56 int _data_offset; // offset to where data region begins |
56 int _data_offset; // offset to where data region begins |
57 int _oops_offset; // offset to where embedded oop table begins (inside data) |
|
58 int _oops_length; // number of embedded oops |
|
59 int _frame_size; // size of stack frame |
57 int _frame_size; // size of stack frame |
60 OopMapSet* _oop_maps; // OopMap for this CodeBlob |
58 OopMapSet* _oop_maps; // OopMap for this CodeBlob |
61 CodeComments _comments; |
59 CodeComments _comments; |
62 |
60 |
63 friend class OopRecorder; |
61 friend class OopRecorder; |
64 |
|
65 void fix_oop_relocations(address begin, address end, bool initialize_immediates); |
|
66 inline void initialize_immediate_oop(oop* dest, jobject handle); |
|
67 |
62 |
68 public: |
63 public: |
69 // Returns the space needed for CodeBlob |
64 // Returns the space needed for CodeBlob |
70 static unsigned int allocation_size(CodeBuffer* cb, int header_size); |
65 static unsigned int allocation_size(CodeBuffer* cb, int header_size); |
71 |
66 |
113 relocInfo* relocation_end() const { return (relocInfo*)(header_end() + _relocation_size); } |
108 relocInfo* relocation_end() const { return (relocInfo*)(header_end() + _relocation_size); } |
114 address instructions_begin() const { return (address) header_begin() + _instructions_offset; } |
109 address instructions_begin() const { return (address) header_begin() + _instructions_offset; } |
115 address instructions_end() const { return (address) header_begin() + _data_offset; } |
110 address instructions_end() const { return (address) header_begin() + _data_offset; } |
116 address data_begin() const { return (address) header_begin() + _data_offset; } |
111 address data_begin() const { return (address) header_begin() + _data_offset; } |
117 address data_end() const { return (address) header_begin() + _size; } |
112 address data_end() const { return (address) header_begin() + _size; } |
118 oop* oops_begin() const { return (oop*) (header_begin() + _oops_offset); } |
|
119 oop* oops_end() const { return oops_begin() + _oops_length; } |
|
120 |
113 |
121 // Offsets |
114 // Offsets |
122 int relocation_offset() const { return _header_size; } |
115 int relocation_offset() const { return _header_size; } |
123 int instructions_offset() const { return _instructions_offset; } |
116 int instructions_offset() const { return _instructions_offset; } |
124 int data_offset() const { return _data_offset; } |
117 int data_offset() const { return _data_offset; } |
125 int oops_offset() const { return _oops_offset; } |
|
126 |
118 |
127 // Sizes |
119 // Sizes |
128 int size() const { return _size; } |
120 int size() const { return _size; } |
129 int header_size() const { return _header_size; } |
121 int header_size() const { return _header_size; } |
130 int relocation_size() const { return (address) relocation_end() - (address) relocation_begin(); } |
122 int relocation_size() const { return (address) relocation_end() - (address) relocation_begin(); } |
131 int instructions_size() const { return instructions_end() - instructions_begin(); } |
123 int instructions_size() const { return instructions_end() - instructions_begin(); } |
132 int data_size() const { return data_end() - data_begin(); } |
124 int data_size() const { return data_end() - data_begin(); } |
133 int oops_size() const { return (address) oops_end() - (address) oops_begin(); } |
|
134 |
125 |
135 // Containment |
126 // Containment |
136 bool blob_contains(address addr) const { return header_begin() <= addr && addr < data_end(); } |
127 bool blob_contains(address addr) const { return header_begin() <= addr && addr < data_end(); } |
137 bool relocation_contains(relocInfo* addr) const{ return relocation_begin() <= addr && addr < relocation_end(); } |
128 bool relocation_contains(relocInfo* addr) const{ return relocation_begin() <= addr && addr < relocation_end(); } |
138 bool instructions_contains(address addr) const { return instructions_begin() <= addr && addr < instructions_end(); } |
129 bool instructions_contains(address addr) const { return instructions_begin() <= addr && addr < instructions_end(); } |
139 bool data_contains(address addr) const { return data_begin() <= addr && addr < data_end(); } |
130 bool data_contains(address addr) const { return data_begin() <= addr && addr < data_end(); } |
140 bool oops_contains(oop* addr) const { return oops_begin() <= addr && addr < oops_end(); } |
|
141 bool contains(address addr) const { return instructions_contains(addr); } |
131 bool contains(address addr) const { return instructions_contains(addr); } |
142 bool is_frame_complete_at(address addr) const { return instructions_contains(addr) && |
132 bool is_frame_complete_at(address addr) const { return instructions_contains(addr) && |
143 addr >= instructions_begin() + _frame_complete_offset; } |
133 addr >= instructions_begin() + _frame_complete_offset; } |
144 |
|
145 // Relocation support |
|
146 void fix_oop_relocations(address begin, address end) { |
|
147 fix_oop_relocations(begin, end, false); |
|
148 } |
|
149 void fix_oop_relocations() { |
|
150 fix_oop_relocations(NULL, NULL, false); |
|
151 } |
|
152 relocInfo::relocType reloc_type_for_address(address pc); |
|
153 bool is_at_poll_return(address pc); |
|
154 bool is_at_poll_or_poll_return(address pc); |
|
155 |
|
156 // Support for oops in scopes and relocs: |
|
157 // Note: index 0 is reserved for null. |
|
158 oop oop_at(int index) const { return index == 0? (oop)NULL: *oop_addr_at(index); } |
|
159 oop* oop_addr_at(int index) const{ // for GC |
|
160 // relocation indexes are biased by 1 (because 0 is reserved) |
|
161 assert(index > 0 && index <= _oops_length, "must be a valid non-zero index"); |
|
162 return &oops_begin()[index-1]; |
|
163 } |
|
164 |
|
165 void copy_oops(GrowableArray<jobject>* oops); |
|
166 |
134 |
167 // CodeCache support: really only used by the nmethods, but in order to get |
135 // CodeCache support: really only used by the nmethods, but in order to get |
168 // asserts and certain bookkeeping to work in the CodeCache they are defined |
136 // asserts and certain bookkeeping to work in the CodeCache they are defined |
169 // virtual here. |
137 // virtual here. |
170 virtual bool is_zombie() const { return false; } |
138 virtual bool is_zombie() const { return false; } |
173 virtual bool is_unloaded() const { return false; } |
141 virtual bool is_unloaded() const { return false; } |
174 virtual bool is_not_entrant() const { return false; } |
142 virtual bool is_not_entrant() const { return false; } |
175 |
143 |
176 // GC support |
144 // GC support |
177 virtual bool is_alive() const = 0; |
145 virtual bool is_alive() const = 0; |
178 virtual void do_unloading(BoolObjectClosure* is_alive, |
|
179 OopClosure* keep_alive, |
|
180 bool unloading_occurred); |
|
181 virtual void oops_do(OopClosure* f) = 0; |
|
182 // (All CodeBlob subtypes other than NMethod currently have |
|
183 // an empty oops_do() method. |
|
184 |
146 |
185 // OopMap for frame |
147 // OopMap for frame |
186 OopMapSet* oop_maps() const { return _oop_maps; } |
148 OopMapSet* oop_maps() const { return _oop_maps; } |
187 void set_oop_maps(OopMapSet* p); |
149 void set_oop_maps(OopMapSet* p); |
188 OopMap* oop_map_for_return_address(address return_address); |
150 OopMap* oop_map_for_return_address(address return_address); |
243 virtual bool is_buffer_blob() const { return true; } |
205 virtual bool is_buffer_blob() const { return true; } |
244 |
206 |
245 // GC/Verification support |
207 // GC/Verification support |
246 void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { /* nothing to do */ } |
208 void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { /* nothing to do */ } |
247 bool is_alive() const { return true; } |
209 bool is_alive() const { return true; } |
248 void do_unloading(BoolObjectClosure* is_alive, |
|
249 OopClosure* keep_alive, |
|
250 bool unloading_occurred) { /* do nothing */ } |
|
251 |
|
252 void oops_do(OopClosure* f) { /* do nothing*/ } |
|
253 |
210 |
254 void verify(); |
211 void verify(); |
255 void print() const PRODUCT_RETURN; |
212 void print() const PRODUCT_RETURN; |
256 void print_value_on(outputStream* st) const PRODUCT_RETURN; |
213 void print_value_on(outputStream* st) const PRODUCT_RETURN; |
257 }; |
214 }; |
332 address entry_point() { return instructions_begin(); } |
289 address entry_point() { return instructions_begin(); } |
333 |
290 |
334 // GC/Verification support |
291 // GC/Verification support |
335 void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* nothing to do */ } |
292 void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* nothing to do */ } |
336 bool is_alive() const { return true; } |
293 bool is_alive() const { return true; } |
337 void do_unloading(BoolObjectClosure* is_alive, |
|
338 OopClosure* keep_alive, |
|
339 bool unloading_occurred) { /* do nothing */ } |
|
340 void oops_do(OopClosure* f) { /* do-nothing*/ } |
|
341 |
294 |
342 void verify(); |
295 void verify(); |
343 void print() const PRODUCT_RETURN; |
296 void print() const PRODUCT_RETURN; |
344 void print_value_on(outputStream* st) const PRODUCT_RETURN; |
297 void print_value_on(outputStream* st) const PRODUCT_RETURN; |
345 }; |
298 }; |
361 ) |
314 ) |
362 : CodeBlob(name, cb, header_size, size, CodeOffsets::frame_never_safe, frame_size, oop_maps) |
315 : CodeBlob(name, cb, header_size, size, CodeOffsets::frame_never_safe, frame_size, oop_maps) |
363 {}; |
316 {}; |
364 |
317 |
365 bool is_alive() const { return true; } |
318 bool is_alive() const { return true; } |
366 void do_unloading(BoolObjectClosure* is_alive, |
|
367 OopClosure* keep_alive, |
|
368 bool unloading_occurred) { /* do-nothing*/ } |
|
369 |
319 |
370 void verify(); // does nothing |
320 void verify(); // does nothing |
371 void print() const PRODUCT_RETURN; |
321 void print() const PRODUCT_RETURN; |
372 void print_value_on(outputStream* st) const PRODUCT_RETURN; |
322 void print_value_on(outputStream* st) const PRODUCT_RETURN; |
373 }; |
323 }; |