< prev index next >

src/hotspot/share/oops/methodData.hpp

Print this page

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


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

 245     return DataLayout::compute_size_in_bytes(cells);
 246   }
 247   int cell_count();
 248 
 249   // GC support
 250   void clean_weak_klass_links(bool always_clean);
 251 };
 252 
 253 
 254 // ProfileData class hierarchy
 255 class ProfileData;
 256 class   BitData;
 257 class     CounterData;
 258 class       ReceiverTypeData;
 259 class         VirtualCallData;
 260 class           VirtualCallTypeData;
 261 class       RetData;
 262 class       CallTypeData;
 263 class   JumpData;
 264 class     BranchData;

 265 class   ArrayData;
 266 class     MultiBranchData;
 267 class     ArgInfoData;
 268 class     ParametersTypeData;
 269 class   SpeculativeTrapData;

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

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


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

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








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

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

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

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

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

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

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

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


















































































































































1848   virtual void print_data_on(outputStream* st, const char* extra = NULL) const;
1849 };
1850 
1851 // MethodData*
1852 //
1853 // A MethodData* holds information which has been collected about
1854 // a method.  Its layout looks like this:
1855 //
1856 // -----------------------------
1857 // | header                    |
1858 // | klass                     |
1859 // -----------------------------
1860 // | method                    |
1861 // | size of the MethodData* |
1862 // -----------------------------
1863 // | Data entries...           |
1864 // |   (variable size)         |
1865 // |                           |
1866 // .                           .
1867 // .                           .

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

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

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

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

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

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

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

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

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

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