Mercurial > hg > truffle
comparison src/share/vm/oops/methodData.hpp @ 17812:a7d4d4655766
Merge
author | kvn |
---|---|
date | Wed, 26 Mar 2014 18:21:05 -0700 |
parents | 62c54fcc0a35 |
children | ce9fd31ffd14 |
comparison
equal
deleted
inserted
replaced
17789:6b207d038106 | 17812:a7d4d4655766 |
---|---|
226 return byte_offset_of(DataLayout, _header._struct._bci); | 226 return byte_offset_of(DataLayout, _header._struct._bci); |
227 } | 227 } |
228 static ByteSize cell_offset(int index) { | 228 static ByteSize cell_offset(int index) { |
229 return byte_offset_of(DataLayout, _cells) + in_ByteSize(index * cell_size); | 229 return byte_offset_of(DataLayout, _cells) + in_ByteSize(index * cell_size); |
230 } | 230 } |
231 #ifdef CC_INTERP | |
232 static int cell_offset_in_bytes(int index) { | |
233 return (int)offset_of(DataLayout, _cells[index]); | |
234 } | |
235 #endif // CC_INTERP | |
231 // Return a value which, when or-ed as a byte into _flags, sets the flag. | 236 // Return a value which, when or-ed as a byte into _flags, sets the flag. |
232 static int flag_number_to_byte_constant(int flag_number) { | 237 static int flag_number_to_byte_constant(int flag_number) { |
233 assert(0 <= flag_number && flag_number < flag_limit, "oob"); | 238 assert(0 <= flag_number && flag_number < flag_limit, "oob"); |
234 DataLayout temp; temp.set_header(0); | 239 DataLayout temp; temp.set_header(0); |
235 temp.set_flag_at(flag_number); | 240 temp.set_flag_at(flag_number); |
366 | 371 |
367 ProfileData(DataLayout* data) { | 372 ProfileData(DataLayout* data) { |
368 _data = data; | 373 _data = data; |
369 } | 374 } |
370 | 375 |
376 #ifdef CC_INTERP | |
377 // Static low level accessors for DataLayout with ProfileData's semantics. | |
378 | |
379 static int cell_offset_in_bytes(int index) { | |
380 return DataLayout::cell_offset_in_bytes(index); | |
381 } | |
382 | |
383 static void increment_uint_at_no_overflow(DataLayout* layout, int index, | |
384 int inc = DataLayout::counter_increment) { | |
385 uint count = ((uint)layout->cell_at(index)) + inc; | |
386 if (count == 0) return; | |
387 layout->set_cell_at(index, (intptr_t) count); | |
388 } | |
389 | |
390 static int int_at(DataLayout* layout, int index) { | |
391 return (int)layout->cell_at(index); | |
392 } | |
393 | |
394 static int uint_at(DataLayout* layout, int index) { | |
395 return (uint)layout->cell_at(index); | |
396 } | |
397 | |
398 static oop oop_at(DataLayout* layout, int index) { | |
399 return cast_to_oop(layout->cell_at(index)); | |
400 } | |
401 | |
402 static void set_intptr_at(DataLayout* layout, int index, intptr_t value) { | |
403 layout->set_cell_at(index, (intptr_t) value); | |
404 } | |
405 | |
406 static void set_flag_at(DataLayout* layout, int flag_number) { | |
407 layout->set_flag_at(flag_number); | |
408 } | |
409 #endif // CC_INTERP | |
410 | |
371 public: | 411 public: |
372 // Constructor for invalid ProfileData. | 412 // Constructor for invalid ProfileData. |
373 ProfileData(); | 413 ProfileData(); |
374 | 414 |
375 u2 bci() const { | 415 u2 bci() const { |
527 | 567 |
528 static ByteSize bit_data_size() { | 568 static ByteSize bit_data_size() { |
529 return cell_offset(bit_cell_count); | 569 return cell_offset(bit_cell_count); |
530 } | 570 } |
531 | 571 |
572 #ifdef CC_INTERP | |
573 static int bit_data_size_in_bytes() { | |
574 return cell_offset_in_bytes(bit_cell_count); | |
575 } | |
576 | |
577 static void set_null_seen(DataLayout* layout) { | |
578 set_flag_at(layout, null_seen_flag); | |
579 } | |
580 | |
581 static DataLayout* advance(DataLayout* layout) { | |
582 return (DataLayout*) (((address)layout) + (ssize_t)BitData::bit_data_size_in_bytes()); | |
583 } | |
584 #endif // CC_INTERP | |
585 | |
532 #ifndef PRODUCT | 586 #ifndef PRODUCT |
533 void print_data_on(outputStream* st, const char* extra = NULL) const; | 587 void print_data_on(outputStream* st, const char* extra = NULL) const; |
534 #endif | 588 #endif |
535 }; | 589 }; |
536 | 590 |
570 } | 624 } |
571 | 625 |
572 void set_count(uint count) { | 626 void set_count(uint count) { |
573 set_uint_at(count_off, count); | 627 set_uint_at(count_off, count); |
574 } | 628 } |
629 | |
630 #ifdef CC_INTERP | |
631 static int counter_data_size_in_bytes() { | |
632 return cell_offset_in_bytes(counter_cell_count); | |
633 } | |
634 | |
635 static void increment_count_no_overflow(DataLayout* layout) { | |
636 increment_uint_at_no_overflow(layout, count_off); | |
637 } | |
638 | |
639 // Support counter decrementation at checkcast / subtype check failed. | |
640 static void decrement_count(DataLayout* layout) { | |
641 increment_uint_at_no_overflow(layout, count_off, -1); | |
642 } | |
643 | |
644 static DataLayout* advance(DataLayout* layout) { | |
645 return (DataLayout*) (((address)layout) + (ssize_t)CounterData::counter_data_size_in_bytes()); | |
646 } | |
647 #endif // CC_INTERP | |
575 | 648 |
576 #ifndef PRODUCT | 649 #ifndef PRODUCT |
577 void print_data_on(outputStream* st, const char* extra = NULL) const; | 650 void print_data_on(outputStream* st, const char* extra = NULL) const; |
578 #endif | 651 #endif |
579 }; | 652 }; |
640 } | 713 } |
641 | 714 |
642 static ByteSize displacement_offset() { | 715 static ByteSize displacement_offset() { |
643 return cell_offset(displacement_off_set); | 716 return cell_offset(displacement_off_set); |
644 } | 717 } |
718 | |
719 #ifdef CC_INTERP | |
720 static void increment_taken_count_no_overflow(DataLayout* layout) { | |
721 increment_uint_at_no_overflow(layout, taken_off_set); | |
722 } | |
723 | |
724 static DataLayout* advance_taken(DataLayout* layout) { | |
725 return (DataLayout*) (((address)layout) + (ssize_t)int_at(layout, displacement_off_set)); | |
726 } | |
727 | |
728 static uint taken_count(DataLayout* layout) { | |
729 return (uint) uint_at(layout, taken_off_set); | |
730 } | |
731 #endif // CC_INTERP | |
645 | 732 |
646 // Specific initialization. | 733 // Specific initialization. |
647 void post_initialize(BytecodeStream* stream, MethodData* mdo); | 734 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
648 | 735 |
649 #ifndef PRODUCT | 736 #ifndef PRODUCT |
1162 } | 1249 } |
1163 | 1250 |
1164 // GC support | 1251 // GC support |
1165 virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure); | 1252 virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure); |
1166 | 1253 |
1254 #ifdef CC_INTERP | |
1255 static int receiver_type_data_size_in_bytes() { | |
1256 return cell_offset_in_bytes(static_cell_count()); | |
1257 } | |
1258 | |
1259 static Klass *receiver_unchecked(DataLayout* layout, uint row) { | |
1260 Klass* recv = (Klass*)layout->cell_at(receiver_cell_index(row)); | |
1261 return recv; | |
1262 } | |
1263 | |
1264 static void increment_receiver_count_no_overflow(DataLayout* layout, Klass *rcvr) { | |
1265 const int num_rows = row_limit(); | |
1266 // Receiver already exists? | |
1267 for (int row = 0; row < num_rows; row++) { | |
1268 if (receiver_unchecked(layout, row) == rcvr) { | |
1269 increment_uint_at_no_overflow(layout, receiver_count_cell_index(row)); | |
1270 return; | |
1271 } | |
1272 } | |
1273 // New receiver, find a free slot. | |
1274 for (int row = 0; row < num_rows; row++) { | |
1275 if (receiver_unchecked(layout, row) == NULL) { | |
1276 set_intptr_at(layout, receiver_cell_index(row), (intptr_t)rcvr); | |
1277 increment_uint_at_no_overflow(layout, receiver_count_cell_index(row)); | |
1278 return; | |
1279 } | |
1280 } | |
1281 // Receiver did not match any saved receiver and there is no empty row for it. | |
1282 // Increment total counter to indicate polymorphic case. | |
1283 increment_count_no_overflow(layout); | |
1284 } | |
1285 | |
1286 static DataLayout* advance(DataLayout* layout) { | |
1287 return (DataLayout*) (((address)layout) + (ssize_t)ReceiverTypeData::receiver_type_data_size_in_bytes()); | |
1288 } | |
1289 #endif // CC_INTERP | |
1290 | |
1167 #ifndef PRODUCT | 1291 #ifndef PRODUCT |
1168 void print_receiver_data_on(outputStream* st) const; | 1292 void print_receiver_data_on(outputStream* st) const; |
1169 void print_data_on(outputStream* st, const char* extra = NULL) const; | 1293 void print_data_on(outputStream* st, const char* extra = NULL) const; |
1170 #endif | 1294 #endif |
1171 }; | 1295 }; |
1195 | 1319 |
1196 // Direct accessors | 1320 // Direct accessors |
1197 static ByteSize virtual_call_data_size() { | 1321 static ByteSize virtual_call_data_size() { |
1198 return cell_offset(static_cell_count()); | 1322 return cell_offset(static_cell_count()); |
1199 } | 1323 } |
1324 | |
1325 #ifdef CC_INTERP | |
1326 static int virtual_call_data_size_in_bytes() { | |
1327 return cell_offset_in_bytes(static_cell_count()); | |
1328 } | |
1329 | |
1330 static DataLayout* advance(DataLayout* layout) { | |
1331 return (DataLayout*) (((address)layout) + (ssize_t)VirtualCallData::virtual_call_data_size_in_bytes()); | |
1332 } | |
1333 #endif // CC_INTERP | |
1200 | 1334 |
1201 #ifndef PRODUCT | 1335 #ifndef PRODUCT |
1202 void print_data_on(outputStream* st, const char* extra = NULL) const; | 1336 void print_data_on(outputStream* st, const char* extra = NULL) const; |
1203 #endif | 1337 #endif |
1204 }; | 1338 }; |
1418 } | 1552 } |
1419 static ByteSize bci_displacement_offset(uint row) { | 1553 static ByteSize bci_displacement_offset(uint row) { |
1420 return cell_offset(bci_displacement_cell_index(row)); | 1554 return cell_offset(bci_displacement_cell_index(row)); |
1421 } | 1555 } |
1422 | 1556 |
1557 #ifdef CC_INTERP | |
1558 static DataLayout* advance(MethodData *md, int bci); | |
1559 #endif // CC_INTERP | |
1560 | |
1423 // Specific initialization. | 1561 // Specific initialization. |
1424 void post_initialize(BytecodeStream* stream, MethodData* mdo); | 1562 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
1425 | 1563 |
1426 #ifndef PRODUCT | 1564 #ifndef PRODUCT |
1427 void print_data_on(outputStream* st, const char* extra = NULL) const; | 1565 void print_data_on(outputStream* st, const char* extra = NULL) const; |
1482 } | 1620 } |
1483 static ByteSize branch_data_size() { | 1621 static ByteSize branch_data_size() { |
1484 return cell_offset(branch_cell_count); | 1622 return cell_offset(branch_cell_count); |
1485 } | 1623 } |
1486 | 1624 |
1625 #ifdef CC_INTERP | |
1626 static int branch_data_size_in_bytes() { | |
1627 return cell_offset_in_bytes(branch_cell_count); | |
1628 } | |
1629 | |
1630 static void increment_not_taken_count_no_overflow(DataLayout* layout) { | |
1631 increment_uint_at_no_overflow(layout, not_taken_off_set); | |
1632 } | |
1633 | |
1634 static DataLayout* advance_not_taken(DataLayout* layout) { | |
1635 return (DataLayout*) (((address)layout) + (ssize_t)BranchData::branch_data_size_in_bytes()); | |
1636 } | |
1637 #endif // CC_INTERP | |
1638 | |
1487 // Specific initialization. | 1639 // Specific initialization. |
1488 void post_initialize(BytecodeStream* stream, MethodData* mdo); | 1640 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
1489 | 1641 |
1490 #ifndef PRODUCT | 1642 #ifndef PRODUCT |
1491 void print_data_on(outputStream* st, const char* extra = NULL) const; | 1643 void print_data_on(outputStream* st, const char* extra = NULL) const; |
1520 } | 1672 } |
1521 void array_set_int_at(int index, int value) { | 1673 void array_set_int_at(int index, int value) { |
1522 int aindex = index + array_start_off_set; | 1674 int aindex = index + array_start_off_set; |
1523 set_int_at(aindex, value); | 1675 set_int_at(aindex, value); |
1524 } | 1676 } |
1677 | |
1678 #ifdef CC_INTERP | |
1679 // Static low level accessors for DataLayout with ArrayData's semantics. | |
1680 | |
1681 static void increment_array_uint_at_no_overflow(DataLayout* layout, int index) { | |
1682 int aindex = index + array_start_off_set; | |
1683 increment_uint_at_no_overflow(layout, aindex); | |
1684 } | |
1685 | |
1686 static int array_int_at(DataLayout* layout, int index) { | |
1687 int aindex = index + array_start_off_set; | |
1688 return int_at(layout, aindex); | |
1689 } | |
1690 #endif // CC_INTERP | |
1525 | 1691 |
1526 // Code generation support for subclasses. | 1692 // Code generation support for subclasses. |
1527 static ByteSize array_element_offset(int index) { | 1693 static ByteSize array_element_offset(int index) { |
1528 return cell_offset(array_start_off_set + index); | 1694 return cell_offset(array_start_off_set + index); |
1529 } | 1695 } |
1638 return in_ByteSize(relative_count_off_set) * cell_size; | 1804 return in_ByteSize(relative_count_off_set) * cell_size; |
1639 } | 1805 } |
1640 static ByteSize relative_displacement_offset() { | 1806 static ByteSize relative_displacement_offset() { |
1641 return in_ByteSize(relative_displacement_off_set) * cell_size; | 1807 return in_ByteSize(relative_displacement_off_set) * cell_size; |
1642 } | 1808 } |
1809 | |
1810 #ifdef CC_INTERP | |
1811 static void increment_count_no_overflow(DataLayout* layout, int index) { | |
1812 if (index == -1) { | |
1813 increment_array_uint_at_no_overflow(layout, default_count_off_set); | |
1814 } else { | |
1815 increment_array_uint_at_no_overflow(layout, case_array_start + | |
1816 index * per_case_cell_count + | |
1817 relative_count_off_set); | |
1818 } | |
1819 } | |
1820 | |
1821 static DataLayout* advance(DataLayout* layout, int index) { | |
1822 if (index == -1) { | |
1823 return (DataLayout*) (((address)layout) + (ssize_t)array_int_at(layout, default_disaplacement_off_set)); | |
1824 } else { | |
1825 return (DataLayout*) (((address)layout) + (ssize_t)array_int_at(layout, case_array_start + | |
1826 index * per_case_cell_count + | |
1827 relative_displacement_off_set)); | |
1828 } | |
1829 } | |
1830 #endif // CC_INTERP | |
1643 | 1831 |
1644 // Specific initialization. | 1832 // Specific initialization. |
1645 void post_initialize(BytecodeStream* stream, MethodData* mdo); | 1833 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
1646 | 1834 |
1647 #ifndef PRODUCT | 1835 #ifndef PRODUCT |
1834 // from the base of the data entry array. A "displacement" is the byte offset | 2022 // from the base of the data entry array. A "displacement" is the byte offset |
1835 // in certain ProfileData objects that indicate the amount the mdp must be | 2023 // in certain ProfileData objects that indicate the amount the mdp must be |
1836 // adjusted in the event of a change in control flow. | 2024 // adjusted in the event of a change in control flow. |
1837 // | 2025 // |
1838 | 2026 |
2027 CC_INTERP_ONLY(class BytecodeInterpreter;) | |
2028 | |
1839 class MethodData : public Metadata { | 2029 class MethodData : public Metadata { |
1840 friend class VMStructs; | 2030 friend class VMStructs; |
2031 CC_INTERP_ONLY(friend class BytecodeInterpreter;) | |
1841 private: | 2032 private: |
1842 friend class ProfileData; | 2033 friend class ProfileData; |
1843 | 2034 |
1844 // Back pointer to the Method* | 2035 // Back pointer to the Method* |
1845 Method* _method; | 2036 Method* _method; |