< prev index next >

src/hotspot/share/opto/library_call.cpp

Print this page

 708     return inline_vector_compare();
 709   case vmIntrinsics::_VectorBroadcastInt:
 710     return inline_vector_broadcast_int();
 711   case vmIntrinsics::_VectorConvert:
 712     return inline_vector_convert();
 713   case vmIntrinsics::_VectorInsert:
 714     return inline_vector_insert();
 715   case vmIntrinsics::_VectorExtract:
 716     return inline_vector_extract();
 717   case vmIntrinsics::_VectorCompressExpand:
 718     return inline_vector_compress_expand();
 719   case vmIntrinsics::_IndexVector:
 720     return inline_index_vector();
 721 
 722   case vmIntrinsics::_getObjectSize:
 723     return inline_getObjectSize();
 724 
 725   case vmIntrinsics::_blackhole:
 726     return inline_blackhole();
 727 









 728   default:
 729     // If you get here, it may be that someone has added a new intrinsic
 730     // to the list in vmIntrinsics.hpp without implementing it here.
 731 #ifndef PRODUCT
 732     if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) {
 733       tty->print_cr("*** Warning: Unimplemented intrinsic %s(%d)",
 734                     vmIntrinsics::name_at(intrinsic_id()), vmIntrinsics::as_int(intrinsic_id()));
 735     }
 736 #endif
 737     return false;
 738   }
 739 }
 740 
 741 Node* LibraryCallKit::try_to_predicate(int predicate) {
 742   if (!jvms()->has_method()) {
 743     // Root JVMState has a null method.
 744     assert(map()->memory()->Opcode() == Op_Parm, "");
 745     // Insert the memory aliasing node
 746     set_all_memory(reset_memory());
 747   }

7628     Node* profile = _gvn.transform(new ProfileBooleanNode(result, false_cnt, true_cnt));
7629     C->record_for_igvn(profile);
7630     set_result(profile);
7631     return true;
7632   } else {
7633     // Continue profiling.
7634     // Profile data isn't available at the moment. So, execute method's bytecode version.
7635     // Usually, when GWT LambdaForms are profiled it means that a stand-alone nmethod
7636     // is compiled and counters aren't available since corresponding MethodHandle
7637     // isn't a compile-time constant.
7638     return false;
7639   }
7640 }
7641 
7642 bool LibraryCallKit::inline_isCompileConstant() {
7643   Node* n = argument(0);
7644   set_result(n->is_Con() ? intcon(1) : intcon(0));
7645   return true;
7646 }
7647 
7648 //------------------------------- inline_getObjectSize --------------------------------------
7649 //
7650 // Calculate the runtime size of the object/array.


7651 //   native long sun.instrument.InstrumentationImpl.getObjectSize0(long nativeAgent, Object objectToSize);
7652 //





7653 bool LibraryCallKit::inline_getObjectSize() {
7654   Node* obj = argument(3);




7655   Node* klass_node = load_object_klass(obj);
7656 
7657   jint  layout_con = Klass::_lh_neutral_value;
7658   Node* layout_val = get_layout_helper(klass_node, layout_con);
7659   int   layout_is_con = (layout_val == NULL);
7660 
7661   if (layout_is_con) {
7662     // Layout helper is constant, can figure out things at compile time.
7663 
7664     if (Klass::layout_helper_is_instance(layout_con)) {
7665       // Instance case:  layout_con contains the size itself.
7666       Node *size = longcon(Klass::layout_helper_size_in_bytes(layout_con));
7667       set_result(size);
7668     } else {
7669       // Array case: size is round(header + element_size*arraylength).
7670       // Since arraylength is different for every array instance, we have to
7671       // compute the whole thing at runtime.
7672 
7673       Node* arr_length = load_array_length(obj);
7674 

7754       result_reg->init_req(_instance_path, control());
7755       result_val->init_req(_instance_path, size);
7756     }
7757 
7758     set_result(result_reg, result_val);
7759   }
7760 
7761   return true;
7762 }
7763 
7764 //------------------------------- inline_blackhole --------------------------------------
7765 //
7766 // Make sure all arguments to this node are alive.
7767 // This matches methods that were requested to be blackholed through compile commands.
7768 //
7769 bool LibraryCallKit::inline_blackhole() {
7770   assert(callee()->is_static(), "Should have been checked before: only static methods here");
7771   assert(callee()->is_empty(), "Should have been checked before: only empty methods here");
7772   assert(callee()->holder()->is_loaded(), "Should have been checked before: only methods for loaded classes here");
7773 








7774   // Bind call arguments as blackhole arguments to keep them alive
7775   Node* bh = insert_mem_bar(Op_Blackhole);
7776   uint nargs = callee()->arg_size();
7777   for (uint i = 0; i < nargs; i++) {
7778     bh->add_req(argument(i));
7779   }
7780 
7781   return true;
7782 }



















 708     return inline_vector_compare();
 709   case vmIntrinsics::_VectorBroadcastInt:
 710     return inline_vector_broadcast_int();
 711   case vmIntrinsics::_VectorConvert:
 712     return inline_vector_convert();
 713   case vmIntrinsics::_VectorInsert:
 714     return inline_vector_insert();
 715   case vmIntrinsics::_VectorExtract:
 716     return inline_vector_extract();
 717   case vmIntrinsics::_VectorCompressExpand:
 718     return inline_vector_compress_expand();
 719   case vmIntrinsics::_IndexVector:
 720     return inline_index_vector();
 721 
 722   case vmIntrinsics::_getObjectSize:
 723     return inline_getObjectSize();
 724 
 725   case vmIntrinsics::_blackhole:
 726     return inline_blackhole();
 727 
 728   case vmIntrinsics::_shipilev_magic_timestamp:
 729     return inline_timestamp(false);
 730   case vmIntrinsics::_shipilev_magic_timestamp_serial:
 731     return inline_timestamp(true);
 732   case vmIntrinsics::_shipilev_magic_sizeOf:
 733     return inline_sizeOf();
 734   case vmIntrinsics::_shipilev_magic_addressOf:
 735     return inline_addressOf();
 736 
 737   default:
 738     // If you get here, it may be that someone has added a new intrinsic
 739     // to the list in vmIntrinsics.hpp without implementing it here.
 740 #ifndef PRODUCT
 741     if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) {
 742       tty->print_cr("*** Warning: Unimplemented intrinsic %s(%d)",
 743                     vmIntrinsics::name_at(intrinsic_id()), vmIntrinsics::as_int(intrinsic_id()));
 744     }
 745 #endif
 746     return false;
 747   }
 748 }
 749 
 750 Node* LibraryCallKit::try_to_predicate(int predicate) {
 751   if (!jvms()->has_method()) {
 752     // Root JVMState has a null method.
 753     assert(map()->memory()->Opcode() == Op_Parm, "");
 754     // Insert the memory aliasing node
 755     set_all_memory(reset_memory());
 756   }

7637     Node* profile = _gvn.transform(new ProfileBooleanNode(result, false_cnt, true_cnt));
7638     C->record_for_igvn(profile);
7639     set_result(profile);
7640     return true;
7641   } else {
7642     // Continue profiling.
7643     // Profile data isn't available at the moment. So, execute method's bytecode version.
7644     // Usually, when GWT LambdaForms are profiled it means that a stand-alone nmethod
7645     // is compiled and counters aren't available since corresponding MethodHandle
7646     // isn't a compile-time constant.
7647     return false;
7648   }
7649 }
7650 
7651 bool LibraryCallKit::inline_isCompileConstant() {
7652   Node* n = argument(0);
7653   set_result(n->is_Con() ? intcon(1) : intcon(0));
7654   return true;
7655 }
7656 
7657 //------------------------------- inline_getObjectSize/sizeOf --------------------------------------
7658 //
7659 // Calculate the runtime size of the object/array.
7660 //
7661 //   long java.lang.Runtime.sizeOf(Object obj)
7662 //   native long sun.instrument.InstrumentationImpl.getObjectSize0(long nativeAgent, Object objectToSize);
7663 //
7664 bool LibraryCallKit::inline_sizeOf() {
7665   Node* obj = argument(0);
7666   return inline_sizeOf_impl(obj);
7667 }
7668 
7669 bool LibraryCallKit::inline_getObjectSize() {
7670   Node* obj = argument(3);
7671   return inline_sizeOf_impl(obj);
7672 }
7673 
7674 bool LibraryCallKit::inline_sizeOf_impl(Node* obj) {
7675   Node* klass_node = load_object_klass(obj);
7676 
7677   jint  layout_con = Klass::_lh_neutral_value;
7678   Node* layout_val = get_layout_helper(klass_node, layout_con);
7679   int   layout_is_con = (layout_val == NULL);
7680 
7681   if (layout_is_con) {
7682     // Layout helper is constant, can figure out things at compile time.
7683 
7684     if (Klass::layout_helper_is_instance(layout_con)) {
7685       // Instance case:  layout_con contains the size itself.
7686       Node *size = longcon(Klass::layout_helper_size_in_bytes(layout_con));
7687       set_result(size);
7688     } else {
7689       // Array case: size is round(header + element_size*arraylength).
7690       // Since arraylength is different for every array instance, we have to
7691       // compute the whole thing at runtime.
7692 
7693       Node* arr_length = load_array_length(obj);
7694 

7774       result_reg->init_req(_instance_path, control());
7775       result_val->init_req(_instance_path, size);
7776     }
7777 
7778     set_result(result_reg, result_val);
7779   }
7780 
7781   return true;
7782 }
7783 
7784 //------------------------------- inline_blackhole --------------------------------------
7785 //
7786 // Make sure all arguments to this node are alive.
7787 // This matches methods that were requested to be blackholed through compile commands.
7788 //
7789 bool LibraryCallKit::inline_blackhole() {
7790   assert(callee()->is_static(), "Should have been checked before: only static methods here");
7791   assert(callee()->is_empty(), "Should have been checked before: only empty methods here");
7792   assert(callee()->holder()->is_loaded(), "Should have been checked before: only methods for loaded classes here");
7793 
7794   // Blackhole node pinches only the control, not memory. This allows
7795   // the blackhole to be pinned in the loop that computes blackholed
7796   // values, but have no other side effects, like breaking the optimizations
7797   // across the blackhole.
7798 
7799   Node* bh = _gvn.transform(new BlackholeNode(control()));
7800   set_control(_gvn.transform(new ProjNode(bh, TypeFunc::Control)));
7801 
7802   // Bind call arguments as blackhole arguments to keep them alive

7803   uint nargs = callee()->arg_size();
7804   for (uint i = 0; i < nargs; i++) {
7805     bh->add_req(argument(i));
7806   }
7807 
7808   return true;
7809 }
7810 
7811 bool LibraryCallKit::inline_timestamp(bool serial) {
7812   insert_mem_bar(Op_MemBarCPUOrder);
7813   Node* node = serial ?
7814           _gvn.transform(new TimestampSerialNode(control())) :
7815           _gvn.transform(new TimestampNode(control()));
7816   set_result(node);
7817   insert_mem_bar(Op_MemBarCPUOrder);
7818   return true;
7819 }
7820 
7821 bool LibraryCallKit::inline_addressOf() {
7822   Node* obj = argument(0);
7823   Node* raw_val = _gvn.transform(new CastP2XNode(NULL, obj));
7824   Node* long_val = ConvX2L(raw_val);
7825   set_result(long_val);
7826   return true;
7827 }
< prev index next >