src/hotspot/share/oops/methodData.hpp
changeset 50322 c75f3cdeb48c
parent 49821 02c08e20d66c
child 50577 bf7e2684cd0a
equal deleted inserted replaced
50321:b186322970f4 50322:c75f3cdeb48c
   230     return byte_offset_of(DataLayout, _header._struct._bci);
   230     return byte_offset_of(DataLayout, _header._struct._bci);
   231   }
   231   }
   232   static ByteSize cell_offset(int index) {
   232   static ByteSize cell_offset(int index) {
   233     return byte_offset_of(DataLayout, _cells) + in_ByteSize(index * cell_size);
   233     return byte_offset_of(DataLayout, _cells) + in_ByteSize(index * cell_size);
   234   }
   234   }
   235 #ifdef CC_INTERP
       
   236   static int cell_offset_in_bytes(int index) {
       
   237     return (int)offset_of(DataLayout, _cells[index]);
       
   238   }
       
   239 #endif // CC_INTERP
       
   240   // Return a value which, when or-ed as a byte into _flags, sets the flag.
   235   // Return a value which, when or-ed as a byte into _flags, sets the flag.
   241   static int flag_number_to_byte_constant(int flag_number) {
   236   static int flag_number_to_byte_constant(int flag_number) {
   242     assert(0 <= flag_number && flag_number < flag_limit, "oob");
   237     assert(0 <= flag_number && flag_number < flag_limit, "oob");
   243     DataLayout temp; temp.set_header(0);
   238     DataLayout temp; temp.set_header(0);
   244     temp.set_flag_at(flag_number);
   239     temp.set_flag_at(flag_number);
   369   }
   364   }
   370 
   365 
   371   ProfileData(DataLayout* data) {
   366   ProfileData(DataLayout* data) {
   372     _data = data;
   367     _data = data;
   373   }
   368   }
   374 
       
   375 #ifdef CC_INTERP
       
   376   // Static low level accessors for DataLayout with ProfileData's semantics.
       
   377 
       
   378   static int cell_offset_in_bytes(int index) {
       
   379     return DataLayout::cell_offset_in_bytes(index);
       
   380   }
       
   381 
       
   382   static void increment_uint_at_no_overflow(DataLayout* layout, int index,
       
   383                                             int inc = DataLayout::counter_increment) {
       
   384     uint count = ((uint)layout->cell_at(index)) + inc;
       
   385     if (count == 0) return;
       
   386     layout->set_cell_at(index, (intptr_t) count);
       
   387   }
       
   388 
       
   389   static int int_at(DataLayout* layout, int index) {
       
   390     return (int)layout->cell_at(index);
       
   391   }
       
   392 
       
   393   static int uint_at(DataLayout* layout, int index) {
       
   394     return (uint)layout->cell_at(index);
       
   395   }
       
   396 
       
   397   static oop oop_at(DataLayout* layout, int index) {
       
   398     return cast_to_oop(layout->cell_at(index));
       
   399   }
       
   400 
       
   401   static void set_intptr_at(DataLayout* layout, int index, intptr_t value) {
       
   402     layout->set_cell_at(index, (intptr_t) value);
       
   403   }
       
   404 
       
   405   static void set_flag_at(DataLayout* layout, int flag_number) {
       
   406     layout->set_flag_at(flag_number);
       
   407   }
       
   408 #endif // CC_INTERP
       
   409 
   369 
   410 public:
   370 public:
   411   // Constructor for invalid ProfileData.
   371   // Constructor for invalid ProfileData.
   412   ProfileData();
   372   ProfileData();
   413 
   373 
   579 
   539 
   580   static ByteSize bit_data_size() {
   540   static ByteSize bit_data_size() {
   581     return cell_offset(bit_cell_count);
   541     return cell_offset(bit_cell_count);
   582   }
   542   }
   583 
   543 
   584 #ifdef CC_INTERP
       
   585   static int bit_data_size_in_bytes() {
       
   586     return cell_offset_in_bytes(bit_cell_count);
       
   587   }
       
   588 
       
   589   static void set_null_seen(DataLayout* layout) {
       
   590     set_flag_at(layout, null_seen_flag);
       
   591   }
       
   592 
       
   593   static DataLayout* advance(DataLayout* layout) {
       
   594     return (DataLayout*) (((address)layout) + (ssize_t)BitData::bit_data_size_in_bytes());
       
   595   }
       
   596 #endif // CC_INTERP
       
   597 
       
   598   void print_data_on(outputStream* st, const char* extra = NULL) const;
   544   void print_data_on(outputStream* st, const char* extra = NULL) const;
   599 };
   545 };
   600 
   546 
   601 // CounterData
   547 // CounterData
   602 //
   548 //
   636   }
   582   }
   637 
   583 
   638   void set_count(uint count) {
   584   void set_count(uint count) {
   639     set_uint_at(count_off, count);
   585     set_uint_at(count_off, count);
   640   }
   586   }
   641 
       
   642 #ifdef CC_INTERP
       
   643   static int counter_data_size_in_bytes() {
       
   644     return cell_offset_in_bytes(counter_cell_count);
       
   645   }
       
   646 
       
   647   static void increment_count_no_overflow(DataLayout* layout) {
       
   648     increment_uint_at_no_overflow(layout, count_off);
       
   649   }
       
   650 
       
   651   // Support counter decrementation at checkcast / subtype check failed.
       
   652   static void decrement_count(DataLayout* layout) {
       
   653     increment_uint_at_no_overflow(layout, count_off, -1);
       
   654   }
       
   655 
       
   656   static DataLayout* advance(DataLayout* layout) {
       
   657     return (DataLayout*) (((address)layout) + (ssize_t)CounterData::counter_data_size_in_bytes());
       
   658   }
       
   659 #endif // CC_INTERP
       
   660 
   587 
   661   void print_data_on(outputStream* st, const char* extra = NULL) const;
   588   void print_data_on(outputStream* st, const char* extra = NULL) const;
   662 };
   589 };
   663 
   590 
   664 // JumpData
   591 // JumpData
   725   }
   652   }
   726 
   653 
   727   static ByteSize displacement_offset() {
   654   static ByteSize displacement_offset() {
   728     return cell_offset(displacement_off_set);
   655     return cell_offset(displacement_off_set);
   729   }
   656   }
   730 
       
   731 #ifdef CC_INTERP
       
   732   static void increment_taken_count_no_overflow(DataLayout* layout) {
       
   733     increment_uint_at_no_overflow(layout, taken_off_set);
       
   734   }
       
   735 
       
   736   static DataLayout* advance_taken(DataLayout* layout) {
       
   737     return (DataLayout*) (((address)layout) + (ssize_t)int_at(layout, displacement_off_set));
       
   738   }
       
   739 
       
   740   static uint taken_count(DataLayout* layout) {
       
   741     return (uint) uint_at(layout, taken_off_set);
       
   742   }
       
   743 #endif // CC_INTERP
       
   744 
   657 
   745   // Specific initialization.
   658   // Specific initialization.
   746   void post_initialize(BytecodeStream* stream, MethodData* mdo);
   659   void post_initialize(BytecodeStream* stream, MethodData* mdo);
   747 
   660 
   748   void print_data_on(outputStream* st, const char* extra = NULL) const;
   661   void print_data_on(outputStream* st, const char* extra = NULL) const;
  1300   }
  1213   }
  1301 
  1214 
  1302   // GC support
  1215   // GC support
  1303   virtual void clean_weak_klass_links(bool always_clean);
  1216   virtual void clean_weak_klass_links(bool always_clean);
  1304 
  1217 
  1305 #ifdef CC_INTERP
       
  1306   static int receiver_type_data_size_in_bytes() {
       
  1307     return cell_offset_in_bytes(static_cell_count());
       
  1308   }
       
  1309 
       
  1310   static Klass *receiver_unchecked(DataLayout* layout, uint row) {
       
  1311     Klass* recv = (Klass*)layout->cell_at(receiver_cell_index(row));
       
  1312     return recv;
       
  1313   }
       
  1314 
       
  1315   static void increment_receiver_count_no_overflow(DataLayout* layout, Klass *rcvr) {
       
  1316     const int num_rows = row_limit();
       
  1317     // Receiver already exists?
       
  1318     for (int row = 0; row < num_rows; row++) {
       
  1319       if (receiver_unchecked(layout, row) == rcvr) {
       
  1320         increment_uint_at_no_overflow(layout, receiver_count_cell_index(row));
       
  1321         return;
       
  1322       }
       
  1323     }
       
  1324     // New receiver, find a free slot.
       
  1325     for (int row = 0; row < num_rows; row++) {
       
  1326       if (receiver_unchecked(layout, row) == NULL) {
       
  1327         set_intptr_at(layout, receiver_cell_index(row), (intptr_t)rcvr);
       
  1328         increment_uint_at_no_overflow(layout, receiver_count_cell_index(row));
       
  1329         return;
       
  1330       }
       
  1331     }
       
  1332     // Receiver did not match any saved receiver and there is no empty row for it.
       
  1333     // Increment total counter to indicate polymorphic case.
       
  1334     increment_count_no_overflow(layout);
       
  1335   }
       
  1336 
       
  1337   static DataLayout* advance(DataLayout* layout) {
       
  1338     return (DataLayout*) (((address)layout) + (ssize_t)ReceiverTypeData::receiver_type_data_size_in_bytes());
       
  1339   }
       
  1340 #endif // CC_INTERP
       
  1341 
       
  1342   void print_receiver_data_on(outputStream* st) const;
  1218   void print_receiver_data_on(outputStream* st) const;
  1343   void print_data_on(outputStream* st, const char* extra = NULL) const;
  1219   void print_data_on(outputStream* st, const char* extra = NULL) const;
  1344 };
  1220 };
  1345 
  1221 
  1346 // VirtualCallData
  1222 // VirtualCallData
  1368 
  1244 
  1369   // Direct accessors
  1245   // Direct accessors
  1370   static ByteSize virtual_call_data_size() {
  1246   static ByteSize virtual_call_data_size() {
  1371     return cell_offset(static_cell_count());
  1247     return cell_offset(static_cell_count());
  1372   }
  1248   }
  1373 
       
  1374 #ifdef CC_INTERP
       
  1375   static int virtual_call_data_size_in_bytes() {
       
  1376     return cell_offset_in_bytes(static_cell_count());
       
  1377   }
       
  1378 
       
  1379   static DataLayout* advance(DataLayout* layout) {
       
  1380     return (DataLayout*) (((address)layout) + (ssize_t)VirtualCallData::virtual_call_data_size_in_bytes());
       
  1381   }
       
  1382 #endif // CC_INTERP
       
  1383 
  1249 
  1384 #if INCLUDE_JVMCI
  1250 #if INCLUDE_JVMCI
  1385   static ByteSize method_offset(uint row) {
  1251   static ByteSize method_offset(uint row) {
  1386     return cell_offset(method_cell_index(row));
  1252     return cell_offset(method_cell_index(row));
  1387   }
  1253   }
  1656   }
  1522   }
  1657   static ByteSize bci_displacement_offset(uint row) {
  1523   static ByteSize bci_displacement_offset(uint row) {
  1658     return cell_offset(bci_displacement_cell_index(row));
  1524     return cell_offset(bci_displacement_cell_index(row));
  1659   }
  1525   }
  1660 
  1526 
  1661 #ifdef CC_INTERP
       
  1662   static DataLayout* advance(MethodData *md, int bci);
       
  1663 #endif // CC_INTERP
       
  1664 
       
  1665   // Specific initialization.
  1527   // Specific initialization.
  1666   void post_initialize(BytecodeStream* stream, MethodData* mdo);
  1528   void post_initialize(BytecodeStream* stream, MethodData* mdo);
  1667 
  1529 
  1668   void print_data_on(outputStream* st, const char* extra = NULL) const;
  1530   void print_data_on(outputStream* st, const char* extra = NULL) const;
  1669 };
  1531 };
  1724   }
  1586   }
  1725   static ByteSize branch_data_size() {
  1587   static ByteSize branch_data_size() {
  1726     return cell_offset(branch_cell_count);
  1588     return cell_offset(branch_cell_count);
  1727   }
  1589   }
  1728 
  1590 
  1729 #ifdef CC_INTERP
       
  1730   static int branch_data_size_in_bytes() {
       
  1731     return cell_offset_in_bytes(branch_cell_count);
       
  1732   }
       
  1733 
       
  1734   static void increment_not_taken_count_no_overflow(DataLayout* layout) {
       
  1735     increment_uint_at_no_overflow(layout, not_taken_off_set);
       
  1736   }
       
  1737 
       
  1738   static DataLayout* advance_not_taken(DataLayout* layout) {
       
  1739     return (DataLayout*) (((address)layout) + (ssize_t)BranchData::branch_data_size_in_bytes());
       
  1740   }
       
  1741 #endif // CC_INTERP
       
  1742 
       
  1743   // Specific initialization.
  1591   // Specific initialization.
  1744   void post_initialize(BytecodeStream* stream, MethodData* mdo);
  1592   void post_initialize(BytecodeStream* stream, MethodData* mdo);
  1745 
  1593 
  1746   void print_data_on(outputStream* st, const char* extra = NULL) const;
  1594   void print_data_on(outputStream* st, const char* extra = NULL) const;
  1747 };
  1595 };
  1776   }
  1624   }
  1777   void array_set_int_at(int index, int value) {
  1625   void array_set_int_at(int index, int value) {
  1778     int aindex = index + array_start_off_set;
  1626     int aindex = index + array_start_off_set;
  1779     set_int_at(aindex, value);
  1627     set_int_at(aindex, value);
  1780   }
  1628   }
  1781 
       
  1782 #ifdef CC_INTERP
       
  1783   // Static low level accessors for DataLayout with ArrayData's semantics.
       
  1784 
       
  1785   static void increment_array_uint_at_no_overflow(DataLayout* layout, int index) {
       
  1786     int aindex = index + array_start_off_set;
       
  1787     increment_uint_at_no_overflow(layout, aindex);
       
  1788   }
       
  1789 
       
  1790   static int array_int_at(DataLayout* layout, int index) {
       
  1791     int aindex = index + array_start_off_set;
       
  1792     return int_at(layout, aindex);
       
  1793   }
       
  1794 #endif // CC_INTERP
       
  1795 
  1629 
  1796   // Code generation support for subclasses.
  1630   // Code generation support for subclasses.
  1797   static ByteSize array_element_offset(int index) {
  1631   static ByteSize array_element_offset(int index) {
  1798     return cell_offset(array_start_off_set + index);
  1632     return cell_offset(array_start_off_set + index);
  1799   }
  1633   }
  1910     return in_ByteSize(relative_count_off_set) * cell_size;
  1744     return in_ByteSize(relative_count_off_set) * cell_size;
  1911   }
  1745   }
  1912   static ByteSize relative_displacement_offset() {
  1746   static ByteSize relative_displacement_offset() {
  1913     return in_ByteSize(relative_displacement_off_set) * cell_size;
  1747     return in_ByteSize(relative_displacement_off_set) * cell_size;
  1914   }
  1748   }
  1915 
       
  1916 #ifdef CC_INTERP
       
  1917   static void increment_count_no_overflow(DataLayout* layout, int index) {
       
  1918     if (index == -1) {
       
  1919       increment_array_uint_at_no_overflow(layout, default_count_off_set);
       
  1920     } else {
       
  1921       increment_array_uint_at_no_overflow(layout, case_array_start +
       
  1922                                                   index * per_case_cell_count +
       
  1923                                                   relative_count_off_set);
       
  1924     }
       
  1925   }
       
  1926 
       
  1927   static DataLayout* advance(DataLayout* layout, int index) {
       
  1928     if (index == -1) {
       
  1929       return (DataLayout*) (((address)layout) + (ssize_t)array_int_at(layout, default_disaplacement_off_set));
       
  1930     } else {
       
  1931       return (DataLayout*) (((address)layout) + (ssize_t)array_int_at(layout, case_array_start +
       
  1932                                                                               index * per_case_cell_count +
       
  1933                                                                               relative_displacement_off_set));
       
  1934     }
       
  1935   }
       
  1936 #endif // CC_INTERP
       
  1937 
  1749 
  1938   // Specific initialization.
  1750   // Specific initialization.
  1939   void post_initialize(BytecodeStream* stream, MethodData* mdo);
  1751   void post_initialize(BytecodeStream* stream, MethodData* mdo);
  1940 
  1752 
  1941   void print_data_on(outputStream* st, const char* extra = NULL) const;
  1753   void print_data_on(outputStream* st, const char* extra = NULL) const;
  2125 // from the base of the data entry array.  A "displacement" is the byte offset
  1937 // from the base of the data entry array.  A "displacement" is the byte offset
  2126 // in certain ProfileData objects that indicate the amount the mdp must be
  1938 // in certain ProfileData objects that indicate the amount the mdp must be
  2127 // adjusted in the event of a change in control flow.
  1939 // adjusted in the event of a change in control flow.
  2128 //
  1940 //
  2129 
  1941 
  2130 CC_INTERP_ONLY(class BytecodeInterpreter;)
       
  2131 class CleanExtraDataClosure;
  1942 class CleanExtraDataClosure;
  2132 
  1943 
  2133 class MethodData : public Metadata {
  1944 class MethodData : public Metadata {
  2134   friend class VMStructs;
  1945   friend class VMStructs;
  2135   friend class JVMCIVMStructs;
  1946   friend class JVMCIVMStructs;
  2136   CC_INTERP_ONLY(friend class BytecodeInterpreter;)
       
  2137 private:
  1947 private:
  2138   friend class ProfileData;
  1948   friend class ProfileData;
  2139   friend class TypeEntriesAtCall;
  1949   friend class TypeEntriesAtCall;
  2140 
  1950 
  2141   // If you add a new field that points to any metaspace object, you
  1951   // If you add a new field that points to any metaspace object, you