< prev index next >

src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp

Print this page

127   // we do unlocking via runtime call
128   jcc(Assembler::notEqual, slow_case);
129   // done
130   bind(done);
131 
132   dec_held_monitor_count();
133 }
134 
135 
136 // Defines obj, preserves var_size_in_bytes
137 void C1_MacroAssembler::try_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes, Register t1, Register t2, Label& slow_case) {
138   if (UseTLAB) {
139     tlab_allocate(noreg, obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
140   } else {
141     jmp(slow_case);
142   }
143 }
144 
145 
146 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {
147   assert_different_registers(obj, klass, len);
148   Register tmp_encode_klass = LP64_ONLY(rscratch1) NOT_LP64(noreg);
149   // This assumes that all prototype bits fit in an int32_t
150   movptr(Address(obj, oopDesc::mark_offset_in_bytes ()), (int32_t)(intptr_t)markWord::prototype().value());
151 #ifdef _LP64
152   if (UseCompressedClassPointers) { // Take care not to kill klass
153     movptr(t1, klass);
154     encode_klass_not_null(t1, tmp_encode_klass);
155     movl(Address(obj, oopDesc::klass_offset_in_bytes()), t1);
156   } else
157 #endif
158   {
159     movptr(Address(obj, oopDesc::klass_offset_in_bytes()), klass);
160   }
161 
162   if (len->is_valid()) {
163     movl(Address(obj, arrayOopDesc::length_offset_in_bytes()), len);
164   }
165 #ifdef _LP64
166   else if (UseCompressedClassPointers) {
167     xorptr(t1, t1);
168     store_klass_gap(obj, t1);
169   }
170 #endif
171 }
172 
173 
174 // preserves obj, destroys len_in_bytes
175 void C1_MacroAssembler::initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1) {
176   assert(hdr_size_in_bytes >= 0, "header size must be positive or 0");
177   Label done;
178 
179   // len_in_bytes is positive and ptr sized
180   subptr(len_in_bytes, hdr_size_in_bytes);
181   jcc(Assembler::zero, done);
182   zero_memory(obj, len_in_bytes, hdr_size_in_bytes, t1);
183   bind(done);
184 }
185 
186 
187 void C1_MacroAssembler::allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case) {
188   assert(obj == rax, "obj must be in rax, for cmpxchg");
189   assert_different_registers(obj, t1, t2); // XXX really?
190   assert(header_size >= 0 && object_size >= header_size, "illegal sizes");

228       { Label loop;
229         bind(loop);
230         movptr(Address(obj, index, Address::times_8, hdr_size_in_bytes - (1*BytesPerWord)),
231                t1_zero);
232         NOT_LP64(movptr(Address(obj, index, Address::times_8, hdr_size_in_bytes - (2*BytesPerWord)),
233                t1_zero);)
234         decrement(index);
235         jcc(Assembler::notZero, loop);
236       }
237     }
238   }
239 
240   if (CURRENT_ENV->dtrace_alloc_probes()) {
241     assert(obj == rax, "must be");
242     call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)));
243   }
244 
245   verify_oop(obj);
246 }
247 
248 void C1_MacroAssembler::allocate_array(Register obj, Register len, Register t1, Register t2, int header_size, Address::ScaleFactor f, Register klass, Label& slow_case) {
249   assert(obj == rax, "obj must be in rax, for cmpxchg");
250   assert_different_registers(obj, len, t1, t2, klass);
251 
252   // determine alignment mask
253   assert(!(BytesPerWord & 1), "must be a multiple of 2 for masking code to work");
254 
255   // check for negative or excessive length
256   cmpptr(len, (int32_t)max_array_allocation_length);
257   jcc(Assembler::above, slow_case);
258 
259   const Register arr_size = t2; // okay to be the same
260   // align object end
261   movptr(arr_size, (int32_t)header_size * BytesPerWord + MinObjAlignmentInBytesMask);
262   lea(arr_size, Address(arr_size, len, f));
263   andptr(arr_size, ~MinObjAlignmentInBytesMask);
264 
265   try_allocate(obj, arr_size, 0, t1, t2, slow_case);
266 
267   initialize_header(obj, klass, len, t1, t2);
268 
269   // clear rest of allocated space
270   const Register len_zero = len;
271   initialize_body(obj, arr_size, header_size * BytesPerWord, len_zero);
272 
273   if (CURRENT_ENV->dtrace_alloc_probes()) {
274     assert(obj == rax, "must be");
275     call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)));
276   }
277 
278   verify_oop(obj);
279 }
280 
281 
282 
283 void C1_MacroAssembler::inline_cache_check(Register receiver, Register iCache) {
284   verify_oop(receiver);
285   // explicit NULL check not needed since load from [klass_offset] causes a trap
286   // check against inline cache
287   assert(!MacroAssembler::needs_explicit_null_check(oopDesc::klass_offset_in_bytes()), "must add explicit null check");
288   int start_offset = offset();
289   Register tmp_load_klass = LP64_ONLY(rscratch2) NOT_LP64(noreg);
290 
291   if (UseCompressedClassPointers) {

127   // we do unlocking via runtime call
128   jcc(Assembler::notEqual, slow_case);
129   // done
130   bind(done);
131 
132   dec_held_monitor_count();
133 }
134 
135 
136 // Defines obj, preserves var_size_in_bytes
137 void C1_MacroAssembler::try_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes, Register t1, Register t2, Label& slow_case) {
138   if (UseTLAB) {
139     tlab_allocate(noreg, obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
140   } else {
141     jmp(slow_case);
142   }
143 }
144 
145 
146 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {

147   Register tmp_encode_klass = LP64_ONLY(rscratch1) NOT_LP64(noreg);
148   assert_different_registers(obj, klass, len, t1, t2);
149   movptr(t1, Address(klass, Klass::prototype_header_offset()));
150   movptr(Address(obj, oopDesc::mark_offset_in_bytes()), t1);
151 #ifndef _LP64
152   movptr(Address(obj, oopDesc::klass_offset_in_bytes()), klass);



153 #endif



154 
155   if (len->is_valid()) {
156     movl(Address(obj, arrayOopDesc::length_offset_in_bytes()), len);
157   }






158 }
159 
160 
161 // preserves obj, destroys len_in_bytes
162 void C1_MacroAssembler::initialize_body(Register obj, Register len_in_bytes, int hdr_size_in_bytes, Register t1) {
163   assert(hdr_size_in_bytes >= 0, "header size must be positive or 0");
164   Label done;
165 
166   // len_in_bytes is positive and ptr sized
167   subptr(len_in_bytes, hdr_size_in_bytes);
168   jcc(Assembler::zero, done);
169   zero_memory(obj, len_in_bytes, hdr_size_in_bytes, t1);
170   bind(done);
171 }
172 
173 
174 void C1_MacroAssembler::allocate_object(Register obj, Register t1, Register t2, int header_size, int object_size, Register klass, Label& slow_case) {
175   assert(obj == rax, "obj must be in rax, for cmpxchg");
176   assert_different_registers(obj, t1, t2); // XXX really?
177   assert(header_size >= 0 && object_size >= header_size, "illegal sizes");

215       { Label loop;
216         bind(loop);
217         movptr(Address(obj, index, Address::times_8, hdr_size_in_bytes - (1*BytesPerWord)),
218                t1_zero);
219         NOT_LP64(movptr(Address(obj, index, Address::times_8, hdr_size_in_bytes - (2*BytesPerWord)),
220                t1_zero);)
221         decrement(index);
222         jcc(Assembler::notZero, loop);
223       }
224     }
225   }
226 
227   if (CURRENT_ENV->dtrace_alloc_probes()) {
228     assert(obj == rax, "must be");
229     call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)));
230   }
231 
232   verify_oop(obj);
233 }
234 
235 void C1_MacroAssembler::allocate_array(Register obj, Register len, Register t1, Register t2, int base_offset_in_bytes, Address::ScaleFactor f, Register klass, Label& slow_case) {
236   assert(obj == rax, "obj must be in rax, for cmpxchg");
237   assert_different_registers(obj, len, t1, t2, klass);
238 
239   // determine alignment mask
240   assert(!(BytesPerWord & 1), "must be a multiple of 2 for masking code to work");
241 
242   // check for negative or excessive length
243   cmpptr(len, (int32_t)max_array_allocation_length);
244   jcc(Assembler::above, slow_case);
245 
246   const Register arr_size = t2; // okay to be the same
247   // align object end
248   movptr(arr_size, (int32_t)base_offset_in_bytes + MinObjAlignmentInBytesMask);
249   lea(arr_size, Address(arr_size, len, f));
250   andptr(arr_size, ~MinObjAlignmentInBytesMask);
251 
252   try_allocate(obj, arr_size, 0, t1, t2, slow_case);
253 
254   initialize_header(obj, klass, len, t1, t2);
255 
256   // clear rest of allocated space
257   const Register len_zero = len;
258   initialize_body(obj, arr_size, base_offset_in_bytes, len_zero);
259 
260   if (CURRENT_ENV->dtrace_alloc_probes()) {
261     assert(obj == rax, "must be");
262     call(RuntimeAddress(Runtime1::entry_for(Runtime1::dtrace_object_alloc_id)));
263   }
264 
265   verify_oop(obj);
266 }
267 
268 
269 
270 void C1_MacroAssembler::inline_cache_check(Register receiver, Register iCache) {
271   verify_oop(receiver);
272   // explicit NULL check not needed since load from [klass_offset] causes a trap
273   // check against inline cache
274   assert(!MacroAssembler::needs_explicit_null_check(oopDesc::klass_offset_in_bytes()), "must add explicit null check");
275   int start_offset = offset();
276   Register tmp_load_klass = LP64_ONLY(rscratch2) NOT_LP64(noreg);
277 
278   if (UseCompressedClassPointers) {
< prev index next >