< prev index next >

src/hotspot/share/oops/methodData.hpp

Print this page

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



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

 269 
 270   int size_in_bytes() {
 271     int cells = cell_count();
 272     assert(cells >= 0, "invalid number of cells");
 273     return DataLayout::compute_size_in_bytes(cells);
 274   }
 275   int cell_count();
 276 
 277   // GC support
 278   void clean_weak_klass_links(bool always_clean);
 279 };
 280 
 281 
 282 // ProfileData class hierarchy
 283 class ProfileData;
 284 class   BitData;
 285 class     CounterData;
 286 class       ReceiverTypeData;
 287 class         VirtualCallData;
 288 class           VirtualCallTypeData;

 289 class       RetData;
 290 class       CallTypeData;
 291 class   JumpData;
 292 class     BranchData;

 293 class   ArrayData;
 294 class     MultiBranchData;
 295 class     ArgInfoData;
 296 class     ParametersTypeData;
 297 class   SpeculativeTrapData;

 298 
 299 // ProfileData
 300 //
 301 // A ProfileData object is created to refer to a section of profiling
 302 // data in a structured way.
 303 class ProfileData : public ResourceObj {
 304   friend class TypeEntries;
 305   friend class ReturnTypeEntry;
 306   friend class TypeStackSlotEntries;
 307 private:
 308   enum {
 309     tab_width_one = 16,
 310     tab_width_two = 36
 311   };
 312 
 313   // This is a pointer to a section of profiling data.
 314   DataLayout* _data;
 315 
 316   char* print_data_on_helper(const MethodData* md) const;
 317 
 318 protected:
 319   DataLayout* data() { return _data; }
 320   const DataLayout* data() const { return _data; }
 321 
 322   enum {
 323     cell_size = DataLayout::cell_size
 324   };
 325 

 406   }
 407   void set_trap_state(int new_state) {
 408     data()->set_trap_state(new_state);
 409   }
 410 
 411   // Type checking
 412   virtual bool is_BitData()         const { return false; }
 413   virtual bool is_CounterData()     const { return false; }
 414   virtual bool is_JumpData()        const { return false; }
 415   virtual bool is_ReceiverTypeData()const { return false; }
 416   virtual bool is_VirtualCallData() const { return false; }
 417   virtual bool is_RetData()         const { return false; }
 418   virtual bool is_BranchData()      const { return false; }
 419   virtual bool is_ArrayData()       const { return false; }
 420   virtual bool is_MultiBranchData() const { return false; }
 421   virtual bool is_ArgInfoData()     const { return false; }
 422   virtual bool is_CallTypeData()    const { return false; }
 423   virtual bool is_VirtualCallTypeData()const { return false; }
 424   virtual bool is_ParametersTypeData() const { return false; }
 425   virtual bool is_SpeculativeTrapData()const { return false; }



 426 
 427 
 428   BitData* as_BitData() const {
 429     assert(is_BitData(), "wrong type");
 430     return is_BitData()         ? (BitData*)        this : nullptr;
 431   }
 432   CounterData* as_CounterData() const {
 433     assert(is_CounterData(), "wrong type");
 434     return is_CounterData()     ? (CounterData*)    this : nullptr;
 435   }
 436   JumpData* as_JumpData() const {
 437     assert(is_JumpData(), "wrong type");
 438     return is_JumpData()        ? (JumpData*)       this : nullptr;
 439   }
 440   ReceiverTypeData* as_ReceiverTypeData() const {
 441     assert(is_ReceiverTypeData(), "wrong type");
 442     return is_ReceiverTypeData() ? (ReceiverTypeData*)this : nullptr;
 443   }
 444   VirtualCallData* as_VirtualCallData() const {
 445     assert(is_VirtualCallData(), "wrong type");

 464   ArgInfoData* as_ArgInfoData() const {
 465     assert(is_ArgInfoData(), "wrong type");
 466     return is_ArgInfoData() ? (ArgInfoData*)this : nullptr;
 467   }
 468   CallTypeData* as_CallTypeData() const {
 469     assert(is_CallTypeData(), "wrong type");
 470     return is_CallTypeData() ? (CallTypeData*)this : nullptr;
 471   }
 472   VirtualCallTypeData* as_VirtualCallTypeData() const {
 473     assert(is_VirtualCallTypeData(), "wrong type");
 474     return is_VirtualCallTypeData() ? (VirtualCallTypeData*)this : nullptr;
 475   }
 476   ParametersTypeData* as_ParametersTypeData() const {
 477     assert(is_ParametersTypeData(), "wrong type");
 478     return is_ParametersTypeData() ? (ParametersTypeData*)this : nullptr;
 479   }
 480   SpeculativeTrapData* as_SpeculativeTrapData() const {
 481     assert(is_SpeculativeTrapData(), "wrong type");
 482     return is_SpeculativeTrapData() ? (SpeculativeTrapData*)this : nullptr;
 483   }












 484 
 485 
 486   // Subclass specific initialization
 487   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo) {}
 488 
 489   // GC support
 490   virtual void clean_weak_klass_links(bool always_clean) {}
 491 
 492   // CI translation: ProfileData can represent both MethodDataOop data
 493   // as well as CIMethodData data. This function is provided for translating
 494   // an oop in a ProfileData to the ci equivalent. Generally speaking,
 495   // most ProfileData don't require any translation, so we provide the null
 496   // translation here, and the required translators are in the ci subclasses.
 497   virtual void translate_from(const ProfileData* data) {}
 498 
 499   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const {
 500     ShouldNotReachHere();
 501   }
 502 
 503   void print_data_on(outputStream* st, const MethodData* md) const;

 506   void tab(outputStream* st, bool first = false) const;
 507 };
 508 
 509 // BitData
 510 //
 511 // A BitData holds a flag or two in its header.
 512 class BitData : public ProfileData {
 513   friend class VMStructs;
 514   friend class JVMCIVMStructs;
 515 protected:
 516   enum : u1 {
 517     // null_seen:
 518     //  saw a null operand (cast/aastore/instanceof)
 519       null_seen_flag                  = DataLayout::first_flag + 0,
 520       exception_handler_entered_flag  = null_seen_flag + 1,
 521       deprecated_method_callsite_flag = exception_handler_entered_flag + 1
 522 #if INCLUDE_JVMCI
 523     // bytecode threw any exception
 524     , exception_seen_flag             = deprecated_method_callsite_flag + 1
 525 #endif

 526   };
 527   enum { bit_cell_count = 0 };  // no additional data fields needed.
 528 public:
 529   BitData(DataLayout* layout) : ProfileData(layout) {
 530   }
 531 
 532   virtual bool is_BitData() const { return true; }
 533 
 534   static int static_cell_count() {
 535     return bit_cell_count;
 536   }
 537 
 538   virtual int cell_count() const {
 539     return static_cell_count();
 540   }
 541 
 542   // Accessor
 543 
 544   // The null_seen flag bit is specially known to the interpreter.
 545   // Consulting it allows the compiler to avoid setting up null_check traps.
 546   bool null_seen()     { return flag_at(null_seen_flag); }
 547   void set_null_seen()    { set_flag_at(null_seen_flag); }
 548   bool deprecated_method_call_site() const { return flag_at(deprecated_method_callsite_flag); }
 549   bool set_deprecated_method_call_site() { return data()->set_flag_at(deprecated_method_callsite_flag); }
 550   bool clear_deprecated_method_call_site() { return data()->clear_flag_at(deprecated_method_callsite_flag); }
 551 
 552 #if INCLUDE_JVMCI
 553   // true if an exception was thrown at the specific BCI
 554   bool exception_seen() { return flag_at(exception_seen_flag); }
 555   void set_exception_seen() { set_flag_at(exception_seen_flag); }
 556 #endif
 557 
 558   // true if a ex handler block at this bci was entered
 559   bool exception_handler_entered() { return flag_at(exception_handler_entered_flag); }
 560   void set_exception_handler_entered() { set_flag_at(exception_handler_entered_flag); }
 561 
 562   // Code generation support
 563   static u1 null_seen_byte_constant() {
 564     return flag_number_to_constant(null_seen_flag);
 565   }
 566 

 627 // branch.  It is a counter, used for counting the number of branches,
 628 // plus a data displacement, used for realigning the data pointer to
 629 // the corresponding target bci.
 630 class JumpData : public ProfileData {
 631   friend class VMStructs;
 632   friend class JVMCIVMStructs;
 633 protected:
 634   enum {
 635     taken_off_set,
 636     displacement_off_set,
 637     jump_cell_count
 638   };
 639 
 640   void set_displacement(int displacement) {
 641     set_int_at(displacement_off_set, displacement);
 642   }
 643 
 644 public:
 645   JumpData(DataLayout* layout) : ProfileData(layout) {
 646     assert(layout->tag() == DataLayout::jump_data_tag ||
 647       layout->tag() == DataLayout::branch_data_tag, "wrong type");

 648   }
 649 
 650   virtual bool is_JumpData() const { return true; }
 651 
 652   static int static_cell_count() {
 653     return jump_cell_count;
 654   }
 655 
 656   virtual int cell_count() const {
 657     return static_cell_count();
 658   }
 659 
 660   // Direct accessor
 661   uint taken() const {
 662     return uint_at(taken_off_set);
 663   }
 664 
 665   void set_taken(uint cnt) {
 666     set_uint_at(taken_off_set, cnt);
 667   }

 863   static ByteSize per_arg_size() {
 864     return in_ByteSize(per_arg_cell_count * DataLayout::cell_size);
 865   }
 866 
 867   static int per_arg_count() {
 868     return per_arg_cell_count;
 869   }
 870 
 871   ByteSize type_offset(int i) const {
 872     return DataLayout::cell_offset(type_offset_in_cells(i));
 873   }
 874 
 875   // GC support
 876   void clean_weak_klass_links(bool always_clean);
 877 
 878   void print_data_on(outputStream* st) const;
 879 };
 880 
 881 // Type entry used for return from a call. A single cell to record the
 882 // type.
 883 class ReturnTypeEntry : public TypeEntries {
 884 
 885 private:
 886   enum {
 887     cell_count = 1
 888   };
 889 
 890 public:
 891   ReturnTypeEntry(int base_off)
 892     : TypeEntries(base_off) {}
 893 
 894   void post_initialize() {
 895     set_type(type_none());
 896   }
 897 
 898   intptr_t type() const {
 899     return _pd->intptr_at(_base_off);
 900   }
 901 
 902   void set_type(intptr_t k) {
 903     _pd->set_intptr_at(_base_off, k);
 904   }
 905 
 906   static int static_cell_count() {
 907     return cell_count;
 908   }
 909 
 910   static ByteSize size() {
 911     return in_ByteSize(cell_count * DataLayout::cell_size);
 912   }
 913 
 914   ByteSize type_offset() {
 915     return DataLayout::cell_offset(_base_off);
 916   }
 917 
 918   // GC support
 919   void clean_weak_klass_links(bool always_clean);
 920 
 921   void print_data_on(outputStream* st) const;
 922 };
 923 
 924 // Entries to collect type information at a call: contains arguments
 925 // (TypeStackSlotEntries), a return type (ReturnTypeEntry) and a
 926 // number of cells. Because the number of cells for the return type is
 927 // smaller than the number of cells for the type of an arguments, the
 928 // number of cells is used to tell how many arguments are profiled and
 929 // whether a return value is profiled. See has_arguments() and
 930 // has_return().
 931 class TypeEntriesAtCall {
 932 private:
 933   static int stack_slot_local_offset(int i) {
 934     return header_cell_count() + TypeStackSlotEntries::stack_slot_local_offset(i);
 935   }
 936 
 937   static int argument_type_local_offset(int i) {
 938     return header_cell_count() + TypeStackSlotEntries::type_local_offset(i);
 939   }
 940 
 941 public:
 942 
 943   static int header_cell_count() {
 944     return 1;
 945   }

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

1118 // dynamic type check.  It consists of a series of (Klass*, count)
1119 // pairs which are used to store a type profile for the receiver of
1120 // the check, the associated count is incremented every time the type
1121 // is seen. A per ReceiverTypeData counter is incremented on type
1122 // overflow (when there's no more room for a not yet profiled Klass*).
1123 //
1124 class ReceiverTypeData : public CounterData {
1125   friend class VMStructs;
1126   friend class JVMCIVMStructs;
1127 protected:
1128   enum {
1129     receiver0_offset = counter_cell_count,
1130     count0_offset,
1131     receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
1132   };
1133 
1134 public:
1135   ReceiverTypeData(DataLayout* layout) : CounterData(layout) {
1136     assert(layout->tag() == DataLayout::receiver_type_data_tag ||
1137            layout->tag() == DataLayout::virtual_call_data_tag ||
1138            layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");

1139   }
1140 
1141   virtual bool is_ReceiverTypeData() const { return true; }
1142 
1143   static int static_cell_count() {
1144     return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count;
1145   }
1146 
1147   virtual int cell_count() const {
1148     return static_cell_count();
1149   }
1150 
1151   // Direct accessors
1152   static uint row_limit() {
1153     return (uint) TypeProfileWidth;
1154   }
1155   static int receiver_cell_index(uint row) {
1156     return receiver0_offset + row * receiver_type_row_cell_count;
1157   }
1158   static int receiver_count_cell_index(uint row) {

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

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

1839     return static_cell_count();
1840   }
1841 
1842   // Direct accessor
1843   Method* method() const {
1844     return (Method*)intptr_at(speculative_trap_method);
1845   }
1846 
1847   void set_method(Method* m) {
1848     assert(!m->is_old(), "cannot add old methods");
1849     set_intptr_at(speculative_trap_method, (intptr_t)m);
1850   }
1851 
1852   static ByteSize method_offset() {
1853     return cell_offset(speculative_trap_method);
1854   }
1855 
1856   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
1857 };
1858 
















































































































































































































1859 // MethodData*
1860 //
1861 // A MethodData* holds information which has been collected about
1862 // a method.  Its layout looks like this:
1863 //
1864 // -----------------------------
1865 // | header                    |
1866 // | klass                     |
1867 // -----------------------------
1868 // | method                    |
1869 // | size of the MethodData* |
1870 // -----------------------------
1871 // | Data entries...           |
1872 // |   (variable size)         |
1873 // |                           |
1874 // .                           .
1875 // .                           .
1876 // .                           .
1877 // |                           |
1878 // -----------------------------

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

 272 
 273   int size_in_bytes() {
 274     int cells = cell_count();
 275     assert(cells >= 0, "invalid number of cells");
 276     return DataLayout::compute_size_in_bytes(cells);
 277   }
 278   int cell_count();
 279 
 280   // GC support
 281   void clean_weak_klass_links(bool always_clean);
 282 };
 283 
 284 
 285 // ProfileData class hierarchy
 286 class ProfileData;
 287 class   BitData;
 288 class     CounterData;
 289 class       ReceiverTypeData;
 290 class         VirtualCallData;
 291 class           VirtualCallTypeData;
 292 class         ArrayStoreData;
 293 class       RetData;
 294 class       CallTypeData;
 295 class   JumpData;
 296 class     BranchData;
 297 class       ACmpData;
 298 class   ArrayData;
 299 class     MultiBranchData;
 300 class     ArgInfoData;
 301 class     ParametersTypeData;
 302 class   SpeculativeTrapData;
 303 class   ArrayLoadData;
 304 
 305 // ProfileData
 306 //
 307 // A ProfileData object is created to refer to a section of profiling
 308 // data in a structured way.
 309 class ProfileData : public ResourceObj {
 310   friend class TypeEntries;
 311   friend class SingleTypeEntry;
 312   friend class TypeStackSlotEntries;
 313 private:
 314   enum {
 315     tab_width_one = 16,
 316     tab_width_two = 36
 317   };
 318 
 319   // This is a pointer to a section of profiling data.
 320   DataLayout* _data;
 321 
 322   char* print_data_on_helper(const MethodData* md) const;
 323 
 324 protected:
 325   DataLayout* data() { return _data; }
 326   const DataLayout* data() const { return _data; }
 327 
 328   enum {
 329     cell_size = DataLayout::cell_size
 330   };
 331 

 412   }
 413   void set_trap_state(int new_state) {
 414     data()->set_trap_state(new_state);
 415   }
 416 
 417   // Type checking
 418   virtual bool is_BitData()         const { return false; }
 419   virtual bool is_CounterData()     const { return false; }
 420   virtual bool is_JumpData()        const { return false; }
 421   virtual bool is_ReceiverTypeData()const { return false; }
 422   virtual bool is_VirtualCallData() const { return false; }
 423   virtual bool is_RetData()         const { return false; }
 424   virtual bool is_BranchData()      const { return false; }
 425   virtual bool is_ArrayData()       const { return false; }
 426   virtual bool is_MultiBranchData() const { return false; }
 427   virtual bool is_ArgInfoData()     const { return false; }
 428   virtual bool is_CallTypeData()    const { return false; }
 429   virtual bool is_VirtualCallTypeData()const { return false; }
 430   virtual bool is_ParametersTypeData() const { return false; }
 431   virtual bool is_SpeculativeTrapData()const { return false; }
 432   virtual bool is_ArrayStoreData() const { return false; }
 433   virtual bool is_ArrayLoadData() const { return false; }
 434   virtual bool is_ACmpData()           const { return false; }
 435 
 436 
 437   BitData* as_BitData() const {
 438     assert(is_BitData(), "wrong type");
 439     return is_BitData()         ? (BitData*)        this : nullptr;
 440   }
 441   CounterData* as_CounterData() const {
 442     assert(is_CounterData(), "wrong type");
 443     return is_CounterData()     ? (CounterData*)    this : nullptr;
 444   }
 445   JumpData* as_JumpData() const {
 446     assert(is_JumpData(), "wrong type");
 447     return is_JumpData()        ? (JumpData*)       this : nullptr;
 448   }
 449   ReceiverTypeData* as_ReceiverTypeData() const {
 450     assert(is_ReceiverTypeData(), "wrong type");
 451     return is_ReceiverTypeData() ? (ReceiverTypeData*)this : nullptr;
 452   }
 453   VirtualCallData* as_VirtualCallData() const {
 454     assert(is_VirtualCallData(), "wrong type");

 473   ArgInfoData* as_ArgInfoData() const {
 474     assert(is_ArgInfoData(), "wrong type");
 475     return is_ArgInfoData() ? (ArgInfoData*)this : nullptr;
 476   }
 477   CallTypeData* as_CallTypeData() const {
 478     assert(is_CallTypeData(), "wrong type");
 479     return is_CallTypeData() ? (CallTypeData*)this : nullptr;
 480   }
 481   VirtualCallTypeData* as_VirtualCallTypeData() const {
 482     assert(is_VirtualCallTypeData(), "wrong type");
 483     return is_VirtualCallTypeData() ? (VirtualCallTypeData*)this : nullptr;
 484   }
 485   ParametersTypeData* as_ParametersTypeData() const {
 486     assert(is_ParametersTypeData(), "wrong type");
 487     return is_ParametersTypeData() ? (ParametersTypeData*)this : nullptr;
 488   }
 489   SpeculativeTrapData* as_SpeculativeTrapData() const {
 490     assert(is_SpeculativeTrapData(), "wrong type");
 491     return is_SpeculativeTrapData() ? (SpeculativeTrapData*)this : nullptr;
 492   }
 493   ArrayStoreData* as_ArrayStoreData() const {
 494     assert(is_ArrayStoreData(), "wrong type");
 495     return is_ArrayStoreData() ? (ArrayStoreData*)this : nullptr;
 496   }
 497   ArrayLoadData* as_ArrayLoadData() const {
 498     assert(is_ArrayLoadData(), "wrong type");
 499     return is_ArrayLoadData() ? (ArrayLoadData*)this : nullptr;
 500   }
 501   ACmpData* as_ACmpData() const {
 502     assert(is_ACmpData(), "wrong type");
 503     return is_ACmpData() ? (ACmpData*)this : nullptr;
 504   }
 505 
 506 
 507   // Subclass specific initialization
 508   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo) {}
 509 
 510   // GC support
 511   virtual void clean_weak_klass_links(bool always_clean) {}
 512 
 513   // CI translation: ProfileData can represent both MethodDataOop data
 514   // as well as CIMethodData data. This function is provided for translating
 515   // an oop in a ProfileData to the ci equivalent. Generally speaking,
 516   // most ProfileData don't require any translation, so we provide the null
 517   // translation here, and the required translators are in the ci subclasses.
 518   virtual void translate_from(const ProfileData* data) {}
 519 
 520   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const {
 521     ShouldNotReachHere();
 522   }
 523 
 524   void print_data_on(outputStream* st, const MethodData* md) const;

 527   void tab(outputStream* st, bool first = false) const;
 528 };
 529 
 530 // BitData
 531 //
 532 // A BitData holds a flag or two in its header.
 533 class BitData : public ProfileData {
 534   friend class VMStructs;
 535   friend class JVMCIVMStructs;
 536 protected:
 537   enum : u1 {
 538     // null_seen:
 539     //  saw a null operand (cast/aastore/instanceof)
 540       null_seen_flag                  = DataLayout::first_flag + 0,
 541       exception_handler_entered_flag  = null_seen_flag + 1,
 542       deprecated_method_callsite_flag = exception_handler_entered_flag + 1
 543 #if INCLUDE_JVMCI
 544     // bytecode threw any exception
 545     , exception_seen_flag             = deprecated_method_callsite_flag + 1
 546 #endif
 547     , last_bit_data_flag
 548   };
 549   enum { bit_cell_count = 0 };  // no additional data fields needed.
 550 public:
 551   BitData(DataLayout* layout) : ProfileData(layout) {
 552   }
 553 
 554   virtual bool is_BitData() const { return true; }
 555 
 556   static int static_cell_count() {
 557     return bit_cell_count;
 558   }
 559 
 560   virtual int cell_count() const {
 561     return static_cell_count();
 562   }
 563 
 564   // Accessor
 565 
 566   // The null_seen flag bit is specially known to the interpreter.
 567   // Consulting it allows the compiler to avoid setting up null_check traps.
 568   bool null_seen() const  { return flag_at(null_seen_flag); }
 569   void set_null_seen()    { set_flag_at(null_seen_flag); }
 570   bool deprecated_method_call_site() const { return flag_at(deprecated_method_callsite_flag); }
 571   bool set_deprecated_method_call_site() { return data()->set_flag_at(deprecated_method_callsite_flag); }
 572   bool clear_deprecated_method_call_site() { return data()->clear_flag_at(deprecated_method_callsite_flag); }
 573 
 574 #if INCLUDE_JVMCI
 575   // true if an exception was thrown at the specific BCI
 576   bool exception_seen() { return flag_at(exception_seen_flag); }
 577   void set_exception_seen() { set_flag_at(exception_seen_flag); }
 578 #endif
 579 
 580   // true if a ex handler block at this bci was entered
 581   bool exception_handler_entered() { return flag_at(exception_handler_entered_flag); }
 582   void set_exception_handler_entered() { set_flag_at(exception_handler_entered_flag); }
 583 
 584   // Code generation support
 585   static u1 null_seen_byte_constant() {
 586     return flag_number_to_constant(null_seen_flag);
 587   }
 588 

 649 // branch.  It is a counter, used for counting the number of branches,
 650 // plus a data displacement, used for realigning the data pointer to
 651 // the corresponding target bci.
 652 class JumpData : public ProfileData {
 653   friend class VMStructs;
 654   friend class JVMCIVMStructs;
 655 protected:
 656   enum {
 657     taken_off_set,
 658     displacement_off_set,
 659     jump_cell_count
 660   };
 661 
 662   void set_displacement(int displacement) {
 663     set_int_at(displacement_off_set, displacement);
 664   }
 665 
 666 public:
 667   JumpData(DataLayout* layout) : ProfileData(layout) {
 668     assert(layout->tag() == DataLayout::jump_data_tag ||
 669       layout->tag() == DataLayout::branch_data_tag ||
 670       layout->tag() == DataLayout::acmp_data_tag, "wrong type");
 671   }
 672 
 673   virtual bool is_JumpData() const { return true; }
 674 
 675   static int static_cell_count() {
 676     return jump_cell_count;
 677   }
 678 
 679   virtual int cell_count() const {
 680     return static_cell_count();
 681   }
 682 
 683   // Direct accessor
 684   uint taken() const {
 685     return uint_at(taken_off_set);
 686   }
 687 
 688   void set_taken(uint cnt) {
 689     set_uint_at(taken_off_set, cnt);
 690   }

 886   static ByteSize per_arg_size() {
 887     return in_ByteSize(per_arg_cell_count * DataLayout::cell_size);
 888   }
 889 
 890   static int per_arg_count() {
 891     return per_arg_cell_count;
 892   }
 893 
 894   ByteSize type_offset(int i) const {
 895     return DataLayout::cell_offset(type_offset_in_cells(i));
 896   }
 897 
 898   // GC support
 899   void clean_weak_klass_links(bool always_clean);
 900 
 901   void print_data_on(outputStream* st) const;
 902 };
 903 
 904 // Type entry used for return from a call. A single cell to record the
 905 // type.
 906 class SingleTypeEntry : public TypeEntries {
 907 
 908 private:
 909   enum {
 910     cell_count = 1
 911   };
 912 
 913 public:
 914   SingleTypeEntry(int base_off)
 915     : TypeEntries(base_off) {}
 916 
 917   void post_initialize() {
 918     set_type(type_none());
 919   }
 920 
 921   intptr_t type() const {
 922     return _pd->intptr_at(_base_off);
 923   }
 924 
 925   void set_type(intptr_t k) {
 926     _pd->set_intptr_at(_base_off, k);
 927   }
 928 
 929   static int static_cell_count() {
 930     return cell_count;
 931   }
 932 
 933   static ByteSize size() {
 934     return in_ByteSize(cell_count * DataLayout::cell_size);
 935   }
 936 
 937   ByteSize type_offset() {
 938     return DataLayout::cell_offset(_base_off);
 939   }
 940 
 941   // GC support
 942   void clean_weak_klass_links(bool always_clean);
 943 
 944   void print_data_on(outputStream* st) const;
 945 };
 946 
 947 // Entries to collect type information at a call: contains arguments
 948 // (TypeStackSlotEntries), a return type (SingleTypeEntry) and a
 949 // number of cells. Because the number of cells for the return type is
 950 // smaller than the number of cells for the type of an arguments, the
 951 // number of cells is used to tell how many arguments are profiled and
 952 // whether a return value is profiled. See has_arguments() and
 953 // has_return().
 954 class TypeEntriesAtCall {
 955 private:
 956   static int stack_slot_local_offset(int i) {
 957     return header_cell_count() + TypeStackSlotEntries::stack_slot_local_offset(i);
 958   }
 959 
 960   static int argument_type_local_offset(int i) {
 961     return header_cell_count() + TypeStackSlotEntries::type_local_offset(i);
 962   }
 963 
 964 public:
 965 
 966   static int header_cell_count() {
 967     return 1;
 968   }

 982   static bool return_profiling_enabled();
 983 
 984   // Code generation support
 985   static ByteSize cell_count_offset() {
 986     return in_ByteSize(cell_count_local_offset() * DataLayout::cell_size);
 987   }
 988 
 989   static ByteSize args_data_offset() {
 990     return in_ByteSize(header_cell_count() * DataLayout::cell_size);
 991   }
 992 
 993   static ByteSize stack_slot_offset(int i) {
 994     return in_ByteSize(stack_slot_local_offset(i) * DataLayout::cell_size);
 995   }
 996 
 997   static ByteSize argument_type_offset(int i) {
 998     return in_ByteSize(argument_type_local_offset(i) * DataLayout::cell_size);
 999   }
1000 
1001   static ByteSize return_only_size() {
1002     return SingleTypeEntry::size() + in_ByteSize(header_cell_count() * DataLayout::cell_size);
1003   }
1004 
1005 };
1006 
1007 // CallTypeData
1008 //
1009 // A CallTypeData is used to access profiling information about a non
1010 // virtual call for which we collect type information about arguments
1011 // and return value.
1012 class CallTypeData : public CounterData {
1013 private:
1014   // entries for arguments if any
1015   TypeStackSlotEntries _args;
1016   // entry for return type if any
1017   SingleTypeEntry _ret;
1018 
1019   int cell_count_global_offset() const {
1020     return CounterData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
1021   }
1022 
1023   // number of cells not counting the header
1024   int cell_count_no_header() const {
1025     return uint_at(cell_count_global_offset());
1026   }
1027 
1028   void check_number_of_arguments(int total) {
1029     assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
1030   }
1031 
1032 public:
1033   CallTypeData(DataLayout* layout) :
1034     CounterData(layout),
1035     _args(CounterData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()),
1036     _ret(cell_count() - SingleTypeEntry::static_cell_count())
1037   {
1038     assert(layout->tag() == DataLayout::call_type_data_tag, "wrong type");
1039     // Some compilers (VC++) don't want this passed in member initialization list
1040     _args.set_profile_data(this);
1041     _ret.set_profile_data(this);
1042   }
1043 
1044   const TypeStackSlotEntries* args() const {
1045     assert(has_arguments(), "no profiling of arguments");
1046     return &_args;
1047   }
1048 
1049   const SingleTypeEntry* ret() const {
1050     assert(has_return(), "no profiling of return value");
1051     return &_ret;
1052   }
1053 
1054   virtual bool is_CallTypeData() const { return true; }
1055 
1056   static int static_cell_count() {
1057     return -1;
1058   }
1059 
1060   static int compute_cell_count(BytecodeStream* stream) {
1061     return CounterData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1062   }
1063 
1064   static void initialize(DataLayout* dl, int cell_count) {
1065     TypeEntriesAtCall::initialize(dl, CounterData::static_cell_count(), cell_count);
1066   }
1067 
1068   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);
1069 

1141 // dynamic type check.  It consists of a series of (Klass*, count)
1142 // pairs which are used to store a type profile for the receiver of
1143 // the check, the associated count is incremented every time the type
1144 // is seen. A per ReceiverTypeData counter is incremented on type
1145 // overflow (when there's no more room for a not yet profiled Klass*).
1146 //
1147 class ReceiverTypeData : public CounterData {
1148   friend class VMStructs;
1149   friend class JVMCIVMStructs;
1150 protected:
1151   enum {
1152     receiver0_offset = counter_cell_count,
1153     count0_offset,
1154     receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
1155   };
1156 
1157 public:
1158   ReceiverTypeData(DataLayout* layout) : CounterData(layout) {
1159     assert(layout->tag() == DataLayout::receiver_type_data_tag ||
1160            layout->tag() == DataLayout::virtual_call_data_tag ||
1161            layout->tag() == DataLayout::virtual_call_type_data_tag ||
1162            layout->tag() == DataLayout::array_store_data_tag, "wrong type");
1163   }
1164 
1165   virtual bool is_ReceiverTypeData() const { return true; }
1166 
1167   static int static_cell_count() {
1168     return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count;
1169   }
1170 
1171   virtual int cell_count() const {
1172     return static_cell_count();
1173   }
1174 
1175   // Direct accessors
1176   static uint row_limit() {
1177     return (uint) TypeProfileWidth;
1178   }
1179   static int receiver_cell_index(uint row) {
1180     return receiver0_offset + row * receiver_type_row_cell_count;
1181   }
1182   static int receiver_count_cell_index(uint row) {

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

1506 // BranchData
1507 //
1508 // A BranchData is used to access profiling data for a two-way branch.
1509 // It consists of taken and not_taken counts as well as a data displacement
1510 // for the taken case.
1511 class BranchData : public JumpData {
1512   friend class VMStructs;
1513   friend class JVMCIVMStructs;
1514 protected:
1515   enum {
1516     not_taken_off_set = jump_cell_count,
1517     branch_cell_count
1518   };
1519 
1520   void set_displacement(int displacement) {
1521     set_int_at(displacement_off_set, displacement);
1522   }
1523 
1524 public:
1525   BranchData(DataLayout* layout) : JumpData(layout) {
1526     assert(layout->tag() == DataLayout::branch_data_tag || layout->tag() == DataLayout::acmp_data_tag, "wrong type");
1527   }
1528 
1529   virtual bool is_BranchData() const { return true; }
1530 
1531   static int static_cell_count() {
1532     return branch_cell_count;
1533   }
1534 
1535   virtual int cell_count() const {
1536     return static_cell_count();
1537   }
1538 
1539   // Direct accessor
1540   uint not_taken() const {
1541     return uint_at(not_taken_off_set);
1542   }
1543 
1544   void set_not_taken(uint cnt) {
1545     set_uint_at(not_taken_off_set, cnt);
1546   }

1863     return static_cell_count();
1864   }
1865 
1866   // Direct accessor
1867   Method* method() const {
1868     return (Method*)intptr_at(speculative_trap_method);
1869   }
1870 
1871   void set_method(Method* m) {
1872     assert(!m->is_old(), "cannot add old methods");
1873     set_intptr_at(speculative_trap_method, (intptr_t)m);
1874   }
1875 
1876   static ByteSize method_offset() {
1877     return cell_offset(speculative_trap_method);
1878   }
1879 
1880   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
1881 };
1882 
1883 class ArrayStoreData : public ReceiverTypeData {
1884 private:
1885   enum {
1886     flat_array_flag = BitData::last_bit_data_flag,
1887     null_free_array_flag = flat_array_flag + 1,
1888   };
1889 
1890   SingleTypeEntry _array;
1891 
1892 public:
1893   ArrayStoreData(DataLayout* layout) :
1894     ReceiverTypeData(layout),
1895     _array(ReceiverTypeData::static_cell_count()) {
1896     assert(layout->tag() == DataLayout::array_store_data_tag, "wrong type");
1897     _array.set_profile_data(this);
1898   }
1899 
1900   const SingleTypeEntry* array() const {
1901     return &_array;
1902   }
1903 
1904   virtual bool is_ArrayStoreData() const { return true; }
1905 
1906   static int static_cell_count() {
1907     return ReceiverTypeData::static_cell_count() + SingleTypeEntry::static_cell_count();
1908   }
1909 
1910   virtual int cell_count() const {
1911     return static_cell_count();
1912   }
1913 
1914   void set_flat_array() { set_flag_at(flat_array_flag); }
1915   bool flat_array() const { return flag_at(flat_array_flag); }
1916 
1917   void set_null_free_array() { set_flag_at(null_free_array_flag); }
1918   bool null_free_array() const { return flag_at(null_free_array_flag); }
1919 
1920   // Code generation support
1921   static int flat_array_byte_constant() {
1922     return flag_number_to_constant(flat_array_flag);
1923   }
1924 
1925   static int null_free_array_byte_constant() {
1926     return flag_number_to_constant(null_free_array_flag);
1927   }
1928 
1929   static ByteSize array_offset() {
1930     return cell_offset(ReceiverTypeData::static_cell_count());
1931   }
1932 
1933   virtual void clean_weak_klass_links(bool always_clean) {
1934     ReceiverTypeData::clean_weak_klass_links(always_clean);
1935     _array.clean_weak_klass_links(always_clean);
1936   }
1937 
1938   static ByteSize array_store_data_size() {
1939     return cell_offset(static_cell_count());
1940   }
1941 
1942   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
1943 };
1944 
1945 class ArrayLoadData : public ProfileData {
1946 private:
1947   enum {
1948     flat_array_flag = DataLayout::first_flag,
1949     null_free_array_flag = flat_array_flag + 1,
1950   };
1951 
1952   SingleTypeEntry _array;
1953   SingleTypeEntry _element;
1954 
1955 public:
1956   ArrayLoadData(DataLayout* layout) :
1957     ProfileData(layout),
1958     _array(0),
1959     _element(SingleTypeEntry::static_cell_count()) {
1960     assert(layout->tag() == DataLayout::array_load_data_tag, "wrong type");
1961     _array.set_profile_data(this);
1962     _element.set_profile_data(this);
1963   }
1964 
1965   const SingleTypeEntry* array() const {
1966     return &_array;
1967   }
1968 
1969   const SingleTypeEntry* element() const {
1970     return &_element;
1971   }
1972 
1973   virtual bool is_ArrayLoadData() const { return true; }
1974 
1975   static int static_cell_count() {
1976     return SingleTypeEntry::static_cell_count() * 2;
1977   }
1978 
1979   virtual int cell_count() const {
1980     return static_cell_count();
1981   }
1982 
1983   void set_flat_array() { set_flag_at(flat_array_flag); }
1984   bool flat_array() const { return flag_at(flat_array_flag); }
1985 
1986   void set_null_free_array() { set_flag_at(null_free_array_flag); }
1987   bool null_free_array() const { return flag_at(null_free_array_flag); }
1988 
1989   // Code generation support
1990   static int flat_array_byte_constant() {
1991     return flag_number_to_constant(flat_array_flag);
1992   }
1993 
1994   static int null_free_array_byte_constant() {
1995     return flag_number_to_constant(null_free_array_flag);
1996   }
1997 
1998   static ByteSize array_offset() {
1999     return cell_offset(0);
2000   }
2001 
2002   static ByteSize element_offset() {
2003     return cell_offset(SingleTypeEntry::static_cell_count());
2004   }
2005 
2006   virtual void clean_weak_klass_links(bool always_clean) {
2007     _array.clean_weak_klass_links(always_clean);
2008     _element.clean_weak_klass_links(always_clean);
2009   }
2010 
2011   static ByteSize array_load_data_size() {
2012     return cell_offset(static_cell_count());
2013   }
2014 
2015   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
2016 };
2017 
2018 class ACmpData : public BranchData {
2019 private:
2020   enum {
2021     left_inline_type_flag = DataLayout::first_flag,
2022     right_inline_type_flag
2023   };
2024 
2025   SingleTypeEntry _left;
2026   SingleTypeEntry _right;
2027 
2028 public:
2029   ACmpData(DataLayout* layout) :
2030     BranchData(layout),
2031     _left(BranchData::static_cell_count()),
2032     _right(BranchData::static_cell_count() + SingleTypeEntry::static_cell_count()) {
2033     assert(layout->tag() == DataLayout::acmp_data_tag, "wrong type");
2034     _left.set_profile_data(this);
2035     _right.set_profile_data(this);
2036   }
2037 
2038   const SingleTypeEntry* left() const {
2039     return &_left;
2040   }
2041 
2042   const SingleTypeEntry* right() const {
2043     return &_right;
2044   }
2045 
2046   virtual bool is_ACmpData() const { return true; }
2047 
2048   static int static_cell_count() {
2049     return BranchData::static_cell_count() + SingleTypeEntry::static_cell_count() * 2;
2050   }
2051 
2052   virtual int cell_count() const {
2053     return static_cell_count();
2054   }
2055 
2056   void set_left_inline_type() { set_flag_at(left_inline_type_flag); }
2057   bool left_inline_type() const { return flag_at(left_inline_type_flag); }
2058 
2059   void set_right_inline_type() { set_flag_at(right_inline_type_flag); }
2060   bool right_inline_type() const { return flag_at(right_inline_type_flag); }
2061 
2062   // Code generation support
2063   static int left_inline_type_byte_constant() {
2064     return flag_number_to_constant(left_inline_type_flag);
2065   }
2066 
2067   static int right_inline_type_byte_constant() {
2068     return flag_number_to_constant(right_inline_type_flag);
2069   }
2070 
2071   static ByteSize left_offset() {
2072     return cell_offset(BranchData::static_cell_count());
2073   }
2074 
2075   static ByteSize right_offset() {
2076     return cell_offset(BranchData::static_cell_count() + SingleTypeEntry::static_cell_count());
2077   }
2078 
2079   virtual void clean_weak_klass_links(bool always_clean) {
2080     _left.clean_weak_klass_links(always_clean);
2081     _right.clean_weak_klass_links(always_clean);
2082   }
2083 
2084   static ByteSize acmp_data_size() {
2085     return cell_offset(static_cell_count());
2086   }
2087 
2088   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
2089 };
2090 
2091 // MethodData*
2092 //
2093 // A MethodData* holds information which has been collected about
2094 // a method.  Its layout looks like this:
2095 //
2096 // -----------------------------
2097 // | header                    |
2098 // | klass                     |
2099 // -----------------------------
2100 // | method                    |
2101 // | size of the MethodData* |
2102 // -----------------------------
2103 // | Data entries...           |
2104 // |   (variable size)         |
2105 // |                           |
2106 // .                           .
2107 // .                           .
2108 // .                           .
2109 // |                           |
2110 // -----------------------------
< prev index next >