src/share/vm/oops/methodData.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/oops

src/share/vm/oops/methodData.hpp

Print this page
rev 5400 : 8023657: New type profiling points: arguments to call
Summary: x86 interpreter and c1 type profiling for arguments at calls
Reviewed-by: kvn, twisti
rev 5401 : 8026054: New type profiling points: type of return values at calls
Summary: x86 interpreter and c1 type profiling for return values at calls
Reviewed-by:
rev 5402 : imported patch kvn
rev 5403 : [mq]: twisti


 254 class ProfileData;
 255 class   BitData;
 256 class     CounterData;
 257 class       ReceiverTypeData;
 258 class         VirtualCallData;
 259 class           VirtualCallTypeData;
 260 class       RetData;
 261 class       CallTypeData;
 262 class   JumpData;
 263 class     BranchData;
 264 class   ArrayData;
 265 class     MultiBranchData;
 266 class     ArgInfoData;
 267 
 268 // ProfileData
 269 //
 270 // A ProfileData object is created to refer to a section of profiling
 271 // data in a structured way.
 272 class ProfileData : public ResourceObj {
 273   friend class TypeEntries;

 274   friend class TypeStackSlotEntries;
 275 private:
 276 #ifndef PRODUCT
 277   enum {
 278     tab_width_one = 16,
 279     tab_width_two = 36
 280   };
 281 #endif // !PRODUCT
 282 
 283   // This is a pointer to a section of profiling data.
 284   DataLayout* _data;
 285 
 286 protected:
 287   DataLayout* data() { return _data; }
 288   const DataLayout* data() const { return _data; }
 289 
 290   enum {
 291     cell_size = DataLayout::cell_size
 292   };
 293 


 726 
 727   intptr_t intptr_at(int index) const {
 728     return _pd->intptr_at(index);
 729   }
 730 };
 731 
 732 // Type entries used for arguments passed at a call and parameters on
 733 // method entry. 2 cells per entry: one for the type encoded as in
 734 // TypeEntries and one initialized with the stack slot where the
 735 // profiled object is to be found so that the interpreter can locate
 736 // it quickly.
 737 class TypeStackSlotEntries : public TypeEntries {
 738 
 739 private:
 740   enum {
 741     stack_slot_entry,
 742     type_entry,
 743     per_arg_cell_count
 744   };
 745 
 746   // Start with a header if needed. It stores the number of cells used
 747   // for this call type information. Unless we collect only profiling
 748   // for a single argument the number of cells is unknown statically.
 749   static int header_cell_count() {
 750     return (TypeProfileArgsLimit > 1) ? 1 : 0;
 751   }
 752 
 753   static int cell_count_local_offset() {
 754      assert(arguments_profiling_enabled() && TypeProfileArgsLimit > 1, "no cell count");
 755      return 0;
 756    }
 757 
 758   int cell_count_global_offset() const {
 759     return _base_off + cell_count_local_offset();
 760   }
 761 
 762   // offset of cell for stack slot for entry i within ProfileData object
 763   int stack_slot_global_offset(int i) const {
 764     return _base_off + stack_slot_local_offset(i);
 765   }
 766 
 767   void check_number_of_arguments(uint total) {
 768     assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
 769   }
 770 
 771   // number of cells not counting the header
 772   int cell_count_no_header() const {
 773     return _pd->uint_at(cell_count_global_offset());
 774   }
 775 
 776   static bool arguments_profiling_enabled();
 777   static void assert_arguments_profiling_enabled() {
 778     assert(arguments_profiling_enabled(), "args profiling should be on");
 779   }
 780 
 781 protected:

 782 
 783   // offset of cell for type for entry i within ProfileData object
 784   int type_global_offset(int i) const {
 785     return _base_off + type_local_offset(i);
 786   }
 787 
 788 public:
 789 
 790   TypeStackSlotEntries(int base_off, ProfileData* pd)
 791     : TypeEntries(base_off, pd) {}
 792 
 793   static int compute_cell_count(BytecodeStream* stream);
 794 
 795   static void initialize(DataLayout* dl, int base, int cell_count) {
 796     if (TypeProfileArgsLimit > 1) {
 797       int off = base + cell_count_local_offset();
 798       dl->set_cell_at(off, cell_count - base - header_cell_count());
 799     }
 800   }
 801 
 802   void post_initialize(BytecodeStream* stream);
 803 
 804   uint number_of_arguments() const {
 805     assert_arguments_profiling_enabled();
 806     if (TypeProfileArgsLimit > 1) {
 807       int cell_count = cell_count_no_header();
 808       int nb = cell_count / TypeStackSlotEntries::per_arg_count();
 809       assert(nb > 0 && nb <= TypeProfileArgsLimit , "only when we profile args");
 810       return nb;
 811     } else {
 812       assert(TypeProfileArgsLimit == 1, "at least one arg");
 813       return 1;
 814     }
 815   }
 816 
 817   int cell_count() const {
 818     assert_arguments_profiling_enabled();
 819     if (TypeProfileArgsLimit > 1) {
 820       return _base_off + header_cell_count() + _pd->int_at_unchecked(cell_count_global_offset());
 821     } else {
 822       return _base_off + TypeStackSlotEntries::per_arg_count();
 823     }
 824   }
 825 
 826   // offset of cell for stack slot for entry i within this block of cells for a TypeStackSlotEntries
 827   static int stack_slot_local_offset(int i) {
 828     assert_arguments_profiling_enabled();
 829     return header_cell_count() + i * per_arg_cell_count + stack_slot_entry;
 830   }
 831 
 832   // offset of cell for type for entry i within this block of cells for a TypeStackSlotEntries
 833   static int type_local_offset(int i) {
 834     return header_cell_count() + i * per_arg_cell_count + type_entry;
 835   }
 836 
 837   // stack slot for entry i
 838   uint stack_slot(int i) const {
 839     assert(i >= 0 && i < number_of_arguments(), "oob");
 840     return _pd->uint_at(stack_slot_global_offset(i));
 841   }
 842 
 843   // set stack slot for entry i
 844   void set_stack_slot(int i, uint num) {
 845     assert(i >= 0 && i < number_of_arguments(), "oob");
 846     _pd->set_uint_at(stack_slot_global_offset(i), num);
 847   }
 848 
 849   // type for entry i
 850   intptr_t type(int i) const {
 851     assert(i >= 0 && i < number_of_arguments(), "oob");
 852     return _pd->intptr_at(type_global_offset(i));
 853   }
 854 
 855   // set type for entry i
 856   void set_type(int i, intptr_t k) {
 857     assert(i >= 0 && i < number_of_arguments(), "oob");
 858     _pd->set_intptr_at(type_global_offset(i), k);
 859   }
 860 
 861   static ByteSize per_arg_size() {
 862     return in_ByteSize(per_arg_cell_count * DataLayout::cell_size);
 863   }
 864 
 865   static int per_arg_count() {
 866     return per_arg_cell_count ;
 867   }
 868 
 869   // Code generation support
 870    static ByteSize cell_count_offset() {
 871      return in_ByteSize(cell_count_local_offset() * DataLayout::cell_size);




















 872    }
 873 
 874    static ByteSize args_data_offset() {
 875      return in_ByteSize(header_cell_count() * DataLayout::cell_size);
 876    }
 877 
 878    static ByteSize stack_slot_offset(int i) {
 879      return in_ByteSize(stack_slot_local_offset(i) * DataLayout::cell_size);








 880    }
 881 
 882    static ByteSize type_offset(int i) {
 883      return in_ByteSize(type_local_offset(i) * DataLayout::cell_size);
 884    }
 885 
 886   // GC support
 887   void clean_weak_klass_links(BoolObjectClosure* is_alive_closure);
 888 
 889 #ifndef PRODUCT
 890   void print_data_on(outputStream* st) const;
 891 #endif
 892 };
 893 























































 894 // CallTypeData
 895 //
 896 // A CallTypeData is used to access profiling information about a non
 897 // virtual call for which we collect type information about arguments.

 898 class CallTypeData : public CounterData {
 899 private:

 900   TypeStackSlotEntries _args;


























 901 
 902 public:
 903   CallTypeData(DataLayout* layout) :
 904     CounterData(layout), _args(CounterData::static_cell_count(), this)  {



 905     assert(layout->tag() == DataLayout::call_type_data_tag, "wrong type");
 906   }
 907 
 908   const TypeStackSlotEntries* args() const { return &_args; }








 909 
 910   virtual bool is_CallTypeData() const { return true; }
 911 
 912   static int static_cell_count() {
 913     return -1;
 914   }
 915 
 916   static int compute_cell_count(BytecodeStream* stream) {
 917     return CounterData::static_cell_count() + TypeStackSlotEntries::compute_cell_count(stream);
 918   }
 919 
 920   static void initialize(DataLayout* dl, int cell_count) {
 921     TypeStackSlotEntries::initialize(dl, CounterData::static_cell_count(), cell_count);
 922   }
 923 
 924   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo) {
 925     _args.post_initialize(stream);
 926   }
 927 
 928   virtual int cell_count() const {
 929     return _args.cell_count();


 930   }
 931 
 932   uint number_of_arguments() const {
 933     return args()->number_of_arguments();
 934   }
 935 
 936   void set_argument_type(int i, Klass* k) {

 937     intptr_t current = _args.type(i);
 938     _args.set_type(i, TypeEntries::with_status(k, current));
 939   }
 940 
















 941   // Code generation support
 942   static ByteSize args_data_offset() {
 943     return cell_offset(CounterData::static_cell_count()) + TypeStackSlotEntries::args_data_offset();
 944   }
 945 
 946   // GC support
 947   virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure) {

 948     _args.clean_weak_klass_links(is_alive_closure);
 949   }




 950 
 951 #ifndef PRODUCT
 952   virtual void print_data_on(outputStream* st) const;
 953 #endif
 954 };
 955 
 956 // ReceiverTypeData
 957 //
 958 // A ReceiverTypeData is used to access profiling information about a
 959 // dynamic type check.  It consists of a counter which counts the total times
 960 // that the check is reached, and a series of (Klass*, count) pairs
 961 // which are used to store a type profile for the receiver of the check.
 962 class ReceiverTypeData : public CounterData {
 963 protected:
 964   enum {
 965     receiver0_offset = counter_cell_count,
 966     count0_offset,
 967     receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
 968   };
 969 


1081   }
1082 
1083   virtual int cell_count() const {
1084     return static_cell_count();
1085   }
1086 
1087   // Direct accessors
1088   static ByteSize virtual_call_data_size() {
1089     return cell_offset(static_cell_count());
1090   }
1091 
1092 #ifndef PRODUCT
1093   void print_data_on(outputStream* st) const;
1094 #endif
1095 };
1096 
1097 // VirtualCallTypeData
1098 //
1099 // A VirtualCallTypeData is used to access profiling information about
1100 // a virtual call for which we collect type information about
1101 // arguments.
1102 class VirtualCallTypeData : public VirtualCallData {
1103 private:

1104   TypeStackSlotEntries _args;


























1105 
1106 public:
1107   VirtualCallTypeData(DataLayout* layout) :
1108     VirtualCallData(layout), _args(VirtualCallData::static_cell_count(), this)  {



1109     assert(layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");
1110   }
1111 
1112   const TypeStackSlotEntries* args() const { return &_args; }








1113 
1114   virtual bool is_VirtualCallTypeData() const { return true; }
1115 
1116   static int static_cell_count() {
1117     return -1;
1118   }
1119 
1120   static int compute_cell_count(BytecodeStream* stream) {
1121     return VirtualCallData::static_cell_count() + TypeStackSlotEntries::compute_cell_count(stream);
1122   }
1123 
1124   static void initialize(DataLayout* dl, int cell_count) {
1125     TypeStackSlotEntries::initialize(dl, VirtualCallData::static_cell_count(), cell_count);
1126   }
1127 
1128   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo) {
1129     _args.post_initialize(stream);
1130   }
1131 
1132   virtual int cell_count() const {
1133     return _args.cell_count();


1134   }
1135 
1136   uint number_of_arguments() const {
1137     return args()->number_of_arguments();
1138   }
1139 
1140   void set_argument_type(int i, Klass* k) {

1141     intptr_t current = _args.type(i);
1142     _args.set_type(i, TypeEntries::with_status(k, current));
1143   }
1144 
















1145   // Code generation support
1146   static ByteSize args_data_offset() {
1147     return cell_offset(VirtualCallData::static_cell_count()) + TypeStackSlotEntries::args_data_offset();
1148   }
1149 
1150   // GC support
1151   virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure) {
1152     ReceiverTypeData::clean_weak_klass_links(is_alive_closure);

1153     _args.clean_weak_klass_links(is_alive_closure);
1154   }




1155 
1156 #ifndef PRODUCT
1157   virtual void print_data_on(outputStream* st) const;
1158 #endif
1159 };
1160 
1161 // RetData
1162 //
1163 // A RetData is used to access profiling information for a ret bytecode.
1164 // It is composed of a count of the number of times that the ret has
1165 // been executed, followed by a series of triples of the form
1166 // (bci, count, di) which count the number of times that some bci was the
1167 // target of the ret and cache a corresponding data displacement.
1168 class RetData : public CounterData {
1169 protected:
1170   enum {
1171     bci0_offset = counter_cell_count,
1172     count0_offset,
1173     displacement0_offset,
1174     ret_row_cell_count = (displacement0_offset + 1) - bci0_offset


1665   // What is the index of the first data entry?
1666   int first_di() const { return 0; }
1667 
1668   // Find or create an extra ProfileData:
1669   ProfileData* bci_to_extra_data(int bci, bool create_if_missing);
1670 
1671   // return the argument info cell
1672   ArgInfoData *arg_info();
1673 
1674   enum {
1675     no_type_profile = 0,
1676     type_profile_jsr292 = 1,
1677     type_profile_all = 2
1678   };
1679 
1680   static bool profile_jsr292(methodHandle m, int bci);
1681   static int profile_arguments_flag();
1682   static bool profile_arguments_jsr292_only();
1683   static bool profile_all_arguments();
1684   static bool profile_arguments_for_invoke(methodHandle m, int bci);




1685 
1686 public:
1687   static int header_size() {
1688     return sizeof(MethodData)/wordSize;
1689   }
1690 
1691   // Compute the size of a MethodData* before it is created.
1692   static int compute_allocation_size_in_bytes(methodHandle method);
1693   static int compute_allocation_size_in_words(methodHandle method);
1694   static int compute_extra_data_count(int data_size, int empty_bc_count);
1695 
1696   // Determine if a given bytecode can have profile information.
1697   static bool bytecode_has_profile(Bytecodes::Code code) {
1698     return bytecode_cell_count(code) != no_profile_data;
1699   }
1700 
1701   // reset into original state
1702   void init();
1703 
1704   // My size


1907   void set_size(int object_size_in_bytes) { _size = object_size_in_bytes; }
1908 
1909   // Printing
1910 #ifndef PRODUCT
1911   void print_on      (outputStream* st) const;
1912 #endif
1913   void print_value_on(outputStream* st) const;
1914 
1915 #ifndef PRODUCT
1916   // printing support for method data
1917   void print_data_on(outputStream* st) const;
1918 #endif
1919 
1920   const char* internal_name() const { return "{method data}"; }
1921 
1922   // verification
1923   void verify_on(outputStream* st);
1924   void verify_data_on(outputStream* st);
1925 
1926   static bool profile_arguments();

1927 };
1928 
1929 #endif // SHARE_VM_OOPS_METHODDATAOOP_HPP


 254 class ProfileData;
 255 class   BitData;
 256 class     CounterData;
 257 class       ReceiverTypeData;
 258 class         VirtualCallData;
 259 class           VirtualCallTypeData;
 260 class       RetData;
 261 class       CallTypeData;
 262 class   JumpData;
 263 class     BranchData;
 264 class   ArrayData;
 265 class     MultiBranchData;
 266 class     ArgInfoData;
 267 
 268 // ProfileData
 269 //
 270 // A ProfileData object is created to refer to a section of profiling
 271 // data in a structured way.
 272 class ProfileData : public ResourceObj {
 273   friend class TypeEntries;
 274   friend class ReturnTypeEntry;
 275   friend class TypeStackSlotEntries;
 276 private:
 277 #ifndef PRODUCT
 278   enum {
 279     tab_width_one = 16,
 280     tab_width_two = 36
 281   };
 282 #endif // !PRODUCT
 283 
 284   // This is a pointer to a section of profiling data.
 285   DataLayout* _data;
 286 
 287 protected:
 288   DataLayout* data() { return _data; }
 289   const DataLayout* data() const { return _data; }
 290 
 291   enum {
 292     cell_size = DataLayout::cell_size
 293   };
 294 


 727 
 728   intptr_t intptr_at(int index) const {
 729     return _pd->intptr_at(index);
 730   }
 731 };
 732 
 733 // Type entries used for arguments passed at a call and parameters on
 734 // method entry. 2 cells per entry: one for the type encoded as in
 735 // TypeEntries and one initialized with the stack slot where the
 736 // profiled object is to be found so that the interpreter can locate
 737 // it quickly.
 738 class TypeStackSlotEntries : public TypeEntries {
 739 
 740 private:
 741   enum {
 742     stack_slot_entry,
 743     type_entry,
 744     per_arg_cell_count
 745   };
 746 
















 747   // offset of cell for stack slot for entry i within ProfileData object
 748   int stack_slot_offset(int i) const {
 749     return _base_off + stack_slot_local_offset(i);
 750   }
 751 














 752 protected:
 753   const int _number_of_entries;
 754 
 755   // offset of cell for type for entry i within ProfileData object
 756   int type_offset(int i) const {
 757     return _base_off + type_local_offset(i);
 758   }
 759 
 760 public:
 761 
 762   TypeStackSlotEntries(int base_off, ProfileData* pd, int nb_entries)
 763     : TypeEntries(base_off, pd), _number_of_entries(nb_entries) {}











 764 
 765   static int compute_cell_count(Symbol* signature, int max);











 766 
 767   void post_initialize(Symbol* signature, bool has_receiver);







 768 
 769   // offset of cell for stack slot for entry i within this block of cells for a TypeStackSlotEntries
 770   static int stack_slot_local_offset(int i) {
 771     return i * per_arg_cell_count + stack_slot_entry;

 772   }
 773 
 774   // offset of cell for type for entry i within this block of cells for a TypeStackSlotEntries
 775   static int type_local_offset(int i) {
 776     return i * per_arg_cell_count + type_entry;
 777   }
 778 
 779   // stack slot for entry i
 780   uint stack_slot(int i) const {
 781     assert(i >= 0 && i < _number_of_entries, "oob");
 782     return _pd->uint_at(stack_slot_offset(i));
 783   }
 784 
 785   // set stack slot for entry i
 786   void set_stack_slot(int i, uint num) {
 787     assert(i >= 0 && i < _number_of_entries, "oob");
 788     _pd->set_uint_at(stack_slot_offset(i), num);
 789   }
 790 
 791   // type for entry i
 792   intptr_t type(int i) const {
 793     assert(i >= 0 && i < _number_of_entries, "oob");
 794     return _pd->intptr_at(type_offset(i));
 795   }
 796 
 797   // set type for entry i
 798   void set_type(int i, intptr_t k) {
 799     assert(i >= 0 && i < _number_of_entries, "oob");
 800     _pd->set_intptr_at(type_offset(i), k);
 801   }
 802 
 803   static ByteSize per_arg_size() {
 804     return in_ByteSize(per_arg_cell_count * DataLayout::cell_size);
 805   }
 806 
 807   static int per_arg_count() {
 808     return per_arg_cell_count ;
 809   }
 810 
 811   // GC support
 812   void clean_weak_klass_links(BoolObjectClosure* is_alive_closure);
 813 
 814 #ifndef PRODUCT
 815   void print_data_on(outputStream* st) const;
 816 #endif
 817 };
 818 
 819 // Type entry used for return from a call. A single cell to record the
 820 // type.
 821 class ReturnTypeEntry : public TypeEntries {
 822 
 823 private:
 824   enum {
 825     cell_count = 1
 826   };
 827 
 828 public:
 829   ReturnTypeEntry(int base_off, ProfileData* pd)
 830     : TypeEntries(base_off, pd) {}
 831 
 832   void post_initialize() {
 833     set_type(type_none());
 834   }
 835 
 836   intptr_t type() const {
 837     return _pd->intptr_at(_base_off);
 838   }
 839 
 840   void set_type(intptr_t k) {
 841     _pd->set_intptr_at(_base_off, k);
 842   }
 843 
 844   static int static_cell_count() {
 845     return cell_count;
 846   }
 847 
 848   static ByteSize size() {
 849     return in_ByteSize(cell_count * DataLayout::cell_size);
 850   }
 851 
 852   ByteSize type_offset() {
 853     return DataLayout::cell_offset(_base_off);
 854   }
 855 
 856   // GC support
 857   void clean_weak_klass_links(BoolObjectClosure* is_alive_closure);
 858 
 859 #ifndef PRODUCT
 860   void print_data_on(outputStream* st) const;
 861 #endif
 862 };
 863 
 864 // Entries to collect type information at a call: contains arguments
 865 // (TypeStackSlotEntries), a return type (ReturnTypeEntry) and a
 866 // number of cells. Because the number of cells for the return type is
 867 // smaller than the number of cells for the type of an arguments, the
 868 // number of cells is used to tell how many arguments are profiled and
 869 // whether a return value is profiled. See has_arguments() and
 870 // has_return().
 871 class TypeEntriesAtCall {
 872 private:
 873   static int stack_slot_local_offset(int i) {
 874     return header_cell_count() + TypeStackSlotEntries::stack_slot_local_offset(i);
 875   }
 876 
 877   static int argument_type_local_offset(int i) {
 878     return header_cell_count() + TypeStackSlotEntries::type_local_offset(i);;
 879   }
 880 
 881 public:
 882 
 883   static int header_cell_count() {
 884     return 1;
 885   }
 886 
 887   static int cell_count_local_offset() {
 888     return 0;
 889   }
 890 
 891   static int compute_cell_count(BytecodeStream* stream);
 892 
 893   static void initialize(DataLayout* dl, int base, int cell_count) {
 894     int off = base + cell_count_local_offset();
 895     dl->set_cell_at(off, cell_count - base - header_cell_count());
 896   }
 897 
 898   static bool arguments_profiling_enabled();
 899   static bool return_profiling_enabled();
 900 
 901   // Code generation support
 902   static ByteSize cell_count_offset() {
 903     return in_ByteSize(cell_count_local_offset() * DataLayout::cell_size);
 904   }
 905 
 906   static ByteSize args_data_offset() {
 907     return in_ByteSize(header_cell_count() * DataLayout::cell_size);
 908   }
 909 
 910   static ByteSize stack_slot_offset(int i) {
 911     return in_ByteSize(stack_slot_local_offset(i) * DataLayout::cell_size);
 912   }
 913 
 914   static ByteSize argument_type_offset(int i) {
 915     return in_ByteSize(argument_type_local_offset(i) * DataLayout::cell_size);
 916   }
 917 };
 918 
 919 // CallTypeData
 920 //
 921 // A CallTypeData is used to access profiling information about a non
 922 // virtual call for which we collect type information about arguments
 923 // and return value.
 924 class CallTypeData : public CounterData {
 925 private:
 926   // entries for arguments if any
 927   TypeStackSlotEntries _args;
 928   // entry for return type if any
 929   ReturnTypeEntry _ret;
 930 
 931   int cell_count_global_offset() const {
 932     return CounterData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
 933   }
 934 
 935   // number of cells not counting the header
 936   int cell_count_no_header() const {
 937     return uint_at(cell_count_global_offset());
 938   }
 939 
 940   void check_number_of_arguments(uint total) {
 941     assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
 942   }
 943 
 944 protected:
 945   // An entry for a return value takes less space than an entry for an
 946   // argument so if the number of cells exceeds the number of cells
 947   // needed for an argument, this object contains type information for
 948   // at least one argument.
 949   bool has_arguments() const {
 950     bool res = cell_count_no_header() >= TypeStackSlotEntries::per_arg_count();
 951     assert (!res || TypeEntriesAtCall::arguments_profiling_enabled(), "no profiling of arguments");
 952     return res;
 953   }
 954 
 955 public:
 956   CallTypeData(DataLayout* layout) :
 957     CounterData(layout),
 958     _args(CounterData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), this, number_of_arguments()),
 959     _ret(cell_count() - ReturnTypeEntry::static_cell_count(), this)
 960   {
 961     assert(layout->tag() == DataLayout::call_type_data_tag, "wrong type");
 962   }
 963 
 964   const TypeStackSlotEntries* args() const {
 965     assert(has_arguments(), "no profiling of arguments");
 966     return &_args;
 967   }
 968 
 969   const ReturnTypeEntry* ret() const {
 970     assert(has_return(), "no profiling of return value");
 971     return &_ret;
 972   }
 973 
 974   virtual bool is_CallTypeData() const { return true; }
 975 
 976   static int static_cell_count() {
 977     return -1;
 978   }
 979 
 980   static int compute_cell_count(BytecodeStream* stream) {
 981     return CounterData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
 982   }
 983 
 984   static void initialize(DataLayout* dl, int cell_count) {
 985     TypeEntriesAtCall::initialize(dl, CounterData::static_cell_count(), cell_count);
 986   }
 987 
 988   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);


 989 
 990   virtual int cell_count() const {
 991     return CounterData::static_cell_count() +
 992       TypeEntriesAtCall::header_cell_count() +
 993       int_at_unchecked(cell_count_global_offset());
 994   }
 995 
 996   uint number_of_arguments() const {
 997     return cell_count_no_header() / TypeStackSlotEntries::per_arg_count();
 998   }
 999 
1000   void set_argument_type(int i, Klass* k) {
1001     assert(has_arguments(), "no arguments!");
1002     intptr_t current = _args.type(i);
1003     _args.set_type(i, TypeEntries::with_status(k, current));
1004   }
1005 
1006   void set_return_type(Klass* k) {
1007     assert(has_return(), "no return!");
1008     intptr_t current = _ret.type();
1009     _ret.set_type(TypeEntries::with_status(k, current));
1010   }
1011 
1012   // An entry for a return value takes less space than an entry for an
1013   // argument, so if the remainder of the number of cells divided by
1014   // the number of cells for an argument is not null, a return value
1015   // is profiled in this object.
1016   bool has_return() const {
1017     bool res = (cell_count_no_header() % TypeStackSlotEntries::per_arg_count()) != 0;
1018     assert (!res || TypeEntriesAtCall::return_profiling_enabled(), "no profiling of return values");
1019     return res;
1020   }
1021 
1022   // Code generation support
1023   static ByteSize args_data_offset() {
1024     return cell_offset(CounterData::static_cell_count()) + TypeEntriesAtCall::args_data_offset();
1025   }
1026 
1027   // GC support
1028   virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure) {
1029     if (has_arguments()) {
1030       _args.clean_weak_klass_links(is_alive_closure);
1031     }
1032     if (has_return()) {
1033       _ret.clean_weak_klass_links(is_alive_closure);
1034     }
1035   }
1036 
1037 #ifndef PRODUCT
1038   virtual void print_data_on(outputStream* st) const;
1039 #endif
1040 };
1041 
1042 // ReceiverTypeData
1043 //
1044 // A ReceiverTypeData is used to access profiling information about a
1045 // dynamic type check.  It consists of a counter which counts the total times
1046 // that the check is reached, and a series of (Klass*, count) pairs
1047 // which are used to store a type profile for the receiver of the check.
1048 class ReceiverTypeData : public CounterData {
1049 protected:
1050   enum {
1051     receiver0_offset = counter_cell_count,
1052     count0_offset,
1053     receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
1054   };
1055 


1167   }
1168 
1169   virtual int cell_count() const {
1170     return static_cell_count();
1171   }
1172 
1173   // Direct accessors
1174   static ByteSize virtual_call_data_size() {
1175     return cell_offset(static_cell_count());
1176   }
1177 
1178 #ifndef PRODUCT
1179   void print_data_on(outputStream* st) const;
1180 #endif
1181 };
1182 
1183 // VirtualCallTypeData
1184 //
1185 // A VirtualCallTypeData is used to access profiling information about
1186 // a virtual call for which we collect type information about
1187 // arguments and return value.
1188 class VirtualCallTypeData : public VirtualCallData {
1189 private:
1190   // entries for arguments if any
1191   TypeStackSlotEntries _args;
1192   // entry for return type if any
1193   ReturnTypeEntry _ret;
1194 
1195   int cell_count_global_offset() const {
1196     return VirtualCallData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
1197   }
1198 
1199   // number of cells not counting the header
1200   int cell_count_no_header() const {
1201     return uint_at(cell_count_global_offset());
1202   }
1203 
1204   void check_number_of_arguments(uint total) {
1205     assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
1206   }
1207 
1208 protected:
1209   // An entry for a return value takes less space than an entry for an
1210   // argument so if the number of cells exceeds the number of cells
1211   // needed for an argument, this object contains type information for
1212   // at least one argument.
1213   bool has_arguments() const {
1214     bool res = cell_count_no_header() >= TypeStackSlotEntries::per_arg_count();
1215     assert (!res || TypeEntriesAtCall::arguments_profiling_enabled(), "no profiling of arguments");
1216     return res;
1217   }
1218 
1219 public:
1220   VirtualCallTypeData(DataLayout* layout) :
1221     VirtualCallData(layout),
1222     _args(VirtualCallData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), this, number_of_arguments()),
1223     _ret(cell_count() - ReturnTypeEntry::static_cell_count(), this)
1224   {
1225     assert(layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");
1226   }
1227 
1228   const TypeStackSlotEntries* args() const {
1229     assert(has_arguments(), "no profiling of arguments");
1230     return &_args;
1231   }
1232 
1233   const ReturnTypeEntry* ret() const {
1234     assert(has_return(), "no profiling of return value");
1235     return &_ret;
1236   }
1237 
1238   virtual bool is_VirtualCallTypeData() const { return true; }
1239 
1240   static int static_cell_count() {
1241     return -1;
1242   }
1243 
1244   static int compute_cell_count(BytecodeStream* stream) {
1245     return VirtualCallData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1246   }
1247 
1248   static void initialize(DataLayout* dl, int cell_count) {
1249     TypeEntriesAtCall::initialize(dl, VirtualCallData::static_cell_count(), cell_count);
1250   }
1251 
1252   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);


1253 
1254   virtual int cell_count() const {
1255     return VirtualCallData::static_cell_count() +
1256       TypeEntriesAtCall::header_cell_count() +
1257       int_at_unchecked(cell_count_global_offset());
1258   }
1259 
1260   uint number_of_arguments() const {
1261     return cell_count_no_header() / TypeStackSlotEntries::per_arg_count();
1262   }
1263 
1264   void set_argument_type(int i, Klass* k) {
1265     assert(has_arguments(), "no arguments!");
1266     intptr_t current = _args.type(i);
1267     _args.set_type(i, TypeEntries::with_status(k, current));
1268   }
1269 
1270   void set_return_type(Klass* k) {
1271     assert(has_return(), "no return!");
1272     intptr_t current = _ret.type();
1273     _ret.set_type(TypeEntries::with_status(k, current));
1274   }
1275 
1276   // An entry for a return value takes less space than an entry for an
1277   // argument, so if the remainder of the number of cells divided by
1278   // the number of cells for an argument is not null, a return value
1279   // is profiled in this object.
1280   bool has_return() const {
1281     bool res = (cell_count_no_header() % TypeStackSlotEntries::per_arg_count()) != 0;
1282     assert (!res || TypeEntriesAtCall::return_profiling_enabled(), "no profiling of return values");
1283     return res;
1284   }
1285 
1286   // Code generation support
1287   static ByteSize args_data_offset() {
1288     return cell_offset(VirtualCallData::static_cell_count()) + TypeEntriesAtCall::args_data_offset();
1289   }
1290 
1291   // GC support
1292   virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure) {
1293     ReceiverTypeData::clean_weak_klass_links(is_alive_closure);
1294     if (has_arguments()) {
1295       _args.clean_weak_klass_links(is_alive_closure);
1296     }
1297     if (has_return()) {
1298       _ret.clean_weak_klass_links(is_alive_closure);
1299     }
1300   }
1301 
1302 #ifndef PRODUCT
1303   virtual void print_data_on(outputStream* st) const;
1304 #endif
1305 };
1306 
1307 // RetData
1308 //
1309 // A RetData is used to access profiling information for a ret bytecode.
1310 // It is composed of a count of the number of times that the ret has
1311 // been executed, followed by a series of triples of the form
1312 // (bci, count, di) which count the number of times that some bci was the
1313 // target of the ret and cache a corresponding data displacement.
1314 class RetData : public CounterData {
1315 protected:
1316   enum {
1317     bci0_offset = counter_cell_count,
1318     count0_offset,
1319     displacement0_offset,
1320     ret_row_cell_count = (displacement0_offset + 1) - bci0_offset


1811   // What is the index of the first data entry?
1812   int first_di() const { return 0; }
1813 
1814   // Find or create an extra ProfileData:
1815   ProfileData* bci_to_extra_data(int bci, bool create_if_missing);
1816 
1817   // return the argument info cell
1818   ArgInfoData *arg_info();
1819 
1820   enum {
1821     no_type_profile = 0,
1822     type_profile_jsr292 = 1,
1823     type_profile_all = 2
1824   };
1825 
1826   static bool profile_jsr292(methodHandle m, int bci);
1827   static int profile_arguments_flag();
1828   static bool profile_arguments_jsr292_only();
1829   static bool profile_all_arguments();
1830   static bool profile_arguments_for_invoke(methodHandle m, int bci);
1831   static int profile_return_flag();
1832   static bool profile_return_jsr292_only();
1833   static bool profile_all_return();
1834   static bool profile_return_for_invoke(methodHandle m, int bci);
1835 
1836 public:
1837   static int header_size() {
1838     return sizeof(MethodData)/wordSize;
1839   }
1840 
1841   // Compute the size of a MethodData* before it is created.
1842   static int compute_allocation_size_in_bytes(methodHandle method);
1843   static int compute_allocation_size_in_words(methodHandle method);
1844   static int compute_extra_data_count(int data_size, int empty_bc_count);
1845 
1846   // Determine if a given bytecode can have profile information.
1847   static bool bytecode_has_profile(Bytecodes::Code code) {
1848     return bytecode_cell_count(code) != no_profile_data;
1849   }
1850 
1851   // reset into original state
1852   void init();
1853 
1854   // My size


2057   void set_size(int object_size_in_bytes) { _size = object_size_in_bytes; }
2058 
2059   // Printing
2060 #ifndef PRODUCT
2061   void print_on      (outputStream* st) const;
2062 #endif
2063   void print_value_on(outputStream* st) const;
2064 
2065 #ifndef PRODUCT
2066   // printing support for method data
2067   void print_data_on(outputStream* st) const;
2068 #endif
2069 
2070   const char* internal_name() const { return "{method data}"; }
2071 
2072   // verification
2073   void verify_on(outputStream* st);
2074   void verify_data_on(outputStream* st);
2075 
2076   static bool profile_arguments();
2077   static bool profile_return();
2078 };
2079 
2080 #endif // SHARE_VM_OOPS_METHODDATAOOP_HPP
src/share/vm/oops/methodData.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File