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