110
111 enum {
112 cell_size = sizeof(intptr_t)
113 };
114
115 // Tag values
116 enum : u1 {
117 no_tag,
118 bit_data_tag,
119 counter_data_tag,
120 jump_data_tag,
121 receiver_type_data_tag,
122 virtual_call_data_tag,
123 ret_data_tag,
124 branch_data_tag,
125 multi_branch_data_tag,
126 arg_info_data_tag,
127 call_type_data_tag,
128 virtual_call_type_data_tag,
129 parameters_type_data_tag,
130 speculative_trap_data_tag
131 };
132
133 enum {
134 // The trap state breaks down as [recompile:1 | reason:31].
135 // This further breakdown is defined in deoptimization.cpp.
136 // See Deoptimization::trap_state_reason for an assert that
137 // trap_bits is big enough to hold reasons < Reason_RECORDED_LIMIT.
138 //
139 // The trap_state is collected only if ProfileTraps is true.
140 trap_bits = 1+31, // 31: enough to distinguish [0..Reason_RECORDED_LIMIT].
141 trap_mask = -1,
142 first_flag = 0
143 };
144
145 // Size computation
146 static int header_size_in_bytes() {
147 return header_size_in_cells() * cell_size;
148 }
149 static int header_size_in_cells() {
150 return LP64_ONLY(1) NOT_LP64(2);
270
271 int size_in_bytes() {
272 int cells = cell_count();
273 assert(cells >= 0, "invalid number of cells");
274 return DataLayout::compute_size_in_bytes(cells);
275 }
276 int cell_count();
277
278 // GC support
279 void clean_weak_klass_links(bool always_clean);
280 };
281
282
283 // ProfileData class hierarchy
284 class ProfileData;
285 class BitData;
286 class CounterData;
287 class ReceiverTypeData;
288 class VirtualCallData;
289 class VirtualCallTypeData;
290 class RetData;
291 class CallTypeData;
292 class JumpData;
293 class BranchData;
294 class ArrayData;
295 class MultiBranchData;
296 class ArgInfoData;
297 class ParametersTypeData;
298 class SpeculativeTrapData;
299
300 // ProfileData
301 //
302 // A ProfileData object is created to refer to a section of profiling
303 // data in a structured way.
304 class ProfileData : public ResourceObj {
305 friend class TypeEntries;
306 friend class ReturnTypeEntry;
307 friend class TypeStackSlotEntries;
308 private:
309 enum {
310 tab_width_one = 16,
311 tab_width_two = 36
312 };
313
314 // This is a pointer to a section of profiling data.
315 DataLayout* _data;
316
317 char* print_data_on_helper(const MethodData* md) const;
318
319 protected:
320 DataLayout* data() { return _data; }
321 const DataLayout* data() const { return _data; }
322
323 enum {
324 cell_size = DataLayout::cell_size
325 };
326
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 // CDS support
492 virtual void metaspace_pointers_do(MetaspaceClosure* it) {}
493
494 // CI translation: ProfileData can represent both MethodDataOop data
495 // as well as CIMethodData data. This function is provided for translating
496 // an oop in a ProfileData to the ci equivalent. Generally speaking,
497 // most ProfileData don't require any translation, so we provide the null
498 // translation here, and the required translators are in the ci subclasses.
499 virtual void translate_from(const ProfileData* data) {}
500
501 virtual void print_data_on(outputStream* st, const char* extra = nullptr) const {
502 ShouldNotReachHere();
508 void tab(outputStream* st, bool first = false) const;
509 };
510
511 // BitData
512 //
513 // A BitData holds a flag or two in its header.
514 class BitData : public ProfileData {
515 friend class VMStructs;
516 friend class JVMCIVMStructs;
517 protected:
518 enum : u1 {
519 // null_seen:
520 // saw a null operand (cast/aastore/instanceof)
521 null_seen_flag = DataLayout::first_flag + 0,
522 exception_handler_entered_flag = null_seen_flag + 1,
523 deprecated_method_callsite_flag = exception_handler_entered_flag + 1
524 #if INCLUDE_JVMCI
525 // bytecode threw any exception
526 , exception_seen_flag = deprecated_method_callsite_flag + 1
527 #endif
528 };
529 enum { bit_cell_count = 0 }; // no additional data fields needed.
530 public:
531 BitData(DataLayout* layout) : ProfileData(layout) {
532 }
533
534 virtual bool is_BitData() const { return true; }
535
536 static int static_cell_count() {
537 return bit_cell_count;
538 }
539
540 virtual int cell_count() const {
541 return static_cell_count();
542 }
543
544 // Accessor
545
546 // The null_seen flag bit is specially known to the interpreter.
547 // Consulting it allows the compiler to avoid setting up null_check traps.
548 bool null_seen() { return flag_at(null_seen_flag); }
549 void set_null_seen() { set_flag_at(null_seen_flag); }
550 bool deprecated_method_call_site() const { return flag_at(deprecated_method_callsite_flag); }
551 bool set_deprecated_method_call_site() { return data()->set_flag_at(deprecated_method_callsite_flag); }
552 bool clear_deprecated_method_call_site() { return data()->clear_flag_at(deprecated_method_callsite_flag); }
553
554 #if INCLUDE_JVMCI
555 // true if an exception was thrown at the specific BCI
556 bool exception_seen() { return flag_at(exception_seen_flag); }
557 void set_exception_seen() { set_flag_at(exception_seen_flag); }
558 #endif
559
560 // true if a ex handler block at this bci was entered
561 bool exception_handler_entered() { return flag_at(exception_handler_entered_flag); }
562 void set_exception_handler_entered() { set_flag_at(exception_handler_entered_flag); }
563
564 // Code generation support
565 static u1 null_seen_byte_constant() {
566 return flag_number_to_constant(null_seen_flag);
567 }
568
629 // branch. It is a counter, used for counting the number of branches,
630 // plus a data displacement, used for realigning the data pointer to
631 // the corresponding target bci.
632 class JumpData : public ProfileData {
633 friend class VMStructs;
634 friend class JVMCIVMStructs;
635 protected:
636 enum {
637 taken_off_set,
638 displacement_off_set,
639 jump_cell_count
640 };
641
642 void set_displacement(int displacement) {
643 set_int_at(displacement_off_set, displacement);
644 }
645
646 public:
647 JumpData(DataLayout* layout) : ProfileData(layout) {
648 assert(layout->tag() == DataLayout::jump_data_tag ||
649 layout->tag() == DataLayout::branch_data_tag, "wrong type");
650 }
651
652 virtual bool is_JumpData() const { return true; }
653
654 static int static_cell_count() {
655 return jump_cell_count;
656 }
657
658 virtual int cell_count() const {
659 return static_cell_count();
660 }
661
662 // Direct accessor
663 uint taken() const {
664 return uint_at(taken_off_set);
665 }
666
667 void set_taken(uint cnt) {
668 set_uint_at(taken_off_set, cnt);
669 }
873
874 static int per_arg_count() {
875 return per_arg_cell_count;
876 }
877
878 ByteSize type_offset(int i) const {
879 return DataLayout::cell_offset(type_offset_in_cells(i));
880 }
881
882 // GC support
883 void clean_weak_klass_links(bool always_clean);
884
885 // CDS support
886 virtual void metaspace_pointers_do(MetaspaceClosure* it);
887
888 void print_data_on(outputStream* st) const;
889 };
890
891 // Type entry used for return from a call. A single cell to record the
892 // type.
893 class ReturnTypeEntry : public TypeEntries {
894
895 private:
896 enum {
897 cell_count = 1
898 };
899
900 public:
901 ReturnTypeEntry(int base_off)
902 : TypeEntries(base_off) {}
903
904 void post_initialize() {
905 set_type(type_none());
906 }
907
908 intptr_t type() const {
909 return _pd->intptr_at(_base_off);
910 }
911
912 intptr_t* type_adr() const {
913 return _pd->intptr_at_adr(_base_off);
914 }
915
916 void set_type(intptr_t k) {
917 _pd->set_intptr_at(_base_off, k);
918 }
919
920 static int static_cell_count() {
921 return cell_count;
922 }
923
924 static ByteSize size() {
925 return in_ByteSize(cell_count * DataLayout::cell_size);
926 }
927
928 ByteSize type_offset() {
929 return DataLayout::cell_offset(_base_off);
930 }
931
932 // GC support
933 void clean_weak_klass_links(bool always_clean);
934
935 // CDS support
936 virtual void metaspace_pointers_do(MetaspaceClosure* it);
937
938 void print_data_on(outputStream* st) const;
939 };
940
941 // Entries to collect type information at a call: contains arguments
942 // (TypeStackSlotEntries), a return type (ReturnTypeEntry) and a
943 // number of cells. Because the number of cells for the return type is
944 // smaller than the number of cells for the type of an arguments, the
945 // number of cells is used to tell how many arguments are profiled and
946 // whether a return value is profiled. See has_arguments() and
947 // has_return().
948 class TypeEntriesAtCall {
949 private:
950 static int stack_slot_local_offset(int i) {
951 return header_cell_count() + TypeStackSlotEntries::stack_slot_local_offset(i);
952 }
953
954 static int argument_type_local_offset(int i) {
955 return header_cell_count() + TypeStackSlotEntries::type_local_offset(i);
956 }
957
958 public:
959
960 static int header_cell_count() {
961 return 1;
962 }
976 static bool return_profiling_enabled();
977
978 // Code generation support
979 static ByteSize cell_count_offset() {
980 return in_ByteSize(cell_count_local_offset() * DataLayout::cell_size);
981 }
982
983 static ByteSize args_data_offset() {
984 return in_ByteSize(header_cell_count() * DataLayout::cell_size);
985 }
986
987 static ByteSize stack_slot_offset(int i) {
988 return in_ByteSize(stack_slot_local_offset(i) * DataLayout::cell_size);
989 }
990
991 static ByteSize argument_type_offset(int i) {
992 return in_ByteSize(argument_type_local_offset(i) * DataLayout::cell_size);
993 }
994
995 static ByteSize return_only_size() {
996 return ReturnTypeEntry::size() + in_ByteSize(header_cell_count() * DataLayout::cell_size);
997 }
998
999 };
1000
1001 // CallTypeData
1002 //
1003 // A CallTypeData is used to access profiling information about a non
1004 // virtual call for which we collect type information about arguments
1005 // and return value.
1006 class CallTypeData : public CounterData {
1007 private:
1008 // entries for arguments if any
1009 TypeStackSlotEntries _args;
1010 // entry for return type if any
1011 ReturnTypeEntry _ret;
1012
1013 int cell_count_global_offset() const {
1014 return CounterData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
1015 }
1016
1017 // number of cells not counting the header
1018 int cell_count_no_header() const {
1019 return uint_at(cell_count_global_offset());
1020 }
1021
1022 void check_number_of_arguments(int total) {
1023 assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
1024 }
1025
1026 public:
1027 CallTypeData(DataLayout* layout) :
1028 CounterData(layout),
1029 _args(CounterData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()),
1030 _ret(cell_count() - ReturnTypeEntry::static_cell_count())
1031 {
1032 assert(layout->tag() == DataLayout::call_type_data_tag, "wrong type");
1033 // Some compilers (VC++) don't want this passed in member initialization list
1034 _args.set_profile_data(this);
1035 _ret.set_profile_data(this);
1036 }
1037
1038 const TypeStackSlotEntries* args() const {
1039 assert(has_arguments(), "no profiling of arguments");
1040 return &_args;
1041 }
1042
1043 const ReturnTypeEntry* ret() const {
1044 assert(has_return(), "no profiling of return value");
1045 return &_ret;
1046 }
1047
1048 virtual bool is_CallTypeData() const { return true; }
1049
1050 static int static_cell_count() {
1051 return -1;
1052 }
1053
1054 static int compute_cell_count(BytecodeStream* stream) {
1055 return CounterData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1056 }
1057
1058 static void initialize(DataLayout* dl, int cell_count) {
1059 TypeEntriesAtCall::initialize(dl, CounterData::static_cell_count(), cell_count);
1060 }
1061
1062 virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);
1063
1145 // dynamic type check. It consists of a series of (Klass*, count)
1146 // pairs which are used to store a type profile for the receiver of
1147 // the check, the associated count is incremented every time the type
1148 // is seen. A per ReceiverTypeData counter is incremented on type
1149 // overflow (when there's no more room for a not yet profiled Klass*).
1150 //
1151 class ReceiverTypeData : public CounterData {
1152 friend class VMStructs;
1153 friend class JVMCIVMStructs;
1154 protected:
1155 enum {
1156 receiver0_offset = counter_cell_count,
1157 count0_offset,
1158 receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
1159 };
1160
1161 public:
1162 ReceiverTypeData(DataLayout* layout) : CounterData(layout) {
1163 assert(layout->tag() == DataLayout::receiver_type_data_tag ||
1164 layout->tag() == DataLayout::virtual_call_data_tag ||
1165 layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");
1166 }
1167
1168 virtual bool is_ReceiverTypeData() const { return true; }
1169
1170 static int static_cell_count() {
1171 return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count;
1172 }
1173
1174 virtual int cell_count() const {
1175 return static_cell_count();
1176 }
1177
1178 // Direct accessors
1179 static uint row_limit() {
1180 return (uint) TypeProfileWidth;
1181 }
1182 static int receiver_cell_index(uint row) {
1183 return receiver0_offset + row * receiver_type_row_cell_count;
1184 }
1185 static int receiver_count_cell_index(uint row) {
1278
1279 // Direct accessors
1280 static ByteSize virtual_call_data_size() {
1281 return cell_offset(static_cell_count());
1282 }
1283
1284 void print_method_data_on(outputStream* st) const NOT_JVMCI_RETURN;
1285 void print_data_on(outputStream* st, const char* extra = nullptr) const;
1286 };
1287
1288 // VirtualCallTypeData
1289 //
1290 // A VirtualCallTypeData is used to access profiling information about
1291 // a virtual call for which we collect type information about
1292 // arguments and return value.
1293 class VirtualCallTypeData : public VirtualCallData {
1294 private:
1295 // entries for arguments if any
1296 TypeStackSlotEntries _args;
1297 // entry for return type if any
1298 ReturnTypeEntry _ret;
1299
1300 int cell_count_global_offset() const {
1301 return VirtualCallData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
1302 }
1303
1304 // number of cells not counting the header
1305 int cell_count_no_header() const {
1306 return uint_at(cell_count_global_offset());
1307 }
1308
1309 void check_number_of_arguments(int total) {
1310 assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
1311 }
1312
1313 public:
1314 VirtualCallTypeData(DataLayout* layout) :
1315 VirtualCallData(layout),
1316 _args(VirtualCallData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()),
1317 _ret(cell_count() - ReturnTypeEntry::static_cell_count())
1318 {
1319 assert(layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");
1320 // Some compilers (VC++) don't want this passed in member initialization list
1321 _args.set_profile_data(this);
1322 _ret.set_profile_data(this);
1323 }
1324
1325 const TypeStackSlotEntries* args() const {
1326 assert(has_arguments(), "no profiling of arguments");
1327 return &_args;
1328 }
1329
1330 const ReturnTypeEntry* ret() const {
1331 assert(has_return(), "no profiling of return value");
1332 return &_ret;
1333 }
1334
1335 virtual bool is_VirtualCallTypeData() const { return true; }
1336
1337 static int static_cell_count() {
1338 return -1;
1339 }
1340
1341 static int compute_cell_count(BytecodeStream* stream) {
1342 return VirtualCallData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1343 }
1344
1345 static void initialize(DataLayout* dl, int cell_count) {
1346 TypeEntriesAtCall::initialize(dl, VirtualCallData::static_cell_count(), cell_count);
1347 }
1348
1349 virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);
1350
1523 // BranchData
1524 //
1525 // A BranchData is used to access profiling data for a two-way branch.
1526 // It consists of taken and not_taken counts as well as a data displacement
1527 // for the taken case.
1528 class BranchData : public JumpData {
1529 friend class VMStructs;
1530 friend class JVMCIVMStructs;
1531 protected:
1532 enum {
1533 not_taken_off_set = jump_cell_count,
1534 branch_cell_count
1535 };
1536
1537 void set_displacement(int displacement) {
1538 set_int_at(displacement_off_set, displacement);
1539 }
1540
1541 public:
1542 BranchData(DataLayout* layout) : JumpData(layout) {
1543 assert(layout->tag() == DataLayout::branch_data_tag, "wrong type");
1544 }
1545
1546 virtual bool is_BranchData() const { return true; }
1547
1548 static int static_cell_count() {
1549 return branch_cell_count;
1550 }
1551
1552 virtual int cell_count() const {
1553 return static_cell_count();
1554 }
1555
1556 // Direct accessor
1557 uint not_taken() const {
1558 return uint_at(not_taken_off_set);
1559 }
1560
1561 void set_not_taken(uint cnt) {
1562 set_uint_at(not_taken_off_set, cnt);
1563 }
1884 // Direct accessor
1885 Method* method() const {
1886 return (Method*)intptr_at(speculative_trap_method);
1887 }
1888
1889 void set_method(Method* m) {
1890 assert(!m->is_old(), "cannot add old methods");
1891 set_intptr_at(speculative_trap_method, (intptr_t)m);
1892 }
1893
1894 static ByteSize method_offset() {
1895 return cell_offset(speculative_trap_method);
1896 }
1897
1898 // CDS support
1899 virtual void metaspace_pointers_do(MetaspaceClosure* it);
1900
1901 virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
1902 };
1903
1904 // MethodData*
1905 //
1906 // A MethodData* holds information which has been collected about
1907 // a method. Its layout looks like this:
1908 //
1909 // -----------------------------
1910 // | header |
1911 // | klass |
1912 // -----------------------------
1913 // | method |
1914 // | size of the MethodData* |
1915 // -----------------------------
1916 // | Data entries... |
1917 // | (variable size) |
1918 // | |
1919 // . .
1920 // . .
1921 // . .
1922 // | |
1923 // -----------------------------
|
110
111 enum {
112 cell_size = sizeof(intptr_t)
113 };
114
115 // Tag values
116 enum : u1 {
117 no_tag,
118 bit_data_tag,
119 counter_data_tag,
120 jump_data_tag,
121 receiver_type_data_tag,
122 virtual_call_data_tag,
123 ret_data_tag,
124 branch_data_tag,
125 multi_branch_data_tag,
126 arg_info_data_tag,
127 call_type_data_tag,
128 virtual_call_type_data_tag,
129 parameters_type_data_tag,
130 speculative_trap_data_tag,
131 array_store_data_tag,
132 array_load_data_tag,
133 acmp_data_tag
134 };
135
136 enum {
137 // The trap state breaks down as [recompile:1 | reason:31].
138 // This further breakdown is defined in deoptimization.cpp.
139 // See Deoptimization::trap_state_reason for an assert that
140 // trap_bits is big enough to hold reasons < Reason_RECORDED_LIMIT.
141 //
142 // The trap_state is collected only if ProfileTraps is true.
143 trap_bits = 1+31, // 31: enough to distinguish [0..Reason_RECORDED_LIMIT].
144 trap_mask = -1,
145 first_flag = 0
146 };
147
148 // Size computation
149 static int header_size_in_bytes() {
150 return header_size_in_cells() * cell_size;
151 }
152 static int header_size_in_cells() {
153 return LP64_ONLY(1) NOT_LP64(2);
273
274 int size_in_bytes() {
275 int cells = cell_count();
276 assert(cells >= 0, "invalid number of cells");
277 return DataLayout::compute_size_in_bytes(cells);
278 }
279 int cell_count();
280
281 // GC support
282 void clean_weak_klass_links(bool always_clean);
283 };
284
285
286 // ProfileData class hierarchy
287 class ProfileData;
288 class BitData;
289 class CounterData;
290 class ReceiverTypeData;
291 class VirtualCallData;
292 class VirtualCallTypeData;
293 class ArrayStoreData;
294 class RetData;
295 class CallTypeData;
296 class JumpData;
297 class BranchData;
298 class ACmpData;
299 class ArrayData;
300 class MultiBranchData;
301 class ArgInfoData;
302 class ParametersTypeData;
303 class SpeculativeTrapData;
304 class ArrayLoadData;
305
306 // ProfileData
307 //
308 // A ProfileData object is created to refer to a section of profiling
309 // data in a structured way.
310 class ProfileData : public ResourceObj {
311 friend class TypeEntries;
312 friend class SingleTypeEntry;
313 friend class TypeStackSlotEntries;
314 private:
315 enum {
316 tab_width_one = 16,
317 tab_width_two = 36
318 };
319
320 // This is a pointer to a section of profiling data.
321 DataLayout* _data;
322
323 char* print_data_on_helper(const MethodData* md) const;
324
325 protected:
326 DataLayout* data() { return _data; }
327 const DataLayout* data() const { return _data; }
328
329 enum {
330 cell_size = DataLayout::cell_size
331 };
332
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 // CDS support
513 virtual void metaspace_pointers_do(MetaspaceClosure* it) {}
514
515 // CI translation: ProfileData can represent both MethodDataOop data
516 // as well as CIMethodData data. This function is provided for translating
517 // an oop in a ProfileData to the ci equivalent. Generally speaking,
518 // most ProfileData don't require any translation, so we provide the null
519 // translation here, and the required translators are in the ci subclasses.
520 virtual void translate_from(const ProfileData* data) {}
521
522 virtual void print_data_on(outputStream* st, const char* extra = nullptr) const {
523 ShouldNotReachHere();
529 void tab(outputStream* st, bool first = false) const;
530 };
531
532 // BitData
533 //
534 // A BitData holds a flag or two in its header.
535 class BitData : public ProfileData {
536 friend class VMStructs;
537 friend class JVMCIVMStructs;
538 protected:
539 enum : u1 {
540 // null_seen:
541 // saw a null operand (cast/aastore/instanceof)
542 null_seen_flag = DataLayout::first_flag + 0,
543 exception_handler_entered_flag = null_seen_flag + 1,
544 deprecated_method_callsite_flag = exception_handler_entered_flag + 1
545 #if INCLUDE_JVMCI
546 // bytecode threw any exception
547 , exception_seen_flag = deprecated_method_callsite_flag + 1
548 #endif
549 , last_bit_data_flag
550 };
551 enum { bit_cell_count = 0 }; // no additional data fields needed.
552 public:
553 BitData(DataLayout* layout) : ProfileData(layout) {
554 }
555
556 virtual bool is_BitData() const { return true; }
557
558 static int static_cell_count() {
559 return bit_cell_count;
560 }
561
562 virtual int cell_count() const {
563 return static_cell_count();
564 }
565
566 // Accessor
567
568 // The null_seen flag bit is specially known to the interpreter.
569 // Consulting it allows the compiler to avoid setting up null_check traps.
570 bool null_seen() const { return flag_at(null_seen_flag); }
571 void set_null_seen() { set_flag_at(null_seen_flag); }
572 bool deprecated_method_call_site() const { return flag_at(deprecated_method_callsite_flag); }
573 bool set_deprecated_method_call_site() { return data()->set_flag_at(deprecated_method_callsite_flag); }
574 bool clear_deprecated_method_call_site() { return data()->clear_flag_at(deprecated_method_callsite_flag); }
575
576 #if INCLUDE_JVMCI
577 // true if an exception was thrown at the specific BCI
578 bool exception_seen() { return flag_at(exception_seen_flag); }
579 void set_exception_seen() { set_flag_at(exception_seen_flag); }
580 #endif
581
582 // true if a ex handler block at this bci was entered
583 bool exception_handler_entered() { return flag_at(exception_handler_entered_flag); }
584 void set_exception_handler_entered() { set_flag_at(exception_handler_entered_flag); }
585
586 // Code generation support
587 static u1 null_seen_byte_constant() {
588 return flag_number_to_constant(null_seen_flag);
589 }
590
651 // branch. It is a counter, used for counting the number of branches,
652 // plus a data displacement, used for realigning the data pointer to
653 // the corresponding target bci.
654 class JumpData : public ProfileData {
655 friend class VMStructs;
656 friend class JVMCIVMStructs;
657 protected:
658 enum {
659 taken_off_set,
660 displacement_off_set,
661 jump_cell_count
662 };
663
664 void set_displacement(int displacement) {
665 set_int_at(displacement_off_set, displacement);
666 }
667
668 public:
669 JumpData(DataLayout* layout) : ProfileData(layout) {
670 assert(layout->tag() == DataLayout::jump_data_tag ||
671 layout->tag() == DataLayout::branch_data_tag ||
672 layout->tag() == DataLayout::acmp_data_tag, "wrong type");
673 }
674
675 virtual bool is_JumpData() const { return true; }
676
677 static int static_cell_count() {
678 return jump_cell_count;
679 }
680
681 virtual int cell_count() const {
682 return static_cell_count();
683 }
684
685 // Direct accessor
686 uint taken() const {
687 return uint_at(taken_off_set);
688 }
689
690 void set_taken(uint cnt) {
691 set_uint_at(taken_off_set, cnt);
692 }
896
897 static int per_arg_count() {
898 return per_arg_cell_count;
899 }
900
901 ByteSize type_offset(int i) const {
902 return DataLayout::cell_offset(type_offset_in_cells(i));
903 }
904
905 // GC support
906 void clean_weak_klass_links(bool always_clean);
907
908 // CDS support
909 virtual void metaspace_pointers_do(MetaspaceClosure* it);
910
911 void print_data_on(outputStream* st) const;
912 };
913
914 // Type entry used for return from a call. A single cell to record the
915 // type.
916 class SingleTypeEntry : public TypeEntries {
917
918 private:
919 enum {
920 cell_count = 1
921 };
922
923 public:
924 SingleTypeEntry(int base_off)
925 : TypeEntries(base_off) {}
926
927 void post_initialize() {
928 set_type(type_none());
929 }
930
931 intptr_t type() const {
932 return _pd->intptr_at(_base_off);
933 }
934
935 intptr_t* type_adr() const {
936 return _pd->intptr_at_adr(_base_off);
937 }
938
939 void set_type(intptr_t k) {
940 _pd->set_intptr_at(_base_off, k);
941 }
942
943 static int static_cell_count() {
944 return cell_count;
945 }
946
947 static ByteSize size() {
948 return in_ByteSize(cell_count * DataLayout::cell_size);
949 }
950
951 ByteSize type_offset() {
952 return DataLayout::cell_offset(_base_off);
953 }
954
955 // GC support
956 void clean_weak_klass_links(bool always_clean);
957
958 // CDS support
959 virtual void metaspace_pointers_do(MetaspaceClosure* it);
960
961 void print_data_on(outputStream* st) const;
962 };
963
964 // Entries to collect type information at a call: contains arguments
965 // (TypeStackSlotEntries), a return type (SingleTypeEntry) and a
966 // number of cells. Because the number of cells for the return type is
967 // smaller than the number of cells for the type of an arguments, the
968 // number of cells is used to tell how many arguments are profiled and
969 // whether a return value is profiled. See has_arguments() and
970 // has_return().
971 class TypeEntriesAtCall {
972 private:
973 static int stack_slot_local_offset(int i) {
974 return header_cell_count() + TypeStackSlotEntries::stack_slot_local_offset(i);
975 }
976
977 static int argument_type_local_offset(int i) {
978 return header_cell_count() + TypeStackSlotEntries::type_local_offset(i);
979 }
980
981 public:
982
983 static int header_cell_count() {
984 return 1;
985 }
999 static bool return_profiling_enabled();
1000
1001 // Code generation support
1002 static ByteSize cell_count_offset() {
1003 return in_ByteSize(cell_count_local_offset() * DataLayout::cell_size);
1004 }
1005
1006 static ByteSize args_data_offset() {
1007 return in_ByteSize(header_cell_count() * DataLayout::cell_size);
1008 }
1009
1010 static ByteSize stack_slot_offset(int i) {
1011 return in_ByteSize(stack_slot_local_offset(i) * DataLayout::cell_size);
1012 }
1013
1014 static ByteSize argument_type_offset(int i) {
1015 return in_ByteSize(argument_type_local_offset(i) * DataLayout::cell_size);
1016 }
1017
1018 static ByteSize return_only_size() {
1019 return SingleTypeEntry::size() + in_ByteSize(header_cell_count() * DataLayout::cell_size);
1020 }
1021
1022 };
1023
1024 // CallTypeData
1025 //
1026 // A CallTypeData is used to access profiling information about a non
1027 // virtual call for which we collect type information about arguments
1028 // and return value.
1029 class CallTypeData : public CounterData {
1030 private:
1031 // entries for arguments if any
1032 TypeStackSlotEntries _args;
1033 // entry for return type if any
1034 SingleTypeEntry _ret;
1035
1036 int cell_count_global_offset() const {
1037 return CounterData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
1038 }
1039
1040 // number of cells not counting the header
1041 int cell_count_no_header() const {
1042 return uint_at(cell_count_global_offset());
1043 }
1044
1045 void check_number_of_arguments(int total) {
1046 assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
1047 }
1048
1049 public:
1050 CallTypeData(DataLayout* layout) :
1051 CounterData(layout),
1052 _args(CounterData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()),
1053 _ret(cell_count() - SingleTypeEntry::static_cell_count())
1054 {
1055 assert(layout->tag() == DataLayout::call_type_data_tag, "wrong type");
1056 // Some compilers (VC++) don't want this passed in member initialization list
1057 _args.set_profile_data(this);
1058 _ret.set_profile_data(this);
1059 }
1060
1061 const TypeStackSlotEntries* args() const {
1062 assert(has_arguments(), "no profiling of arguments");
1063 return &_args;
1064 }
1065
1066 const SingleTypeEntry* ret() const {
1067 assert(has_return(), "no profiling of return value");
1068 return &_ret;
1069 }
1070
1071 virtual bool is_CallTypeData() const { return true; }
1072
1073 static int static_cell_count() {
1074 return -1;
1075 }
1076
1077 static int compute_cell_count(BytecodeStream* stream) {
1078 return CounterData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1079 }
1080
1081 static void initialize(DataLayout* dl, int cell_count) {
1082 TypeEntriesAtCall::initialize(dl, CounterData::static_cell_count(), cell_count);
1083 }
1084
1085 virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);
1086
1168 // dynamic type check. It consists of a series of (Klass*, count)
1169 // pairs which are used to store a type profile for the receiver of
1170 // the check, the associated count is incremented every time the type
1171 // is seen. A per ReceiverTypeData counter is incremented on type
1172 // overflow (when there's no more room for a not yet profiled Klass*).
1173 //
1174 class ReceiverTypeData : public CounterData {
1175 friend class VMStructs;
1176 friend class JVMCIVMStructs;
1177 protected:
1178 enum {
1179 receiver0_offset = counter_cell_count,
1180 count0_offset,
1181 receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
1182 };
1183
1184 public:
1185 ReceiverTypeData(DataLayout* layout) : CounterData(layout) {
1186 assert(layout->tag() == DataLayout::receiver_type_data_tag ||
1187 layout->tag() == DataLayout::virtual_call_data_tag ||
1188 layout->tag() == DataLayout::virtual_call_type_data_tag ||
1189 layout->tag() == DataLayout::array_store_data_tag, "wrong type");
1190 }
1191
1192 virtual bool is_ReceiverTypeData() const { return true; }
1193
1194 static int static_cell_count() {
1195 return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count;
1196 }
1197
1198 virtual int cell_count() const {
1199 return static_cell_count();
1200 }
1201
1202 // Direct accessors
1203 static uint row_limit() {
1204 return (uint) TypeProfileWidth;
1205 }
1206 static int receiver_cell_index(uint row) {
1207 return receiver0_offset + row * receiver_type_row_cell_count;
1208 }
1209 static int receiver_count_cell_index(uint row) {
1302
1303 // Direct accessors
1304 static ByteSize virtual_call_data_size() {
1305 return cell_offset(static_cell_count());
1306 }
1307
1308 void print_method_data_on(outputStream* st) const NOT_JVMCI_RETURN;
1309 void print_data_on(outputStream* st, const char* extra = nullptr) const;
1310 };
1311
1312 // VirtualCallTypeData
1313 //
1314 // A VirtualCallTypeData is used to access profiling information about
1315 // a virtual call for which we collect type information about
1316 // arguments and return value.
1317 class VirtualCallTypeData : public VirtualCallData {
1318 private:
1319 // entries for arguments if any
1320 TypeStackSlotEntries _args;
1321 // entry for return type if any
1322 SingleTypeEntry _ret;
1323
1324 int cell_count_global_offset() const {
1325 return VirtualCallData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
1326 }
1327
1328 // number of cells not counting the header
1329 int cell_count_no_header() const {
1330 return uint_at(cell_count_global_offset());
1331 }
1332
1333 void check_number_of_arguments(int total) {
1334 assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
1335 }
1336
1337 public:
1338 VirtualCallTypeData(DataLayout* layout) :
1339 VirtualCallData(layout),
1340 _args(VirtualCallData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()),
1341 _ret(cell_count() - SingleTypeEntry::static_cell_count())
1342 {
1343 assert(layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");
1344 // Some compilers (VC++) don't want this passed in member initialization list
1345 _args.set_profile_data(this);
1346 _ret.set_profile_data(this);
1347 }
1348
1349 const TypeStackSlotEntries* args() const {
1350 assert(has_arguments(), "no profiling of arguments");
1351 return &_args;
1352 }
1353
1354 const SingleTypeEntry* ret() const {
1355 assert(has_return(), "no profiling of return value");
1356 return &_ret;
1357 }
1358
1359 virtual bool is_VirtualCallTypeData() const { return true; }
1360
1361 static int static_cell_count() {
1362 return -1;
1363 }
1364
1365 static int compute_cell_count(BytecodeStream* stream) {
1366 return VirtualCallData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1367 }
1368
1369 static void initialize(DataLayout* dl, int cell_count) {
1370 TypeEntriesAtCall::initialize(dl, VirtualCallData::static_cell_count(), cell_count);
1371 }
1372
1373 virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);
1374
1547 // BranchData
1548 //
1549 // A BranchData is used to access profiling data for a two-way branch.
1550 // It consists of taken and not_taken counts as well as a data displacement
1551 // for the taken case.
1552 class BranchData : public JumpData {
1553 friend class VMStructs;
1554 friend class JVMCIVMStructs;
1555 protected:
1556 enum {
1557 not_taken_off_set = jump_cell_count,
1558 branch_cell_count
1559 };
1560
1561 void set_displacement(int displacement) {
1562 set_int_at(displacement_off_set, displacement);
1563 }
1564
1565 public:
1566 BranchData(DataLayout* layout) : JumpData(layout) {
1567 assert(layout->tag() == DataLayout::branch_data_tag || layout->tag() == DataLayout::acmp_data_tag, "wrong type");
1568 }
1569
1570 virtual bool is_BranchData() const { return true; }
1571
1572 static int static_cell_count() {
1573 return branch_cell_count;
1574 }
1575
1576 virtual int cell_count() const {
1577 return static_cell_count();
1578 }
1579
1580 // Direct accessor
1581 uint not_taken() const {
1582 return uint_at(not_taken_off_set);
1583 }
1584
1585 void set_not_taken(uint cnt) {
1586 set_uint_at(not_taken_off_set, cnt);
1587 }
1908 // Direct accessor
1909 Method* method() const {
1910 return (Method*)intptr_at(speculative_trap_method);
1911 }
1912
1913 void set_method(Method* m) {
1914 assert(!m->is_old(), "cannot add old methods");
1915 set_intptr_at(speculative_trap_method, (intptr_t)m);
1916 }
1917
1918 static ByteSize method_offset() {
1919 return cell_offset(speculative_trap_method);
1920 }
1921
1922 // CDS support
1923 virtual void metaspace_pointers_do(MetaspaceClosure* it);
1924
1925 virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
1926 };
1927
1928 class ArrayStoreData : public ReceiverTypeData {
1929 private:
1930 enum {
1931 flat_array_flag = BitData::last_bit_data_flag,
1932 null_free_array_flag = flat_array_flag + 1,
1933 };
1934
1935 SingleTypeEntry _array;
1936
1937 public:
1938 ArrayStoreData(DataLayout* layout) :
1939 ReceiverTypeData(layout),
1940 _array(ReceiverTypeData::static_cell_count()) {
1941 assert(layout->tag() == DataLayout::array_store_data_tag, "wrong type");
1942 _array.set_profile_data(this);
1943 }
1944
1945 const SingleTypeEntry* array() const {
1946 return &_array;
1947 }
1948
1949 virtual bool is_ArrayStoreData() const { return true; }
1950
1951 static int static_cell_count() {
1952 return ReceiverTypeData::static_cell_count() + SingleTypeEntry::static_cell_count();
1953 }
1954
1955 virtual int cell_count() const {
1956 return static_cell_count();
1957 }
1958
1959 void set_flat_array() { set_flag_at(flat_array_flag); }
1960 bool flat_array() const { return flag_at(flat_array_flag); }
1961
1962 void set_null_free_array() { set_flag_at(null_free_array_flag); }
1963 bool null_free_array() const { return flag_at(null_free_array_flag); }
1964
1965 // Code generation support
1966 static int flat_array_byte_constant() {
1967 return flag_number_to_constant(flat_array_flag);
1968 }
1969
1970 static int null_free_array_byte_constant() {
1971 return flag_number_to_constant(null_free_array_flag);
1972 }
1973
1974 static ByteSize array_offset() {
1975 return cell_offset(ReceiverTypeData::static_cell_count());
1976 }
1977
1978 virtual void clean_weak_klass_links(bool always_clean) {
1979 ReceiverTypeData::clean_weak_klass_links(always_clean);
1980 _array.clean_weak_klass_links(always_clean);
1981 }
1982
1983 virtual void metaspace_pointers_do(MetaspaceClosure* it) {
1984 ReceiverTypeData::metaspace_pointers_do(it);
1985 _array.metaspace_pointers_do(it);
1986 }
1987
1988 static ByteSize array_store_data_size() {
1989 return cell_offset(static_cell_count());
1990 }
1991
1992 virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
1993 };
1994
1995 class ArrayLoadData : public ProfileData {
1996 private:
1997 enum {
1998 flat_array_flag = DataLayout::first_flag,
1999 null_free_array_flag = flat_array_flag + 1,
2000 };
2001
2002 SingleTypeEntry _array;
2003 SingleTypeEntry _element;
2004
2005 public:
2006 ArrayLoadData(DataLayout* layout) :
2007 ProfileData(layout),
2008 _array(0),
2009 _element(SingleTypeEntry::static_cell_count()) {
2010 assert(layout->tag() == DataLayout::array_load_data_tag, "wrong type");
2011 _array.set_profile_data(this);
2012 _element.set_profile_data(this);
2013 }
2014
2015 const SingleTypeEntry* array() const {
2016 return &_array;
2017 }
2018
2019 const SingleTypeEntry* element() const {
2020 return &_element;
2021 }
2022
2023 virtual bool is_ArrayLoadData() const { return true; }
2024
2025 static int static_cell_count() {
2026 return SingleTypeEntry::static_cell_count() * 2;
2027 }
2028
2029 virtual int cell_count() const {
2030 return static_cell_count();
2031 }
2032
2033 void set_flat_array() { set_flag_at(flat_array_flag); }
2034 bool flat_array() const { return flag_at(flat_array_flag); }
2035
2036 void set_null_free_array() { set_flag_at(null_free_array_flag); }
2037 bool null_free_array() const { return flag_at(null_free_array_flag); }
2038
2039 // Code generation support
2040 static int flat_array_byte_constant() {
2041 return flag_number_to_constant(flat_array_flag);
2042 }
2043
2044 static int null_free_array_byte_constant() {
2045 return flag_number_to_constant(null_free_array_flag);
2046 }
2047
2048 static ByteSize array_offset() {
2049 return cell_offset(0);
2050 }
2051
2052 static ByteSize element_offset() {
2053 return cell_offset(SingleTypeEntry::static_cell_count());
2054 }
2055
2056 virtual void clean_weak_klass_links(bool always_clean) {
2057 _array.clean_weak_klass_links(always_clean);
2058 _element.clean_weak_klass_links(always_clean);
2059 }
2060
2061 virtual void metaspace_pointers_do(MetaspaceClosure* it) {
2062 _array.metaspace_pointers_do(it);
2063 _element.metaspace_pointers_do(it);
2064 }
2065
2066 static ByteSize array_load_data_size() {
2067 return cell_offset(static_cell_count());
2068 }
2069
2070 virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
2071 };
2072
2073 class ACmpData : public BranchData {
2074 private:
2075 enum {
2076 left_inline_type_flag = DataLayout::first_flag,
2077 right_inline_type_flag
2078 };
2079
2080 SingleTypeEntry _left;
2081 SingleTypeEntry _right;
2082
2083 public:
2084 ACmpData(DataLayout* layout) :
2085 BranchData(layout),
2086 _left(BranchData::static_cell_count()),
2087 _right(BranchData::static_cell_count() + SingleTypeEntry::static_cell_count()) {
2088 assert(layout->tag() == DataLayout::acmp_data_tag, "wrong type");
2089 _left.set_profile_data(this);
2090 _right.set_profile_data(this);
2091 }
2092
2093 const SingleTypeEntry* left() const {
2094 return &_left;
2095 }
2096
2097 const SingleTypeEntry* right() const {
2098 return &_right;
2099 }
2100
2101 virtual bool is_ACmpData() const { return true; }
2102
2103 static int static_cell_count() {
2104 return BranchData::static_cell_count() + SingleTypeEntry::static_cell_count() * 2;
2105 }
2106
2107 virtual int cell_count() const {
2108 return static_cell_count();
2109 }
2110
2111 void set_left_inline_type() { set_flag_at(left_inline_type_flag); }
2112 bool left_inline_type() const { return flag_at(left_inline_type_flag); }
2113
2114 void set_right_inline_type() { set_flag_at(right_inline_type_flag); }
2115 bool right_inline_type() const { return flag_at(right_inline_type_flag); }
2116
2117 // Code generation support
2118 static int left_inline_type_byte_constant() {
2119 return flag_number_to_constant(left_inline_type_flag);
2120 }
2121
2122 static int right_inline_type_byte_constant() {
2123 return flag_number_to_constant(right_inline_type_flag);
2124 }
2125
2126 static ByteSize left_offset() {
2127 return cell_offset(BranchData::static_cell_count());
2128 }
2129
2130 static ByteSize right_offset() {
2131 return cell_offset(BranchData::static_cell_count() + SingleTypeEntry::static_cell_count());
2132 }
2133
2134 virtual void clean_weak_klass_links(bool always_clean) {
2135 _left.clean_weak_klass_links(always_clean);
2136 _right.clean_weak_klass_links(always_clean);
2137 }
2138
2139 virtual void metaspace_pointers_do(MetaspaceClosure* it) {
2140 _left.metaspace_pointers_do(it);
2141 _right.metaspace_pointers_do(it);
2142 }
2143
2144 static ByteSize acmp_data_size() {
2145 return cell_offset(static_cell_count());
2146 }
2147
2148 virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
2149 };
2150
2151 // MethodData*
2152 //
2153 // A MethodData* holds information which has been collected about
2154 // a method. Its layout looks like this:
2155 //
2156 // -----------------------------
2157 // | header |
2158 // | klass |
2159 // -----------------------------
2160 // | method |
2161 // | size of the MethodData* |
2162 // -----------------------------
2163 // | Data entries... |
2164 // | (variable size) |
2165 // | |
2166 // . .
2167 // . .
2168 // . .
2169 // | |
2170 // -----------------------------
|