|
88 | 88 | #include "utilities/events.hpp" |
89 | 89 | #include "utilities/macros.hpp" |
90 | 90 | #include "utilities/stringUtils.hpp" |
91 | | -#include "utilities/pair.hpp" |
92 | 91 | #ifdef COMPILER1 |
93 | 92 | #include "c1/c1_Compiler.hpp" |
94 | 93 | #endif |
@@ -1624,57 +1623,43 @@ void InstanceKlass::do_local_static_fields(void f(fieldDescriptor*, Handle, TRAP |
1624 | 1623 | } |
1625 | 1624 | } |
1626 | 1625 |
|
| 1626 | + |
| 1627 | +static int compare_fields_by_offset(int* a, int* b) { |
| 1628 | + return a[0] - b[0]; |
| 1629 | +} |
| 1630 | + |
1627 | 1631 | void InstanceKlass::do_nonstatic_fields(FieldClosure* cl) { |
1628 | 1632 | InstanceKlass* super = superklass(); |
1629 | 1633 | if (super != NULL) { |
1630 | 1634 | super->do_nonstatic_fields(cl); |
1631 | 1635 | } |
1632 | 1636 | fieldDescriptor fd; |
1633 | 1637 | int length = java_fields_count(); |
| 1638 | + // In DebugInfo nonstatic fields are sorted by offset. |
| 1639 | + int* fields_sorted = NEW_C_HEAP_ARRAY(int, 2*(length+1), mtClass); |
| 1640 | + int j = 0; |
1634 | 1641 | for (int i = 0; i < length; i += 1) { |
1635 | 1642 | fd.reinitialize(this, i); |
1636 | 1643 | if (!fd.is_static()) { |
1637 | | - cl->do_field(&fd); |
| 1644 | + fields_sorted[j + 0] = fd.offset(); |
| 1645 | + fields_sorted[j + 1] = i; |
| 1646 | + j += 2; |
1638 | 1647 | } |
1639 | 1648 | } |
1640 | | -} |
1641 | | - |
1642 | | -// first in Pair is offset, second is index. |
1643 | | -static int compare_fields_by_offset(Pair<int,int>* a, Pair<int,int>* b) { |
1644 | | - return a->first - b->first; |
1645 | | -} |
1646 | | - |
1647 | | -void InstanceKlass::print_nonstatic_fields(FieldClosure* cl) { |
1648 | | - InstanceKlass* super = superklass(); |
1649 | | - if (super != NULL) { |
1650 | | - super->print_nonstatic_fields(cl); |
1651 | | - } |
1652 | | - ResourceMark rm; |
1653 | | - fieldDescriptor fd; |
1654 | | - // In DebugInfo nonstatic fields are sorted by offset. |
1655 | | - GrowableArray<Pair<int,int> > fields_sorted; |
1656 | | - int i = 0; |
1657 | | - for (AllFieldStream fs(this); !fs.done(); fs.next()) { |
1658 | | - if (!fs.access_flags().is_static()) { |
1659 | | - fd = fs.field_descriptor(); |
1660 | | - Pair<int,int> f(fs.offset(), fs.index()); |
1661 | | - fields_sorted.push(f); |
1662 | | - i++; |
1663 | | - } |
1664 | | - } |
1665 | | - if (i > 0) { |
1666 | | - int length = i; |
1667 | | - assert(length == fields_sorted.length(), "duh"); |
| 1649 | + if (j > 0) { |
| 1650 | + length = j; |
1668 | 1651 | // _sort_Fn is defined in growableArray.hpp. |
1669 | | - fields_sorted.sort(compare_fields_by_offset); |
1670 | | - for (int i = 0; i < length; i++) { |
1671 | | - fd.reinitialize(this, fields_sorted.at(i).second); |
1672 | | - assert(!fd.is_static() && fd.offset() == fields_sorted.at(i).first, "only nonstatic fields"); |
| 1652 | + qsort(fields_sorted, length/2, 2*sizeof(int), (_sort_Fn)compare_fields_by_offset); |
| 1653 | + for (int i = 0; i < length; i += 2) { |
| 1654 | + fd.reinitialize(this, fields_sorted[i + 1]); |
| 1655 | + assert(!fd.is_static() && fd.offset() == fields_sorted[i], "only nonstatic fields"); |
1673 | 1656 | cl->do_field(&fd); |
1674 | 1657 | } |
1675 | 1658 | } |
| 1659 | + FREE_C_HEAP_ARRAY(int, fields_sorted); |
1676 | 1660 | } |
1677 | 1661 |
|
| 1662 | + |
1678 | 1663 | void InstanceKlass::array_klasses_do(void f(Klass* k, TRAPS), TRAPS) { |
1679 | 1664 | if (array_klasses() != NULL) |
1680 | 1665 | array_klasses()->array_klasses_do(f, THREAD); |
@@ -3452,7 +3437,7 @@ void InstanceKlass::print_on(outputStream* st) const { |
3452 | 3437 | st->print_cr(BULLET"---- non-static fields (%d words):", nonstatic_field_size()); |
3453 | 3438 | FieldPrinter print_nonstatic_field(st); |
3454 | 3439 | InstanceKlass* ik = const_cast<InstanceKlass*>(this); |
3455 | | - ik->print_nonstatic_fields(&print_nonstatic_field); |
| 3440 | + ik->do_nonstatic_fields(&print_nonstatic_field); |
3456 | 3441 |
|
3457 | 3442 | st->print(BULLET"non-static oop maps: "); |
3458 | 3443 | OopMapBlock* map = start_of_nonstatic_oop_maps(); |
@@ -3494,20 +3479,30 @@ void InstanceKlass::oop_print_on(oop obj, outputStream* st) { |
3494 | 3479 | st->print(BULLET"string: "); |
3495 | 3480 | java_lang_String::print(obj, st); |
3496 | 3481 | st->cr(); |
| 3482 | + if (!WizardMode) return; // that is enough |
3497 | 3483 | } |
3498 | 3484 | } |
3499 | 3485 |
|
3500 | 3486 | st->print_cr(BULLET"---- fields (total size %d words):", oop_size(obj)); |
3501 | 3487 | FieldPrinter print_field(st, obj); |
3502 | | - print_nonstatic_fields(&print_field); |
| 3488 | + do_nonstatic_fields(&print_field); |
3503 | 3489 |
|
3504 | 3490 | if (this == vmClasses::Class_klass()) { |
3505 | 3491 | st->print(BULLET"signature: "); |
3506 | 3492 | java_lang_Class::print_signature(obj, st); |
3507 | 3493 | st->cr(); |
| 3494 | + Klass* mirrored_klass = java_lang_Class::as_Klass(obj); |
| 3495 | + st->print(BULLET"fake entry for mirror: "); |
| 3496 | + Metadata::print_value_on_maybe_null(st, mirrored_klass); |
| 3497 | + st->cr(); |
| 3498 | + Klass* array_klass = java_lang_Class::array_klass_acquire(obj); |
| 3499 | + st->print(BULLET"fake entry for array: "); |
| 3500 | + Metadata::print_value_on_maybe_null(st, array_klass); |
| 3501 | + st->cr(); |
| 3502 | + st->print_cr(BULLET"fake entry for oop_size: %d", java_lang_Class::oop_size(obj)); |
| 3503 | + st->print_cr(BULLET"fake entry for static_oop_field_count: %d", java_lang_Class::static_oop_field_count(obj)); |
3508 | 3504 | Klass* real_klass = java_lang_Class::as_Klass(obj); |
3509 | 3505 | if (real_klass != NULL && real_klass->is_instance_klass()) { |
3510 | | - st->print_cr(BULLET"---- static fields (%d words):", java_lang_Class::static_oop_field_count(obj)); |
3511 | 3506 | InstanceKlass::cast(real_klass)->do_local_static_fields(&print_field); |
3512 | 3507 | } |
3513 | 3508 | } else if (this == vmClasses::MethodType_klass()) { |
|
0 commit comments