2306
2307 class DetectScavengeRoot: public OopClosure {
2308 bool _detected_scavenge_root;
2309 public:
2310 DetectScavengeRoot() : _detected_scavenge_root(false)
2311 { NOT_PRODUCT(_print_nm = NULL); }
2312 bool detected_scavenge_root() { return _detected_scavenge_root; }
2313 virtual void do_oop(oop* p) {
2314 if ((*p) != NULL && (*p)->is_scavengable()) {
2315 NOT_PRODUCT(maybe_print(p));
2316 _detected_scavenge_root = true;
2317 }
2318 }
2319 virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
2320
2321 #ifndef PRODUCT
2322 nmethod* _print_nm;
2323 void maybe_print(oop* p) {
2324 if (_print_nm == NULL) return;
2325 if (!_detected_scavenge_root) _print_nm->print_on(tty, "new scavenge root");
2326 tty->print_cr(""PTR_FORMAT"[offset=%d] detected scavengable oop "PTR_FORMAT" (found at "PTR_FORMAT")",
2327 _print_nm, (int)((intptr_t)p - (intptr_t)_print_nm),
2328 (void *)(*p), (intptr_t)p);
2329 (*p)->print();
2330 }
2331 #endif //PRODUCT
2332 };
2333
2334 bool nmethod::detect_scavenge_root_oops() {
2335 DetectScavengeRoot detect_scavenge_root;
2336 NOT_PRODUCT(if (TraceScavenge) detect_scavenge_root._print_nm = this);
2337 oops_do(&detect_scavenge_root);
2338 return detect_scavenge_root.detected_scavenge_root();
2339 }
2340
2341 // Method that knows how to preserve outgoing arguments at call. This method must be
2342 // called with a frame corresponding to a Java invoke
2343 void nmethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) {
2344 #ifndef SHARK
2345 if (!method()->is_native()) {
2346 SimpleScopeDesc ssd(this, fr.pc());
2687 return false;
2688 return pd->is_method_handle_invoke();
2689 }
2690
2691
2692 // -----------------------------------------------------------------------------
2693 // Verification
2694
2695 class VerifyOopsClosure: public OopClosure {
2696 nmethod* _nm;
2697 bool _ok;
2698 public:
2699 VerifyOopsClosure(nmethod* nm) : _nm(nm), _ok(true) { }
2700 bool ok() { return _ok; }
2701 virtual void do_oop(oop* p) {
2702 if ((*p) == NULL || (*p)->is_oop()) return;
2703 if (_ok) {
2704 _nm->print_nmethod(true);
2705 _ok = false;
2706 }
2707 tty->print_cr("*** non-oop "PTR_FORMAT" found at "PTR_FORMAT" (offset %d)",
2708 (void *)(*p), (intptr_t)p, (int)((intptr_t)p - (intptr_t)_nm));
2709 }
2710 virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
2711 };
2712
2713 void nmethod::verify() {
2714
2715 // Hmm. OSR methods can be deopted but not marked as zombie or not_entrant
2716 // seems odd.
2717
2718 if (is_zombie() || is_not_entrant() || is_unloaded())
2719 return;
2720
2721 // Make sure all the entry points are correctly aligned for patching.
2722 NativeJump::check_verified_entry_alignment(entry_point(), verified_entry_point());
2723
2724 // assert(method()->is_oop(), "must be valid");
2725
2726 ResourceMark rm;
2727
2811 }
2812 }
2813
2814
2815 // -----------------------------------------------------------------------------
2816 // Non-product code
2817 #ifndef PRODUCT
2818
2819 class DebugScavengeRoot: public OopClosure {
2820 nmethod* _nm;
2821 bool _ok;
2822 public:
2823 DebugScavengeRoot(nmethod* nm) : _nm(nm), _ok(true) { }
2824 bool ok() { return _ok; }
2825 virtual void do_oop(oop* p) {
2826 if ((*p) == NULL || !(*p)->is_scavengable()) return;
2827 if (_ok) {
2828 _nm->print_nmethod(true);
2829 _ok = false;
2830 }
2831 tty->print_cr("*** scavengable oop "PTR_FORMAT" found at "PTR_FORMAT" (offset %d)",
2832 (void *)(*p), (intptr_t)p, (int)((intptr_t)p - (intptr_t)_nm));
2833 (*p)->print();
2834 }
2835 virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
2836 };
2837
2838 void nmethod::verify_scavenge_root_oops() {
2839 if (UseG1GC) {
2840 return;
2841 }
2842
2843 if (!on_scavenge_root_list()) {
2844 // Actually look inside, to verify the claim that it's clean.
2845 DebugScavengeRoot debug_scavenge_root(this);
2846 oops_do(&debug_scavenge_root);
2847 if (!debug_scavenge_root.ok())
2848 fatal("found an unadvertised bad scavengable oop in the code cache");
2849 }
2850 assert(scavenge_root_not_marked(), "");
2851 }
2856
2857 void nmethod::print() const {
2858 ResourceMark rm;
2859 ttyLocker ttyl; // keep the following output all in one block
2860
2861 tty->print("Compiled method ");
2862
2863 if (is_compiled_by_c1()) {
2864 tty->print("(c1) ");
2865 } else if (is_compiled_by_c2()) {
2866 tty->print("(c2) ");
2867 } else if (is_compiled_by_shark()) {
2868 tty->print("(shark) ");
2869 } else {
2870 tty->print("(nm) ");
2871 }
2872
2873 print_on(tty, NULL);
2874
2875 if (WizardMode) {
2876 tty->print("((nmethod*) "INTPTR_FORMAT ") ", this);
2877 tty->print(" for method " INTPTR_FORMAT , (address)method());
2878 tty->print(" { ");
2879 if (is_in_use()) tty->print("in_use ");
2880 if (is_not_entrant()) tty->print("not_entrant ");
2881 if (is_zombie()) tty->print("zombie ");
2882 if (is_unloaded()) tty->print("unloaded ");
2883 if (on_scavenge_root_list()) tty->print("scavenge_root ");
2884 tty->print_cr("}:");
2885 }
2886 if (size () > 0) tty->print_cr(" total in heap [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
2887 (address)this,
2888 (address)this + size(),
2889 size());
2890 if (relocation_size () > 0) tty->print_cr(" relocation [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
2891 relocation_begin(),
2892 relocation_end(),
2893 relocation_size());
2894 if (consts_size () > 0) tty->print_cr(" constants [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
2895 consts_begin(),
2896 consts_end(),
|
2306
2307 class DetectScavengeRoot: public OopClosure {
2308 bool _detected_scavenge_root;
2309 public:
2310 DetectScavengeRoot() : _detected_scavenge_root(false)
2311 { NOT_PRODUCT(_print_nm = NULL); }
2312 bool detected_scavenge_root() { return _detected_scavenge_root; }
2313 virtual void do_oop(oop* p) {
2314 if ((*p) != NULL && (*p)->is_scavengable()) {
2315 NOT_PRODUCT(maybe_print(p));
2316 _detected_scavenge_root = true;
2317 }
2318 }
2319 virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
2320
2321 #ifndef PRODUCT
2322 nmethod* _print_nm;
2323 void maybe_print(oop* p) {
2324 if (_print_nm == NULL) return;
2325 if (!_detected_scavenge_root) _print_nm->print_on(tty, "new scavenge root");
2326 tty->print_cr("" PTR_FORMAT "[offset=%d] detected scavengable oop " PTR_FORMAT " (found at " PTR_FORMAT ")",
2327 _print_nm, (int)((intptr_t)p - (intptr_t)_print_nm),
2328 (void *)(*p), (intptr_t)p);
2329 (*p)->print();
2330 }
2331 #endif //PRODUCT
2332 };
2333
2334 bool nmethod::detect_scavenge_root_oops() {
2335 DetectScavengeRoot detect_scavenge_root;
2336 NOT_PRODUCT(if (TraceScavenge) detect_scavenge_root._print_nm = this);
2337 oops_do(&detect_scavenge_root);
2338 return detect_scavenge_root.detected_scavenge_root();
2339 }
2340
2341 // Method that knows how to preserve outgoing arguments at call. This method must be
2342 // called with a frame corresponding to a Java invoke
2343 void nmethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) {
2344 #ifndef SHARK
2345 if (!method()->is_native()) {
2346 SimpleScopeDesc ssd(this, fr.pc());
2687 return false;
2688 return pd->is_method_handle_invoke();
2689 }
2690
2691
2692 // -----------------------------------------------------------------------------
2693 // Verification
2694
2695 class VerifyOopsClosure: public OopClosure {
2696 nmethod* _nm;
2697 bool _ok;
2698 public:
2699 VerifyOopsClosure(nmethod* nm) : _nm(nm), _ok(true) { }
2700 bool ok() { return _ok; }
2701 virtual void do_oop(oop* p) {
2702 if ((*p) == NULL || (*p)->is_oop()) return;
2703 if (_ok) {
2704 _nm->print_nmethod(true);
2705 _ok = false;
2706 }
2707 tty->print_cr("*** non-oop " PTR_FORMAT " found at " PTR_FORMAT " (offset %d)",
2708 (void *)(*p), (intptr_t)p, (int)((intptr_t)p - (intptr_t)_nm));
2709 }
2710 virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
2711 };
2712
2713 void nmethod::verify() {
2714
2715 // Hmm. OSR methods can be deopted but not marked as zombie or not_entrant
2716 // seems odd.
2717
2718 if (is_zombie() || is_not_entrant() || is_unloaded())
2719 return;
2720
2721 // Make sure all the entry points are correctly aligned for patching.
2722 NativeJump::check_verified_entry_alignment(entry_point(), verified_entry_point());
2723
2724 // assert(method()->is_oop(), "must be valid");
2725
2726 ResourceMark rm;
2727
2811 }
2812 }
2813
2814
2815 // -----------------------------------------------------------------------------
2816 // Non-product code
2817 #ifndef PRODUCT
2818
2819 class DebugScavengeRoot: public OopClosure {
2820 nmethod* _nm;
2821 bool _ok;
2822 public:
2823 DebugScavengeRoot(nmethod* nm) : _nm(nm), _ok(true) { }
2824 bool ok() { return _ok; }
2825 virtual void do_oop(oop* p) {
2826 if ((*p) == NULL || !(*p)->is_scavengable()) return;
2827 if (_ok) {
2828 _nm->print_nmethod(true);
2829 _ok = false;
2830 }
2831 tty->print_cr("*** scavengable oop " PTR_FORMAT " found at " PTR_FORMAT " (offset %d)",
2832 (void *)(*p), (intptr_t)p, (int)((intptr_t)p - (intptr_t)_nm));
2833 (*p)->print();
2834 }
2835 virtual void do_oop(narrowOop* p) { ShouldNotReachHere(); }
2836 };
2837
2838 void nmethod::verify_scavenge_root_oops() {
2839 if (UseG1GC) {
2840 return;
2841 }
2842
2843 if (!on_scavenge_root_list()) {
2844 // Actually look inside, to verify the claim that it's clean.
2845 DebugScavengeRoot debug_scavenge_root(this);
2846 oops_do(&debug_scavenge_root);
2847 if (!debug_scavenge_root.ok())
2848 fatal("found an unadvertised bad scavengable oop in the code cache");
2849 }
2850 assert(scavenge_root_not_marked(), "");
2851 }
2856
2857 void nmethod::print() const {
2858 ResourceMark rm;
2859 ttyLocker ttyl; // keep the following output all in one block
2860
2861 tty->print("Compiled method ");
2862
2863 if (is_compiled_by_c1()) {
2864 tty->print("(c1) ");
2865 } else if (is_compiled_by_c2()) {
2866 tty->print("(c2) ");
2867 } else if (is_compiled_by_shark()) {
2868 tty->print("(shark) ");
2869 } else {
2870 tty->print("(nm) ");
2871 }
2872
2873 print_on(tty, NULL);
2874
2875 if (WizardMode) {
2876 tty->print("((nmethod*) " INTPTR_FORMAT ") ", this);
2877 tty->print(" for method " INTPTR_FORMAT , (address)method());
2878 tty->print(" { ");
2879 if (is_in_use()) tty->print("in_use ");
2880 if (is_not_entrant()) tty->print("not_entrant ");
2881 if (is_zombie()) tty->print("zombie ");
2882 if (is_unloaded()) tty->print("unloaded ");
2883 if (on_scavenge_root_list()) tty->print("scavenge_root ");
2884 tty->print_cr("}:");
2885 }
2886 if (size () > 0) tty->print_cr(" total in heap [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
2887 (address)this,
2888 (address)this + size(),
2889 size());
2890 if (relocation_size () > 0) tty->print_cr(" relocation [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
2891 relocation_begin(),
2892 relocation_end(),
2893 relocation_size());
2894 if (consts_size () > 0) tty->print_cr(" constants [" INTPTR_FORMAT "," INTPTR_FORMAT "] = %d",
2895 consts_begin(),
2896 consts_end(),
|