comparison src/share/vm/code/codeBlob.cpp @ 1579:e9ff18c4ace7

Merge
author jrose
date Wed, 02 Jun 2010 22:45:42 -0700
parents c18cbe5936b8 1a5913bf5e19
children 2a47bd84841f
comparison
equal deleted inserted replaced
1562:dfe27f03244a 1579:e9ff18c4ace7
64 _frame_complete_offset = frame_complete; 64 _frame_complete_offset = frame_complete;
65 _header_size = header_size; 65 _header_size = header_size;
66 _relocation_size = locs_size; 66 _relocation_size = locs_size;
67 _instructions_offset = align_code_offset(header_size + locs_size); 67 _instructions_offset = align_code_offset(header_size + locs_size);
68 _data_offset = size; 68 _data_offset = size;
69 _oops_offset = size;
70 _oops_length = 0;
71 _frame_size = 0; 69 _frame_size = 0;
72 set_oop_maps(NULL); 70 set_oop_maps(NULL);
73 } 71 }
74 72
75 73
92 _frame_complete_offset = frame_complete; 90 _frame_complete_offset = frame_complete;
93 _header_size = header_size; 91 _header_size = header_size;
94 _relocation_size = round_to(cb->total_relocation_size(), oopSize); 92 _relocation_size = round_to(cb->total_relocation_size(), oopSize);
95 _instructions_offset = align_code_offset(header_size + _relocation_size); 93 _instructions_offset = align_code_offset(header_size + _relocation_size);
96 _data_offset = _instructions_offset + round_to(cb->total_code_size(), oopSize); 94 _data_offset = _instructions_offset + round_to(cb->total_code_size(), oopSize);
97 _oops_offset = _size - round_to(cb->total_oop_size(), oopSize);
98 _oops_length = 0; // temporary, until the copy_oops handshake
99 assert(_oops_offset >= _data_offset, "codeBlob is too small");
100 assert(_data_offset <= size, "codeBlob is too small"); 95 assert(_data_offset <= size, "codeBlob is too small");
101 96
102 cb->copy_code_and_locs_to(this); 97 cb->copy_code_and_locs_to(this);
103 set_oop_maps(oop_maps); 98 set_oop_maps(oop_maps);
104 _frame_size = frame_size; 99 _frame_size = frame_size;
128 _oop_maps = NULL; 123 _oop_maps = NULL;
129 } 124 }
130 _comments.free(); 125 _comments.free();
131 } 126 }
132 127
133
134 // Promote one word from an assembly-time handle to a live embedded oop.
135 inline void CodeBlob::initialize_immediate_oop(oop* dest, jobject handle) {
136 if (handle == NULL ||
137 // As a special case, IC oops are initialized to 1 or -1.
138 handle == (jobject) Universe::non_oop_word()) {
139 (*dest) = (oop)handle;
140 } else {
141 (*dest) = JNIHandles::resolve_non_null(handle);
142 }
143 }
144
145
146 void CodeBlob::copy_oops(GrowableArray<jobject>* array) {
147 assert(_oops_length == 0, "do this handshake just once, please");
148 int length = array->length();
149 assert((address)(oops_begin() + length) <= data_end(), "oops big enough");
150 oop* dest = oops_begin();
151 for (int index = 0 ; index < length; index++) {
152 initialize_immediate_oop(&dest[index], array->at(index));
153 }
154 _oops_length = length;
155
156 // Now we can fix up all the oops in the code.
157 // We need to do this in the code because
158 // the assembler uses jobjects as placeholders.
159 // The code and relocations have already been
160 // initialized by the CodeBlob constructor,
161 // so it is valid even at this early point to
162 // iterate over relocations and patch the code.
163 fix_oop_relocations(NULL, NULL, /*initialize_immediates=*/ true);
164 }
165
166
167 relocInfo::relocType CodeBlob::reloc_type_for_address(address pc) {
168 RelocIterator iter(this, pc, pc+1);
169 while (iter.next()) {
170 return (relocInfo::relocType) iter.type();
171 }
172 // No relocation info found for pc
173 ShouldNotReachHere();
174 return relocInfo::none; // dummy return value
175 }
176
177
178 bool CodeBlob::is_at_poll_return(address pc) {
179 RelocIterator iter(this, pc, pc+1);
180 while (iter.next()) {
181 if (iter.type() == relocInfo::poll_return_type)
182 return true;
183 }
184 return false;
185 }
186
187
188 bool CodeBlob::is_at_poll_or_poll_return(address pc) {
189 RelocIterator iter(this, pc, pc+1);
190 while (iter.next()) {
191 relocInfo::relocType t = iter.type();
192 if (t == relocInfo::poll_return_type || t == relocInfo::poll_type)
193 return true;
194 }
195 return false;
196 }
197
198
199 void CodeBlob::fix_oop_relocations(address begin, address end,
200 bool initialize_immediates) {
201 // re-patch all oop-bearing instructions, just in case some oops moved
202 RelocIterator iter(this, begin, end);
203 while (iter.next()) {
204 if (iter.type() == relocInfo::oop_type) {
205 oop_Relocation* reloc = iter.oop_reloc();
206 if (initialize_immediates && reloc->oop_is_immediate()) {
207 oop* dest = reloc->oop_addr();
208 initialize_immediate_oop(dest, (jobject) *dest);
209 }
210 // Refresh the oop-related bits of this instruction.
211 reloc->fix_oop_relocation();
212 }
213
214 // There must not be any interfering patches or breakpoints.
215 assert(!(iter.type() == relocInfo::breakpoint_type
216 && iter.breakpoint_reloc()->active()),
217 "no active breakpoint");
218 }
219 }
220
221 void CodeBlob::do_unloading(BoolObjectClosure* is_alive,
222 OopClosure* keep_alive,
223 bool unloading_occurred) {
224 ShouldNotReachHere();
225 }
226 128
227 OopMap* CodeBlob::oop_map_for_return_address(address return_address) { 129 OopMap* CodeBlob::oop_map_for_return_address(address return_address) {
228 address pc = return_address ; 130 address pc = return_address ;
229 assert (oop_maps() != NULL, "nope"); 131 assert (oop_maps() != NULL, "nope");
230 return oop_maps()->find_map_at_offset ((intptr_t) pc - (intptr_t) instructions_begin()); 132 return oop_maps()->find_map_at_offset ((intptr_t) pc - (intptr_t) instructions_begin());