< 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);

 244 
 245   int size_in_bytes() {
 246     int cells = cell_count();
 247     assert(cells >= 0, "invalid number of cells");
 248     return DataLayout::compute_size_in_bytes(cells);
 249   }
 250   int cell_count();
 251 
 252   // GC support
 253   void clean_weak_klass_links(bool always_clean);
 254 };
 255 
 256 
 257 // ProfileData class hierarchy
 258 class ProfileData;
 259 class   BitData;
 260 class     CounterData;
 261 class       ReceiverTypeData;
 262 class         VirtualCallData;
 263 class           VirtualCallTypeData;

 264 class       RetData;
 265 class       CallTypeData;
 266 class   JumpData;
 267 class     BranchData;

 268 class   ArrayData;
 269 class     MultiBranchData;
 270 class     ArgInfoData;
 271 class     ParametersTypeData;
 272 class   SpeculativeTrapData;

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

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



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

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












 459 
 460 
 461   // Subclass specific initialization
 462   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo) {}
 463 
 464   // GC support
 465   virtual void clean_weak_klass_links(bool always_clean) {}
 466 
 467   // CI translation: ProfileData can represent both MethodDataOop data
 468   // as well as CIMethodData data. This function is provided for translating
 469   // an oop in a ProfileData to the ci equivalent. Generally speaking,
 470   // most ProfileData don't require any translation, so we provide the null
 471   // translation here, and the required translators are in the ci subclasses.
 472   virtual void translate_from(const ProfileData* data) {}
 473 
 474   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const {
 475     ShouldNotReachHere();
 476   }
 477 
 478   void print_data_on(outputStream* st, const MethodData* md) const;
 479 
 480   void print_shared(outputStream* st, const char* name, const char* extra) const;
 481   void tab(outputStream* st, bool first = false) const;
 482 };
 483 
 484 // BitData
 485 //
 486 // A BitData holds a flag or two in its header.
 487 class BitData : public ProfileData {
 488   friend class VMStructs;
 489   friend class JVMCIVMStructs;
 490 protected:
 491   enum : u1 {
 492     // null_seen:
 493     //  saw a null operand (cast/aastore/instanceof)
 494       null_seen_flag              = DataLayout::first_flag + 0
 495 #if INCLUDE_JVMCI
 496     // bytecode threw any exception
 497     , exception_seen_flag         = null_seen_flag + 1
 498 #endif

 499   };
 500   enum { bit_cell_count = 0 };  // no additional data fields needed.
 501 public:
 502   BitData(DataLayout* layout) : ProfileData(layout) {
 503   }
 504 
 505   virtual bool is_BitData() const { return true; }
 506 
 507   static int static_cell_count() {
 508     return bit_cell_count;
 509   }
 510 
 511   virtual int cell_count() const {
 512     return static_cell_count();
 513   }
 514 
 515   // Accessor
 516 
 517   // The null_seen flag bit is specially known to the interpreter.
 518   // Consulting it allows the compiler to avoid setting up null_check traps.
 519   bool null_seen()     { return flag_at(null_seen_flag); }
 520   void set_null_seen()    { set_flag_at(null_seen_flag); }
 521 
 522 #if INCLUDE_JVMCI
 523   // true if an exception was thrown at the specific BCI
 524   bool exception_seen() { return flag_at(exception_seen_flag); }
 525   void set_exception_seen() { set_flag_at(exception_seen_flag); }
 526 #endif
 527 
 528   // Code generation support
 529   static u1 null_seen_byte_constant() {
 530     return flag_number_to_constant(null_seen_flag);
 531   }
 532 
 533   static ByteSize bit_data_size() {
 534     return cell_offset(bit_cell_count);
 535   }
 536 
 537   void print_data_on(outputStream* st, const char* extra = nullptr) const;
 538 };
 539 

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

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

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

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

1084 // dynamic type check.  It consists of a series of (Klass*, count)
1085 // pairs which are used to store a type profile for the receiver of
1086 // the check, the associated count is incremented every time the type
1087 // is seen. A per ReceiverTypeData counter is incremented on type
1088 // overflow (when there's no more room for a not yet profiled Klass*).
1089 //
1090 class ReceiverTypeData : public CounterData {
1091   friend class VMStructs;
1092   friend class JVMCIVMStructs;
1093 protected:
1094   enum {
1095     receiver0_offset = counter_cell_count,
1096     count0_offset,
1097     receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
1098   };
1099 
1100 public:
1101   ReceiverTypeData(DataLayout* layout) : CounterData(layout) {
1102     assert(layout->tag() == DataLayout::receiver_type_data_tag ||
1103            layout->tag() == DataLayout::virtual_call_data_tag ||
1104            layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");

1105   }
1106 
1107   virtual bool is_ReceiverTypeData() const { return true; }
1108 
1109   static int static_cell_count() {
1110     return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count;
1111   }
1112 
1113   virtual int cell_count() const {
1114     return static_cell_count();
1115   }
1116 
1117   // Direct accessors
1118   static uint row_limit() {
1119     return (uint) TypeProfileWidth;
1120   }
1121   static int receiver_cell_index(uint row) {
1122     return receiver0_offset + row * receiver_type_row_cell_count;
1123   }
1124   static int receiver_count_cell_index(uint row) {

1214 
1215   // Direct accessors
1216   static ByteSize virtual_call_data_size() {
1217     return cell_offset(static_cell_count());
1218   }
1219 
1220   void print_method_data_on(outputStream* st) const NOT_JVMCI_RETURN;
1221   void print_data_on(outputStream* st, const char* extra = nullptr) const;
1222 };
1223 
1224 // VirtualCallTypeData
1225 //
1226 // A VirtualCallTypeData is used to access profiling information about
1227 // a virtual call for which we collect type information about
1228 // arguments and return value.
1229 class VirtualCallTypeData : public VirtualCallData {
1230 private:
1231   // entries for arguments if any
1232   TypeStackSlotEntries _args;
1233   // entry for return type if any
1234   ReturnTypeEntry _ret;
1235 
1236   int cell_count_global_offset() const {
1237     return VirtualCallData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
1238   }
1239 
1240   // number of cells not counting the header
1241   int cell_count_no_header() const {
1242     return uint_at(cell_count_global_offset());
1243   }
1244 
1245   void check_number_of_arguments(int total) {
1246     assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
1247   }
1248 
1249 public:
1250   VirtualCallTypeData(DataLayout* layout) :
1251     VirtualCallData(layout),
1252     _args(VirtualCallData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()),
1253     _ret(cell_count() - ReturnTypeEntry::static_cell_count())
1254   {
1255     assert(layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");
1256     // Some compilers (VC++) don't want this passed in member initialization list
1257     _args.set_profile_data(this);
1258     _ret.set_profile_data(this);
1259   }
1260 
1261   const TypeStackSlotEntries* args() const {
1262     assert(has_arguments(), "no profiling of arguments");
1263     return &_args;
1264   }
1265 
1266   const ReturnTypeEntry* ret() const {
1267     assert(has_return(), "no profiling of return value");
1268     return &_ret;
1269   }
1270 
1271   virtual bool is_VirtualCallTypeData() const { return true; }
1272 
1273   static int static_cell_count() {
1274     return -1;
1275   }
1276 
1277   static int compute_cell_count(BytecodeStream* stream) {
1278     return VirtualCallData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1279   }
1280 
1281   static void initialize(DataLayout* dl, int cell_count) {
1282     TypeEntriesAtCall::initialize(dl, VirtualCallData::static_cell_count(), cell_count);
1283   }
1284 
1285   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);
1286 

1448 // BranchData
1449 //
1450 // A BranchData is used to access profiling data for a two-way branch.
1451 // It consists of taken and not_taken counts as well as a data displacement
1452 // for the taken case.
1453 class BranchData : public JumpData {
1454   friend class VMStructs;
1455   friend class JVMCIVMStructs;
1456 protected:
1457   enum {
1458     not_taken_off_set = jump_cell_count,
1459     branch_cell_count
1460   };
1461 
1462   void set_displacement(int displacement) {
1463     set_int_at(displacement_off_set, displacement);
1464   }
1465 
1466 public:
1467   BranchData(DataLayout* layout) : JumpData(layout) {
1468     assert(layout->tag() == DataLayout::branch_data_tag, "wrong type");
1469   }
1470 
1471   virtual bool is_BranchData() const { return true; }
1472 
1473   static int static_cell_count() {
1474     return branch_cell_count;
1475   }
1476 
1477   virtual int cell_count() const {
1478     return static_cell_count();
1479   }
1480 
1481   // Direct accessor
1482   uint not_taken() const {
1483     return uint_at(not_taken_off_set);
1484   }
1485 
1486   void set_not_taken(uint cnt) {
1487     set_uint_at(not_taken_off_set, cnt);
1488   }

1802   }
1803 
1804   virtual int cell_count() const {
1805     return static_cell_count();
1806   }
1807 
1808   // Direct accessor
1809   Method* method() const {
1810     return (Method*)intptr_at(speculative_trap_method);
1811   }
1812 
1813   void set_method(Method* m) {
1814     assert(!m->is_old(), "cannot add old methods");
1815     set_intptr_at(speculative_trap_method, (intptr_t)m);
1816   }
1817 
1818   static ByteSize method_offset() {
1819     return cell_offset(speculative_trap_method);
1820   }
1821 
















































































































































































































1822   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
1823 };
1824 
1825 // MethodData*
1826 //
1827 // A MethodData* holds information which has been collected about
1828 // a method.  Its layout looks like this:
1829 //
1830 // -----------------------------
1831 // | header                    |
1832 // | klass                     |
1833 // -----------------------------
1834 // | method                    |
1835 // | size of the MethodData* |
1836 // -----------------------------
1837 // | Data entries...           |
1838 // |   (variable size)         |
1839 // |                           |
1840 // .                           .
1841 // .                           .

 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);

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

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

 448   ArgInfoData* as_ArgInfoData() const {
 449     assert(is_ArgInfoData(), "wrong type");
 450     return is_ArgInfoData() ? (ArgInfoData*)this : nullptr;
 451   }
 452   CallTypeData* as_CallTypeData() const {
 453     assert(is_CallTypeData(), "wrong type");
 454     return is_CallTypeData() ? (CallTypeData*)this : nullptr;
 455   }
 456   VirtualCallTypeData* as_VirtualCallTypeData() const {
 457     assert(is_VirtualCallTypeData(), "wrong type");
 458     return is_VirtualCallTypeData() ? (VirtualCallTypeData*)this : nullptr;
 459   }
 460   ParametersTypeData* as_ParametersTypeData() const {
 461     assert(is_ParametersTypeData(), "wrong type");
 462     return is_ParametersTypeData() ? (ParametersTypeData*)this : nullptr;
 463   }
 464   SpeculativeTrapData* as_SpeculativeTrapData() const {
 465     assert(is_SpeculativeTrapData(), "wrong type");
 466     return is_SpeculativeTrapData() ? (SpeculativeTrapData*)this : nullptr;
 467   }
 468   ArrayStoreData* as_ArrayStoreData() const {
 469     assert(is_ArrayStoreData(), "wrong type");
 470     return is_ArrayStoreData() ? (ArrayStoreData*)this : nullptr;
 471   }
 472   ArrayLoadData* as_ArrayLoadData() const {
 473     assert(is_ArrayLoadData(), "wrong type");
 474     return is_ArrayLoadData() ? (ArrayLoadData*)this : nullptr;
 475   }
 476   ACmpData* as_ACmpData() const {
 477     assert(is_ACmpData(), "wrong type");
 478     return is_ACmpData() ? (ACmpData*)this : nullptr;
 479   }
 480 
 481 
 482   // Subclass specific initialization
 483   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo) {}
 484 
 485   // GC support
 486   virtual void clean_weak_klass_links(bool always_clean) {}
 487 
 488   // CI translation: ProfileData can represent both MethodDataOop data
 489   // as well as CIMethodData data. This function is provided for translating
 490   // an oop in a ProfileData to the ci equivalent. Generally speaking,
 491   // most ProfileData don't require any translation, so we provide the null
 492   // translation here, and the required translators are in the ci subclasses.
 493   virtual void translate_from(const ProfileData* data) {}
 494 
 495   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const {
 496     ShouldNotReachHere();
 497   }
 498 
 499   void print_data_on(outputStream* st, const MethodData* md) const;
 500 
 501   void print_shared(outputStream* st, const char* name, const char* extra) const;
 502   void tab(outputStream* st, bool first = false) const;
 503 };
 504 
 505 // BitData
 506 //
 507 // A BitData holds a flag or two in its header.
 508 class BitData : public ProfileData {
 509   friend class VMStructs;
 510   friend class JVMCIVMStructs;
 511 protected:
 512   enum : u1 {
 513     // null_seen:
 514     //  saw a null operand (cast/aastore/instanceof)
 515       null_seen_flag              = DataLayout::first_flag + 0,
 516 #if INCLUDE_JVMCI
 517     // bytecode threw any exception
 518       exception_seen_flag         = null_seen_flag + 1,
 519 #endif
 520       last_bit_data_flag
 521   };
 522   enum { bit_cell_count = 0 };  // no additional data fields needed.
 523 public:
 524   BitData(DataLayout* layout) : ProfileData(layout) {
 525   }
 526 
 527   virtual bool is_BitData() const { return true; }
 528 
 529   static int static_cell_count() {
 530     return bit_cell_count;
 531   }
 532 
 533   virtual int cell_count() const {
 534     return static_cell_count();
 535   }
 536 
 537   // Accessor
 538 
 539   // The null_seen flag bit is specially known to the interpreter.
 540   // Consulting it allows the compiler to avoid setting up null_check traps.
 541   bool null_seen() const  { return flag_at(null_seen_flag); }
 542   void set_null_seen()    { set_flag_at(null_seen_flag); }
 543 
 544 #if INCLUDE_JVMCI
 545   // true if an exception was thrown at the specific BCI
 546   bool exception_seen() { return flag_at(exception_seen_flag); }
 547   void set_exception_seen() { set_flag_at(exception_seen_flag); }
 548 #endif
 549 
 550   // Code generation support
 551   static u1 null_seen_byte_constant() {
 552     return flag_number_to_constant(null_seen_flag);
 553   }
 554 
 555   static ByteSize bit_data_size() {
 556     return cell_offset(bit_cell_count);
 557   }
 558 
 559   void print_data_on(outputStream* st, const char* extra = nullptr) const;
 560 };
 561 

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

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

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

1107 // dynamic type check.  It consists of a series of (Klass*, count)
1108 // pairs which are used to store a type profile for the receiver of
1109 // the check, the associated count is incremented every time the type
1110 // is seen. A per ReceiverTypeData counter is incremented on type
1111 // overflow (when there's no more room for a not yet profiled Klass*).
1112 //
1113 class ReceiverTypeData : public CounterData {
1114   friend class VMStructs;
1115   friend class JVMCIVMStructs;
1116 protected:
1117   enum {
1118     receiver0_offset = counter_cell_count,
1119     count0_offset,
1120     receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
1121   };
1122 
1123 public:
1124   ReceiverTypeData(DataLayout* layout) : CounterData(layout) {
1125     assert(layout->tag() == DataLayout::receiver_type_data_tag ||
1126            layout->tag() == DataLayout::virtual_call_data_tag ||
1127            layout->tag() == DataLayout::virtual_call_type_data_tag ||
1128            layout->tag() == DataLayout::array_store_data_tag, "wrong type");
1129   }
1130 
1131   virtual bool is_ReceiverTypeData() const { return true; }
1132 
1133   static int static_cell_count() {
1134     return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count;
1135   }
1136 
1137   virtual int cell_count() const {
1138     return static_cell_count();
1139   }
1140 
1141   // Direct accessors
1142   static uint row_limit() {
1143     return (uint) TypeProfileWidth;
1144   }
1145   static int receiver_cell_index(uint row) {
1146     return receiver0_offset + row * receiver_type_row_cell_count;
1147   }
1148   static int receiver_count_cell_index(uint row) {

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

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

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