< prev index next >

src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp

Print this page

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

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

123   cmpxchgptr(hdr, Address(obj, hdr_offset));
124   // if the object header was not pointing to the displaced header,
125   // we do unlocking via runtime call
126   jcc(Assembler::notEqual, slow_case);
127   // done
128   bind(done);
129 }
130 
131 
132 // Defines obj, preserves var_size_in_bytes
133 void C1_MacroAssembler::try_allocate(Register obj, Register var_size_in_bytes, int con_size_in_bytes, Register t1, Register t2, Label& slow_case) {
134   if (UseTLAB) {
135     tlab_allocate(noreg, obj, var_size_in_bytes, con_size_in_bytes, t1, t2, slow_case);
136   } else {
137     eden_allocate(noreg, obj, var_size_in_bytes, con_size_in_bytes, t1, slow_case);
138   }
139 }
140 
141 
142 void C1_MacroAssembler::initialize_header(Register obj, Register klass, Register len, Register t1, Register t2) {

143   Register tmp_encode_klass = LP64_ONLY(rscratch1) NOT_LP64(noreg);
144   assert_different_registers(obj, klass, len, t1, t2);
145   movptr(t1, Address(klass, Klass::prototype_header_offset()));
146   movptr(Address(obj, oopDesc::mark_offset_in_bytes()), t1);
147 #ifndef _LP64
148   movptr(Address(obj, oopDesc::klass_offset_in_bytes()), klass);



149 #endif



150 
151   if (len->is_valid()) {
152     movl(Address(obj, arrayOopDesc::length_offset_in_bytes()), len);
153   }






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

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