Mercurial > hg > graal-compiler
comparison src/share/vm/oops/methodData.hpp @ 14909:4ca6dc0799b6
Backout jdk9 merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 01 Apr 2014 13:57:07 +0200 |
parents | 8762b6b8fbb6 |
children | e165f4223650 |
comparison
equal
deleted
inserted
replaced
14908:8db6e76cb658 | 14909:4ca6dc0799b6 |
---|---|
118 branch_data_tag, | 118 branch_data_tag, |
119 multi_branch_data_tag, | 119 multi_branch_data_tag, |
120 arg_info_data_tag, | 120 arg_info_data_tag, |
121 call_type_data_tag, | 121 call_type_data_tag, |
122 virtual_call_type_data_tag, | 122 virtual_call_type_data_tag, |
123 parameters_type_data_tag, | 123 parameters_type_data_tag |
124 speculative_trap_data_tag | |
125 }; | 124 }; |
126 | 125 |
127 enum { | 126 enum { |
128 // The _struct._flags word is formatted as [trap_state:4 | flags:4]. | 127 // The _struct._flags word is formatted as [trap_state:4 | flags:4]. |
129 // The trap state breaks down further as [recompile:1 | reason:3]. | 128 // The trap state breaks down further as [recompile:1 | reason:3]. |
188 } | 187 } |
189 | 188 |
190 void set_header(intptr_t value) { | 189 void set_header(intptr_t value) { |
191 _header._bits = value; | 190 _header._bits = value; |
192 } | 191 } |
193 bool atomic_set_header(intptr_t value) { | 192 void release_set_header(intptr_t value) { |
194 if (Atomic::cmpxchg_ptr(value, (volatile intptr_t*)&_header._bits, 0) == 0) { | 193 OrderAccess::release_store_ptr(&_header._bits, value); |
195 return true; | |
196 } | |
197 return false; | |
198 } | 194 } |
199 intptr_t header() { | 195 intptr_t header() { |
200 return _header._bits; | 196 return _header._bits; |
201 } | 197 } |
202 void set_cell_at(int index, intptr_t value) { | 198 void set_cell_at(int index, intptr_t value) { |
232 return byte_offset_of(DataLayout, _header._struct._bci); | 228 return byte_offset_of(DataLayout, _header._struct._bci); |
233 } | 229 } |
234 static ByteSize cell_offset(int index) { | 230 static ByteSize cell_offset(int index) { |
235 return byte_offset_of(DataLayout, _cells) + in_ByteSize(index * cell_size); | 231 return byte_offset_of(DataLayout, _cells) + in_ByteSize(index * cell_size); |
236 } | 232 } |
237 #ifdef CC_INTERP | |
238 static int cell_offset_in_bytes(int index) { | |
239 return (int)offset_of(DataLayout, _cells[index]); | |
240 } | |
241 #endif // CC_INTERP | |
242 // 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. |
243 static int flag_number_to_byte_constant(int flag_number) { | 234 static int flag_number_to_byte_constant(int flag_number) { |
244 assert(0 <= flag_number && flag_number < flag_limit, "oob"); | 235 assert(0 <= flag_number && flag_number < flag_limit, "oob"); |
245 DataLayout temp; temp.set_header(0); | 236 DataLayout temp; temp.set_header(0); |
246 temp.set_flag_at(flag_number); | 237 temp.set_flag_at(flag_number); |
276 class BranchData; | 267 class BranchData; |
277 class ArrayData; | 268 class ArrayData; |
278 class MultiBranchData; | 269 class MultiBranchData; |
279 class ArgInfoData; | 270 class ArgInfoData; |
280 class ParametersTypeData; | 271 class ParametersTypeData; |
281 class SpeculativeTrapData; | |
282 | 272 |
283 // ProfileData | 273 // ProfileData |
284 // | 274 // |
285 // A ProfileData object is created to refer to a section of profiling | 275 // A ProfileData object is created to refer to a section of profiling |
286 // data in a structured way. | 276 // data in a structured way. |
297 #endif // !PRODUCT | 287 #endif // !PRODUCT |
298 | 288 |
299 // This is a pointer to a section of profiling data. | 289 // This is a pointer to a section of profiling data. |
300 DataLayout* _data; | 290 DataLayout* _data; |
301 | 291 |
302 char* print_data_on_helper(const MethodData* md) const; | |
303 | |
304 protected: | 292 protected: |
305 DataLayout* data() { return _data; } | 293 DataLayout* data() { return _data; } |
306 const DataLayout* data() const { return _data; } | 294 const DataLayout* data() const { return _data; } |
307 | 295 |
308 enum { | 296 enum { |
379 } | 367 } |
380 | 368 |
381 ProfileData(DataLayout* data) { | 369 ProfileData(DataLayout* data) { |
382 _data = data; | 370 _data = data; |
383 } | 371 } |
384 | |
385 #ifdef CC_INTERP | |
386 // Static low level accessors for DataLayout with ProfileData's semantics. | |
387 | |
388 static int cell_offset_in_bytes(int index) { | |
389 return DataLayout::cell_offset_in_bytes(index); | |
390 } | |
391 | |
392 static void increment_uint_at_no_overflow(DataLayout* layout, int index, | |
393 int inc = DataLayout::counter_increment) { | |
394 uint count = ((uint)layout->cell_at(index)) + inc; | |
395 if (count == 0) return; | |
396 layout->set_cell_at(index, (intptr_t) count); | |
397 } | |
398 | |
399 static int int_at(DataLayout* layout, int index) { | |
400 return (int)layout->cell_at(index); | |
401 } | |
402 | |
403 static int uint_at(DataLayout* layout, int index) { | |
404 return (uint)layout->cell_at(index); | |
405 } | |
406 | |
407 static oop oop_at(DataLayout* layout, int index) { | |
408 return cast_to_oop(layout->cell_at(index)); | |
409 } | |
410 | |
411 static void set_intptr_at(DataLayout* layout, int index, intptr_t value) { | |
412 layout->set_cell_at(index, (intptr_t) value); | |
413 } | |
414 | |
415 static void set_flag_at(DataLayout* layout, int flag_number) { | |
416 layout->set_flag_at(flag_number); | |
417 } | |
418 #endif // CC_INTERP | |
419 | 372 |
420 public: | 373 public: |
421 // Constructor for invalid ProfileData. | 374 // Constructor for invalid ProfileData. |
422 ProfileData(); | 375 ProfileData(); |
423 | 376 |
448 virtual bool is_MultiBranchData() const { return false; } | 401 virtual bool is_MultiBranchData() const { return false; } |
449 virtual bool is_ArgInfoData() const { return false; } | 402 virtual bool is_ArgInfoData() const { return false; } |
450 virtual bool is_CallTypeData() const { return false; } | 403 virtual bool is_CallTypeData() const { return false; } |
451 virtual bool is_VirtualCallTypeData()const { return false; } | 404 virtual bool is_VirtualCallTypeData()const { return false; } |
452 virtual bool is_ParametersTypeData() const { return false; } | 405 virtual bool is_ParametersTypeData() const { return false; } |
453 virtual bool is_SpeculativeTrapData()const { return false; } | |
454 | 406 |
455 | 407 |
456 BitData* as_BitData() const { | 408 BitData* as_BitData() const { |
457 assert(is_BitData(), "wrong type"); | 409 assert(is_BitData(), "wrong type"); |
458 return is_BitData() ? (BitData*) this : NULL; | 410 return is_BitData() ? (BitData*) this : NULL; |
502 return is_VirtualCallTypeData() ? (VirtualCallTypeData*)this : NULL; | 454 return is_VirtualCallTypeData() ? (VirtualCallTypeData*)this : NULL; |
503 } | 455 } |
504 ParametersTypeData* as_ParametersTypeData() const { | 456 ParametersTypeData* as_ParametersTypeData() const { |
505 assert(is_ParametersTypeData(), "wrong type"); | 457 assert(is_ParametersTypeData(), "wrong type"); |
506 return is_ParametersTypeData() ? (ParametersTypeData*)this : NULL; | 458 return is_ParametersTypeData() ? (ParametersTypeData*)this : NULL; |
507 } | |
508 SpeculativeTrapData* as_SpeculativeTrapData() const { | |
509 assert(is_SpeculativeTrapData(), "wrong type"); | |
510 return is_SpeculativeTrapData() ? (SpeculativeTrapData*)this : NULL; | |
511 } | 459 } |
512 | 460 |
513 | 461 |
514 // Subclass specific initialization | 462 // Subclass specific initialization |
515 virtual void post_initialize(BytecodeStream* stream, MethodData* mdo) {} | 463 virtual void post_initialize(BytecodeStream* stream, MethodData* mdo) {} |
525 // an oop in a ProfileData to the ci equivalent. Generally speaking, | 473 // an oop in a ProfileData to the ci equivalent. Generally speaking, |
526 // most ProfileData don't require any translation, so we provide the null | 474 // most ProfileData don't require any translation, so we provide the null |
527 // translation here, and the required translators are in the ci subclasses. | 475 // translation here, and the required translators are in the ci subclasses. |
528 virtual void translate_from(const ProfileData* data) {} | 476 virtual void translate_from(const ProfileData* data) {} |
529 | 477 |
530 virtual void print_data_on(outputStream* st, const char* extra = NULL) const { | 478 virtual void print_data_on(outputStream* st) const { |
531 ShouldNotReachHere(); | 479 ShouldNotReachHere(); |
532 } | 480 } |
533 | 481 |
534 void print_data_on(outputStream* st, const MethodData* md) const; | |
535 | |
536 #ifndef PRODUCT | 482 #ifndef PRODUCT |
537 void print_shared(outputStream* st, const char* name, const char* extra) const; | 483 void print_shared(outputStream* st, const char* name) const; |
538 void tab(outputStream* st, bool first = false) const; | 484 void tab(outputStream* st, bool first = false) const; |
539 #endif | 485 #endif |
540 }; | 486 }; |
541 | 487 |
542 // BitData | 488 // BitData |
587 | 533 |
588 static ByteSize bit_data_size() { | 534 static ByteSize bit_data_size() { |
589 return cell_offset(bit_cell_count); | 535 return cell_offset(bit_cell_count); |
590 } | 536 } |
591 | 537 |
592 #ifdef CC_INTERP | |
593 static int bit_data_size_in_bytes() { | |
594 return cell_offset_in_bytes(bit_cell_count); | |
595 } | |
596 | |
597 static void set_null_seen(DataLayout* layout) { | |
598 set_flag_at(layout, null_seen_flag); | |
599 } | |
600 | |
601 static DataLayout* advance(DataLayout* layout) { | |
602 return (DataLayout*) (((address)layout) + (ssize_t)BitData::bit_data_size_in_bytes()); | |
603 } | |
604 #endif // CC_INTERP | |
605 | |
606 #ifndef PRODUCT | 538 #ifndef PRODUCT |
607 void print_data_on(outputStream* st, const char* extra = NULL) const; | 539 void print_data_on(outputStream* st) const; |
608 #endif | 540 #endif |
609 }; | 541 }; |
610 | 542 |
611 // CounterData | 543 // CounterData |
612 // | 544 // |
645 | 577 |
646 void set_count(uint count) { | 578 void set_count(uint count) { |
647 set_uint_at(count_off, count); | 579 set_uint_at(count_off, count); |
648 } | 580 } |
649 | 581 |
650 #ifdef CC_INTERP | |
651 static int counter_data_size_in_bytes() { | |
652 return cell_offset_in_bytes(counter_cell_count); | |
653 } | |
654 | |
655 static void increment_count_no_overflow(DataLayout* layout) { | |
656 increment_uint_at_no_overflow(layout, count_off); | |
657 } | |
658 | |
659 // Support counter decrementation at checkcast / subtype check failed. | |
660 static void decrement_count(DataLayout* layout) { | |
661 increment_uint_at_no_overflow(layout, count_off, -1); | |
662 } | |
663 | |
664 static DataLayout* advance(DataLayout* layout) { | |
665 return (DataLayout*) (((address)layout) + (ssize_t)CounterData::counter_data_size_in_bytes()); | |
666 } | |
667 #endif // CC_INTERP | |
668 | |
669 #ifndef PRODUCT | 582 #ifndef PRODUCT |
670 void print_data_on(outputStream* st, const char* extra = NULL) const; | 583 void print_data_on(outputStream* st) const; |
671 #endif | 584 #endif |
672 }; | 585 }; |
673 | 586 |
674 // JumpData | 587 // JumpData |
675 // | 588 // |
734 | 647 |
735 static ByteSize displacement_offset() { | 648 static ByteSize displacement_offset() { |
736 return cell_offset(displacement_off_set); | 649 return cell_offset(displacement_off_set); |
737 } | 650 } |
738 | 651 |
739 #ifdef CC_INTERP | |
740 static void increment_taken_count_no_overflow(DataLayout* layout) { | |
741 increment_uint_at_no_overflow(layout, taken_off_set); | |
742 } | |
743 | |
744 static DataLayout* advance_taken(DataLayout* layout) { | |
745 return (DataLayout*) (((address)layout) + (ssize_t)int_at(layout, displacement_off_set)); | |
746 } | |
747 | |
748 static uint taken_count(DataLayout* layout) { | |
749 return (uint) uint_at(layout, taken_off_set); | |
750 } | |
751 #endif // CC_INTERP | |
752 | |
753 // Specific initialization. | 652 // Specific initialization. |
754 void post_initialize(BytecodeStream* stream, MethodData* mdo); | 653 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
755 | 654 |
756 #ifndef PRODUCT | 655 #ifndef PRODUCT |
757 void print_data_on(outputStream* st, const char* extra = NULL) const; | 656 void print_data_on(outputStream* st) const; |
758 #endif | 657 #endif |
759 }; | 658 }; |
760 | 659 |
761 // Entries in a ProfileData object to record types: it can either be | 660 // Entries in a ProfileData object to record types: it can either be |
762 // none (no profile), unknown (conflicting profile data) or a klass if | 661 // none (no profile), unknown (conflicting profile data) or a klass if |
1163 _ret.clean_weak_klass_links(is_alive_closure); | 1062 _ret.clean_weak_klass_links(is_alive_closure); |
1164 } | 1063 } |
1165 } | 1064 } |
1166 | 1065 |
1167 #ifndef PRODUCT | 1066 #ifndef PRODUCT |
1168 virtual void print_data_on(outputStream* st, const char* extra = NULL) const; | 1067 virtual void print_data_on(outputStream* st) const; |
1169 #endif | 1068 #endif |
1170 }; | 1069 }; |
1171 | 1070 |
1172 // ReceiverTypeData | 1071 // ReceiverTypeData |
1173 // | 1072 // |
1302 } | 1201 } |
1303 | 1202 |
1304 // GC support | 1203 // GC support |
1305 virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure); | 1204 virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure); |
1306 | 1205 |
1307 #ifdef CC_INTERP | |
1308 static int receiver_type_data_size_in_bytes() { | |
1309 return cell_offset_in_bytes(static_cell_count()); | |
1310 } | |
1311 | |
1312 static Klass *receiver_unchecked(DataLayout* layout, uint row) { | |
1313 Klass* recv = (Klass*)layout->cell_at(receiver_cell_index(row)); | |
1314 return recv; | |
1315 } | |
1316 | |
1317 static void increment_receiver_count_no_overflow(DataLayout* layout, Klass *rcvr) { | |
1318 const int num_rows = row_limit(); | |
1319 // Receiver already exists? | |
1320 for (int row = 0; row < num_rows; row++) { | |
1321 if (receiver_unchecked(layout, row) == rcvr) { | |
1322 increment_uint_at_no_overflow(layout, receiver_count_cell_index(row)); | |
1323 return; | |
1324 } | |
1325 } | |
1326 // New receiver, find a free slot. | |
1327 for (int row = 0; row < num_rows; row++) { | |
1328 if (receiver_unchecked(layout, row) == NULL) { | |
1329 set_intptr_at(layout, receiver_cell_index(row), (intptr_t)rcvr); | |
1330 increment_uint_at_no_overflow(layout, receiver_count_cell_index(row)); | |
1331 return; | |
1332 } | |
1333 } | |
1334 // Receiver did not match any saved receiver and there is no empty row for it. | |
1335 // Increment total counter to indicate polymorphic case. | |
1336 increment_count_no_overflow(layout); | |
1337 } | |
1338 | |
1339 static DataLayout* advance(DataLayout* layout) { | |
1340 return (DataLayout*) (((address)layout) + (ssize_t)ReceiverTypeData::receiver_type_data_size_in_bytes()); | |
1341 } | |
1342 #endif // CC_INTERP | |
1343 | |
1344 #ifndef PRODUCT | 1206 #ifndef PRODUCT |
1345 void print_receiver_data_on(outputStream* st) const; | 1207 void print_receiver_data_on(outputStream* st) const; |
1346 void print_data_on(outputStream* st, const char* extra = NULL) const; | 1208 void print_data_on(outputStream* st) const; |
1347 #endif | 1209 #endif |
1348 }; | 1210 }; |
1349 | 1211 |
1350 // VirtualCallData | 1212 // VirtualCallData |
1351 // | 1213 // |
1373 // Direct accessors | 1235 // Direct accessors |
1374 static ByteSize virtual_call_data_size() { | 1236 static ByteSize virtual_call_data_size() { |
1375 return cell_offset(static_cell_count()); | 1237 return cell_offset(static_cell_count()); |
1376 } | 1238 } |
1377 | 1239 |
1378 #ifdef CC_INTERP | |
1379 static int virtual_call_data_size_in_bytes() { | |
1380 return cell_offset_in_bytes(static_cell_count()); | |
1381 } | |
1382 | |
1383 static DataLayout* advance(DataLayout* layout) { | |
1384 return (DataLayout*) (((address)layout) + (ssize_t)VirtualCallData::virtual_call_data_size_in_bytes()); | |
1385 } | |
1386 #endif // CC_INTERP | |
1387 | |
1388 #ifdef GRAAL | 1240 #ifdef GRAAL |
1389 static ByteSize method_offset(uint row) { | 1241 static ByteSize method_offset(uint row) { |
1390 return cell_offset(method_cell_index(row)); | 1242 return cell_offset(method_cell_index(row)); |
1391 } | 1243 } |
1392 static ByteSize method_count_offset(uint row) { | 1244 static ByteSize method_count_offset(uint row) { |
1442 | 1294 |
1443 #ifndef PRODUCT | 1295 #ifndef PRODUCT |
1444 #ifdef GRAAL | 1296 #ifdef GRAAL |
1445 void print_method_data_on(outputStream* st) const; | 1297 void print_method_data_on(outputStream* st) const; |
1446 #endif | 1298 #endif |
1447 void print_data_on(outputStream* st, const char* extra = NULL) const; | 1299 void print_data_on(outputStream* st) const; |
1448 #endif | 1300 #endif |
1449 }; | 1301 }; |
1450 | 1302 |
1451 // VirtualCallTypeData | 1303 // VirtualCallTypeData |
1452 // | 1304 // |
1568 _ret.clean_weak_klass_links(is_alive_closure); | 1420 _ret.clean_weak_klass_links(is_alive_closure); |
1569 } | 1421 } |
1570 } | 1422 } |
1571 | 1423 |
1572 #ifndef PRODUCT | 1424 #ifndef PRODUCT |
1573 virtual void print_data_on(outputStream* st, const char* extra = NULL) const; | 1425 virtual void print_data_on(outputStream* st) const; |
1574 #endif | 1426 #endif |
1575 }; | 1427 }; |
1576 | 1428 |
1577 // RetData | 1429 // RetData |
1578 // | 1430 // |
1663 } | 1515 } |
1664 static ByteSize bci_displacement_offset(uint row) { | 1516 static ByteSize bci_displacement_offset(uint row) { |
1665 return cell_offset(bci_displacement_cell_index(row)); | 1517 return cell_offset(bci_displacement_cell_index(row)); |
1666 } | 1518 } |
1667 | 1519 |
1668 #ifdef CC_INTERP | |
1669 static DataLayout* advance(MethodData *md, int bci); | |
1670 #endif // CC_INTERP | |
1671 | |
1672 // Specific initialization. | 1520 // Specific initialization. |
1673 void post_initialize(BytecodeStream* stream, MethodData* mdo); | 1521 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
1674 | 1522 |
1675 #ifndef PRODUCT | 1523 #ifndef PRODUCT |
1676 void print_data_on(outputStream* st, const char* extra = NULL) const; | 1524 void print_data_on(outputStream* st) const; |
1677 #endif | 1525 #endif |
1678 }; | 1526 }; |
1679 | 1527 |
1680 // BranchData | 1528 // BranchData |
1681 // | 1529 // |
1731 } | 1579 } |
1732 static ByteSize branch_data_size() { | 1580 static ByteSize branch_data_size() { |
1733 return cell_offset(branch_cell_count); | 1581 return cell_offset(branch_cell_count); |
1734 } | 1582 } |
1735 | 1583 |
1736 #ifdef CC_INTERP | |
1737 static int branch_data_size_in_bytes() { | |
1738 return cell_offset_in_bytes(branch_cell_count); | |
1739 } | |
1740 | |
1741 static void increment_not_taken_count_no_overflow(DataLayout* layout) { | |
1742 increment_uint_at_no_overflow(layout, not_taken_off_set); | |
1743 } | |
1744 | |
1745 static DataLayout* advance_not_taken(DataLayout* layout) { | |
1746 return (DataLayout*) (((address)layout) + (ssize_t)BranchData::branch_data_size_in_bytes()); | |
1747 } | |
1748 #endif // CC_INTERP | |
1749 | |
1750 // Specific initialization. | 1584 // Specific initialization. |
1751 void post_initialize(BytecodeStream* stream, MethodData* mdo); | 1585 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
1752 | 1586 |
1753 #ifndef PRODUCT | 1587 #ifndef PRODUCT |
1754 void print_data_on(outputStream* st, const char* extra = NULL) const; | 1588 void print_data_on(outputStream* st) const; |
1755 #endif | 1589 #endif |
1756 }; | 1590 }; |
1757 | 1591 |
1758 // ArrayData | 1592 // ArrayData |
1759 // | 1593 // |
1783 } | 1617 } |
1784 void array_set_int_at(int index, int value) { | 1618 void array_set_int_at(int index, int value) { |
1785 int aindex = index + array_start_off_set; | 1619 int aindex = index + array_start_off_set; |
1786 set_int_at(aindex, value); | 1620 set_int_at(aindex, value); |
1787 } | 1621 } |
1788 | |
1789 #ifdef CC_INTERP | |
1790 // Static low level accessors for DataLayout with ArrayData's semantics. | |
1791 | |
1792 static void increment_array_uint_at_no_overflow(DataLayout* layout, int index) { | |
1793 int aindex = index + array_start_off_set; | |
1794 increment_uint_at_no_overflow(layout, aindex); | |
1795 } | |
1796 | |
1797 static int array_int_at(DataLayout* layout, int index) { | |
1798 int aindex = index + array_start_off_set; | |
1799 return int_at(layout, aindex); | |
1800 } | |
1801 #endif // CC_INTERP | |
1802 | 1622 |
1803 // Code generation support for subclasses. | 1623 // Code generation support for subclasses. |
1804 static ByteSize array_element_offset(int index) { | 1624 static ByteSize array_element_offset(int index) { |
1805 return cell_offset(array_start_off_set + index); | 1625 return cell_offset(array_start_off_set + index); |
1806 } | 1626 } |
1916 } | 1736 } |
1917 static ByteSize relative_displacement_offset() { | 1737 static ByteSize relative_displacement_offset() { |
1918 return in_ByteSize(relative_displacement_off_set) * cell_size; | 1738 return in_ByteSize(relative_displacement_off_set) * cell_size; |
1919 } | 1739 } |
1920 | 1740 |
1921 #ifdef CC_INTERP | |
1922 static void increment_count_no_overflow(DataLayout* layout, int index) { | |
1923 if (index == -1) { | |
1924 increment_array_uint_at_no_overflow(layout, default_count_off_set); | |
1925 } else { | |
1926 increment_array_uint_at_no_overflow(layout, case_array_start + | |
1927 index * per_case_cell_count + | |
1928 relative_count_off_set); | |
1929 } | |
1930 } | |
1931 | |
1932 static DataLayout* advance(DataLayout* layout, int index) { | |
1933 if (index == -1) { | |
1934 return (DataLayout*) (((address)layout) + (ssize_t)array_int_at(layout, default_disaplacement_off_set)); | |
1935 } else { | |
1936 return (DataLayout*) (((address)layout) + (ssize_t)array_int_at(layout, case_array_start + | |
1937 index * per_case_cell_count + | |
1938 relative_displacement_off_set)); | |
1939 } | |
1940 } | |
1941 #endif // CC_INTERP | |
1942 | |
1943 // Specific initialization. | 1741 // Specific initialization. |
1944 void post_initialize(BytecodeStream* stream, MethodData* mdo); | 1742 void post_initialize(BytecodeStream* stream, MethodData* mdo); |
1945 | 1743 |
1946 #ifndef PRODUCT | 1744 #ifndef PRODUCT |
1947 void print_data_on(outputStream* st, const char* extra = NULL) const; | 1745 void print_data_on(outputStream* st) const; |
1948 #endif | 1746 #endif |
1949 }; | 1747 }; |
1950 | 1748 |
1951 class ArgInfoData : public ArrayData { | 1749 class ArgInfoData : public ArrayData { |
1952 | 1750 |
1969 void set_arg_modified(int arg, uint val) { | 1767 void set_arg_modified(int arg, uint val) { |
1970 array_set_int_at(arg, val); | 1768 array_set_int_at(arg, val); |
1971 } | 1769 } |
1972 | 1770 |
1973 #ifndef PRODUCT | 1771 #ifndef PRODUCT |
1974 void print_data_on(outputStream* st, const char* extra = NULL) const; | 1772 void print_data_on(outputStream* st) const; |
1975 #endif | 1773 #endif |
1976 }; | 1774 }; |
1977 | 1775 |
1978 // ParametersTypeData | 1776 // ParametersTypeData |
1979 // | 1777 // |
2030 virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure) { | 1828 virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure) { |
2031 _parameters.clean_weak_klass_links(is_alive_closure); | 1829 _parameters.clean_weak_klass_links(is_alive_closure); |
2032 } | 1830 } |
2033 | 1831 |
2034 #ifndef PRODUCT | 1832 #ifndef PRODUCT |
2035 virtual void print_data_on(outputStream* st, const char* extra = NULL) const; | 1833 virtual void print_data_on(outputStream* st) const; |
2036 #endif | 1834 #endif |
2037 | 1835 |
2038 static ByteSize stack_slot_offset(int i) { | 1836 static ByteSize stack_slot_offset(int i) { |
2039 return cell_offset(stack_slot_local_offset(i)); | 1837 return cell_offset(stack_slot_local_offset(i)); |
2040 } | 1838 } |
2041 | 1839 |
2042 static ByteSize type_offset(int i) { | 1840 static ByteSize type_offset(int i) { |
2043 return cell_offset(type_local_offset(i)); | 1841 return cell_offset(type_local_offset(i)); |
2044 } | 1842 } |
2045 }; | |
2046 | |
2047 // SpeculativeTrapData | |
2048 // | |
2049 // A SpeculativeTrapData is used to record traps due to type | |
2050 // speculation. It records the root of the compilation: that type | |
2051 // speculation is wrong in the context of one compilation (for | |
2052 // method1) doesn't mean it's wrong in the context of another one (for | |
2053 // method2). Type speculation could have more/different data in the | |
2054 // context of the compilation of method2 and it's worthwhile to try an | |
2055 // optimization that failed for compilation of method1 in the context | |
2056 // of compilation of method2. | |
2057 // Space for SpeculativeTrapData entries is allocated from the extra | |
2058 // data space in the MDO. If we run out of space, the trap data for | |
2059 // the ProfileData at that bci is updated. | |
2060 class SpeculativeTrapData : public ProfileData { | |
2061 protected: | |
2062 enum { | |
2063 method_offset, | |
2064 speculative_trap_cell_count | |
2065 }; | |
2066 public: | |
2067 SpeculativeTrapData(DataLayout* layout) : ProfileData(layout) { | |
2068 assert(layout->tag() == DataLayout::speculative_trap_data_tag, "wrong type"); | |
2069 } | |
2070 | |
2071 virtual bool is_SpeculativeTrapData() const { return true; } | |
2072 | |
2073 static int static_cell_count() { | |
2074 return speculative_trap_cell_count; | |
2075 } | |
2076 | |
2077 virtual int cell_count() const { | |
2078 return static_cell_count(); | |
2079 } | |
2080 | |
2081 // Direct accessor | |
2082 Method* method() const { | |
2083 return (Method*)intptr_at(method_offset); | |
2084 } | |
2085 | |
2086 void set_method(Method* m) { | |
2087 set_intptr_at(method_offset, (intptr_t)m); | |
2088 } | |
2089 | |
2090 #ifndef PRODUCT | |
2091 virtual void print_data_on(outputStream* st, const char* extra = NULL) const; | |
2092 #endif | |
2093 }; | 1843 }; |
2094 | 1844 |
2095 // MethodData* | 1845 // MethodData* |
2096 // | 1846 // |
2097 // A MethodData* holds information which has been collected about | 1847 // A MethodData* holds information which has been collected about |
2133 // from the base of the data entry array. A "displacement" is the byte offset | 1883 // from the base of the data entry array. A "displacement" is the byte offset |
2134 // in certain ProfileData objects that indicate the amount the mdp must be | 1884 // in certain ProfileData objects that indicate the amount the mdp must be |
2135 // adjusted in the event of a change in control flow. | 1885 // adjusted in the event of a change in control flow. |
2136 // | 1886 // |
2137 | 1887 |
2138 CC_INTERP_ONLY(class BytecodeInterpreter;) | |
2139 | |
2140 class MethodData : public Metadata { | 1888 class MethodData : public Metadata { |
2141 friend class VMStructs; | 1889 friend class VMStructs; |
2142 CC_INTERP_ONLY(friend class BytecodeInterpreter;) | |
2143 private: | 1890 private: |
2144 friend class ProfileData; | 1891 friend class ProfileData; |
2145 | 1892 |
2146 // Back pointer to the Method* | 1893 // Back pointer to the Method* |
2147 Method* _method; | 1894 Method* _method; |
2228 intptr_t _data[1]; | 1975 intptr_t _data[1]; |
2229 | 1976 |
2230 // Helper for size computation | 1977 // Helper for size computation |
2231 static int compute_data_size(BytecodeStream* stream); | 1978 static int compute_data_size(BytecodeStream* stream); |
2232 static int bytecode_cell_count(Bytecodes::Code code); | 1979 static int bytecode_cell_count(Bytecodes::Code code); |
2233 static bool is_speculative_trap_bytecode(Bytecodes::Code code); | |
2234 enum { no_profile_data = -1, variable_cell_count = -2 }; | 1980 enum { no_profile_data = -1, variable_cell_count = -2 }; |
2235 | 1981 |
2236 // Helper for initialization | 1982 // Helper for initialization |
2237 DataLayout* data_layout_at(int data_index) const { | 1983 DataLayout* data_layout_at(int data_index) const { |
2238 assert(data_index % sizeof(intptr_t) == 0, "unaligned"); | 1984 assert(data_index % sizeof(intptr_t) == 0, "unaligned"); |
2272 } | 2018 } |
2273 | 2019 |
2274 // What is the index of the first data entry? | 2020 // What is the index of the first data entry? |
2275 int first_di() const { return 0; } | 2021 int first_di() const { return 0; } |
2276 | 2022 |
2277 ProfileData* bci_to_extra_data_helper(int bci, Method* m, DataLayout*& dp); | |
2278 // Find or create an extra ProfileData: | 2023 // Find or create an extra ProfileData: |
2279 ProfileData* bci_to_extra_data(int bci, Method* m, bool create_if_missing); | 2024 ProfileData* bci_to_extra_data(int bci, bool create_if_missing); |
2280 | 2025 |
2281 // return the argument info cell | 2026 // return the argument info cell |
2282 ArgInfoData *arg_info(); | 2027 ArgInfoData *arg_info(); |
2283 | 2028 |
2284 enum { | 2029 enum { |
2297 static bool profile_return_for_invoke(methodHandle m, int bci); | 2042 static bool profile_return_for_invoke(methodHandle m, int bci); |
2298 static int profile_parameters_flag(); | 2043 static int profile_parameters_flag(); |
2299 static bool profile_parameters_jsr292_only(); | 2044 static bool profile_parameters_jsr292_only(); |
2300 static bool profile_all_parameters(); | 2045 static bool profile_all_parameters(); |
2301 | 2046 |
2302 void clean_extra_data(BoolObjectClosure* is_alive); | |
2303 void clean_extra_data_helper(DataLayout* dp, int shift, bool reset = false); | |
2304 void verify_extra_data_clean(BoolObjectClosure* is_alive); | |
2305 | |
2306 // Redefinition support | |
2307 void clean_weak_method_extra_data(); | |
2308 void verify_weak_method_extra_data_clean(); | |
2309 | |
2310 public: | 2047 public: |
2311 static int header_size() { | 2048 static int header_size() { |
2312 return sizeof(MethodData)/wordSize; | 2049 return sizeof(MethodData)/wordSize; |
2313 } | 2050 } |
2314 | 2051 |
2315 // Compute the size of a MethodData* before it is created. | 2052 // Compute the size of a MethodData* before it is created. |
2316 static int compute_allocation_size_in_bytes(methodHandle method); | 2053 static int compute_allocation_size_in_bytes(methodHandle method); |
2317 static int compute_allocation_size_in_words(methodHandle method); | 2054 static int compute_allocation_size_in_words(methodHandle method); |
2318 static int compute_extra_data_count(int data_size, int empty_bc_count, bool needs_speculative_traps); | 2055 static int compute_extra_data_count(int data_size, int empty_bc_count); |
2319 | 2056 |
2320 // Determine if a given bytecode can have profile information. | 2057 // Determine if a given bytecode can have profile information. |
2321 static bool bytecode_has_profile(Bytecodes::Code code) { | 2058 static bool bytecode_has_profile(Bytecodes::Code code) { |
2322 return bytecode_cell_count(code) != no_profile_data; | 2059 return bytecode_cell_count(code) != no_profile_data; |
2323 } | 2060 } |
2454 | 2191 |
2455 // Get the data at an arbitrary bci, or NULL if there is none. | 2192 // Get the data at an arbitrary bci, or NULL if there is none. |
2456 ProfileData* bci_to_data(int bci); | 2193 ProfileData* bci_to_data(int bci); |
2457 | 2194 |
2458 // Same, but try to create an extra_data record if one is needed: | 2195 // Same, but try to create an extra_data record if one is needed: |
2459 ProfileData* allocate_bci_to_data(int bci, Method* m) { | 2196 ProfileData* allocate_bci_to_data(int bci) { |
2460 ProfileData* data = NULL; | 2197 ProfileData* data = bci_to_data(bci); |
2461 // If m not NULL, try to allocate a SpeculativeTrapData entry | 2198 return (data != NULL) ? data : bci_to_extra_data(bci, true); |
2462 if (m == NULL) { | |
2463 data = bci_to_data(bci); | |
2464 } | |
2465 if (data != NULL) { | |
2466 return data; | |
2467 } | |
2468 data = bci_to_extra_data(bci, m, true); | |
2469 if (data != NULL) { | |
2470 return data; | |
2471 } | |
2472 // If SpeculativeTrapData allocation fails try to allocate a | |
2473 // regular entry | |
2474 data = bci_to_data(bci); | |
2475 if (data != NULL) { | |
2476 return data; | |
2477 } | |
2478 return bci_to_extra_data(bci, NULL, true); | |
2479 } | 2199 } |
2480 | 2200 |
2481 // Add a handful of extra data records, for trap tracking. | 2201 // Add a handful of extra data records, for trap tracking. |
2482 DataLayout* extra_data_base() const { return limit_data_position(); } | 2202 DataLayout* extra_data_base() const { return limit_data_position(); } |
2483 DataLayout* extra_data_limit() const { return (DataLayout*)((address)this + size_in_bytes()); } | 2203 DataLayout* extra_data_limit() const { return (DataLayout*)((address)this + size_in_bytes()); } |
2484 int extra_data_size() const { return (address)extra_data_limit() | 2204 int extra_data_size() const { return (address)extra_data_limit() |
2485 - (address)extra_data_base(); } | 2205 - (address)extra_data_base(); } |
2486 static DataLayout* next_extra(DataLayout* dp); | 2206 static DataLayout* next_extra(DataLayout* dp) { return (DataLayout*)((address)dp + in_bytes(DataLayout::cell_offset(0))); } |
2487 | 2207 |
2488 // Return (uint)-1 for overflow. | 2208 // Return (uint)-1 for overflow. |
2489 uint trap_count(int reason) const { | 2209 uint trap_count(int reason) const { |
2490 assert((uint)reason < GRAAL_ONLY(2*) _trap_hist_limit, "oob"); | 2210 assert((uint)reason < GRAAL_ONLY(2*) _trap_hist_limit, "oob"); |
2491 return (int)((_trap_hist._array[reason]+1) & _trap_hist_mask) - 1; | 2211 return (int)((_trap_hist._array[reason]+1) & _trap_hist_mask) - 1; |
2582 static bool profile_arguments(); | 2302 static bool profile_arguments(); |
2583 static bool profile_return(); | 2303 static bool profile_return(); |
2584 static bool profile_parameters(); | 2304 static bool profile_parameters(); |
2585 static bool profile_return_jsr292_only(); | 2305 static bool profile_return_jsr292_only(); |
2586 | 2306 |
2587 void clean_method_data(BoolObjectClosure* is_alive); | |
2588 | |
2589 void clean_weak_method_links(); | 2307 void clean_weak_method_links(); |
2590 }; | 2308 }; |
2591 | 2309 |
2592 #endif // SHARE_VM_OOPS_METHODDATAOOP_HPP | 2310 #endif // SHARE_VM_OOPS_METHODDATAOOP_HPP |