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
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 // Updated by platform-specific code, for example MacroAssembler::profile_receiver_type.
1152 //
1153 class ReceiverTypeData : public CounterData {
1154 friend class VMStructs;
1155 friend class JVMCIVMStructs;
1156 protected:
1157 enum {
1158 receiver0_offset = counter_cell_count,
1159 count0_offset,
1160 receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
1161 };
1162
1163 public:
1164 ReceiverTypeData(DataLayout* layout) : CounterData(layout) {
1165 assert(layout->tag() == DataLayout::receiver_type_data_tag ||
1166 layout->tag() == DataLayout::virtual_call_data_tag ||
1167 layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");
1168 }
1169
1170 virtual bool is_ReceiverTypeData() const { return true; }
1171
1172 static int static_cell_count() {
1173 return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count;
1174 }
1175
1176 virtual int cell_count() const {
1177 return static_cell_count();
1178 }
1179
1180 // Direct accessors
1181 static uint row_limit() {
1182 return (uint) TypeProfileWidth;
1183 }
1184 static int receiver_cell_index(uint row) {
1185 return receiver0_offset + row * receiver_type_row_cell_count;
1186 }
1187 static int receiver_count_cell_index(uint row) {
1280
1281 // Direct accessors
1282 static ByteSize virtual_call_data_size() {
1283 return cell_offset(static_cell_count());
1284 }
1285
1286 void print_method_data_on(outputStream* st) const NOT_JVMCI_RETURN;
1287 void print_data_on(outputStream* st, const char* extra = nullptr) const;
1288 };
1289
1290 // VirtualCallTypeData
1291 //
1292 // A VirtualCallTypeData is used to access profiling information about
1293 // a virtual call for which we collect type information about
1294 // arguments and return value.
1295 class VirtualCallTypeData : public VirtualCallData {
1296 private:
1297 // entries for arguments if any
1298 TypeStackSlotEntries _args;
1299 // entry for return type if any
1300 ReturnTypeEntry _ret;
1301
1302 int cell_count_global_offset() const {
1303 return VirtualCallData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
1304 }
1305
1306 // number of cells not counting the header
1307 int cell_count_no_header() const {
1308 return uint_at(cell_count_global_offset());
1309 }
1310
1311 void check_number_of_arguments(int total) {
1312 assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
1313 }
1314
1315 public:
1316 VirtualCallTypeData(DataLayout* layout) :
1317 VirtualCallData(layout),
1318 _args(VirtualCallData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()),
1319 _ret(cell_count() - ReturnTypeEntry::static_cell_count())
1320 {
1321 assert(layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");
1322 // Some compilers (VC++) don't want this passed in member initialization list
1323 _args.set_profile_data(this);
1324 _ret.set_profile_data(this);
1325 }
1326
1327 const TypeStackSlotEntries* args() const {
1328 assert(has_arguments(), "no profiling of arguments");
1329 return &_args;
1330 }
1331
1332 const ReturnTypeEntry* ret() const {
1333 assert(has_return(), "no profiling of return value");
1334 return &_ret;
1335 }
1336
1337 virtual bool is_VirtualCallTypeData() const { return true; }
1338
1339 static int static_cell_count() {
1340 return -1;
1341 }
1342
1343 static int compute_cell_count(BytecodeStream* stream) {
1344 return VirtualCallData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1345 }
1346
1347 static void initialize(DataLayout* dl, int cell_count) {
1348 TypeEntriesAtCall::initialize(dl, VirtualCallData::static_cell_count(), cell_count);
1349 }
1350
1351 virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);
1352
1525 // BranchData
1526 //
1527 // A BranchData is used to access profiling data for a two-way branch.
1528 // It consists of taken and not_taken counts as well as a data displacement
1529 // for the taken case.
1530 class BranchData : public JumpData {
1531 friend class VMStructs;
1532 friend class JVMCIVMStructs;
1533 protected:
1534 enum {
1535 not_taken_off_set = jump_cell_count,
1536 branch_cell_count
1537 };
1538
1539 void set_displacement(int displacement) {
1540 set_int_at(displacement_off_set, displacement);
1541 }
1542
1543 public:
1544 BranchData(DataLayout* layout) : JumpData(layout) {
1545 assert(layout->tag() == DataLayout::branch_data_tag, "wrong type");
1546 }
1547
1548 virtual bool is_BranchData() const { return true; }
1549
1550 static int static_cell_count() {
1551 return branch_cell_count;
1552 }
1553
1554 virtual int cell_count() const {
1555 return static_cell_count();
1556 }
1557
1558 // Direct accessor
1559 uint not_taken() const {
1560 return uint_at(not_taken_off_set);
1561 }
1562
1563 void set_not_taken(uint cnt) {
1564 set_uint_at(not_taken_off_set, cnt);
1565 }
1886 // Direct accessor
1887 Method* method() const {
1888 return (Method*)intptr_at(speculative_trap_method);
1889 }
1890
1891 void set_method(Method* m) {
1892 assert(!m->is_old(), "cannot add old methods");
1893 set_intptr_at(speculative_trap_method, (intptr_t)m);
1894 }
1895
1896 static ByteSize method_offset() {
1897 return cell_offset(speculative_trap_method);
1898 }
1899
1900 // CDS support
1901 virtual void metaspace_pointers_do(MetaspaceClosure* it);
1902
1903 virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
1904 };
1905
1906 // MethodData*
1907 //
1908 // A MethodData* holds information which has been collected about
1909 // a method. Its layout looks like this:
1910 //
1911 // -----------------------------
1912 // | header |
1913 // | klass |
1914 // -----------------------------
1915 // | method |
1916 // | size of the MethodData* |
1917 // -----------------------------
1918 // | Data entries... |
1919 // | (variable size) |
1920 // | |
1921 // . .
1922 // . .
1923 // . .
1924 // | |
1925 // -----------------------------
|
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
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 // Updated by platform-specific code, for example MacroAssembler::profile_receiver_type.
1175 //
1176 class ReceiverTypeData : public CounterData {
1177 friend class VMStructs;
1178 friend class JVMCIVMStructs;
1179 protected:
1180 enum {
1181 receiver0_offset = counter_cell_count,
1182 count0_offset,
1183 receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
1184 };
1185
1186 public:
1187 ReceiverTypeData(DataLayout* layout) : CounterData(layout) {
1188 assert(layout->tag() == DataLayout::receiver_type_data_tag ||
1189 layout->tag() == DataLayout::virtual_call_data_tag ||
1190 layout->tag() == DataLayout::virtual_call_type_data_tag ||
1191 layout->tag() == DataLayout::array_store_data_tag, "wrong type");
1192 }
1193
1194 virtual bool is_ReceiverTypeData() const { return true; }
1195
1196 static int static_cell_count() {
1197 return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count;
1198 }
1199
1200 virtual int cell_count() const {
1201 return static_cell_count();
1202 }
1203
1204 // Direct accessors
1205 static uint row_limit() {
1206 return (uint) TypeProfileWidth;
1207 }
1208 static int receiver_cell_index(uint row) {
1209 return receiver0_offset + row * receiver_type_row_cell_count;
1210 }
1211 static int receiver_count_cell_index(uint row) {
1304
1305 // Direct accessors
1306 static ByteSize virtual_call_data_size() {
1307 return cell_offset(static_cell_count());
1308 }
1309
1310 void print_method_data_on(outputStream* st) const NOT_JVMCI_RETURN;
1311 void print_data_on(outputStream* st, const char* extra = nullptr) const;
1312 };
1313
1314 // VirtualCallTypeData
1315 //
1316 // A VirtualCallTypeData is used to access profiling information about
1317 // a virtual call for which we collect type information about
1318 // arguments and return value.
1319 class VirtualCallTypeData : public VirtualCallData {
1320 private:
1321 // entries for arguments if any
1322 TypeStackSlotEntries _args;
1323 // entry for return type if any
1324 SingleTypeEntry _ret;
1325
1326 int cell_count_global_offset() const {
1327 return VirtualCallData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset();
1328 }
1329
1330 // number of cells not counting the header
1331 int cell_count_no_header() const {
1332 return uint_at(cell_count_global_offset());
1333 }
1334
1335 void check_number_of_arguments(int total) {
1336 assert(number_of_arguments() == total, "should be set in DataLayout::initialize");
1337 }
1338
1339 public:
1340 VirtualCallTypeData(DataLayout* layout) :
1341 VirtualCallData(layout),
1342 _args(VirtualCallData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()),
1343 _ret(cell_count() - SingleTypeEntry::static_cell_count())
1344 {
1345 assert(layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type");
1346 // Some compilers (VC++) don't want this passed in member initialization list
1347 _args.set_profile_data(this);
1348 _ret.set_profile_data(this);
1349 }
1350
1351 const TypeStackSlotEntries* args() const {
1352 assert(has_arguments(), "no profiling of arguments");
1353 return &_args;
1354 }
1355
1356 const SingleTypeEntry* ret() const {
1357 assert(has_return(), "no profiling of return value");
1358 return &_ret;
1359 }
1360
1361 virtual bool is_VirtualCallTypeData() const { return true; }
1362
1363 static int static_cell_count() {
1364 return -1;
1365 }
1366
1367 static int compute_cell_count(BytecodeStream* stream) {
1368 return VirtualCallData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream);
1369 }
1370
1371 static void initialize(DataLayout* dl, int cell_count) {
1372 TypeEntriesAtCall::initialize(dl, VirtualCallData::static_cell_count(), cell_count);
1373 }
1374
1375 virtual void post_initialize(BytecodeStream* stream, MethodData* mdo);
1376
1549 // BranchData
1550 //
1551 // A BranchData is used to access profiling data for a two-way branch.
1552 // It consists of taken and not_taken counts as well as a data displacement
1553 // for the taken case.
1554 class BranchData : public JumpData {
1555 friend class VMStructs;
1556 friend class JVMCIVMStructs;
1557 protected:
1558 enum {
1559 not_taken_off_set = jump_cell_count,
1560 branch_cell_count
1561 };
1562
1563 void set_displacement(int displacement) {
1564 set_int_at(displacement_off_set, displacement);
1565 }
1566
1567 public:
1568 BranchData(DataLayout* layout) : JumpData(layout) {
1569 assert(layout->tag() == DataLayout::branch_data_tag || layout->tag() == DataLayout::acmp_data_tag, "wrong type");
1570 }
1571
1572 virtual bool is_BranchData() const { return true; }
1573
1574 static int static_cell_count() {
1575 return branch_cell_count;
1576 }
1577
1578 virtual int cell_count() const {
1579 return static_cell_count();
1580 }
1581
1582 // Direct accessor
1583 uint not_taken() const {
1584 return uint_at(not_taken_off_set);
1585 }
1586
1587 void set_not_taken(uint cnt) {
1588 set_uint_at(not_taken_off_set, cnt);
1589 }
1910 // Direct accessor
1911 Method* method() const {
1912 return (Method*)intptr_at(speculative_trap_method);
1913 }
1914
1915 void set_method(Method* m) {
1916 assert(!m->is_old(), "cannot add old methods");
1917 set_intptr_at(speculative_trap_method, (intptr_t)m);
1918 }
1919
1920 static ByteSize method_offset() {
1921 return cell_offset(speculative_trap_method);
1922 }
1923
1924 // CDS support
1925 virtual void metaspace_pointers_do(MetaspaceClosure* it);
1926
1927 virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
1928 };
1929
1930 class ArrayStoreData : public ReceiverTypeData {
1931 private:
1932 enum {
1933 flat_array_flag = BitData::last_bit_data_flag,
1934 null_free_array_flag = flat_array_flag + 1,
1935 };
1936
1937 SingleTypeEntry _array;
1938
1939 public:
1940 ArrayStoreData(DataLayout* layout) :
1941 ReceiverTypeData(layout),
1942 _array(ReceiverTypeData::static_cell_count()) {
1943 assert(layout->tag() == DataLayout::array_store_data_tag, "wrong type");
1944 _array.set_profile_data(this);
1945 }
1946
1947 const SingleTypeEntry* array() const {
1948 return &_array;
1949 }
1950
1951 virtual bool is_ArrayStoreData() const { return true; }
1952
1953 static int static_cell_count() {
1954 return ReceiverTypeData::static_cell_count() + SingleTypeEntry::static_cell_count();
1955 }
1956
1957 virtual int cell_count() const {
1958 return static_cell_count();
1959 }
1960
1961 void set_flat_array() { set_flag_at(flat_array_flag); }
1962 bool flat_array() const { return flag_at(flat_array_flag); }
1963
1964 void set_null_free_array() { set_flag_at(null_free_array_flag); }
1965 bool null_free_array() const { return flag_at(null_free_array_flag); }
1966
1967 // Code generation support
1968 static int flat_array_byte_constant() {
1969 return flag_number_to_constant(flat_array_flag);
1970 }
1971
1972 static int null_free_array_byte_constant() {
1973 return flag_number_to_constant(null_free_array_flag);
1974 }
1975
1976 static ByteSize array_offset() {
1977 return cell_offset(ReceiverTypeData::static_cell_count());
1978 }
1979
1980 virtual void clean_weak_klass_links(bool always_clean) {
1981 ReceiverTypeData::clean_weak_klass_links(always_clean);
1982 _array.clean_weak_klass_links(always_clean);
1983 }
1984
1985 virtual void metaspace_pointers_do(MetaspaceClosure* it) {
1986 ReceiverTypeData::metaspace_pointers_do(it);
1987 _array.metaspace_pointers_do(it);
1988 }
1989
1990 static ByteSize array_store_data_size() {
1991 return cell_offset(static_cell_count());
1992 }
1993
1994 virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
1995 };
1996
1997 class ArrayLoadData : public BitData {
1998 private:
1999 enum {
2000 flat_array_flag = BitData::last_bit_data_flag,
2001 null_free_array_flag = flat_array_flag + 1,
2002 };
2003
2004 SingleTypeEntry _array;
2005 SingleTypeEntry _element;
2006
2007 public:
2008 ArrayLoadData(DataLayout* layout) :
2009 BitData(layout),
2010 _array(0),
2011 _element(SingleTypeEntry::static_cell_count()) {
2012 assert(layout->tag() == DataLayout::array_load_data_tag, "wrong type");
2013 _array.set_profile_data(this);
2014 _element.set_profile_data(this);
2015 }
2016
2017 const SingleTypeEntry* array() const {
2018 return &_array;
2019 }
2020
2021 const SingleTypeEntry* element() const {
2022 return &_element;
2023 }
2024
2025 virtual bool is_ArrayLoadData() const { return true; }
2026
2027 static int static_cell_count() {
2028 return SingleTypeEntry::static_cell_count() * 2;
2029 }
2030
2031 virtual int cell_count() const {
2032 return static_cell_count();
2033 }
2034
2035 void set_flat_array() { set_flag_at(flat_array_flag); }
2036 bool flat_array() const { return flag_at(flat_array_flag); }
2037
2038 void set_null_free_array() { set_flag_at(null_free_array_flag); }
2039 bool null_free_array() const { return flag_at(null_free_array_flag); }
2040
2041 // Code generation support
2042 static int flat_array_byte_constant() {
2043 return flag_number_to_constant(flat_array_flag);
2044 }
2045
2046 static int null_free_array_byte_constant() {
2047 return flag_number_to_constant(null_free_array_flag);
2048 }
2049
2050 static ByteSize array_offset() {
2051 return cell_offset(0);
2052 }
2053
2054 static ByteSize element_offset() {
2055 return cell_offset(SingleTypeEntry::static_cell_count());
2056 }
2057
2058 virtual void clean_weak_klass_links(bool always_clean) {
2059 _array.clean_weak_klass_links(always_clean);
2060 _element.clean_weak_klass_links(always_clean);
2061 }
2062
2063 virtual void metaspace_pointers_do(MetaspaceClosure* it) {
2064 _array.metaspace_pointers_do(it);
2065 _element.metaspace_pointers_do(it);
2066 }
2067
2068 static ByteSize array_load_data_size() {
2069 return cell_offset(static_cell_count());
2070 }
2071
2072 virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
2073 };
2074
2075 class ACmpData : public BranchData {
2076 private:
2077 enum {
2078 left_inline_type_flag = DataLayout::first_flag,
2079 right_inline_type_flag
2080 };
2081
2082 SingleTypeEntry _left;
2083 SingleTypeEntry _right;
2084
2085 public:
2086 ACmpData(DataLayout* layout) :
2087 BranchData(layout),
2088 _left(BranchData::static_cell_count()),
2089 _right(BranchData::static_cell_count() + SingleTypeEntry::static_cell_count()) {
2090 assert(layout->tag() == DataLayout::acmp_data_tag, "wrong type");
2091 _left.set_profile_data(this);
2092 _right.set_profile_data(this);
2093 }
2094
2095 const SingleTypeEntry* left() const {
2096 return &_left;
2097 }
2098
2099 const SingleTypeEntry* right() const {
2100 return &_right;
2101 }
2102
2103 virtual bool is_ACmpData() const { return true; }
2104
2105 static int static_cell_count() {
2106 return BranchData::static_cell_count() + SingleTypeEntry::static_cell_count() * 2;
2107 }
2108
2109 virtual int cell_count() const {
2110 return static_cell_count();
2111 }
2112
2113 void set_left_inline_type() { set_flag_at(left_inline_type_flag); }
2114 bool left_inline_type() const { return flag_at(left_inline_type_flag); }
2115
2116 void set_right_inline_type() { set_flag_at(right_inline_type_flag); }
2117 bool right_inline_type() const { return flag_at(right_inline_type_flag); }
2118
2119 // Code generation support
2120 static int left_inline_type_byte_constant() {
2121 return flag_number_to_constant(left_inline_type_flag);
2122 }
2123
2124 static int right_inline_type_byte_constant() {
2125 return flag_number_to_constant(right_inline_type_flag);
2126 }
2127
2128 static ByteSize left_offset() {
2129 return cell_offset(BranchData::static_cell_count());
2130 }
2131
2132 static ByteSize right_offset() {
2133 return cell_offset(BranchData::static_cell_count() + SingleTypeEntry::static_cell_count());
2134 }
2135
2136 virtual void clean_weak_klass_links(bool always_clean) {
2137 _left.clean_weak_klass_links(always_clean);
2138 _right.clean_weak_klass_links(always_clean);
2139 }
2140
2141 virtual void metaspace_pointers_do(MetaspaceClosure* it) {
2142 _left.metaspace_pointers_do(it);
2143 _right.metaspace_pointers_do(it);
2144 }
2145
2146 static ByteSize acmp_data_size() {
2147 return cell_offset(static_cell_count());
2148 }
2149
2150 virtual void print_data_on(outputStream* st, const char* extra = nullptr) const;
2151 };
2152
2153 // MethodData*
2154 //
2155 // A MethodData* holds information which has been collected about
2156 // a method. Its layout looks like this:
2157 //
2158 // -----------------------------
2159 // | header |
2160 // | klass |
2161 // -----------------------------
2162 // | method |
2163 // | size of the MethodData* |
2164 // -----------------------------
2165 // | Data entries... |
2166 // | (variable size) |
2167 // | |
2168 // . .
2169 // . .
2170 // . .
2171 // | |
2172 // -----------------------------
|