src/share/vm/services/memTracker.cpp

Print this page
rev 6314 : imported patch nmtfix


 768       }
 769     }
 770   }
 771 }
 772 
 773 void MemTracker::Tracker::discard() {
 774   if (MemTracker::is_on() && _seq != 0) {
 775     if (_need_thread_critical_lock) {
 776       ThreadCritical tc;
 777       MemTracker::dec_pending_op_count();
 778     }
 779     _seq = 0;
 780   }
 781 }
 782 
 783 
 784 void MemTracker::Tracker::record(address old_addr, address new_addr, size_t size,
 785   MEMFLAGS flags, address pc) {
 786   assert(old_addr != NULL && new_addr != NULL, "Sanity check");
 787   assert(_op == Realloc || _op == NoOp, "Wrong call");
 788   if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp) {
 789     assert(_seq > 0, "Need pre-reserve sequence number");
 790     if (_need_thread_critical_lock) {
 791       ThreadCritical tc;
 792       // free old address, use pre-reserved sequence number
 793       MemTracker::write_tracking_record(old_addr, MemPointerRecord::free_tag(),
 794         0, _seq, pc, _java_thread);
 795       MemTracker::write_tracking_record(new_addr, flags | MemPointerRecord::malloc_tag(),
 796         size, SequenceGenerator::next(), pc, _java_thread);
 797       // decrement MemTracker pending_op_count
 798       MemTracker::dec_pending_op_count();
 799     } else {
 800       // free old address, use pre-reserved sequence number
 801       MemTracker::write_tracking_record(old_addr, MemPointerRecord::free_tag(),
 802         0, _seq, pc, _java_thread);
 803       MemTracker::write_tracking_record(new_addr, flags | MemPointerRecord::malloc_tag(),
 804         size, SequenceGenerator::next(), pc, _java_thread);
 805     }
 806     _seq = 0;
 807   }
 808 }
 809 
 810 void MemTracker::Tracker::record(address addr, size_t size, MEMFLAGS flags, address pc) {
 811   // OOM already?
 812   if (addr == NULL) return;
 813 
 814   if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp) {
 815     bool pre_reserved_seq = (_seq != 0);
 816     address  pc = CALLER_CALLER_PC;
 817     MEMFLAGS orig_flags = flags;
 818 
 819     // or the tagging flags
 820     switch(_op) {
 821       case Malloc:
 822         flags |= MemPointerRecord::malloc_tag();
 823         break;
 824       case Free:
 825         flags = MemPointerRecord::free_tag();
 826         break;
 827       case Realloc:
 828         fatal("Use the other Tracker::record()");
 829         break;
 830       case Reserve:
 831       case ReserveAndCommit:
 832         flags |= MemPointerRecord::virtual_memory_reserve_tag();
 833         break;
 834       case Commit:




 768       }
 769     }
 770   }
 771 }
 772 
 773 void MemTracker::Tracker::discard() {
 774   if (MemTracker::is_on() && _seq != 0) {
 775     if (_need_thread_critical_lock) {
 776       ThreadCritical tc;
 777       MemTracker::dec_pending_op_count();
 778     }
 779     _seq = 0;
 780   }
 781 }
 782 
 783 
 784 void MemTracker::Tracker::record(address old_addr, address new_addr, size_t size,
 785   MEMFLAGS flags, address pc) {
 786   assert(old_addr != NULL && new_addr != NULL, "Sanity check");
 787   assert(_op == Realloc || _op == NoOp, "Wrong call");
 788   if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp && !MemTracker::shutdown_in_progress()) {
 789     assert(_seq > 0, "Need pre-reserve sequence number");
 790     if (_need_thread_critical_lock) {
 791       ThreadCritical tc;
 792       // free old address, use pre-reserved sequence number
 793       MemTracker::write_tracking_record(old_addr, MemPointerRecord::free_tag(),
 794         0, _seq, pc, _java_thread);
 795       MemTracker::write_tracking_record(new_addr, flags | MemPointerRecord::malloc_tag(),
 796         size, SequenceGenerator::next(), pc, _java_thread);
 797       // decrement MemTracker pending_op_count
 798       MemTracker::dec_pending_op_count();
 799     } else {
 800       // free old address, use pre-reserved sequence number
 801       MemTracker::write_tracking_record(old_addr, MemPointerRecord::free_tag(),
 802         0, _seq, pc, _java_thread);
 803       MemTracker::write_tracking_record(new_addr, flags | MemPointerRecord::malloc_tag(),
 804         size, SequenceGenerator::next(), pc, _java_thread);
 805     }
 806     _seq = 0;
 807   }
 808 }
 809 
 810 void MemTracker::Tracker::record(address addr, size_t size, MEMFLAGS flags, address pc) {
 811   // OOM already?
 812   if (addr == NULL) return;
 813 
 814   if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp && !MemTracker::shutdown_in_progress()) {
 815     bool pre_reserved_seq = (_seq != 0);
 816     address  pc = CALLER_CALLER_PC;
 817     MEMFLAGS orig_flags = flags;
 818 
 819     // or the tagging flags
 820     switch(_op) {
 821       case Malloc:
 822         flags |= MemPointerRecord::malloc_tag();
 823         break;
 824       case Free:
 825         flags = MemPointerRecord::free_tag();
 826         break;
 827       case Realloc:
 828         fatal("Use the other Tracker::record()");
 829         break;
 830       case Reserve:
 831       case ReserveAndCommit:
 832         flags |= MemPointerRecord::virtual_memory_reserve_tag();
 833         break;
 834       case Commit: