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

 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       RetData;
 292 class       CallTypeData;
 293 class   JumpData;
 294 class     BranchData;

 295 class   ArrayData;
 296 class     MultiBranchData;
 297 class     ArgInfoData;
 298 class     ParametersTypeData;
 299 class   SpeculativeTrapData;

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

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



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

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












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

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

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

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

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

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

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

1148 // the check, the associated count is incremented every time the type
1149 // is seen. A per ReceiverTypeData counter is incremented on type
1150 // overflow (when there's no more room for a not yet profiled Klass*).
1151 //
1152 // Updated by platform-specific code, for example MacroAssembler::profile_receiver_type.
1153 //
1154 class ReceiverTypeData : public CounterData {
1155   friend class VMStructs;
1156   friend class JVMCIVMStructs;
1157 protected:
1158   enum {
1159     receiver0_offset = counter_cell_count,
1160     count0_offset,
1161     receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
1162   };
1163 
1164 public:
1165   ReceiverTypeData(DataLayout* layout) : CounterData(layout) {
1166     assert(layout->tag() == DataLayout::receiver_type_data_tag ||
1167            layout->tag() == DataLayout::virtual_call_data_tag ||
1168            layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");

1169   }
1170 
1171   virtual bool is_ReceiverTypeData() const { return true; }
1172 
1173   static int static_cell_count() {
1174     return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count;
1175   }
1176 
1177   virtual int cell_count() const {
1178     return static_cell_count();
1179   }
1180 
1181   // Direct accessors
1182   static uint row_limit() {
1183     return (uint) TypeProfileWidth;
1184   }
1185   static int receiver_cell_index(uint row) {
1186     return receiver0_offset + row * receiver_type_row_cell_count;
1187   }
1188   static int receiver_count_cell_index(uint row) {

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

1526 // BranchData
1527 //
1528 // A BranchData is used to access profiling data for a two-way branch.
1529 // It consists of taken and not_taken counts as well as a data displacement
1530 // for the taken case.
1531 class BranchData : public JumpData {
1532   friend class VMStructs;
1533   friend class JVMCIVMStructs;
1534 protected:
1535   enum {
1536     not_taken_off_set = jump_cell_count,
1537     branch_cell_count
1538   };
1539 
1540   void set_displacement(int displacement) {
1541     set_int_at(displacement_off_set, displacement);
1542   }
1543 
1544 public:
1545   BranchData(DataLayout* layout) : JumpData(layout) {
1546     assert(layout->tag() == DataLayout::branch_data_tag, "wrong type");
1547   }
1548 
1549   virtual bool is_BranchData() const { return true; }
1550 
1551   static int static_cell_count() {
1552     return branch_cell_count;
1553   }
1554 
1555   virtual int cell_count() const {
1556     return static_cell_count();
1557   }
1558 
1559   // Direct accessor
1560   uint not_taken() const {
1561     return uint_at(not_taken_off_set);
1562   }
1563 
1564   void set_not_taken(uint cnt) {
1565     set_uint_at(not_taken_off_set, cnt);
1566   }

1887   // Direct accessor
1888   Method* method() const {
1889     return (Method*)intptr_at(speculative_trap_method);
1890   }
1891 
1892   void set_method(Method* m) {
1893     assert(!m->is_old(), "cannot add old methods");
1894     set_intptr_at(speculative_trap_method, (intptr_t)m);
1895   }
1896 
1897   static ByteSize method_offset() {
1898     return cell_offset(speculative_trap_method);
1899   }
1900 
1901   // CDS support
1902   virtual void metaspace_pointers_do(MetaspaceClosure* it);
1903 
1904   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
1905 };
1906 































































































































































































































1907 // MethodData*
1908 //
1909 // A MethodData* holds information which has been collected about
1910 // a method.  Its layout looks like this:
1911 //
1912 // -----------------------------
1913 // | header                    |
1914 // | klass                     |
1915 // -----------------------------
1916 // | method                    |
1917 // | size of the MethodData* |
1918 // -----------------------------
1919 // | Data entries...           |
1920 // |   (variable size)         |
1921 // |                           |
1922 // .                           .
1923 // .                           .
1924 // .                           .
1925 // |                           |
1926 // -----------------------------

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

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

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

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

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

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

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

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

1171 // the check, the associated count is incremented every time the type
1172 // is seen. A per ReceiverTypeData counter is incremented on type
1173 // overflow (when there's no more room for a not yet profiled Klass*).
1174 //
1175 // Updated by platform-specific code, for example MacroAssembler::profile_receiver_type.
1176 //
1177 class ReceiverTypeData : public CounterData {
1178   friend class VMStructs;
1179   friend class JVMCIVMStructs;
1180 protected:
1181   enum {
1182     receiver0_offset = counter_cell_count,
1183     count0_offset,
1184     receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
1185   };
1186 
1187 public:
1188   ReceiverTypeData(DataLayout* layout) : CounterData(layout) {
1189     assert(layout->tag() == DataLayout::receiver_type_data_tag ||
1190            layout->tag() == DataLayout::virtual_call_data_tag ||
1191            layout->tag() == DataLayout::virtual_call_type_data_tag ||
1192            layout->tag() == DataLayout::array_store_data_tag, "wrong type");
1193   }
1194 
1195   virtual bool is_ReceiverTypeData() const { return true; }
1196 
1197   static int static_cell_count() {
1198     return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count;
1199   }
1200 
1201   virtual int cell_count() const {
1202     return static_cell_count();
1203   }
1204 
1205   // Direct accessors
1206   static uint row_limit() {
1207     return (uint) TypeProfileWidth;
1208   }
1209   static int receiver_cell_index(uint row) {
1210     return receiver0_offset + row * receiver_type_row_cell_count;
1211   }
1212   static int receiver_count_cell_index(uint row) {

1305 
1306   // Direct accessors
1307   static ByteSize virtual_call_data_size() {
1308     return cell_offset(static_cell_count());
1309   }
1310 
1311   void print_method_data_on(outputStream* st) const NOT_JVMCI_RETURN;
1312   void print_data_on(outputStream* st, const char* extra = nullptr) const;
1313 };
1314 
1315 // VirtualCallTypeData
1316 //
1317 // A VirtualCallTypeData is used to access profiling information about
1318 // a virtual call for which we collect type information about
1319 // arguments and return value.
1320 class VirtualCallTypeData : public VirtualCallData {
1321 private:
1322   // entries for arguments if any
1323   TypeStackSlotEntries _args;
1324   // entry for return type if any
1325   SingleTypeEntry _ret;
1326 
1327   int cell_count_global_offset() const {
1328     return VirtualCallData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
1329   }
1330 
1331   // number of cells not counting the header
1332   int cell_count_no_header() const {
1333     return uint_at(cell_count_global_offset());
1334   }
1335 
1336   void check_number_of_arguments(int total) {
1337     assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
1338   }
1339 
1340 public:
1341   VirtualCallTypeData(DataLayout* layout) :
1342     VirtualCallData(layout),
1343     _args(VirtualCallData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()),
1344     _ret(cell_count() - SingleTypeEntry::static_cell_count())
1345   {
1346     assert(layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");
1347     // Some compilers (VC++) don't want this passed in member initialization list
1348     _args.set_profile_data(this);
1349     _ret.set_profile_data(this);
1350   }
1351 
1352   const TypeStackSlotEntries* args() const {
1353     assert(has_arguments(), "no profiling of arguments");
1354     return &_args;
1355   }
1356 
1357   const SingleTypeEntry* ret() const {
1358     assert(has_return(), "no profiling of return value");
1359     return &_ret;
1360   }
1361 
1362   virtual bool is_VirtualCallTypeData() const { return true; }
1363 
1364   static int static_cell_count() {
1365     return -1;
1366   }
1367 
1368   static int compute_cell_count(BytecodeStream* stream) {
1369     return VirtualCallData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1370   }
1371 
1372   static void initialize(DataLayout* dl, int cell_count) {
1373     TypeEntriesAtCall::initialize(dl, VirtualCallData::static_cell_count(), cell_count);
1374   }
1375 
1376   virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);
1377 

1550 // BranchData
1551 //
1552 // A BranchData is used to access profiling data for a two-way branch.
1553 // It consists of taken and not_taken counts as well as a data displacement
1554 // for the taken case.
1555 class BranchData : public JumpData {
1556   friend class VMStructs;
1557   friend class JVMCIVMStructs;
1558 protected:
1559   enum {
1560     not_taken_off_set = jump_cell_count,
1561     branch_cell_count
1562   };
1563 
1564   void set_displacement(int displacement) {
1565     set_int_at(displacement_off_set, displacement);
1566   }
1567 
1568 public:
1569   BranchData(DataLayout* layout) : JumpData(layout) {
1570     assert(layout->tag() == DataLayout::branch_data_tag || layout->tag() == DataLayout::acmp_data_tag, "wrong type");
1571   }
1572 
1573   virtual bool is_BranchData() const { return true; }
1574 
1575   static int static_cell_count() {
1576     return branch_cell_count;
1577   }
1578 
1579   virtual int cell_count() const {
1580     return static_cell_count();
1581   }
1582 
1583   // Direct accessor
1584   uint not_taken() const {
1585     return uint_at(not_taken_off_set);
1586   }
1587 
1588   void set_not_taken(uint cnt) {
1589     set_uint_at(not_taken_off_set, cnt);
1590   }

1911   // Direct accessor
1912   Method* method() const {
1913     return (Method*)intptr_at(speculative_trap_method);
1914   }
1915 
1916   void set_method(Method* m) {
1917     assert(!m->is_old(), "cannot add old methods");
1918     set_intptr_at(speculative_trap_method, (intptr_t)m);
1919   }
1920 
1921   static ByteSize method_offset() {
1922     return cell_offset(speculative_trap_method);
1923   }
1924 
1925   // CDS support
1926   virtual void metaspace_pointers_do(MetaspaceClosure* it);
1927 
1928   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
1929 };
1930 
1931 class ArrayStoreData : public ReceiverTypeData {
1932 private:
1933   enum {
1934     flat_array_flag = BitData::last_bit_data_flag,
1935     null_free_array_flag = flat_array_flag + 1,
1936   };
1937 
1938   SingleTypeEntry _array;
1939 
1940 public:
1941   ArrayStoreData(DataLayout* layout) :
1942     ReceiverTypeData(layout),
1943     _array(ReceiverTypeData::static_cell_count()) {
1944     assert(layout->tag() == DataLayout::array_store_data_tag, "wrong type");
1945     _array.set_profile_data(this);
1946   }
1947 
1948   const SingleTypeEntry* array() const {
1949     return &_array;
1950   }
1951 
1952   virtual bool is_ArrayStoreData() const { return true; }
1953 
1954   static int static_cell_count() {
1955     return ReceiverTypeData::static_cell_count() + SingleTypeEntry::static_cell_count();
1956   }
1957 
1958   virtual int cell_count() const {
1959     return static_cell_count();
1960   }
1961 
1962   void set_flat_array() { set_flag_at(flat_array_flag); }
1963   bool flat_array() const { return flag_at(flat_array_flag); }
1964 
1965   void set_null_free_array() { set_flag_at(null_free_array_flag); }
1966   bool null_free_array() const { return flag_at(null_free_array_flag); }
1967 
1968   // Code generation support
1969   static int flat_array_byte_constant() {
1970     return flag_number_to_constant(flat_array_flag);
1971   }
1972 
1973   static int null_free_array_byte_constant() {
1974     return flag_number_to_constant(null_free_array_flag);
1975   }
1976 
1977   static ByteSize array_offset() {
1978     return cell_offset(ReceiverTypeData::static_cell_count());
1979   }
1980 
1981   virtual void clean_weak_klass_links(bool always_clean) {
1982     ReceiverTypeData::clean_weak_klass_links(always_clean);
1983     _array.clean_weak_klass_links(always_clean);
1984   }
1985 
1986   virtual void metaspace_pointers_do(MetaspaceClosure* it) {
1987     ReceiverTypeData::metaspace_pointers_do(it);
1988     _array.metaspace_pointers_do(it);
1989   }
1990 
1991   static ByteSize array_store_data_size() {
1992     return cell_offset(static_cell_count());
1993   }
1994 
1995   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
1996 };
1997 
1998 class ArrayLoadData : public BitData {
1999 private:
2000   enum {
2001     flat_array_flag = BitData::last_bit_data_flag,
2002     null_free_array_flag = flat_array_flag + 1,
2003   };
2004 
2005   SingleTypeEntry _array;
2006   SingleTypeEntry _element;
2007 
2008 public:
2009   ArrayLoadData(DataLayout* layout) :
2010     BitData(layout),
2011     _array(0),
2012     _element(SingleTypeEntry::static_cell_count()) {
2013     assert(layout->tag() == DataLayout::array_load_data_tag, "wrong type");
2014     _array.set_profile_data(this);
2015     _element.set_profile_data(this);
2016   }
2017 
2018   const SingleTypeEntry* array() const {
2019     return &_array;
2020   }
2021 
2022   const SingleTypeEntry* element() const {
2023     return &_element;
2024   }
2025 
2026   virtual bool is_ArrayLoadData() const { return true; }
2027 
2028   static int static_cell_count() {
2029     return SingleTypeEntry::static_cell_count() * 2;
2030   }
2031 
2032   virtual int cell_count() const {
2033     return static_cell_count();
2034   }
2035 
2036   void set_flat_array() { set_flag_at(flat_array_flag); }
2037   bool flat_array() const { return flag_at(flat_array_flag); }
2038 
2039   void set_null_free_array() { set_flag_at(null_free_array_flag); }
2040   bool null_free_array() const { return flag_at(null_free_array_flag); }
2041 
2042   // Code generation support
2043   static int flat_array_byte_constant() {
2044     return flag_number_to_constant(flat_array_flag);
2045   }
2046 
2047   static int null_free_array_byte_constant() {
2048     return flag_number_to_constant(null_free_array_flag);
2049   }
2050 
2051   static ByteSize array_offset() {
2052     return cell_offset(0);
2053   }
2054 
2055   static ByteSize element_offset() {
2056     return cell_offset(SingleTypeEntry::static_cell_count());
2057   }
2058 
2059   virtual void clean_weak_klass_links(bool always_clean) {
2060     _array.clean_weak_klass_links(always_clean);
2061     _element.clean_weak_klass_links(always_clean);
2062   }
2063 
2064   virtual void metaspace_pointers_do(MetaspaceClosure* it) {
2065     _array.metaspace_pointers_do(it);
2066     _element.metaspace_pointers_do(it);
2067   }
2068 
2069   static ByteSize array_load_data_size() {
2070     return cell_offset(static_cell_count());
2071   }
2072 
2073   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
2074 };
2075 
2076 class ACmpData : public BranchData {
2077 private:
2078   enum {
2079     left_inline_type_flag = DataLayout::first_flag,
2080     right_inline_type_flag
2081   };
2082 
2083   SingleTypeEntry _left;
2084   SingleTypeEntry _right;
2085 
2086 public:
2087   ACmpData(DataLayout* layout) :
2088     BranchData(layout),
2089     _left(BranchData::static_cell_count()),
2090     _right(BranchData::static_cell_count() + SingleTypeEntry::static_cell_count()) {
2091     assert(layout->tag() == DataLayout::acmp_data_tag, "wrong type");
2092     _left.set_profile_data(this);
2093     _right.set_profile_data(this);
2094   }
2095 
2096   const SingleTypeEntry* left() const {
2097     return &_left;
2098   }
2099 
2100   const SingleTypeEntry* right() const {
2101     return &_right;
2102   }
2103 
2104   virtual bool is_ACmpData() const { return true; }
2105 
2106   static int static_cell_count() {
2107     return BranchData::static_cell_count() + SingleTypeEntry::static_cell_count() * 2;
2108   }
2109 
2110   virtual int cell_count() const {
2111     return static_cell_count();
2112   }
2113 
2114   void set_left_inline_type() { set_flag_at(left_inline_type_flag); }
2115   bool left_inline_type() const { return flag_at(left_inline_type_flag); }
2116 
2117   void set_right_inline_type() { set_flag_at(right_inline_type_flag); }
2118   bool right_inline_type() const { return flag_at(right_inline_type_flag); }
2119 
2120   // Code generation support
2121   static int left_inline_type_byte_constant() {
2122     return flag_number_to_constant(left_inline_type_flag);
2123   }
2124 
2125   static int right_inline_type_byte_constant() {
2126     return flag_number_to_constant(right_inline_type_flag);
2127   }
2128 
2129   static ByteSize left_offset() {
2130     return cell_offset(BranchData::static_cell_count());
2131   }
2132 
2133   static ByteSize right_offset() {
2134     return cell_offset(BranchData::static_cell_count() + SingleTypeEntry::static_cell_count());
2135   }
2136 
2137   virtual void clean_weak_klass_links(bool always_clean) {
2138     _left.clean_weak_klass_links(always_clean);
2139     _right.clean_weak_klass_links(always_clean);
2140   }
2141 
2142   virtual void metaspace_pointers_do(MetaspaceClosure* it) {
2143     _left.metaspace_pointers_do(it);
2144     _right.metaspace_pointers_do(it);
2145   }
2146 
2147   static ByteSize acmp_data_size() {
2148     return cell_offset(static_cell_count());
2149   }
2150 
2151   virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
2152 };
2153 
2154 // MethodData*
2155 //
2156 // A MethodData* holds information which has been collected about
2157 // a method.  Its layout looks like this:
2158 //
2159 // -----------------------------
2160 // | header                    |
2161 // | klass                     |
2162 // -----------------------------
2163 // | method                    |
2164 // | size of the MethodData* |
2165 // -----------------------------
2166 // | Data entries...           |
2167 // |   (variable size)         |
2168 // |                           |
2169 // .                           .
2170 // .                           .
2171 // .                           .
2172 // |                           |
2173 // -----------------------------
< prev index next >