< prev index next >

src/hotspot/share/opto/library_call.cpp

Print this page

 732     return inline_vector_broadcast_int();
 733   case vmIntrinsics::_VectorConvert:
 734     return inline_vector_convert();
 735   case vmIntrinsics::_VectorInsert:
 736     return inline_vector_insert();
 737   case vmIntrinsics::_VectorExtract:
 738     return inline_vector_extract();
 739   case vmIntrinsics::_VectorCompressExpand:
 740     return inline_vector_compress_expand();
 741   case vmIntrinsics::_IndexVector:
 742     return inline_index_vector();
 743   case vmIntrinsics::_IndexPartiallyInUpperRange:
 744     return inline_index_partially_in_upper_range();
 745 
 746   case vmIntrinsics::_getObjectSize:
 747     return inline_getObjectSize();
 748 
 749   case vmIntrinsics::_blackhole:
 750     return inline_blackhole();
 751 









 752   default:
 753     // If you get here, it may be that someone has added a new intrinsic
 754     // to the list in vmIntrinsics.hpp without implementing it here.
 755 #ifndef PRODUCT
 756     if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) {
 757       tty->print_cr("*** Warning: Unimplemented intrinsic %s(%d)",
 758                     vmIntrinsics::name_at(intrinsic_id()), vmIntrinsics::as_int(intrinsic_id()));
 759     }
 760 #endif
 761     return false;
 762   }
 763 }
 764 
 765 Node* LibraryCallKit::try_to_predicate(int predicate) {
 766   if (!jvms()->has_method()) {
 767     // Root JVMState has a null method.
 768     assert(map()->memory()->Opcode() == Op_Parm, "");
 769     // Insert the memory aliasing node
 770     set_all_memory(reset_memory());
 771   }

8030     Node* profile = _gvn.transform(new ProfileBooleanNode(result, false_cnt, true_cnt));
8031     C->record_for_igvn(profile);
8032     set_result(profile);
8033     return true;
8034   } else {
8035     // Continue profiling.
8036     // Profile data isn't available at the moment. So, execute method's bytecode version.
8037     // Usually, when GWT LambdaForms are profiled it means that a stand-alone nmethod
8038     // is compiled and counters aren't available since corresponding MethodHandle
8039     // isn't a compile-time constant.
8040     return false;
8041   }
8042 }
8043 
8044 bool LibraryCallKit::inline_isCompileConstant() {
8045   Node* n = argument(0);
8046   set_result(n->is_Con() ? intcon(1) : intcon(0));
8047   return true;
8048 }
8049 
8050 //------------------------------- inline_getObjectSize --------------------------------------
8051 //
8052 // Calculate the runtime size of the object/array.


8053 //   native long sun.instrument.InstrumentationImpl.getObjectSize0(long nativeAgent, Object objectToSize);
8054 //





8055 bool LibraryCallKit::inline_getObjectSize() {
8056   Node* obj = argument(3);




8057   Node* klass_node = load_object_klass(obj);
8058 
8059   jint  layout_con = Klass::_lh_neutral_value;
8060   Node* layout_val = get_layout_helper(klass_node, layout_con);
8061   int   layout_is_con = (layout_val == nullptr);
8062 
8063   if (layout_is_con) {
8064     // Layout helper is constant, can figure out things at compile time.
8065 
8066     if (Klass::layout_helper_is_instance(layout_con)) {
8067       // Instance case:  layout_con contains the size itself.
8068       Node *size = longcon(Klass::layout_helper_size_in_bytes(layout_con));
8069       set_result(size);
8070     } else {
8071       // Array case: size is round(header + element_size*arraylength).
8072       // Since arraylength is different for every array instance, we have to
8073       // compute the whole thing at runtime.
8074 
8075       Node* arr_length = load_array_length(obj);
8076 

8172   assert(callee()->is_static(), "Should have been checked before: only static methods here");
8173   assert(callee()->is_empty(), "Should have been checked before: only empty methods here");
8174   assert(callee()->holder()->is_loaded(), "Should have been checked before: only methods for loaded classes here");
8175 
8176   // Blackhole node pinches only the control, not memory. This allows
8177   // the blackhole to be pinned in the loop that computes blackholed
8178   // values, but have no other side effects, like breaking the optimizations
8179   // across the blackhole.
8180 
8181   Node* bh = _gvn.transform(new BlackholeNode(control()));
8182   set_control(_gvn.transform(new ProjNode(bh, TypeFunc::Control)));
8183 
8184   // Bind call arguments as blackhole arguments to keep them alive
8185   uint nargs = callee()->arg_size();
8186   for (uint i = 0; i < nargs; i++) {
8187     bh->add_req(argument(i));
8188   }
8189 
8190   return true;
8191 }



















 732     return inline_vector_broadcast_int();
 733   case vmIntrinsics::_VectorConvert:
 734     return inline_vector_convert();
 735   case vmIntrinsics::_VectorInsert:
 736     return inline_vector_insert();
 737   case vmIntrinsics::_VectorExtract:
 738     return inline_vector_extract();
 739   case vmIntrinsics::_VectorCompressExpand:
 740     return inline_vector_compress_expand();
 741   case vmIntrinsics::_IndexVector:
 742     return inline_index_vector();
 743   case vmIntrinsics::_IndexPartiallyInUpperRange:
 744     return inline_index_partially_in_upper_range();
 745 
 746   case vmIntrinsics::_getObjectSize:
 747     return inline_getObjectSize();
 748 
 749   case vmIntrinsics::_blackhole:
 750     return inline_blackhole();
 751 
 752   case vmIntrinsics::_shipilev_magic_timestamp:
 753     return inline_timestamp(false);
 754   case vmIntrinsics::_shipilev_magic_timestamp_serial:
 755     return inline_timestamp(true);
 756   case vmIntrinsics::_shipilev_magic_sizeOf:
 757     return inline_sizeOf();
 758   case vmIntrinsics::_shipilev_magic_addressOf:
 759     return inline_addressOf();
 760 
 761   default:
 762     // If you get here, it may be that someone has added a new intrinsic
 763     // to the list in vmIntrinsics.hpp without implementing it here.
 764 #ifndef PRODUCT
 765     if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) {
 766       tty->print_cr("*** Warning: Unimplemented intrinsic %s(%d)",
 767                     vmIntrinsics::name_at(intrinsic_id()), vmIntrinsics::as_int(intrinsic_id()));
 768     }
 769 #endif
 770     return false;
 771   }
 772 }
 773 
 774 Node* LibraryCallKit::try_to_predicate(int predicate) {
 775   if (!jvms()->has_method()) {
 776     // Root JVMState has a null method.
 777     assert(map()->memory()->Opcode() == Op_Parm, "");
 778     // Insert the memory aliasing node
 779     set_all_memory(reset_memory());
 780   }

8039     Node* profile = _gvn.transform(new ProfileBooleanNode(result, false_cnt, true_cnt));
8040     C->record_for_igvn(profile);
8041     set_result(profile);
8042     return true;
8043   } else {
8044     // Continue profiling.
8045     // Profile data isn't available at the moment. So, execute method's bytecode version.
8046     // Usually, when GWT LambdaForms are profiled it means that a stand-alone nmethod
8047     // is compiled and counters aren't available since corresponding MethodHandle
8048     // isn't a compile-time constant.
8049     return false;
8050   }
8051 }
8052 
8053 bool LibraryCallKit::inline_isCompileConstant() {
8054   Node* n = argument(0);
8055   set_result(n->is_Con() ? intcon(1) : intcon(0));
8056   return true;
8057 }
8058 
8059 //------------------------------- inline_getObjectSize/sizeOf --------------------------------------
8060 //
8061 // Calculate the runtime size of the object/array.
8062 //
8063 //   long java.lang.Runtime.sizeOf(Object obj)
8064 //   native long sun.instrument.InstrumentationImpl.getObjectSize0(long nativeAgent, Object objectToSize);
8065 //
8066 bool LibraryCallKit::inline_sizeOf() {
8067   Node* obj = argument(0);
8068   return inline_sizeOf_impl(obj);
8069 }
8070 
8071 bool LibraryCallKit::inline_getObjectSize() {
8072   Node* obj = argument(3);
8073   return inline_sizeOf_impl(obj);
8074 }
8075 
8076 bool LibraryCallKit::inline_sizeOf_impl(Node* obj) {
8077   Node* klass_node = load_object_klass(obj);
8078 
8079   jint  layout_con = Klass::_lh_neutral_value;
8080   Node* layout_val = get_layout_helper(klass_node, layout_con);
8081   int   layout_is_con = (layout_val == nullptr);
8082 
8083   if (layout_is_con) {
8084     // Layout helper is constant, can figure out things at compile time.
8085 
8086     if (Klass::layout_helper_is_instance(layout_con)) {
8087       // Instance case:  layout_con contains the size itself.
8088       Node *size = longcon(Klass::layout_helper_size_in_bytes(layout_con));
8089       set_result(size);
8090     } else {
8091       // Array case: size is round(header + element_size*arraylength).
8092       // Since arraylength is different for every array instance, we have to
8093       // compute the whole thing at runtime.
8094 
8095       Node* arr_length = load_array_length(obj);
8096 

8192   assert(callee()->is_static(), "Should have been checked before: only static methods here");
8193   assert(callee()->is_empty(), "Should have been checked before: only empty methods here");
8194   assert(callee()->holder()->is_loaded(), "Should have been checked before: only methods for loaded classes here");
8195 
8196   // Blackhole node pinches only the control, not memory. This allows
8197   // the blackhole to be pinned in the loop that computes blackholed
8198   // values, but have no other side effects, like breaking the optimizations
8199   // across the blackhole.
8200 
8201   Node* bh = _gvn.transform(new BlackholeNode(control()));
8202   set_control(_gvn.transform(new ProjNode(bh, TypeFunc::Control)));
8203 
8204   // Bind call arguments as blackhole arguments to keep them alive
8205   uint nargs = callee()->arg_size();
8206   for (uint i = 0; i < nargs; i++) {
8207     bh->add_req(argument(i));
8208   }
8209 
8210   return true;
8211 }
8212 
8213 bool LibraryCallKit::inline_timestamp(bool serial) {
8214   insert_mem_bar(Op_MemBarCPUOrder);
8215   Node* node = serial ?
8216           _gvn.transform(new TimestampSerialNode(control())) :
8217           _gvn.transform(new TimestampNode(control()));
8218   set_result(node);
8219   insert_mem_bar(Op_MemBarCPUOrder);
8220   return true;
8221 }
8222 
8223 bool LibraryCallKit::inline_addressOf() {
8224   Node* obj = argument(0);
8225   Node* raw_val = _gvn.transform(new CastP2XNode(NULL, obj));
8226   Node* long_val = ConvX2L(raw_val);
8227   set_result(long_val);
8228   return true;
8229 }
< prev index next >