Mercurial > hg > graal-jvmci-8
comparison src/share/vm/utilities/debug.cpp @ 6725:da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author | coleenp |
---|---|
date | Sat, 01 Sep 2012 13:25:18 -0400 |
parents | 6c5b7a6becc8 |
children | 145ffab733e7 |
comparison
equal
deleted
inserted
replaced
6724:36d1d483d5d6 | 6725:da91efe96a93 |
---|---|
262 | 262 |
263 void report_should_not_reach_here(const char* file, int line) { | 263 void report_should_not_reach_here(const char* file, int line) { |
264 report_vm_error(file, line, "ShouldNotReachHere()"); | 264 report_vm_error(file, line, "ShouldNotReachHere()"); |
265 } | 265 } |
266 | 266 |
267 void report_should_not_reach_here2(const char* file, int line, const char* message) { | |
268 report_vm_error(file, line, "ShouldNotReachHere()", message); | |
269 } | |
270 | |
267 void report_unimplemented(const char* file, int line) { | 271 void report_unimplemented(const char* file, int line) { |
268 report_vm_error(file, line, "Unimplemented()"); | 272 report_vm_error(file, line, "Unimplemented()"); |
269 } | 273 } |
270 | 274 |
271 void report_untested(const char* file, int line, const char* message) { | 275 void report_untested(const char* file, int line, const char* message) { |
274 #endif // !PRODUCT | 278 #endif // !PRODUCT |
275 } | 279 } |
276 | 280 |
277 void report_out_of_shared_space(SharedSpaceType shared_space) { | 281 void report_out_of_shared_space(SharedSpaceType shared_space) { |
278 static const char* name[] = { | 282 static const char* name[] = { |
279 "permanent generation", | 283 "native memory for metadata", |
280 "shared read only space", | 284 "shared read only space", |
281 "shared read write space", | 285 "shared read write space", |
282 "shared miscellaneous data space" | 286 "shared miscellaneous data space" |
283 }; | 287 }; |
284 static const char* flag[] = { | 288 static const char* flag[] = { |
285 "PermGen", | 289 "Metaspace", |
286 "SharedReadOnlySize", | 290 "SharedReadOnlySize", |
287 "SharedReadWriteSize", | 291 "SharedReadWriteSize", |
288 "SharedMiscDataSize" | 292 "SharedMiscDataSize" |
289 }; | 293 }; |
290 | 294 |
411 } | 415 } |
412 | 416 |
413 | 417 |
414 extern "C" void dump_vtable(address p) { | 418 extern "C" void dump_vtable(address p) { |
415 Command c("dump_vtable"); | 419 Command c("dump_vtable"); |
416 klassOop k = (klassOop)p; | 420 Klass* k = (Klass*)p; |
417 instanceKlass::cast(k)->vtable()->print(); | 421 InstanceKlass::cast(k)->vtable()->print(); |
418 } | 422 } |
419 | 423 |
420 | 424 |
421 extern "C" void nm(intptr_t p) { | 425 extern "C" void nm(intptr_t p) { |
422 // Actually we look through all CodeBlobs (the nm name has been kept for backwards compatability) | 426 // Actually we look through all CodeBlobs (the nm name has been kept for backwards compatability) |
625 MarkSweep::print_new_location_of_heap_address((HeapWord*) old_heap_addr); | 629 MarkSweep::print_new_location_of_heap_address((HeapWord*) old_heap_addr); |
626 #endif | 630 #endif |
627 } | 631 } |
628 | 632 |
629 | 633 |
630 extern "C" methodOop findm(intptr_t pc) { | 634 extern "C" Method* findm(intptr_t pc) { |
631 Command c("findm"); | 635 Command c("findm"); |
632 nmethod* nm = CodeCache::find_nmethod((address)pc); | 636 nmethod* nm = CodeCache::find_nmethod((address)pc); |
633 return (nm == NULL) ? (methodOop)NULL : nm->method(); | 637 return (nm == NULL) ? (Method*)NULL : nm->method(); |
634 } | 638 } |
635 | 639 |
636 | 640 |
637 extern "C" nmethod* findnm(intptr_t addr) { | 641 extern "C" nmethod* findnm(intptr_t addr) { |
638 Command c("findnm"); | 642 Command c("findnm"); |
648 } else { | 652 } else { |
649 return (address)(intptr_t(y) & page_bits); | 653 return (address)(intptr_t(y) & page_bits); |
650 } | 654 } |
651 } | 655 } |
652 | 656 |
653 class LookForRefInGenClosure : public OopsInGenClosure { | |
654 public: | |
655 oop target; | |
656 void do_oop(oop* o) { | |
657 if (o != NULL && *o == target) { | |
658 tty->print_cr(INTPTR_FORMAT, o); | |
659 } | |
660 } | |
661 void do_oop(narrowOop* o) { ShouldNotReachHere(); } | |
662 }; | |
663 | |
664 | |
665 class LookForRefInObjectClosure : public ObjectClosure { | |
666 private: | |
667 LookForRefInGenClosure look_in_object; | |
668 public: | |
669 LookForRefInObjectClosure(oop target) { look_in_object.target = target; } | |
670 void do_object(oop obj) { | |
671 obj->oop_iterate(&look_in_object); | |
672 } | |
673 }; | |
674 | |
675 | |
676 static void findref(intptr_t x) { | |
677 CollectedHeap *ch = Universe::heap(); | |
678 LookForRefInGenClosure lookFor; | |
679 lookFor.target = (oop) x; | |
680 LookForRefInObjectClosure look_in_object((oop) x); | |
681 | |
682 tty->print_cr("Searching heap:"); | |
683 ch->object_iterate(&look_in_object); | |
684 | |
685 tty->print_cr("Searching strong roots:"); | |
686 Universe::oops_do(&lookFor, false); | |
687 JNIHandles::oops_do(&lookFor); // Global (strong) JNI handles | |
688 Threads::oops_do(&lookFor, NULL); | |
689 ObjectSynchronizer::oops_do(&lookFor); | |
690 //FlatProfiler::oops_do(&lookFor); | |
691 SystemDictionary::oops_do(&lookFor); | |
692 | |
693 tty->print_cr("Searching code cache:"); | |
694 CodeCache::oops_do(&lookFor); | |
695 | |
696 tty->print_cr("Done."); | |
697 } | |
698 | |
699 class FindClassObjectClosure: public ObjectClosure { | |
700 private: | |
701 const char* _target; | |
702 public: | |
703 FindClassObjectClosure(const char name[]) { _target = name; } | |
704 | |
705 virtual void do_object(oop obj) { | |
706 if (obj->is_klass()) { | |
707 Klass* k = klassOop(obj)->klass_part(); | |
708 if (k->name() != NULL) { | |
709 ResourceMark rm; | |
710 const char* ext = k->external_name(); | |
711 if ( strcmp(_target, ext) == 0 ) { | |
712 tty->print_cr("Found " INTPTR_FORMAT, obj); | |
713 obj->print(); | |
714 } | |
715 } | |
716 } | |
717 } | |
718 }; | |
719 | |
720 // | |
721 extern "C" void findclass(const char name[]) { | |
722 Command c("findclass"); | |
723 if (name != NULL) { | |
724 tty->print_cr("Finding class %s -> ", name); | |
725 FindClassObjectClosure srch(name); | |
726 Universe::heap()->permanent_object_iterate(&srch); | |
727 } | |
728 } | |
729 | 657 |
730 // Another interface that isn't ambiguous in dbx. | 658 // Another interface that isn't ambiguous in dbx. |
731 // Can we someday rename the other find to hsfind? | 659 // Can we someday rename the other find to hsfind? |
732 extern "C" void hsfind(intptr_t x) { | 660 extern "C" void hsfind(intptr_t x) { |
733 Command c("hsfind"); | 661 Command c("hsfind"); |
734 os::print_location(tty, x, false); | 662 os::print_location(tty, x, false); |
735 } | 663 } |
736 | 664 |
737 | 665 |
738 extern "C" void hsfindref(intptr_t x) { | |
739 Command c("hsfindref"); | |
740 findref(x); | |
741 } | |
742 | |
743 extern "C" void find(intptr_t x) { | 666 extern "C" void find(intptr_t x) { |
744 Command c("find"); | 667 Command c("find"); |
745 os::print_location(tty, x, false); | 668 os::print_location(tty, x, false); |
746 } | 669 } |
747 | 670 |
749 extern "C" void findpc(intptr_t x) { | 672 extern "C" void findpc(intptr_t x) { |
750 Command c("findpc"); | 673 Command c("findpc"); |
751 os::print_location(tty, x, true); | 674 os::print_location(tty, x, true); |
752 } | 675 } |
753 | 676 |
677 | |
678 // Need method pointer to find bcp, when not in permgen. | |
679 extern "C" void findbcp(intptr_t method, intptr_t bcp) { | |
680 Command c("findbcp"); | |
681 Method* mh = (Method*)method; | |
682 if (!mh->is_native()) { | |
683 tty->print_cr("bci_from(%p) = %d; print_codes():", | |
684 mh, mh->bci_from(address(bcp))); | |
685 mh->print_codes_on(tty); | |
686 } | |
687 } | |
754 | 688 |
755 // int versions of all methods to avoid having to type type casts in the debugger | 689 // int versions of all methods to avoid having to type type casts in the debugger |
756 | 690 |
757 void pp(intptr_t p) { pp((void*)p); } | 691 void pp(intptr_t p) { pp((void*)p); } |
758 void pp(oop p) { pp((void*)p); } | 692 void pp(oop p) { pp((void*)p); } |
762 tty->print_cr("basic"); | 696 tty->print_cr("basic"); |
763 tty->print_cr(" pp(void* p) - try to make sense of p"); | 697 tty->print_cr(" pp(void* p) - try to make sense of p"); |
764 tty->print_cr(" pv(intptr_t p)- ((PrintableResourceObj*) p)->print()"); | 698 tty->print_cr(" pv(intptr_t p)- ((PrintableResourceObj*) p)->print()"); |
765 tty->print_cr(" ps() - print current thread stack"); | 699 tty->print_cr(" ps() - print current thread stack"); |
766 tty->print_cr(" pss() - print all thread stacks"); | 700 tty->print_cr(" pss() - print all thread stacks"); |
767 tty->print_cr(" pm(int pc) - print methodOop given compiled PC"); | 701 tty->print_cr(" pm(int pc) - print Method* given compiled PC"); |
768 tty->print_cr(" findm(intptr_t pc) - finds methodOop"); | 702 tty->print_cr(" findm(intptr_t pc) - finds Method*"); |
769 tty->print_cr(" find(intptr_t x) - finds & prints nmethod/stub/bytecode/oop based on pointer into it"); | 703 tty->print_cr(" find(intptr_t x) - finds & prints nmethod/stub/bytecode/oop based on pointer into it"); |
770 | 704 |
771 tty->print_cr("misc."); | 705 tty->print_cr("misc."); |
772 tty->print_cr(" flush() - flushes the log file"); | 706 tty->print_cr(" flush() - flushes the log file"); |
773 tty->print_cr(" events() - dump events from ring buffers"); | 707 tty->print_cr(" events() - dump events from ring buffers"); |
810 (char *)"quit", CMDID_QUIT, " Return from this routine", | 744 (char *)"quit", CMDID_QUIT, " Return from this routine", |
811 (char *)"hsfind", CMDID_HSFIND, "Perform an hsfind on an address", | 745 (char *)"hsfind", CMDID_HSFIND, "Perform an hsfind on an address", |
812 (char *)"ps", CMDID_PS, " Print Current Thread Stack Trace", | 746 (char *)"ps", CMDID_PS, " Print Current Thread Stack Trace", |
813 (char *)"pss", CMDID_PSS, " Print All Thread Stack Trace", | 747 (char *)"pss", CMDID_PSS, " Print All Thread Stack Trace", |
814 (char *)"psf", CMDID_PSF, " Print All Stack Frames", | 748 (char *)"psf", CMDID_PSF, " Print All Stack Frames", |
815 (char *)"findm", CMDID_FINDM, " Find a methodOop from a PC", | 749 (char *)"findm", CMDID_FINDM, " Find a Method* from a PC", |
816 (char *)"findnm", CMDID_FINDNM, "Find an nmethod from a PC", | 750 (char *)"findnm", CMDID_FINDNM, "Find an nmethod from a PC", |
817 (char *)"pp", CMDID_PP, " Find out something about a pointer", | 751 (char *)"pp", CMDID_PP, " Find out something about a pointer", |
818 (char *)"break", CMDID_BPT, " Execute a breakpoint", | 752 (char *)"break", CMDID_BPT, " Execute a breakpoint", |
819 (char *)"exitvm", CMDID_EXIT, "Exit the VM", | 753 (char *)"exitvm", CMDID_EXIT, "Exit the VM", |
820 (char *)"verify", CMDID_VERIFY, "Perform a Heap Verify", | 754 (char *)"verify", CMDID_VERIFY, "Perform a Heap Verify", |
835 int i,j; | 769 int i,j; |
836 bool gotcommand; | 770 bool gotcommand; |
837 intptr_t addr; | 771 intptr_t addr; |
838 char buffer[256]; | 772 char buffer[256]; |
839 nmethod *nm; | 773 nmethod *nm; |
840 methodOop m; | 774 Method* m; |
841 | 775 |
842 tty->print_cr("You have entered the diagnostic command interpreter"); | 776 tty->print_cr("You have entered the diagnostic command interpreter"); |
843 tty->print("The supported commands are:\n"); | 777 tty->print("The supported commands are:\n"); |
844 for ( i=0; ; i++ ) { | 778 for ( i=0; ; i++ ) { |
845 if ( CommandList[i].code == CMDID_ILLEGAL ) | 779 if ( CommandList[i].code == CMDID_ILLEGAL ) |
870 psf(); | 804 psf(); |
871 break; | 805 break; |
872 case CMDID_FINDM: | 806 case CMDID_FINDM: |
873 tty->print("Please enter the hex addr to pass to findm: "); | 807 tty->print("Please enter the hex addr to pass to findm: "); |
874 scanf("%I64X", &addr); | 808 scanf("%I64X", &addr); |
875 m = (methodOop)findm(addr); | 809 m = (Method*)findm(addr); |
876 tty->print("findm(0x%I64X) returned 0x%I64X\n", addr, m); | 810 tty->print("findm(0x%I64X) returned 0x%I64X\n", addr, m); |
877 break; | 811 break; |
878 case CMDID_FINDNM: | 812 case CMDID_FINDNM: |
879 tty->print("Please enter the hex addr to pass to findnm: "); | 813 tty->print("Please enter the hex addr to pass to findnm: "); |
880 scanf("%I64X", &addr); | 814 scanf("%I64X", &addr); |