< prev index next >

src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp

Print this page

255   domain_fields[TypeFunc::Parms + 1] = TypeInstPtr::NOTNULL;  // dst
256   domain_fields[TypeFunc::Parms + 2] = TypeLong::LONG;        // size lower
257   domain_fields[TypeFunc::Parms + 3] = Type::HALF;            // size upper
258   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + 4, domain_fields);
259 
260   // Create result type (range)
261   const Type** range_fields = TypeTuple::fields(0);
262   const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 0, range_fields);
263 
264   return TypeFunc::make(domain, range);
265 }
266 
267 #define XTOP LP64_ONLY(COMMA phase->top())
268 
269 void ZBarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const {
270   Node* const src = ac->in(ArrayCopyNode::Src);
271   const TypeAryPtr* ary_ptr = src->get_ptr_type()->isa_aryptr();
272 
273   if (ac->is_clone_array() && ary_ptr != NULL) {
274     BasicType bt = ary_ptr->elem()->array_element_basic_type();
275     if (is_reference_type(bt)) {
276       // Clone object array
277       bt = T_OBJECT;
278     } else {
279       // Clone primitive array
280       bt = T_LONG;
281     }
282 
283     Node* ctrl = ac->in(TypeFunc::Control);
284     Node* mem = ac->in(TypeFunc::Memory);
285     Node* src = ac->in(ArrayCopyNode::Src);
286     Node* src_offset = ac->in(ArrayCopyNode::SrcPos);
287     Node* dest = ac->in(ArrayCopyNode::Dest);
288     Node* dest_offset = ac->in(ArrayCopyNode::DestPos);
289     Node* length = ac->in(ArrayCopyNode::Length);
290 
291     if (bt == T_OBJECT) {
292       // BarrierSetC2::clone sets the offsets via BarrierSetC2::arraycopy_payload_base_offset
293       // which 8-byte aligns them to allow for word size copies. Make sure the offsets point
294       // to the first element in the array when cloning object arrays. Otherwise, load
295       // barriers are applied to parts of the header. Also adjust the length accordingly.
296       assert(src_offset == dest_offset, "should be equal");
297       jlong offset = src_offset->get_long();
298       if (offset != arrayOopDesc::base_offset_in_bytes(T_OBJECT)) {
299         assert(!UseCompressedClassPointers, "should only happen without compressed class pointers");
300         assert((arrayOopDesc::base_offset_in_bytes(T_OBJECT) - offset) == BytesPerLong, "unexpected offset");
301         length = phase->transform_later(new SubLNode(length, phase->longcon(1))); // Size is in longs
302         src_offset = phase->longcon(arrayOopDesc::base_offset_in_bytes(T_OBJECT));
303         dest_offset = src_offset;
304       }
305     }
306     Node* payload_src = phase->basic_plus_adr(src, src_offset);
307     Node* payload_dst = phase->basic_plus_adr(dest, dest_offset);
308 
309     const char* copyfunc_name = "arraycopy";
310     address     copyfunc_addr = phase->basictype2arraycopy(bt, NULL, NULL, true, copyfunc_name, true);
311 
312     const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM;
313     const TypeFunc* call_type = OptoRuntime::fast_arraycopy_Type();
314 
315     Node* call = phase->make_leaf_call(ctrl, mem, call_type, copyfunc_addr, copyfunc_name, raw_adr_type, payload_src, payload_dst, length XTOP);
316     phase->transform_later(call);
317 
318     phase->igvn().replace_node(ac, call);
319     return;
320   }
321 

326   Node* const size       = ac->in(ArrayCopyNode::Length);
327 
328   assert(size->bottom_type()->is_long(), "Should be long");
329 
330   // The native clone we are calling here expects the instance size in words
331   // Add header/offset size to payload size to get instance size.
332   Node* const base_offset = phase->longcon(arraycopy_payload_base_offset(ac->is_clone_array()) >> LogBytesPerLong);
333   Node* const full_size = phase->transform_later(new AddLNode(size, base_offset));
334 
335   Node* const call = phase->make_leaf_call(ctrl,
336                                            mem,
337                                            clone_type(),
338                                            ZBarrierSetRuntime::clone_addr(),
339                                            "ZBarrierSetRuntime::clone",
340                                            TypeRawPtr::BOTTOM,
341                                            src,
342                                            dst,
343                                            full_size,
344                                            phase->top());
345   phase->transform_later(call);
346   phase->igvn().replace_node(ac, call);
347 }
348 
349 #undef XTOP
350 
351 // == Dominating barrier elision ==
352 
353 static bool block_has_safepoint(const Block* block, uint from, uint to) {
354   for (uint i = from; i < to; i++) {
355     if (block->get_node(i)->is_MachSafePoint()) {
356       // Safepoint found
357       return true;
358     }
359   }
360 
361   // Safepoint not found
362   return false;
363 }
364 
365 static bool block_has_safepoint(const Block* block) {
366   return block_has_safepoint(block, 0, block->number_of_nodes());

255   domain_fields[TypeFunc::Parms + 1] = TypeInstPtr::NOTNULL;  // dst
256   domain_fields[TypeFunc::Parms + 2] = TypeLong::LONG;        // size lower
257   domain_fields[TypeFunc::Parms + 3] = Type::HALF;            // size upper
258   const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + 4, domain_fields);
259 
260   // Create result type (range)
261   const Type** range_fields = TypeTuple::fields(0);
262   const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 0, range_fields);
263 
264   return TypeFunc::make(domain, range);
265 }
266 
267 #define XTOP LP64_ONLY(COMMA phase->top())
268 
269 void ZBarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const {
270   Node* const src = ac->in(ArrayCopyNode::Src);
271   const TypeAryPtr* ary_ptr = src->get_ptr_type()->isa_aryptr();
272 
273   if (ac->is_clone_array() && ary_ptr != NULL) {
274     BasicType bt = ary_ptr->elem()->array_element_basic_type();
275     if (is_reference_type(bt) && (!ary_ptr->is_flat())) {
276       // Clone object array
277       bt = T_OBJECT;
278     } else {
279       // Clone primitive array
280       bt = T_LONG;
281     }
282 
283     Node* ctrl = ac->in(TypeFunc::Control);
284     Node* mem = ac->in(TypeFunc::Memory);
285     Node* src = ac->in(ArrayCopyNode::Src);
286     Node* src_offset = ac->in(ArrayCopyNode::SrcPos);
287     Node* dest = ac->in(ArrayCopyNode::Dest);
288     Node* dest_offset = ac->in(ArrayCopyNode::DestPos);
289     Node* length = ac->in(ArrayCopyNode::Length);
290 
291     if (bt == T_OBJECT) {
292       // BarrierSetC2::clone sets the offsets via BarrierSetC2::arraycopy_payload_base_offset
293       // which 8-byte aligns them to allow for word size copies. Make sure the offsets point
294       // to the first element in the array when cloning object arrays. Otherwise, load
295       // barriers are applied to parts of the header. Also adjust the length accordingly.
296       assert(src_offset == dest_offset, "should be equal");
297       jlong offset = src_offset->get_long();
298       if (offset != arrayOopDesc::base_offset_in_bytes(T_OBJECT)) {
299         assert(!UseCompressedClassPointers, "should only happen without compressed class pointers");
300         assert((arrayOopDesc::base_offset_in_bytes(T_OBJECT) - offset) == BytesPerLong, "unexpected offset");
301         length = phase->transform_later(new SubXNode(length, phase->longcon(1))); // Size is in longs
302         src_offset = phase->longcon(arrayOopDesc::base_offset_in_bytes(T_OBJECT));
303         dest_offset = src_offset;
304       }
305     }
306     Node* payload_src = phase->basic_plus_adr(src, src_offset);
307     Node* payload_dst = phase->basic_plus_adr(dest, dest_offset);
308 
309     const char* copyfunc_name = "arraycopy";
310     address     copyfunc_addr = phase->basictype2arraycopy(bt, NULL, NULL, true, copyfunc_name, true);
311 
312     const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM;
313     const TypeFunc* call_type = OptoRuntime::fast_arraycopy_Type();
314 
315     Node* call = phase->make_leaf_call(ctrl, mem, call_type, copyfunc_addr, copyfunc_name, raw_adr_type, payload_src, payload_dst, length XTOP);
316     phase->transform_later(call);
317 
318     phase->igvn().replace_node(ac, call);
319     return;
320   }
321 

326   Node* const size       = ac->in(ArrayCopyNode::Length);
327 
328   assert(size->bottom_type()->is_long(), "Should be long");
329 
330   // The native clone we are calling here expects the instance size in words
331   // Add header/offset size to payload size to get instance size.
332   Node* const base_offset = phase->longcon(arraycopy_payload_base_offset(ac->is_clone_array()) >> LogBytesPerLong);
333   Node* const full_size = phase->transform_later(new AddLNode(size, base_offset));
334 
335   Node* const call = phase->make_leaf_call(ctrl,
336                                            mem,
337                                            clone_type(),
338                                            ZBarrierSetRuntime::clone_addr(),
339                                            "ZBarrierSetRuntime::clone",
340                                            TypeRawPtr::BOTTOM,
341                                            src,
342                                            dst,
343                                            full_size,
344                                            phase->top());
345   phase->transform_later(call);
346   phase->replace_node(ac, call);
347 }
348 
349 #undef XTOP
350 
351 // == Dominating barrier elision ==
352 
353 static bool block_has_safepoint(const Block* block, uint from, uint to) {
354   for (uint i = from; i < to; i++) {
355     if (block->get_node(i)->is_MachSafePoint()) {
356       // Safepoint found
357       return true;
358     }
359   }
360 
361   // Safepoint not found
362   return false;
363 }
364 
365 static bool block_has_safepoint(const Block* block) {
366   return block_has_safepoint(block, 0, block->number_of_nodes());
< prev index next >