< prev index next >

src/hotspot/share/opto/macroArrayCopy.cpp

Print this page




  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/shared/barrierSet.hpp"
  27 #include "opto/arraycopynode.hpp"
  28 #include "oops/objArrayKlass.hpp"
  29 #include "opto/convertnode.hpp"
  30 #include "opto/graphKit.hpp"
  31 #include "opto/macro.hpp"
  32 #include "opto/runtime.hpp"
  33 #include "utilities/align.hpp"




  34 
  35 
  36 void PhaseMacroExpand::insert_mem_bar(Node** ctrl, Node** mem, int opcode, Node* precedent) {
  37   MemBarNode* mb = MemBarNode::make(C, opcode, Compile::AliasIdxBot, precedent);
  38   mb->init_req(TypeFunc::Control, *ctrl);
  39   mb->init_req(TypeFunc::Memory, *mem);
  40   transform_later(mb);
  41   *ctrl = new ProjNode(mb,TypeFunc::Control);
  42   transform_later(*ctrl);
  43   Node* mem_proj = new ProjNode(mb,TypeFunc::Memory);
  44   transform_later(mem_proj);
  45   *mem = mem_proj;
  46 }
  47 
  48 Node* PhaseMacroExpand::array_element_address(Node* ary, Node* idx, BasicType elembt) {
  49   uint shift  = exact_log2(type2aelembytes(elembt));
  50   uint header = arrayOopDesc::base_offset_in_bytes(elembt);
  51   Node* base =  basic_plus_adr(ary, header);
  52 #ifdef _LP64
  53   // see comment in GraphKit::array_element_address


 535         // (At this point we can assume disjoint_bases, since types differ.)
 536         int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset());
 537         Node* p1 = basic_plus_adr(dest_klass, ek_offset);
 538         Node* n1 = LoadKlassNode::make(_igvn, NULL, C->immutable_memory(), p1, TypeRawPtr::BOTTOM);
 539         Node* dest_elem_klass = transform_later(n1);
 540         Node* cv = generate_checkcast_arraycopy(&local_ctrl, &local_mem,
 541                                                 adr_type,
 542                                                 dest_elem_klass,
 543                                                 src, src_offset, dest, dest_offset,
 544                                                 ConvI2X(copy_length), dest_uninitialized);
 545         if (cv == NULL)  cv = intcon(-1);  // failure (no stub available)
 546         checked_control = local_ctrl;
 547         checked_i_o     = *io;
 548         checked_mem     = local_mem->memory_at(alias_idx);
 549         checked_value   = cv;
 550       }
 551     }
 552     // At this point we know we do not need type checks on oop stores.
 553 
 554     BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
 555     if (alloc != NULL && !bs->array_copy_requires_gc_barriers(copy_type)) {
 556       // If we do not need gc barriers, copy using the jint or jlong stub.
 557       copy_type = LP64_ONLY(UseCompressedOops ? T_INT : T_LONG) NOT_LP64(T_INT);
 558       assert(type2aelembytes(basic_elem_type) == type2aelembytes(copy_type),
 559              "sizes agree");
 560     }
 561   }
 562 
 563   if (!(*ctrl)->is_top()) {
 564     // Generate the fast path, if possible.
 565     Node* local_ctrl = *ctrl;
 566     MergeMemNode* local_mem = MergeMemNode::make(mem);
 567     transform_later(local_mem);
 568 
 569     generate_unchecked_arraycopy(&local_ctrl, &local_mem,
 570                                  adr_type, copy_type, disjoint_bases,
 571                                  src, src_offset, dest, dest_offset,
 572                                  ConvI2X(copy_length), dest_uninitialized);
 573 
 574     // Present the results of the fast call.
 575     result_region->init_req(fast_path, local_ctrl);




  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/shared/barrierSet.hpp"
  27 #include "opto/arraycopynode.hpp"
  28 #include "oops/objArrayKlass.hpp"
  29 #include "opto/convertnode.hpp"
  30 #include "opto/graphKit.hpp"
  31 #include "opto/macro.hpp"
  32 #include "opto/runtime.hpp"
  33 #include "utilities/align.hpp"
  34 #if INCLUDE_SHENANDOAHGC
  35 #include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
  36 #include "gc/shenandoah/shenandoahRuntime.hpp"
  37 #endif
  38 
  39 
  40 void PhaseMacroExpand::insert_mem_bar(Node** ctrl, Node** mem, int opcode, Node* precedent) {
  41   MemBarNode* mb = MemBarNode::make(C, opcode, Compile::AliasIdxBot, precedent);
  42   mb->init_req(TypeFunc::Control, *ctrl);
  43   mb->init_req(TypeFunc::Memory, *mem);
  44   transform_later(mb);
  45   *ctrl = new ProjNode(mb,TypeFunc::Control);
  46   transform_later(*ctrl);
  47   Node* mem_proj = new ProjNode(mb,TypeFunc::Memory);
  48   transform_later(mem_proj);
  49   *mem = mem_proj;
  50 }
  51 
  52 Node* PhaseMacroExpand::array_element_address(Node* ary, Node* idx, BasicType elembt) {
  53   uint shift  = exact_log2(type2aelembytes(elembt));
  54   uint header = arrayOopDesc::base_offset_in_bytes(elembt);
  55   Node* base =  basic_plus_adr(ary, header);
  56 #ifdef _LP64
  57   // see comment in GraphKit::array_element_address


 539         // (At this point we can assume disjoint_bases, since types differ.)
 540         int ek_offset = in_bytes(ObjArrayKlass::element_klass_offset());
 541         Node* p1 = basic_plus_adr(dest_klass, ek_offset);
 542         Node* n1 = LoadKlassNode::make(_igvn, NULL, C->immutable_memory(), p1, TypeRawPtr::BOTTOM);
 543         Node* dest_elem_klass = transform_later(n1);
 544         Node* cv = generate_checkcast_arraycopy(&local_ctrl, &local_mem,
 545                                                 adr_type,
 546                                                 dest_elem_klass,
 547                                                 src, src_offset, dest, dest_offset,
 548                                                 ConvI2X(copy_length), dest_uninitialized);
 549         if (cv == NULL)  cv = intcon(-1);  // failure (no stub available)
 550         checked_control = local_ctrl;
 551         checked_i_o     = *io;
 552         checked_mem     = local_mem->memory_at(alias_idx);
 553         checked_value   = cv;
 554       }
 555     }
 556     // At this point we know we do not need type checks on oop stores.
 557 
 558     BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
 559     if (alloc != NULL && !bs->array_copy_requires_gc_barriers(copy_type) && !UseShenandoahGC) {
 560       // If we do not need gc barriers, copy using the jint or jlong stub.
 561       copy_type = LP64_ONLY(UseCompressedOops ? T_INT : T_LONG) NOT_LP64(T_INT);
 562       assert(type2aelembytes(basic_elem_type) == type2aelembytes(copy_type),
 563              "sizes agree");
 564     }
 565   }
 566 
 567   if (!(*ctrl)->is_top()) {
 568     // Generate the fast path, if possible.
 569     Node* local_ctrl = *ctrl;
 570     MergeMemNode* local_mem = MergeMemNode::make(mem);
 571     transform_later(local_mem);
 572 
 573     generate_unchecked_arraycopy(&local_ctrl, &local_mem,
 574                                  adr_type, copy_type, disjoint_bases,
 575                                  src, src_offset, dest, dest_offset,
 576                                  ConvI2X(copy_length), dest_uninitialized);
 577 
 578     // Present the results of the fast call.
 579     result_region->init_req(fast_path, local_ctrl);


< prev index next >