< prev index next >

src/hotspot/share/oops/methodData.hpp

Print this page

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



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

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

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

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

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

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



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

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












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

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

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

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

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

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

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

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

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

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

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

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
















































































































































































































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

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

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

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

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

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

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

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

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

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

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

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

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