Mercurial > hg > truffle
comparison src/share/vm/oops/methodData.hpp @ 14420:abe03600372a
8024468: PPC64 (part 201): cppInterpreter: implement bytecode profiling
Summary: Implement profiling for c2 jit compilation. Also enable new cppInterpreter features.
Reviewed-by: kvn
author | goetz |
---|---|
date | Sun, 15 Sep 2013 15:28:58 +0200 |
parents | 92ef81e2f571 |
children | 2b8e28fdf503 |
comparison
equal
deleted
inserted
replaced
14419:7373e44fa207 | 14420:abe03600372a |
---|---|
223 return byte_offset_of(DataLayout, _header._struct._bci); | 223 return byte_offset_of(DataLayout, _header._struct._bci); |
224 } | 224 } |
225 static ByteSize cell_offset(int index) { | 225 static ByteSize cell_offset(int index) { |
226 return byte_offset_of(DataLayout, _cells) + in_ByteSize(index * cell_size); | 226 return byte_offset_of(DataLayout, _cells) + in_ByteSize(index * cell_size); |
227 } | 227 } |
228 #ifdef CC_INTERP | |
229 static int cell_offset_in_bytes(int index) { | |
230 return (int)offset_of(DataLayout, _cells[index]); | |
231 } | |
232 #endif // CC_INTERP | |
228 // Return a value which, when or-ed as a byte into _flags, sets the flag. | 233 // Return a value which, when or-ed as a byte into _flags, sets the flag. |
229 static int flag_number_to_byte_constant(int flag_number) { | 234 static int flag_number_to_byte_constant(int flag_number) { |
230 assert(0 <= flag_number && flag_number < flag_limit, "oob"); | 235 assert(0 <= flag_number && flag_number < flag_limit, "oob"); |
231 DataLayout temp; temp.set_header(0); | 236 DataLayout temp; temp.set_header(0); |
232 temp.set_flag_at(flag_number); | 237 temp.set_flag_at(flag_number); |
354 | 359 |
355 ProfileData(DataLayout* data) { | 360 ProfileData(DataLayout* data) { |
356 _data = data; | 361 _data = data; |
357 } | 362 } |
358 | 363 |
364 #ifdef CC_INTERP | |
365 // Static low level accessors for DataLayout with ProfileData's semantics. | |
366 | |
367 static int cell_offset_in_bytes(int index) { | |
368 return DataLayout::cell_offset_in_bytes(index); | |
369 } | |
370 | |
371 static void increment_uint_at_no_overflow(DataLayout* layout, int index, | |
372 int inc = DataLayout::counter_increment) { | |
373 uint count = ((uint)layout->cell_at(index)) + inc; | |
374 if (count == 0) return; | |
375 layout->set_cell_at(index, (intptr_t) count); | |
376 } | |
377 | |
378 static int int_at(DataLayout* layout, int index) { | |
379 return (int)layout->cell_at(index); | |
380 } | |
381 | |
382 static int uint_at(DataLayout* layout, int index) { | |
383 return (uint)layout->cell_at(index); | |
384 } | |
385 | |
386 static oop oop_at(DataLayout* layout, int index) { | |
387 return (oop)layout->cell_at(index); | |
388 } | |
389 | |
390 static void set_intptr_at(DataLayout* layout, int index, intptr_t value) { | |
391 layout->set_cell_at(index, (intptr_t) value); | |
392 } | |
393 | |
394 static void set_flag_at(DataLayout* layout, int flag_number) { | |
395 layout->set_flag_at(flag_number); | |
396 } | |
397 #endif // CC_INTERP | |
398 | |
359 public: | 399 public: |
360 // Constructor for invalid ProfileData. | 400 // Constructor for invalid ProfileData. |
361 ProfileData(); | 401 ProfileData(); |
362 | 402 |
363 u2 bci() { | 403 u2 bci() { |
493 | 533 |
494 static ByteSize bit_data_size() { | 534 static ByteSize bit_data_size() { |
495 return cell_offset(bit_cell_count); | 535 return cell_offset(bit_cell_count); |
496 } | 536 } |
497 | 537 |
538 #ifdef CC_INTERP | |
539 static int bit_data_size_in_bytes() { | |
540 return cell_offset_in_bytes(bit_cell_count); | |
541 } | |
542 | |
543 static void set_null_seen(DataLayout* layout) { | |
544 set_flag_at(layout, null_seen_flag); | |
545 } | |
546 | |
547 static DataLayout* advance(DataLayout* layout) { | |
548 return (DataLayout*) (((address)layout) + (ssize_t)BitData::bit_data_size_in_bytes()); | |
549 } | |
550 #endif // CC_INTERP | |
551 | |
498 #ifndef PRODUCT | 552 #ifndef PRODUCT |
499 void print_data_on(outputStream* st); | 553 void print_data_on(outputStream* st); |
500 #endif | 554 #endif |
501 }; | 555 }; |
502 | 556 |
536 } | 590 } |
537 | 591 |
538 void set_count(uint count) { | 592 void set_count(uint count) { |
539 set_uint_at(count_off, count); | 593 set_uint_at(count_off, count); |
540 } | 594 } |
595 | |
596 #ifdef CC_INTERP | |
597 static int counter_data_size_in_bytes() { | |
598 return cell_offset_in_bytes(counter_cell_count); | |
599 } | |
600 | |
601 static void increment_count_no_overflow(DataLayout* layout) { | |
602 increment_uint_at_no_overflow(layout, count_off); | |
603 } | |
604 | |
605 // Support counter decrementation at checkcast / subtype check failed. | |
606 static void decrement_count(DataLayout* layout) { | |
607 increment_uint_at_no_overflow(layout, count_off, -1); | |
608 } | |
609 | |
610 static DataLayout* advance(DataLayout* layout) { | |
611 return (DataLayout*) (((address)layout) + (ssize_t)CounterData::counter_data_size_in_bytes()); | |
612 } | |
613 #endif // CC_INTERP | |
541 | 614 |
542 #ifndef PRODUCT | 615 #ifndef PRODUCT |
543 void print_data_on(outputStream* st); | 616 void print_data_on(outputStream* st); |
544 #endif | 617 #endif |
545 }; | 618 }; |
606 } | 679 } |
607 | 680 |
608 static ByteSize displacement_offset() { | 681 static ByteSize displacement_offset() { |
609 return cell_offset(displacement_off_set); | 682 return cell_offset(displacement_off_set); |
610 } | 683 } |
684 | |
685 #ifdef CC_INTERP | |
686 static void increment_taken_count_no_overflow(DataLayout* layout) { | |
687 increment_uint_at_no_overflow(layout, taken_off_set); | |
688 } | |
689 | |
690 static DataLayout* advance_taken(DataLayout* layout) { | |
691 return (DataLayout*) (((address)layout) + (ssize_t)int_at(layout, displacement_off_set)); | |
692 } | |
693 | |
694 static uint taken_count(DataLayout* layout) { | |
695 return (uint) uint_at(layout, taken_off_set); | |
696 } | |
697 #endif // CC_INTERP | |
611 | 698 |
612 // Specific initialization. | 699 // Specific initialization. |
613 void post_initialize(BytecodeStream* stream, MethodData* mdo); | 700 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
614 | 701 |
615 #ifndef PRODUCT | 702 #ifndef PRODUCT |
716 } | 803 } |
717 | 804 |
718 // GC support | 805 // GC support |
719 virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure); | 806 virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure); |
720 | 807 |
808 #ifdef CC_INTERP | |
809 static int receiver_type_data_size_in_bytes() { | |
810 return cell_offset_in_bytes(static_cell_count()); | |
811 } | |
812 | |
813 static Klass *receiver_unchecked(DataLayout* layout, uint row) { | |
814 oop recv = oop_at(layout, receiver_cell_index(row)); | |
815 return (Klass *)recv; | |
816 } | |
817 | |
818 static void increment_receiver_count_no_overflow(DataLayout* layout, Klass *rcvr) { | |
819 const int num_rows = row_limit(); | |
820 // Receiver already exists? | |
821 for (int row = 0; row < num_rows; row++) { | |
822 if (receiver_unchecked(layout, row) == rcvr) { | |
823 increment_uint_at_no_overflow(layout, receiver_count_cell_index(row)); | |
824 return; | |
825 } | |
826 } | |
827 // New receiver, find a free slot. | |
828 for (int row = 0; row < num_rows; row++) { | |
829 if (receiver_unchecked(layout, row) == NULL) { | |
830 set_intptr_at(layout, receiver_cell_index(row), (intptr_t)rcvr); | |
831 increment_uint_at_no_overflow(layout, receiver_count_cell_index(row)); | |
832 return; | |
833 } | |
834 } | |
835 // Receiver did not match any saved receiver and there is no empty row for it. | |
836 // Increment total counter to indicate polymorphic case. | |
837 increment_count_no_overflow(layout); | |
838 } | |
839 | |
840 static DataLayout* advance(DataLayout* layout) { | |
841 return (DataLayout*) (((address)layout) + (ssize_t)ReceiverTypeData::receiver_type_data_size_in_bytes()); | |
842 } | |
843 #endif // CC_INTERP | |
844 | |
721 #ifndef PRODUCT | 845 #ifndef PRODUCT |
722 void print_receiver_data_on(outputStream* st); | 846 void print_receiver_data_on(outputStream* st); |
723 void print_data_on(outputStream* st); | 847 void print_data_on(outputStream* st); |
724 #endif | 848 #endif |
725 }; | 849 }; |
748 | 872 |
749 // Direct accessors | 873 // Direct accessors |
750 static ByteSize virtual_call_data_size() { | 874 static ByteSize virtual_call_data_size() { |
751 return cell_offset(static_cell_count()); | 875 return cell_offset(static_cell_count()); |
752 } | 876 } |
877 | |
878 #ifdef CC_INTERP | |
879 static int virtual_call_data_size_in_bytes() { | |
880 return cell_offset_in_bytes(static_cell_count()); | |
881 } | |
882 | |
883 static DataLayout* advance(DataLayout* layout) { | |
884 return (DataLayout*) (((address)layout) + (ssize_t)VirtualCallData::virtual_call_data_size_in_bytes()); | |
885 } | |
886 #endif // CC_INTERP | |
753 | 887 |
754 #ifndef PRODUCT | 888 #ifndef PRODUCT |
755 void print_data_on(outputStream* st); | 889 void print_data_on(outputStream* st); |
756 #endif | 890 #endif |
757 }; | 891 }; |
845 } | 979 } |
846 static ByteSize bci_displacement_offset(uint row) { | 980 static ByteSize bci_displacement_offset(uint row) { |
847 return cell_offset(bci_displacement_cell_index(row)); | 981 return cell_offset(bci_displacement_cell_index(row)); |
848 } | 982 } |
849 | 983 |
984 #ifdef CC_INTERP | |
985 static DataLayout* advance(MethodData *md, int bci); | |
986 #endif // CC_INTERP | |
987 | |
850 // Specific initialization. | 988 // Specific initialization. |
851 void post_initialize(BytecodeStream* stream, MethodData* mdo); | 989 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
852 | 990 |
853 #ifndef PRODUCT | 991 #ifndef PRODUCT |
854 void print_data_on(outputStream* st); | 992 void print_data_on(outputStream* st); |
909 } | 1047 } |
910 static ByteSize branch_data_size() { | 1048 static ByteSize branch_data_size() { |
911 return cell_offset(branch_cell_count); | 1049 return cell_offset(branch_cell_count); |
912 } | 1050 } |
913 | 1051 |
1052 #ifdef CC_INTERP | |
1053 static int branch_data_size_in_bytes() { | |
1054 return cell_offset_in_bytes(branch_cell_count); | |
1055 } | |
1056 | |
1057 static void increment_not_taken_count_no_overflow(DataLayout* layout) { | |
1058 increment_uint_at_no_overflow(layout, not_taken_off_set); | |
1059 } | |
1060 | |
1061 static DataLayout* advance_not_taken(DataLayout* layout) { | |
1062 return (DataLayout*) (((address)layout) + (ssize_t)BranchData::branch_data_size_in_bytes()); | |
1063 } | |
1064 #endif // CC_INTERP | |
1065 | |
914 // Specific initialization. | 1066 // Specific initialization. |
915 void post_initialize(BytecodeStream* stream, MethodData* mdo); | 1067 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
916 | 1068 |
917 #ifndef PRODUCT | 1069 #ifndef PRODUCT |
918 void print_data_on(outputStream* st); | 1070 void print_data_on(outputStream* st); |
947 } | 1099 } |
948 void array_set_int_at(int index, int value) { | 1100 void array_set_int_at(int index, int value) { |
949 int aindex = index + array_start_off_set; | 1101 int aindex = index + array_start_off_set; |
950 set_int_at(aindex, value); | 1102 set_int_at(aindex, value); |
951 } | 1103 } |
1104 | |
1105 #ifdef CC_INTERP | |
1106 // Static low level accessors for DataLayout with ArrayData's semantics. | |
1107 | |
1108 static void increment_array_uint_at_no_overflow(DataLayout* layout, int index) { | |
1109 int aindex = index + array_start_off_set; | |
1110 increment_uint_at_no_overflow(layout, aindex); | |
1111 } | |
1112 | |
1113 static int array_int_at(DataLayout* layout, int index) { | |
1114 int aindex = index + array_start_off_set; | |
1115 return int_at(layout, aindex); | |
1116 } | |
1117 #endif // CC_INTERP | |
952 | 1118 |
953 // Code generation support for subclasses. | 1119 // Code generation support for subclasses. |
954 static ByteSize array_element_offset(int index) { | 1120 static ByteSize array_element_offset(int index) { |
955 return cell_offset(array_start_off_set + index); | 1121 return cell_offset(array_start_off_set + index); |
956 } | 1122 } |
1066 } | 1232 } |
1067 static ByteSize relative_displacement_offset() { | 1233 static ByteSize relative_displacement_offset() { |
1068 return in_ByteSize(relative_displacement_off_set) * cell_size; | 1234 return in_ByteSize(relative_displacement_off_set) * cell_size; |
1069 } | 1235 } |
1070 | 1236 |
1237 #ifdef CC_INTERP | |
1238 static void increment_count_no_overflow(DataLayout* layout, int index) { | |
1239 if (index == -1) { | |
1240 increment_array_uint_at_no_overflow(layout, default_count_off_set); | |
1241 } else { | |
1242 increment_array_uint_at_no_overflow(layout, case_array_start + | |
1243 index * per_case_cell_count + | |
1244 relative_count_off_set); | |
1245 } | |
1246 } | |
1247 | |
1248 static DataLayout* advance(DataLayout* layout, int index) { | |
1249 if (index == -1) { | |
1250 return (DataLayout*) (((address)layout) + (ssize_t)array_int_at(layout, default_disaplacement_off_set)); | |
1251 } else { | |
1252 return (DataLayout*) (((address)layout) + (ssize_t)array_int_at(layout, case_array_start + | |
1253 index * per_case_cell_count + | |
1254 relative_displacement_off_set)); | |
1255 } | |
1256 } | |
1257 #endif // CC_INTERP | |
1258 | |
1071 // Specific initialization. | 1259 // Specific initialization. |
1072 void post_initialize(BytecodeStream* stream, MethodData* mdo); | 1260 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
1073 | 1261 |
1074 #ifndef PRODUCT | 1262 #ifndef PRODUCT |
1075 void print_data_on(outputStream* st); | 1263 void print_data_on(outputStream* st); |
1144 // from the base of the data entry array. A "displacement" is the byte offset | 1332 // from the base of the data entry array. A "displacement" is the byte offset |
1145 // in certain ProfileData objects that indicate the amount the mdp must be | 1333 // in certain ProfileData objects that indicate the amount the mdp must be |
1146 // adjusted in the event of a change in control flow. | 1334 // adjusted in the event of a change in control flow. |
1147 // | 1335 // |
1148 | 1336 |
1337 CC_INTERP_ONLY(class BytecodeInterpreter;) | |
1338 | |
1149 class MethodData : public Metadata { | 1339 class MethodData : public Metadata { |
1150 friend class VMStructs; | 1340 friend class VMStructs; |
1341 CC_INTERP_ONLY(friend class BytecodeInterpreter;) | |
1151 private: | 1342 private: |
1152 friend class ProfileData; | 1343 friend class ProfileData; |
1153 | 1344 |
1154 // Back pointer to the Method* | 1345 // Back pointer to the Method* |
1155 Method* _method; | 1346 Method* _method; |