< prev index next >

src/hotspot/share/oops/methodData.hpp

Print this page

 108 
 109   enum {
 110     cell_size = sizeof(intptr_t)
 111   };
 112 
 113   // Tag values
 114   enum {
 115     no_tag,
 116     bit_data_tag,
 117     counter_data_tag,
 118     jump_data_tag,
 119     receiver_type_data_tag,
 120     virtual_call_data_tag,
 121     ret_data_tag,
 122     branch_data_tag,
 123     multi_branch_data_tag,
 124     arg_info_data_tag,
 125     call_type_data_tag,
 126     virtual_call_type_data_tag,
 127     parameters_type_data_tag,
 128     speculative_trap_data_tag


 129   };
 130 
 131   enum {
 132     // The trap state breaks down as [recompile:1 | reason:31].
 133     // This further breakdown is defined in deoptimization.cpp.
 134     // See Deoptimization::trap_state_reason for an assert that
 135     // trap_bits is big enough to hold reasons < Reason_RECORDED_LIMIT.
 136     //
 137     // The trap_state is collected only if ProfileTraps is true.
 138     trap_bits = 1+31,  // 31: enough to distinguish [0..Reason_RECORDED_LIMIT].
 139     trap_mask = -1,
 140     first_flag = 0
 141   };
 142 
 143   // Size computation
 144   static int header_size_in_bytes() {
 145     return header_size_in_cells() * cell_size;
 146   }
 147   static int header_size_in_cells() {
 148     return LP64_ONLY(1) NOT_LP64(2);

 244     return DataLayout::compute_size_in_bytes(cells);
 245   }
 246   int cell_count();
 247 
 248   // GC support
 249   void clean_weak_klass_links(bool always_clean);
 250 };
 251 
 252 
 253 // ProfileData class hierarchy
 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 class     ParametersTypeData;
 268 class   SpeculativeTrapData;

 269 
 270 // ProfileData
 271 //
 272 // A ProfileData object is created to refer to a section of profiling
 273 // data in a structured way.
 274 class ProfileData : public ResourceObj {
 275   friend class TypeEntries;
 276   friend class ReturnTypeEntry;
 277   friend class TypeStackSlotEntries;
 278 private:
 279   enum {
 280     tab_width_one = 16,
 281     tab_width_two = 36
 282   };
 283 
 284   // This is a pointer to a section of profiling data.
 285   DataLayout* _data;
 286 
 287   char* print_data_on_helper(const MethodData* md) const;
 288 
 289 protected:
 290   DataLayout* data() { return _data; }
 291   const DataLayout* data() const { return _data; }
 292 
 293   enum {
 294     cell_size = DataLayout::cell_size
 295   };
 296 

 377   }
 378   void set_trap_state(int new_state) {
 379     data()->set_trap_state(new_state);
 380   }
 381 
 382   // Type checking
 383   virtual bool is_BitData()         const { return false; }
 384   virtual bool is_CounterData()     const { return false; }
 385   virtual bool is_JumpData()        const { return false; }
 386   virtual bool is_ReceiverTypeData()const { return false; }
 387   virtual bool is_VirtualCallData() const { return false; }
 388   virtual bool is_RetData()         const { return false; }
 389   virtual bool is_BranchData()      const { return false; }
 390   virtual bool is_ArrayData()       const { return false; }
 391   virtual bool is_MultiBranchData() const { return false; }
 392   virtual bool is_ArgInfoData()     const { return false; }
 393   virtual bool is_CallTypeData()    const { return false; }
 394   virtual bool is_VirtualCallTypeData()const { return false; }
 395   virtual bool is_ParametersTypeData() const { return false; }
 396   virtual bool is_SpeculativeTrapData()const { return false; }


 397 
 398 
 399   BitData* as_BitData() const {
 400     assert(is_BitData(), "wrong type");
 401     return is_BitData()         ? (BitData*)        this : NULL;
 402   }
 403   CounterData* as_CounterData() const {
 404     assert(is_CounterData(), "wrong type");
 405     return is_CounterData()     ? (CounterData*)    this : NULL;
 406   }
 407   JumpData* as_JumpData() const {
 408     assert(is_JumpData(), "wrong type");
 409     return is_JumpData()        ? (JumpData*)       this : NULL;
 410   }
 411   ReceiverTypeData* as_ReceiverTypeData() const {
 412     assert(is_ReceiverTypeData(), "wrong type");
 413     return is_ReceiverTypeData() ? (ReceiverTypeData*)this : NULL;
 414   }
 415   VirtualCallData* as_VirtualCallData() const {
 416     assert(is_VirtualCallData(), "wrong type");

 435   ArgInfoData* as_ArgInfoData() const {
 436     assert(is_ArgInfoData(), "wrong type");
 437     return is_ArgInfoData() ? (ArgInfoData*)this : NULL;
 438   }
 439   CallTypeData* as_CallTypeData() const {
 440     assert(is_CallTypeData(), "wrong type");
 441     return is_CallTypeData() ? (CallTypeData*)this : NULL;
 442   }
 443   VirtualCallTypeData* as_VirtualCallTypeData() const {
 444     assert(is_VirtualCallTypeData(), "wrong type");
 445     return is_VirtualCallTypeData() ? (VirtualCallTypeData*)this : NULL;
 446   }
 447   ParametersTypeData* as_ParametersTypeData() const {
 448     assert(is_ParametersTypeData(), "wrong type");
 449     return is_ParametersTypeData() ? (ParametersTypeData*)this : NULL;
 450   }
 451   SpeculativeTrapData* as_SpeculativeTrapData() const {
 452     assert(is_SpeculativeTrapData(), "wrong type");
 453     return is_SpeculativeTrapData() ? (SpeculativeTrapData*)this : NULL;
 454   }








 455 
 456 
 457   // Subclass specific initialization
 458   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo) {}
 459 
 460   // GC support
 461   virtual void clean_weak_klass_links(bool always_clean) {}
 462 
 463   // CI translation: ProfileData can represent both MethodDataOop data
 464   // as well as CIMethodData data. This function is provided for translating
 465   // an oop in a ProfileData to the ci equivalent. Generally speaking,
 466   // most ProfileData don't require any translation, so we provide the null
 467   // translation here, and the required translators are in the ci subclasses.
 468   virtual void translate_from(const ProfileData* data) {}
 469 
 470   virtual void print_data_on(outputStream* st, const char* extra = NULL) const {
 471     ShouldNotReachHere();
 472   }
 473 
 474   void print_data_on(outputStream* st, const MethodData* md) const;

 589 // branch.  It is a counter, used for counting the number of branches,
 590 // plus a data displacement, used for realigning the data pointer to
 591 // the corresponding target bci.
 592 class JumpData : public ProfileData {
 593   friend class VMStructs;
 594   friend class JVMCIVMStructs;
 595 protected:
 596   enum {
 597     taken_off_set,
 598     displacement_off_set,
 599     jump_cell_count
 600   };
 601 
 602   void set_displacement(int displacement) {
 603     set_int_at(displacement_off_set, displacement);
 604   }
 605 
 606 public:
 607   JumpData(DataLayout* layout) : ProfileData(layout) {
 608     assert(layout->tag() == DataLayout::jump_data_tag ||
 609       layout->tag() == DataLayout::branch_data_tag, "wrong type");

 610   }
 611 
 612   virtual bool is_JumpData() const { return true; }
 613 
 614   static int static_cell_count() {
 615     return jump_cell_count;
 616   }
 617 
 618   virtual int cell_count() const {
 619     return static_cell_count();
 620   }
 621 
 622   // Direct accessor
 623   uint taken() const {
 624     return uint_at(taken_off_set);
 625   }
 626 
 627   void set_taken(uint cnt) {
 628     set_uint_at(taken_off_set, cnt);
 629   }

 825   static ByteSize per_arg_size() {
 826     return in_ByteSize(per_arg_cell_count * DataLayout::cell_size);
 827   }
 828 
 829   static int per_arg_count() {
 830     return per_arg_cell_count;
 831   }
 832 
 833   ByteSize type_offset(int i) const {
 834     return DataLayout::cell_offset(type_offset_in_cells(i));
 835   }
 836 
 837   // GC support
 838   void clean_weak_klass_links(bool always_clean);
 839 
 840   void print_data_on(outputStream* st) const;
 841 };
 842 
 843 // Type entry used for return from a call. A single cell to record the
 844 // type.
 845 class ReturnTypeEntry : public TypeEntries {
 846 
 847 private:
 848   enum {
 849     cell_count = 1
 850   };
 851 
 852 public:
 853   ReturnTypeEntry(int base_off)
 854     : TypeEntries(base_off) {}
 855 
 856   void post_initialize() {
 857     set_type(type_none());
 858   }
 859 
 860   intptr_t type() const {
 861     return _pd->intptr_at(_base_off);
 862   }
 863 
 864   void set_type(intptr_t k) {
 865     _pd->set_intptr_at(_base_off, k);
 866   }
 867 
 868   static int static_cell_count() {
 869     return cell_count;
 870   }
 871 
 872   static ByteSize size() {
 873     return in_ByteSize(cell_count * DataLayout::cell_size);
 874   }
 875 
 876   ByteSize type_offset() {
 877     return DataLayout::cell_offset(_base_off);
 878   }
 879 
 880   // GC support
 881   void clean_weak_klass_links(bool always_clean);
 882 
 883   void print_data_on(outputStream* st) const;
 884 };
 885 
 886 // Entries to collect type information at a call: contains arguments
 887 // (TypeStackSlotEntries), a return type (ReturnTypeEntry) and a
 888 // number of cells. Because the number of cells for the return type is
 889 // smaller than the number of cells for the type of an arguments, the
 890 // number of cells is used to tell how many arguments are profiled and
 891 // whether a return value is profiled. See has_arguments() and
 892 // has_return().
 893 class TypeEntriesAtCall {
 894 private:
 895   static int stack_slot_local_offset(int i) {
 896     return header_cell_count() + TypeStackSlotEntries::stack_slot_local_offset(i);
 897   }
 898 
 899   static int argument_type_local_offset(int i) {
 900     return header_cell_count() + TypeStackSlotEntries::type_local_offset(i);
 901   }
 902 
 903 public:
 904 
 905   static int header_cell_count() {
 906     return 1;
 907   }

 921   static bool return_profiling_enabled();
 922 
 923   // Code generation support
 924   static ByteSize cell_count_offset() {
 925     return in_ByteSize(cell_count_local_offset() * DataLayout::cell_size);
 926   }
 927 
 928   static ByteSize args_data_offset() {
 929     return in_ByteSize(header_cell_count() * DataLayout::cell_size);
 930   }
 931 
 932   static ByteSize stack_slot_offset(int i) {
 933     return in_ByteSize(stack_slot_local_offset(i) * DataLayout::cell_size);
 934   }
 935 
 936   static ByteSize argument_type_offset(int i) {
 937     return in_ByteSize(argument_type_local_offset(i) * DataLayout::cell_size);
 938   }
 939 
 940   static ByteSize return_only_size() {
 941     return ReturnTypeEntry::size() + in_ByteSize(header_cell_count() * DataLayout::cell_size);
 942   }
 943 
 944 };
 945 
 946 // CallTypeData
 947 //
 948 // A CallTypeData is used to access profiling information about a non
 949 // virtual call for which we collect type information about arguments
 950 // and return value.
 951 class CallTypeData : public CounterData {
 952 private:
 953   // entries for arguments if any
 954   TypeStackSlotEntries _args;
 955   // entry for return type if any
 956   ReturnTypeEntry _ret;
 957 
 958   int cell_count_global_offset() const {
 959     return CounterData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
 960   }
 961 
 962   // number of cells not counting the header
 963   int cell_count_no_header() const {
 964     return uint_at(cell_count_global_offset());
 965   }
 966 
 967   void check_number_of_arguments(int total) {
 968     assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
 969   }
 970 
 971 public:
 972   CallTypeData(DataLayout* layout) :
 973     CounterData(layout),
 974     _args(CounterData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()),
 975     _ret(cell_count() - ReturnTypeEntry::static_cell_count())
 976   {
 977     assert(layout->tag() == DataLayout::call_type_data_tag, "wrong type");
 978     // Some compilers (VC++) don't want this passed in member initialization list
 979     _args.set_profile_data(this);
 980     _ret.set_profile_data(this);
 981   }
 982 
 983   const TypeStackSlotEntries* args() const {
 984     assert(has_arguments(), "no profiling of arguments");
 985     return &_args;
 986   }
 987 
 988   const ReturnTypeEntry* ret() const {
 989     assert(has_return(), "no profiling of return value");
 990     return &_ret;
 991   }
 992 
 993   virtual bool is_CallTypeData() const { return true; }
 994 
 995   static int static_cell_count() {
 996     return -1;
 997   }
 998 
 999   static int compute_cell_count(BytecodeStream* stream) {
1000     return CounterData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1001   }
1002 
1003   static void initialize(DataLayout* dl, int cell_count) {
1004     TypeEntriesAtCall::initialize(dl, CounterData::static_cell_count(), cell_count);
1005   }
1006 
1007   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);
1008 

1239 
1240   // Direct accessors
1241   static ByteSize virtual_call_data_size() {
1242     return cell_offset(static_cell_count());
1243   }
1244 
1245   void print_method_data_on(outputStream* st) const NOT_JVMCI_RETURN;
1246   void print_data_on(outputStream* st, const char* extra = NULL) const;
1247 };
1248 
1249 // VirtualCallTypeData
1250 //
1251 // A VirtualCallTypeData is used to access profiling information about
1252 // a virtual call for which we collect type information about
1253 // arguments and return value.
1254 class VirtualCallTypeData : public VirtualCallData {
1255 private:
1256   // entries for arguments if any
1257   TypeStackSlotEntries _args;
1258   // entry for return type if any
1259   ReturnTypeEntry _ret;
1260 
1261   int cell_count_global_offset() const {
1262     return VirtualCallData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
1263   }
1264 
1265   // number of cells not counting the header
1266   int cell_count_no_header() const {
1267     return uint_at(cell_count_global_offset());
1268   }
1269 
1270   void check_number_of_arguments(int total) {
1271     assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
1272   }
1273 
1274 public:
1275   VirtualCallTypeData(DataLayout* layout) :
1276     VirtualCallData(layout),
1277     _args(VirtualCallData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()),
1278     _ret(cell_count() - ReturnTypeEntry::static_cell_count())
1279   {
1280     assert(layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");
1281     // Some compilers (VC++) don't want this passed in member initialization list
1282     _args.set_profile_data(this);
1283     _ret.set_profile_data(this);
1284   }
1285 
1286   const TypeStackSlotEntries* args() const {
1287     assert(has_arguments(), "no profiling of arguments");
1288     return &_args;
1289   }
1290 
1291   const ReturnTypeEntry* ret() const {
1292     assert(has_return(), "no profiling of return value");
1293     return &_ret;
1294   }
1295 
1296   virtual bool is_VirtualCallTypeData() const { return true; }
1297 
1298   static int static_cell_count() {
1299     return -1;
1300   }
1301 
1302   static int compute_cell_count(BytecodeStream* stream) {
1303     return VirtualCallData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1304   }
1305 
1306   static void initialize(DataLayout* dl, int cell_count) {
1307     TypeEntriesAtCall::initialize(dl, VirtualCallData::static_cell_count(), cell_count);
1308   }
1309 
1310   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);
1311 

1473 // BranchData
1474 //
1475 // A BranchData is used to access profiling data for a two-way branch.
1476 // It consists of taken and not_taken counts as well as a data displacement
1477 // for the taken case.
1478 class BranchData : public JumpData {
1479   friend class VMStructs;
1480   friend class JVMCIVMStructs;
1481 protected:
1482   enum {
1483     not_taken_off_set = jump_cell_count,
1484     branch_cell_count
1485   };
1486 
1487   void set_displacement(int displacement) {
1488     set_int_at(displacement_off_set, displacement);
1489   }
1490 
1491 public:
1492   BranchData(DataLayout* layout) : JumpData(layout) {
1493     assert(layout->tag() == DataLayout::branch_data_tag, "wrong type");
1494   }
1495 
1496   virtual bool is_BranchData() const { return true; }
1497 
1498   static int static_cell_count() {
1499     return branch_cell_count;
1500   }
1501 
1502   virtual int cell_count() const {
1503     return static_cell_count();
1504   }
1505 
1506   // Direct accessor
1507   uint not_taken() const {
1508     return uint_at(not_taken_off_set);
1509   }
1510 
1511   void set_not_taken(uint cnt) {
1512     set_uint_at(not_taken_off_set, cnt);
1513   }

1830     return static_cell_count();
1831   }
1832 
1833   // Direct accessor
1834   Method* method() const {
1835     return (Method*)intptr_at(speculative_trap_method);
1836   }
1837 
1838   void set_method(Method* m) {
1839     assert(!m->is_old(), "cannot add old methods");
1840     set_intptr_at(speculative_trap_method, (intptr_t)m);
1841   }
1842 
1843   static ByteSize method_offset() {
1844     return cell_offset(speculative_trap_method);
1845   }
1846 
1847   virtual void print_data_on(outputStream* st, const char* extra = NULL) const;
1848 };
1849 


















































































































































1850 // MethodData*
1851 //
1852 // A MethodData* holds information which has been collected about
1853 // a method.  Its layout looks like this:
1854 //
1855 // -----------------------------
1856 // | header                    |
1857 // | klass                     |
1858 // -----------------------------
1859 // | method                    |
1860 // | size of the MethodData* |
1861 // -----------------------------
1862 // | Data entries...           |
1863 // |   (variable size)         |
1864 // |                           |
1865 // .                           .
1866 // .                           .
1867 // .                           .
1868 // |                           |
1869 // -----------------------------

 108 
 109   enum {
 110     cell_size = sizeof(intptr_t)
 111   };
 112 
 113   // Tag values
 114   enum {
 115     no_tag,
 116     bit_data_tag,
 117     counter_data_tag,
 118     jump_data_tag,
 119     receiver_type_data_tag,
 120     virtual_call_data_tag,
 121     ret_data_tag,
 122     branch_data_tag,
 123     multi_branch_data_tag,
 124     arg_info_data_tag,
 125     call_type_data_tag,
 126     virtual_call_type_data_tag,
 127     parameters_type_data_tag,
 128     speculative_trap_data_tag,
 129     array_load_store_data_tag,
 130     acmp_data_tag
 131   };
 132 
 133   enum {
 134     // The trap state breaks down as [recompile:1 | reason:31].
 135     // This further breakdown is defined in deoptimization.cpp.
 136     // See Deoptimization::trap_state_reason for an assert that
 137     // trap_bits is big enough to hold reasons < Reason_RECORDED_LIMIT.
 138     //
 139     // The trap_state is collected only if ProfileTraps is true.
 140     trap_bits = 1+31,  // 31: enough to distinguish [0..Reason_RECORDED_LIMIT].
 141     trap_mask = -1,
 142     first_flag = 0
 143   };
 144 
 145   // Size computation
 146   static int header_size_in_bytes() {
 147     return header_size_in_cells() * cell_size;
 148   }
 149   static int header_size_in_cells() {
 150     return LP64_ONLY(1) NOT_LP64(2);

 246     return DataLayout::compute_size_in_bytes(cells);
 247   }
 248   int cell_count();
 249 
 250   // GC support
 251   void clean_weak_klass_links(bool always_clean);
 252 };
 253 
 254 
 255 // ProfileData class hierarchy
 256 class ProfileData;
 257 class   BitData;
 258 class     CounterData;
 259 class       ReceiverTypeData;
 260 class         VirtualCallData;
 261 class           VirtualCallTypeData;
 262 class       RetData;
 263 class       CallTypeData;
 264 class   JumpData;
 265 class     BranchData;
 266 class       ACmpData;
 267 class   ArrayData;
 268 class     MultiBranchData;
 269 class     ArgInfoData;
 270 class     ParametersTypeData;
 271 class   SpeculativeTrapData;
 272 class   ArrayLoadStoreData;
 273 
 274 // ProfileData
 275 //
 276 // A ProfileData object is created to refer to a section of profiling
 277 // data in a structured way.
 278 class ProfileData : public ResourceObj {
 279   friend class TypeEntries;
 280   friend class SingleTypeEntry;
 281   friend class TypeStackSlotEntries;
 282 private:
 283   enum {
 284     tab_width_one = 16,
 285     tab_width_two = 36
 286   };
 287 
 288   // This is a pointer to a section of profiling data.
 289   DataLayout* _data;
 290 
 291   char* print_data_on_helper(const MethodData* md) const;
 292 
 293 protected:
 294   DataLayout* data() { return _data; }
 295   const DataLayout* data() const { return _data; }
 296 
 297   enum {
 298     cell_size = DataLayout::cell_size
 299   };
 300 

 381   }
 382   void set_trap_state(int new_state) {
 383     data()->set_trap_state(new_state);
 384   }
 385 
 386   // Type checking
 387   virtual bool is_BitData()         const { return false; }
 388   virtual bool is_CounterData()     const { return false; }
 389   virtual bool is_JumpData()        const { return false; }
 390   virtual bool is_ReceiverTypeData()const { return false; }
 391   virtual bool is_VirtualCallData() const { return false; }
 392   virtual bool is_RetData()         const { return false; }
 393   virtual bool is_BranchData()      const { return false; }
 394   virtual bool is_ArrayData()       const { return false; }
 395   virtual bool is_MultiBranchData() const { return false; }
 396   virtual bool is_ArgInfoData()     const { return false; }
 397   virtual bool is_CallTypeData()    const { return false; }
 398   virtual bool is_VirtualCallTypeData()const { return false; }
 399   virtual bool is_ParametersTypeData() const { return false; }
 400   virtual bool is_SpeculativeTrapData()const { return false; }
 401   virtual bool is_ArrayLoadStoreData() const { return false; }
 402   virtual bool is_ACmpData()           const { return false; }
 403 
 404 
 405   BitData* as_BitData() const {
 406     assert(is_BitData(), "wrong type");
 407     return is_BitData()         ? (BitData*)        this : NULL;
 408   }
 409   CounterData* as_CounterData() const {
 410     assert(is_CounterData(), "wrong type");
 411     return is_CounterData()     ? (CounterData*)    this : NULL;
 412   }
 413   JumpData* as_JumpData() const {
 414     assert(is_JumpData(), "wrong type");
 415     return is_JumpData()        ? (JumpData*)       this : NULL;
 416   }
 417   ReceiverTypeData* as_ReceiverTypeData() const {
 418     assert(is_ReceiverTypeData(), "wrong type");
 419     return is_ReceiverTypeData() ? (ReceiverTypeData*)this : NULL;
 420   }
 421   VirtualCallData* as_VirtualCallData() const {
 422     assert(is_VirtualCallData(), "wrong type");

 441   ArgInfoData* as_ArgInfoData() const {
 442     assert(is_ArgInfoData(), "wrong type");
 443     return is_ArgInfoData() ? (ArgInfoData*)this : NULL;
 444   }
 445   CallTypeData* as_CallTypeData() const {
 446     assert(is_CallTypeData(), "wrong type");
 447     return is_CallTypeData() ? (CallTypeData*)this : NULL;
 448   }
 449   VirtualCallTypeData* as_VirtualCallTypeData() const {
 450     assert(is_VirtualCallTypeData(), "wrong type");
 451     return is_VirtualCallTypeData() ? (VirtualCallTypeData*)this : NULL;
 452   }
 453   ParametersTypeData* as_ParametersTypeData() const {
 454     assert(is_ParametersTypeData(), "wrong type");
 455     return is_ParametersTypeData() ? (ParametersTypeData*)this : NULL;
 456   }
 457   SpeculativeTrapData* as_SpeculativeTrapData() const {
 458     assert(is_SpeculativeTrapData(), "wrong type");
 459     return is_SpeculativeTrapData() ? (SpeculativeTrapData*)this : NULL;
 460   }
 461   ArrayLoadStoreData* as_ArrayLoadStoreData() const {
 462     assert(is_ArrayLoadStoreData(), "wrong type");
 463     return is_ArrayLoadStoreData() ? (ArrayLoadStoreData*)this : NULL;
 464   }
 465   ACmpData* as_ACmpData() const {
 466     assert(is_ACmpData(), "wrong type");
 467     return is_ACmpData() ? (ACmpData*)this : NULL;
 468   }
 469 
 470 
 471   // Subclass specific initialization
 472   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo) {}
 473 
 474   // GC support
 475   virtual void clean_weak_klass_links(bool always_clean) {}
 476 
 477   // CI translation: ProfileData can represent both MethodDataOop data
 478   // as well as CIMethodData data. This function is provided for translating
 479   // an oop in a ProfileData to the ci equivalent. Generally speaking,
 480   // most ProfileData don't require any translation, so we provide the null
 481   // translation here, and the required translators are in the ci subclasses.
 482   virtual void translate_from(const ProfileData* data) {}
 483 
 484   virtual void print_data_on(outputStream* st, const char* extra = NULL) const {
 485     ShouldNotReachHere();
 486   }
 487 
 488   void print_data_on(outputStream* st, const MethodData* md) const;

 603 // branch.  It is a counter, used for counting the number of branches,
 604 // plus a data displacement, used for realigning the data pointer to
 605 // the corresponding target bci.
 606 class JumpData : public ProfileData {
 607   friend class VMStructs;
 608   friend class JVMCIVMStructs;
 609 protected:
 610   enum {
 611     taken_off_set,
 612     displacement_off_set,
 613     jump_cell_count
 614   };
 615 
 616   void set_displacement(int displacement) {
 617     set_int_at(displacement_off_set, displacement);
 618   }
 619 
 620 public:
 621   JumpData(DataLayout* layout) : ProfileData(layout) {
 622     assert(layout->tag() == DataLayout::jump_data_tag ||
 623       layout->tag() == DataLayout::branch_data_tag ||
 624       layout->tag() == DataLayout::acmp_data_tag, "wrong type");
 625   }
 626 
 627   virtual bool is_JumpData() const { return true; }
 628 
 629   static int static_cell_count() {
 630     return jump_cell_count;
 631   }
 632 
 633   virtual int cell_count() const {
 634     return static_cell_count();
 635   }
 636 
 637   // Direct accessor
 638   uint taken() const {
 639     return uint_at(taken_off_set);
 640   }
 641 
 642   void set_taken(uint cnt) {
 643     set_uint_at(taken_off_set, cnt);
 644   }

 840   static ByteSize per_arg_size() {
 841     return in_ByteSize(per_arg_cell_count * DataLayout::cell_size);
 842   }
 843 
 844   static int per_arg_count() {
 845     return per_arg_cell_count;
 846   }
 847 
 848   ByteSize type_offset(int i) const {
 849     return DataLayout::cell_offset(type_offset_in_cells(i));
 850   }
 851 
 852   // GC support
 853   void clean_weak_klass_links(bool always_clean);
 854 
 855   void print_data_on(outputStream* st) const;
 856 };
 857 
 858 // Type entry used for return from a call. A single cell to record the
 859 // type.
 860 class SingleTypeEntry : public TypeEntries {
 861 
 862 private:
 863   enum {
 864     cell_count = 1
 865   };
 866 
 867 public:
 868   SingleTypeEntry(int base_off)
 869     : TypeEntries(base_off) {}
 870 
 871   void post_initialize() {
 872     set_type(type_none());
 873   }
 874 
 875   intptr_t type() const {
 876     return _pd->intptr_at(_base_off);
 877   }
 878 
 879   void set_type(intptr_t k) {
 880     _pd->set_intptr_at(_base_off, k);
 881   }
 882 
 883   static int static_cell_count() {
 884     return cell_count;
 885   }
 886 
 887   static ByteSize size() {
 888     return in_ByteSize(cell_count * DataLayout::cell_size);
 889   }
 890 
 891   ByteSize type_offset() {
 892     return DataLayout::cell_offset(_base_off);
 893   }
 894 
 895   // GC support
 896   void clean_weak_klass_links(bool always_clean);
 897 
 898   void print_data_on(outputStream* st) const;
 899 };
 900 
 901 // Entries to collect type information at a call: contains arguments
 902 // (TypeStackSlotEntries), a return type (SingleTypeEntry) and a
 903 // number of cells. Because the number of cells for the return type is
 904 // smaller than the number of cells for the type of an arguments, the
 905 // number of cells is used to tell how many arguments are profiled and
 906 // whether a return value is profiled. See has_arguments() and
 907 // has_return().
 908 class TypeEntriesAtCall {
 909 private:
 910   static int stack_slot_local_offset(int i) {
 911     return header_cell_count() + TypeStackSlotEntries::stack_slot_local_offset(i);
 912   }
 913 
 914   static int argument_type_local_offset(int i) {
 915     return header_cell_count() + TypeStackSlotEntries::type_local_offset(i);
 916   }
 917 
 918 public:
 919 
 920   static int header_cell_count() {
 921     return 1;
 922   }

 936   static bool return_profiling_enabled();
 937 
 938   // Code generation support
 939   static ByteSize cell_count_offset() {
 940     return in_ByteSize(cell_count_local_offset() * DataLayout::cell_size);
 941   }
 942 
 943   static ByteSize args_data_offset() {
 944     return in_ByteSize(header_cell_count() * DataLayout::cell_size);
 945   }
 946 
 947   static ByteSize stack_slot_offset(int i) {
 948     return in_ByteSize(stack_slot_local_offset(i) * DataLayout::cell_size);
 949   }
 950 
 951   static ByteSize argument_type_offset(int i) {
 952     return in_ByteSize(argument_type_local_offset(i) * DataLayout::cell_size);
 953   }
 954 
 955   static ByteSize return_only_size() {
 956     return SingleTypeEntry::size() + in_ByteSize(header_cell_count() * DataLayout::cell_size);
 957   }
 958 
 959 };
 960 
 961 // CallTypeData
 962 //
 963 // A CallTypeData is used to access profiling information about a non
 964 // virtual call for which we collect type information about arguments
 965 // and return value.
 966 class CallTypeData : public CounterData {
 967 private:
 968   // entries for arguments if any
 969   TypeStackSlotEntries _args;
 970   // entry for return type if any
 971   SingleTypeEntry _ret;
 972 
 973   int cell_count_global_offset() const {
 974     return CounterData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
 975   }
 976 
 977   // number of cells not counting the header
 978   int cell_count_no_header() const {
 979     return uint_at(cell_count_global_offset());
 980   }
 981 
 982   void check_number_of_arguments(int total) {
 983     assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
 984   }
 985 
 986 public:
 987   CallTypeData(DataLayout* layout) :
 988     CounterData(layout),
 989     _args(CounterData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()),
 990     _ret(cell_count() - SingleTypeEntry::static_cell_count())
 991   {
 992     assert(layout->tag() == DataLayout::call_type_data_tag, "wrong type");
 993     // Some compilers (VC++) don't want this passed in member initialization list
 994     _args.set_profile_data(this);
 995     _ret.set_profile_data(this);
 996   }
 997 
 998   const TypeStackSlotEntries* args() const {
 999     assert(has_arguments(), "no profiling of arguments");
1000     return &_args;
1001   }
1002 
1003   const SingleTypeEntry* ret() const {
1004     assert(has_return(), "no profiling of return value");
1005     return &_ret;
1006   }
1007 
1008   virtual bool is_CallTypeData() const { return true; }
1009 
1010   static int static_cell_count() {
1011     return -1;
1012   }
1013 
1014   static int compute_cell_count(BytecodeStream* stream) {
1015     return CounterData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1016   }
1017 
1018   static void initialize(DataLayout* dl, int cell_count) {
1019     TypeEntriesAtCall::initialize(dl, CounterData::static_cell_count(), cell_count);
1020   }
1021 
1022   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);
1023 

1254 
1255   // Direct accessors
1256   static ByteSize virtual_call_data_size() {
1257     return cell_offset(static_cell_count());
1258   }
1259 
1260   void print_method_data_on(outputStream* st) const NOT_JVMCI_RETURN;
1261   void print_data_on(outputStream* st, const char* extra = NULL) const;
1262 };
1263 
1264 // VirtualCallTypeData
1265 //
1266 // A VirtualCallTypeData is used to access profiling information about
1267 // a virtual call for which we collect type information about
1268 // arguments and return value.
1269 class VirtualCallTypeData : public VirtualCallData {
1270 private:
1271   // entries for arguments if any
1272   TypeStackSlotEntries _args;
1273   // entry for return type if any
1274   SingleTypeEntry _ret;
1275 
1276   int cell_count_global_offset() const {
1277     return VirtualCallData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
1278   }
1279 
1280   // number of cells not counting the header
1281   int cell_count_no_header() const {
1282     return uint_at(cell_count_global_offset());
1283   }
1284 
1285   void check_number_of_arguments(int total) {
1286     assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
1287   }
1288 
1289 public:
1290   VirtualCallTypeData(DataLayout* layout) :
1291     VirtualCallData(layout),
1292     _args(VirtualCallData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()),
1293     _ret(cell_count() - SingleTypeEntry::static_cell_count())
1294   {
1295     assert(layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");
1296     // Some compilers (VC++) don't want this passed in member initialization list
1297     _args.set_profile_data(this);
1298     _ret.set_profile_data(this);
1299   }
1300 
1301   const TypeStackSlotEntries* args() const {
1302     assert(has_arguments(), "no profiling of arguments");
1303     return &_args;
1304   }
1305 
1306   const SingleTypeEntry* ret() const {
1307     assert(has_return(), "no profiling of return value");
1308     return &_ret;
1309   }
1310 
1311   virtual bool is_VirtualCallTypeData() const { return true; }
1312 
1313   static int static_cell_count() {
1314     return -1;
1315   }
1316 
1317   static int compute_cell_count(BytecodeStream* stream) {
1318     return VirtualCallData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1319   }
1320 
1321   static void initialize(DataLayout* dl, int cell_count) {
1322     TypeEntriesAtCall::initialize(dl, VirtualCallData::static_cell_count(), cell_count);
1323   }
1324 
1325   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);
1326 

1488 // BranchData
1489 //
1490 // A BranchData is used to access profiling data for a two-way branch.
1491 // It consists of taken and not_taken counts as well as a data displacement
1492 // for the taken case.
1493 class BranchData : public JumpData {
1494   friend class VMStructs;
1495   friend class JVMCIVMStructs;
1496 protected:
1497   enum {
1498     not_taken_off_set = jump_cell_count,
1499     branch_cell_count
1500   };
1501 
1502   void set_displacement(int displacement) {
1503     set_int_at(displacement_off_set, displacement);
1504   }
1505 
1506 public:
1507   BranchData(DataLayout* layout) : JumpData(layout) {
1508     assert(layout->tag() == DataLayout::branch_data_tag || layout->tag() == DataLayout::acmp_data_tag, "wrong type");
1509   }
1510 
1511   virtual bool is_BranchData() const { return true; }
1512 
1513   static int static_cell_count() {
1514     return branch_cell_count;
1515   }
1516 
1517   virtual int cell_count() const {
1518     return static_cell_count();
1519   }
1520 
1521   // Direct accessor
1522   uint not_taken() const {
1523     return uint_at(not_taken_off_set);
1524   }
1525 
1526   void set_not_taken(uint cnt) {
1527     set_uint_at(not_taken_off_set, cnt);
1528   }

1845     return static_cell_count();
1846   }
1847 
1848   // Direct accessor
1849   Method* method() const {
1850     return (Method*)intptr_at(speculative_trap_method);
1851   }
1852 
1853   void set_method(Method* m) {
1854     assert(!m->is_old(), "cannot add old methods");
1855     set_intptr_at(speculative_trap_method, (intptr_t)m);
1856   }
1857 
1858   static ByteSize method_offset() {
1859     return cell_offset(speculative_trap_method);
1860   }
1861 
1862   virtual void print_data_on(outputStream* st, const char* extra = NULL) const;
1863 };
1864 
1865 class ArrayLoadStoreData : public ProfileData {
1866 private:
1867   enum {
1868     flat_array_flag = DataLayout::first_flag,
1869     null_free_array_flag = flat_array_flag + 1,
1870   };
1871 
1872   SingleTypeEntry _array;
1873   SingleTypeEntry _element;
1874 
1875 public:
1876   ArrayLoadStoreData(DataLayout* layout) :
1877     ProfileData(layout),
1878     _array(0),
1879     _element(SingleTypeEntry::static_cell_count()) {
1880     assert(layout->tag() == DataLayout::array_load_store_data_tag, "wrong type");
1881     _array.set_profile_data(this);
1882     _element.set_profile_data(this);
1883   }
1884 
1885   const SingleTypeEntry* array() const {
1886     return &_array;
1887   }
1888 
1889   const SingleTypeEntry* element() const {
1890     return &_element;
1891   }
1892 
1893   virtual bool is_ArrayLoadStoreData() const { return true; }
1894 
1895   static int static_cell_count() {
1896     return SingleTypeEntry::static_cell_count() * 2;
1897   }
1898 
1899   virtual int cell_count() const {
1900     return static_cell_count();
1901   }
1902 
1903   void set_flat_array() { set_flag_at(flat_array_flag); }
1904   bool flat_array() const { return flag_at(flat_array_flag); }
1905 
1906   void set_null_free_array() { set_flag_at(null_free_array_flag); }
1907   bool null_free_array() const { return flag_at(null_free_array_flag); }
1908 
1909   // Code generation support
1910   static int flat_array_byte_constant() {
1911     return flag_number_to_constant(flat_array_flag);
1912   }
1913 
1914   static int null_free_array_byte_constant() {
1915     return flag_number_to_constant(null_free_array_flag);
1916   }
1917 
1918   static ByteSize array_offset() {
1919     return cell_offset(0);
1920   }
1921 
1922   static ByteSize element_offset() {
1923     return cell_offset(SingleTypeEntry::static_cell_count());
1924   }
1925 
1926   virtual void clean_weak_klass_links(bool always_clean) {
1927     _array.clean_weak_klass_links(always_clean);
1928     _element.clean_weak_klass_links(always_clean);
1929   }
1930 
1931   static ByteSize array_load_store_data_size() {
1932     return cell_offset(static_cell_count());
1933   }
1934 
1935   virtual void print_data_on(outputStream* st, const char* extra = NULL) const;
1936 };
1937 
1938 class ACmpData : public BranchData {
1939 private:
1940   enum {
1941     left_inline_type_flag = DataLayout::first_flag,
1942     right_inline_type_flag
1943   };
1944 
1945   SingleTypeEntry _left;
1946   SingleTypeEntry _right;
1947 
1948 public:
1949   ACmpData(DataLayout* layout) :
1950     BranchData(layout),
1951     _left(BranchData::static_cell_count()),
1952     _right(BranchData::static_cell_count() + SingleTypeEntry::static_cell_count()) {
1953     assert(layout->tag() == DataLayout::acmp_data_tag, "wrong type");
1954     _left.set_profile_data(this);
1955     _right.set_profile_data(this);
1956   }
1957 
1958   const SingleTypeEntry* left() const {
1959     return &_left;
1960   }
1961 
1962   const SingleTypeEntry* right() const {
1963     return &_right;
1964   }
1965 
1966   virtual bool is_ACmpData() const { return true; }
1967 
1968   static int static_cell_count() {
1969     return BranchData::static_cell_count() + SingleTypeEntry::static_cell_count() * 2;
1970   }
1971 
1972   virtual int cell_count() const {
1973     return static_cell_count();
1974   }
1975 
1976   void set_left_inline_type() { set_flag_at(left_inline_type_flag); }
1977   bool left_inline_type() const { return flag_at(left_inline_type_flag); }
1978 
1979   void set_right_inline_type() { set_flag_at(right_inline_type_flag); }
1980   bool right_inline_type() const { return flag_at(right_inline_type_flag); }
1981 
1982   // Code generation support
1983   static int left_inline_type_byte_constant() {
1984     return flag_number_to_constant(left_inline_type_flag);
1985   }
1986 
1987   static int right_inline_type_byte_constant() {
1988     return flag_number_to_constant(right_inline_type_flag);
1989   }
1990 
1991   static ByteSize left_offset() {
1992     return cell_offset(BranchData::static_cell_count());
1993   }
1994 
1995   static ByteSize right_offset() {
1996     return cell_offset(BranchData::static_cell_count() + SingleTypeEntry::static_cell_count());
1997   }
1998 
1999   virtual void clean_weak_klass_links(bool always_clean) {
2000     _left.clean_weak_klass_links(always_clean);
2001     _right.clean_weak_klass_links(always_clean);
2002   }
2003 
2004   static ByteSize acmp_data_size() {
2005     return cell_offset(static_cell_count());
2006   }
2007 
2008   virtual void print_data_on(outputStream* st, const char* extra = NULL) const;
2009 };
2010 
2011 // MethodData*
2012 //
2013 // A MethodData* holds information which has been collected about
2014 // a method.  Its layout looks like this:
2015 //
2016 // -----------------------------
2017 // | header                    |
2018 // | klass                     |
2019 // -----------------------------
2020 // | method                    |
2021 // | size of the MethodData* |
2022 // -----------------------------
2023 // | Data entries...           |
2024 // |   (variable size)         |
2025 // |                           |
2026 // .                           .
2027 // .                           .
2028 // .                           .
2029 // |                           |
2030 // -----------------------------
< prev index next >