hotspot/src/share/vm/services/memTracker.cpp
author zgu
Tue, 08 Jan 2013 14:04:25 -0500
changeset 15104 f5d78994619f
parent 14575 be194f2e2ba1
child 15452 3bfde2dea09d
permissions -rw-r--r--
8005048: NMT: #loaded classes needs to just show the # defined classes Summary: Count number of instance classes so that it matches class metadata size Reviewed-by: coleenp, acorn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     1
/*
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     2
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     4
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     8
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    13
 * accompanied this code).
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    14
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    18
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    21
 * questions.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    22
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    23
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    24
#include "precompiled.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    25
15104
f5d78994619f 8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents: 14575
diff changeset
    26
#include "oops/instanceKlass.hpp"
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    27
#include "runtime/atomic.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    28
#include "runtime/interfaceSupport.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    29
#include "runtime/mutexLocker.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    30
#include "runtime/safepoint.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    31
#include "runtime/threadCritical.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    32
#include "services/memPtr.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    33
#include "services/memReporter.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    34
#include "services/memTracker.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    35
#include "utilities/decoder.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    36
#include "utilities/globalDefinitions.hpp"
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    37
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    38
bool NMT_track_callsite = false;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    39
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    40
// walk all 'known' threads at NMT sync point, and collect their recorders
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    41
void SyncThreadRecorderClosure::do_thread(Thread* thread) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    42
  assert(SafepointSynchronize::is_at_safepoint(), "Safepoint required");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    43
  if (thread->is_Java_thread()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    44
    JavaThread* javaThread = (JavaThread*)thread;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    45
    MemRecorder* recorder = javaThread->get_recorder();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    46
    if (recorder != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    47
      MemTracker::enqueue_pending_recorder(recorder);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    48
      javaThread->set_recorder(NULL);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    49
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    50
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    51
  _thread_count ++;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    52
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    53
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    54
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    55
MemRecorder*                    MemTracker::_global_recorder = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    56
MemSnapshot*                    MemTracker::_snapshot = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    57
MemBaseline                     MemTracker::_baseline;
13301
f6dd749390dd 7181986: NMT ON: Assertion failure when running jdi ExpiredRequestDeletionTest
zgu
parents: 13195
diff changeset
    58
Mutex*                          MemTracker::_query_lock = NULL;
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    59
volatile MemRecorder*           MemTracker::_merge_pending_queue = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    60
volatile MemRecorder*           MemTracker::_pooled_recorders = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    61
MemTrackWorker*                 MemTracker::_worker_thread = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    62
int                             MemTracker::_sync_point_skip_count = 0;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    63
MemTracker::NMTLevel            MemTracker::_tracking_level = MemTracker::NMT_off;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    64
volatile MemTracker::NMTStates  MemTracker::_state = NMT_uninited;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    65
MemTracker::ShutdownReason      MemTracker::_reason = NMT_shutdown_none;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    66
int                             MemTracker::_thread_count = 255;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    67
volatile jint                   MemTracker::_pooled_recorder_count = 0;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    68
debug_only(intx                 MemTracker::_main_thread_tid = 0;)
13478
85fe611440e5 7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents: 13304
diff changeset
    69
NOT_PRODUCT(volatile jint       MemTracker::_pending_recorder_count = 0;)
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    70
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    71
void MemTracker::init_tracking_options(const char* option_line) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    72
  _tracking_level = NMT_off;
14575
be194f2e2ba1 8003689: MemTracker::init_tracking_options() reads outside array if commandline argument is empty
zgu
parents: 14120
diff changeset
    73
  if (strcmp(option_line, "=summary") == 0) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    74
    _tracking_level = NMT_summary;
14575
be194f2e2ba1 8003689: MemTracker::init_tracking_options() reads outside array if commandline argument is empty
zgu
parents: 14120
diff changeset
    75
  } else if (strcmp(option_line, "=detail") == 0) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    76
    _tracking_level = NMT_detail;
14575
be194f2e2ba1 8003689: MemTracker::init_tracking_options() reads outside array if commandline argument is empty
zgu
parents: 14120
diff changeset
    77
  } else if (strcmp(option_line, "=off") != 0) {
be194f2e2ba1 8003689: MemTracker::init_tracking_options() reads outside array if commandline argument is empty
zgu
parents: 14120
diff changeset
    78
    vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    79
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    80
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    81
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    82
// first phase of bootstrapping, when VM is still in single-threaded mode.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    83
void MemTracker::bootstrap_single_thread() {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    84
  if (_tracking_level > NMT_off) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    85
    assert(_state == NMT_uninited, "wrong state");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    86
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    87
    // NMT is not supported with UseMallocOnly is on. NMT can NOT
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    88
    // handle the amount of malloc data without significantly impacting
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    89
    // runtime performance when this flag is on.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    90
    if (UseMallocOnly) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    91
      shutdown(NMT_use_malloc_only);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    92
      return;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    93
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
    94
13301
f6dd749390dd 7181986: NMT ON: Assertion failure when running jdi ExpiredRequestDeletionTest
zgu
parents: 13195
diff changeset
    95
    _query_lock = new (std::nothrow) Mutex(Monitor::max_nonleaf, "NMT_queryLock");
f6dd749390dd 7181986: NMT ON: Assertion failure when running jdi ExpiredRequestDeletionTest
zgu
parents: 13195
diff changeset
    96
    if (_query_lock == NULL) {
f6dd749390dd 7181986: NMT ON: Assertion failure when running jdi ExpiredRequestDeletionTest
zgu
parents: 13195
diff changeset
    97
      shutdown(NMT_out_of_memory);
f6dd749390dd 7181986: NMT ON: Assertion failure when running jdi ExpiredRequestDeletionTest
zgu
parents: 13195
diff changeset
    98
      return;
f6dd749390dd 7181986: NMT ON: Assertion failure when running jdi ExpiredRequestDeletionTest
zgu
parents: 13195
diff changeset
    99
    }
f6dd749390dd 7181986: NMT ON: Assertion failure when running jdi ExpiredRequestDeletionTest
zgu
parents: 13195
diff changeset
   100
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   101
    debug_only(_main_thread_tid = os::current_thread_id();)
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   102
    _state = NMT_bootstrapping_single_thread;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   103
    NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack());
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   104
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   105
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   106
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   107
// second phase of bootstrapping, when VM is about to or already entered multi-theaded mode.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   108
void MemTracker::bootstrap_multi_thread() {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   109
  if (_tracking_level > NMT_off && _state == NMT_bootstrapping_single_thread) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   110
  // create nmt lock for multi-thread execution
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   111
    assert(_main_thread_tid == os::current_thread_id(), "wrong thread");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   112
    _state = NMT_bootstrapping_multi_thread;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   113
    NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack());
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   114
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   115
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   116
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   117
// fully start nmt
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   118
void MemTracker::start() {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   119
  // Native memory tracking is off from command line option
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   120
  if (_tracking_level == NMT_off || shutdown_in_progress()) return;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   121
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   122
  assert(_main_thread_tid == os::current_thread_id(), "wrong thread");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   123
  assert(_state == NMT_bootstrapping_multi_thread, "wrong state");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   124
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   125
  _snapshot = new (std::nothrow)MemSnapshot();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   126
  if (_snapshot != NULL && !_snapshot->out_of_memory()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   127
    if (start_worker()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   128
      _state = NMT_started;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   129
      NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack());
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   130
      return;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   131
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   132
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   133
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   134
  // fail to start native memory tracking, shut it down
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   135
  shutdown(NMT_initialization);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   136
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   137
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   138
/**
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   139
 * Shutting down native memory tracking.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   140
 * We can not shutdown native memory tracking immediately, so we just
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   141
 * setup shutdown pending flag, every native memory tracking component
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   142
 * should orderly shut itself down.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   143
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   144
 * The shutdown sequences:
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   145
 *  1. MemTracker::shutdown() sets MemTracker to shutdown pending state
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   146
 *  2. Worker thread calls MemTracker::final_shutdown(), which transites
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   147
 *     MemTracker to final shutdown state.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   148
 *  3. At sync point, MemTracker does final cleanup, before sets memory
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   149
 *     tracking level to off to complete shutdown.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   150
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   151
void MemTracker::shutdown(ShutdownReason reason) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   152
  if (_tracking_level == NMT_off) return;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   153
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   154
  if (_state <= NMT_bootstrapping_single_thread) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   155
    // we still in single thread mode, there is not contention
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   156
    _state = NMT_shutdown_pending;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   157
    _reason = reason;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   158
  } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   159
    // we want to know who initialized shutdown
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   160
    if ((jint)NMT_started == Atomic::cmpxchg((jint)NMT_shutdown_pending,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   161
                                       (jint*)&_state, (jint)NMT_started)) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   162
        _reason = reason;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   163
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   164
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   165
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   166
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   167
// final phase of shutdown
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   168
void MemTracker::final_shutdown() {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   169
  // delete all pending recorders and pooled recorders
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   170
  delete_all_pending_recorders();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   171
  delete_all_pooled_recorders();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   172
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   173
  {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   174
    // shared baseline and snapshot are the only objects needed to
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   175
    // create query results
13301
f6dd749390dd 7181986: NMT ON: Assertion failure when running jdi ExpiredRequestDeletionTest
zgu
parents: 13195
diff changeset
   176
    MutexLockerEx locker(_query_lock, true);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   177
    // cleanup baseline data and snapshot
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   178
    _baseline.clear();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   179
    delete _snapshot;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   180
    _snapshot = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   181
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   182
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   183
  // shutdown shared decoder instance, since it is only
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   184
  // used by native memory tracking so far.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   185
  Decoder::shutdown();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   186
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   187
  MemTrackWorker* worker = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   188
  {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   189
    ThreadCritical tc;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   190
    // can not delete worker inside the thread critical
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   191
    if (_worker_thread != NULL && Thread::current() == _worker_thread) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   192
      worker = _worker_thread;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   193
      _worker_thread = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   194
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   195
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   196
  if (worker != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   197
    delete worker;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   198
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   199
  _state = NMT_final_shutdown;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   200
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   201
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   202
// delete all pooled recorders
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   203
void MemTracker::delete_all_pooled_recorders() {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   204
  // free all pooled recorders
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   205
  volatile MemRecorder* cur_head = _pooled_recorders;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   206
  if (cur_head != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   207
    MemRecorder* null_ptr = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   208
    while (cur_head != NULL && (void*)cur_head != Atomic::cmpxchg_ptr((void*)null_ptr,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   209
      (void*)&_pooled_recorders, (void*)cur_head)) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   210
      cur_head = _pooled_recorders;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   211
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   212
    if (cur_head != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   213
      delete cur_head;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   214
      _pooled_recorder_count = 0;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   215
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   216
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   217
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   218
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   219
// delete all recorders in pending queue
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   220
void MemTracker::delete_all_pending_recorders() {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   221
  // free all pending recorders
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   222
  MemRecorder* pending_head = get_pending_recorders();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   223
  if (pending_head != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   224
    delete pending_head;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   225
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   226
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   227
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   228
/*
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   229
 * retrieve per-thread recorder of specified thread.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   230
 * if thread == NULL, it means global recorder
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   231
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   232
MemRecorder* MemTracker::get_thread_recorder(JavaThread* thread) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   233
  if (shutdown_in_progress()) return NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   234
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   235
  MemRecorder* rc;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   236
  if (thread == NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   237
    rc = _global_recorder;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   238
  } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   239
    rc = thread->get_recorder();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   240
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   241
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   242
  if (rc != NULL && rc->is_full()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   243
    enqueue_pending_recorder(rc);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   244
    rc = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   245
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   246
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   247
  if (rc == NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   248
    rc = get_new_or_pooled_instance();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   249
    if (thread == NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   250
      _global_recorder = rc;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   251
    } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   252
      thread->set_recorder(rc);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   253
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   254
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   255
  return rc;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   256
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   257
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   258
/*
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   259
 * get a per-thread recorder from pool, or create a new one if
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   260
 * there is not one available.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   261
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   262
MemRecorder* MemTracker::get_new_or_pooled_instance() {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   263
   MemRecorder* cur_head = const_cast<MemRecorder*> (_pooled_recorders);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   264
   if (cur_head == NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   265
     MemRecorder* rec = new (std::nothrow)MemRecorder();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   266
     if (rec == NULL || rec->out_of_memory()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   267
       shutdown(NMT_out_of_memory);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   268
       if (rec != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   269
         delete rec;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   270
         rec = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   271
       }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   272
     }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   273
     return rec;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   274
   } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   275
     MemRecorder* next_head = cur_head->next();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   276
     if ((void*)cur_head != Atomic::cmpxchg_ptr((void*)next_head, (void*)&_pooled_recorders,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   277
       (void*)cur_head)) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   278
       return get_new_or_pooled_instance();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   279
     }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   280
     cur_head->set_next(NULL);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   281
     Atomic::dec(&_pooled_recorder_count);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   282
     debug_only(cur_head->set_generation();)
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   283
     return cur_head;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   284
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   285
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   286
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   287
/*
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   288
 * retrieve all recorders in pending queue, and empty the queue
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   289
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   290
MemRecorder* MemTracker::get_pending_recorders() {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   291
  MemRecorder* cur_head = const_cast<MemRecorder*>(_merge_pending_queue);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   292
  MemRecorder* null_ptr = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   293
  while ((void*)cur_head != Atomic::cmpxchg_ptr((void*)null_ptr, (void*)&_merge_pending_queue,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   294
    (void*)cur_head)) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   295
    cur_head = const_cast<MemRecorder*>(_merge_pending_queue);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   296
  }
13478
85fe611440e5 7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents: 13304
diff changeset
   297
  NOT_PRODUCT(Atomic::store(0, &_pending_recorder_count));
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   298
  return cur_head;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   299
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   300
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   301
/*
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   302
 * release a recorder to recorder pool.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   303
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   304
void MemTracker::release_thread_recorder(MemRecorder* rec) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   305
  assert(rec != NULL, "null recorder");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   306
  // we don't want to pool too many recorders
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   307
  rec->set_next(NULL);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   308
  if (shutdown_in_progress() || _pooled_recorder_count > _thread_count * 2) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   309
    delete rec;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   310
    return;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   311
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   312
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   313
  rec->clear();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   314
  MemRecorder* cur_head = const_cast<MemRecorder*>(_pooled_recorders);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   315
  rec->set_next(cur_head);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   316
  while ((void*)cur_head != Atomic::cmpxchg_ptr((void*)rec, (void*)&_pooled_recorders,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   317
    (void*)cur_head)) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   318
    cur_head = const_cast<MemRecorder*>(_pooled_recorders);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   319
    rec->set_next(cur_head);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   320
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   321
  Atomic::inc(&_pooled_recorder_count);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   322
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   323
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   324
/*
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   325
 * This is the most important method in whole nmt implementation.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   326
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   327
 * Create a memory record.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   328
 * 1. When nmt is in single-threaded bootstrapping mode, no lock is needed as VM
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   329
 *    still in single thread mode.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   330
 * 2. For all threads other than JavaThread, ThreadCritical is needed
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   331
 *    to write to recorders to global recorder.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   332
 * 3. For JavaThreads that are not longer visible by safepoint, also
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   333
 *    need to take ThreadCritical and records are written to global
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   334
 *    recorders, since these threads are NOT walked by Threads.do_thread().
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   335
 * 4. JavaThreads that are running in native state, have to transition
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   336
 *    to VM state before writing to per-thread recorders.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   337
 * 5. JavaThreads that are running in VM state do not need any lock and
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   338
 *    records are written to per-thread recorders.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   339
 * 6. For a thread has yet to attach VM 'Thread', they need to take
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   340
 *    ThreadCritical to write to global recorder.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   341
 *
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   342
 *    Important note:
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   343
 *    NO LOCK should be taken inside ThreadCritical lock !!!
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   344
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   345
void MemTracker::create_memory_record(address addr, MEMFLAGS flags,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   346
    size_t size, address pc, Thread* thread) {
13859
7fe4578493fc 7190089: NMT ON: NMT failed assertion on thread's stack base address
zgu
parents: 13478
diff changeset
   347
  assert(addr != NULL, "Sanity check");
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   348
  if (!shutdown_in_progress()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   349
    // single thread, we just write records direct to global recorder,'
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   350
    // with any lock
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   351
    if (_state == NMT_bootstrapping_single_thread) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   352
      assert(_main_thread_tid == os::current_thread_id(), "wrong thread");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   353
      thread = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   354
    } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   355
      if (thread == NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   356
          // don't use Thread::current(), since it is possible that
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   357
          // the calling thread has yet to attach to VM 'Thread',
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   358
          // which will result assertion failure
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   359
          thread = ThreadLocalStorage::thread();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   360
      }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   361
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   362
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   363
    if (thread != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   364
      if (thread->is_Java_thread() && ((JavaThread*)thread)->is_safepoint_visible()) {
14120
7d298141c258 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 13872
diff changeset
   365
        JavaThread*      java_thread = (JavaThread*)thread;
13300
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   366
        JavaThreadState  state = java_thread->thread_state();
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   367
        if (SafepointSynchronize::safepoint_safe(java_thread, state)) {
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   368
          // JavaThreads that are safepoint safe, can run through safepoint,
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   369
          // so ThreadCritical is needed to ensure no threads at safepoint create
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   370
          // new records while the records are being gathered and the sequence number is changing
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   371
          ThreadCritical tc;
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   372
          create_record_in_recorder(addr, flags, size, pc, java_thread);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   373
        } else {
13300
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   374
          create_record_in_recorder(addr, flags, size, pc, java_thread);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   375
        }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   376
      } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   377
        // other threads, such as worker and watcher threads, etc. need to
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   378
        // take ThreadCritical to write to global recorder
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   379
        ThreadCritical tc;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   380
        create_record_in_recorder(addr, flags, size, pc, NULL);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   381
      }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   382
    } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   383
      if (_state == NMT_bootstrapping_single_thread) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   384
        // single thread, no lock needed
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   385
        create_record_in_recorder(addr, flags, size, pc, NULL);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   386
      } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   387
        // for thread has yet to attach VM 'Thread', we can not use VM mutex.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   388
        // use native thread critical instead
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   389
        ThreadCritical tc;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   390
        create_record_in_recorder(addr, flags, size, pc, NULL);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   391
      }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   392
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   393
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   394
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   395
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   396
// write a record to proper recorder. No lock can be taken from this method
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   397
// down.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   398
void MemTracker::create_record_in_recorder(address addr, MEMFLAGS flags,
13300
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   399
    size_t size, address pc, JavaThread* thread) {
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   400
13300
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   401
    MemRecorder* rc = get_thread_recorder(thread);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   402
    if (rc != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   403
      rc->record(addr, flags, size, pc);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   404
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   405
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   406
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   407
/**
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   408
 * enqueue a recorder to pending queue
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   409
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   410
void MemTracker::enqueue_pending_recorder(MemRecorder* rec) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   411
  assert(rec != NULL, "null recorder");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   412
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   413
  // we are shutting down, so just delete it
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   414
  if (shutdown_in_progress()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   415
    rec->set_next(NULL);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   416
    delete rec;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   417
    return;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   418
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   419
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   420
  MemRecorder* cur_head = const_cast<MemRecorder*>(_merge_pending_queue);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   421
  rec->set_next(cur_head);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   422
  while ((void*)cur_head != Atomic::cmpxchg_ptr((void*)rec, (void*)&_merge_pending_queue,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   423
    (void*)cur_head)) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   424
    cur_head = const_cast<MemRecorder*>(_merge_pending_queue);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   425
    rec->set_next(cur_head);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   426
  }
13478
85fe611440e5 7191124: Optimized build is broken due to inconsistent use of DEBUG_ONLY and NOT_PRODUCT macros in NMT
zgu
parents: 13304
diff changeset
   427
  NOT_PRODUCT(Atomic::inc(&_pending_recorder_count);)
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   428
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   429
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   430
/*
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   431
 * The method is called at global safepoint
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   432
 * during it synchronization process.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   433
 *   1. enqueue all JavaThreads' per-thread recorders
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   434
 *   2. enqueue global recorder
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   435
 *   3. retrieve all pending recorders
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   436
 *   4. reset global sequence number generator
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   437
 *   5. call worker's sync
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   438
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   439
#define MAX_SAFEPOINTS_TO_SKIP     128
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   440
#define SAFE_SEQUENCE_THRESHOLD    30
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   441
#define HIGH_GENERATION_THRESHOLD  60
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   442
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   443
void MemTracker::sync() {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   444
  assert(_tracking_level > NMT_off, "NMT is not enabled");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   445
  assert(SafepointSynchronize::is_at_safepoint(), "Safepoint required");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   446
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   447
  // Some GC tests hit large number of safepoints in short period of time
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   448
  // without meaningful activities. We should prevent going to
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   449
  // sync point in these cases, which can potentially exhaust generation buffer.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   450
  // Here is the factots to determine if we should go into sync point:
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   451
  // 1. not to overflow sequence number
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   452
  // 2. if we are in danger to overflow generation buffer
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   453
  // 3. how many safepoints we already skipped sync point
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   454
  if (_state == NMT_started) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   455
    // worker thread is not ready, no one can manage generation
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   456
    // buffer, so skip this safepoint
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   457
    if (_worker_thread == NULL) return;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   458
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   459
    if (_sync_point_skip_count < MAX_SAFEPOINTS_TO_SKIP) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   460
      int per_seq_in_use = SequenceGenerator::peek() * 100 / max_jint;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   461
      int per_gen_in_use = _worker_thread->generations_in_use() * 100 / MAX_GENERATIONS;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   462
      if (per_seq_in_use < SAFE_SEQUENCE_THRESHOLD && per_gen_in_use >= HIGH_GENERATION_THRESHOLD) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   463
        _sync_point_skip_count ++;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   464
        return;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   465
      }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   466
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   467
    _sync_point_skip_count = 0;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   468
    {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   469
      // This method is running at safepoint, with ThreadCritical lock,
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   470
      // it should guarantee that NMT is fully sync-ed.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   471
      ThreadCritical tc;
13300
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   472
14120
7d298141c258 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 13872
diff changeset
   473
      SequenceGenerator::reset();
7d298141c258 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 13872
diff changeset
   474
13300
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   475
      // walk all JavaThreads to collect recorders
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   476
      SyncThreadRecorderClosure stc;
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   477
      Threads::threads_do(&stc);
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   478
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   479
      _thread_count = stc.get_thread_count();
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   480
      MemRecorder* pending_recorders = get_pending_recorders();
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   481
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   482
      if (_global_recorder != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   483
        _global_recorder->set_next(pending_recorders);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   484
        pending_recorders = _global_recorder;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   485
        _global_recorder = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   486
      }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   487
      // check _worker_thread with lock to avoid racing condition
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   488
      if (_worker_thread != NULL) {
15104
f5d78994619f 8005048: NMT: #loaded classes needs to just show the # defined classes
zgu
parents: 14575
diff changeset
   489
        _worker_thread->at_sync_point(pending_recorders, InstanceKlass::number_of_instance_classes());
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   490
      }
14120
7d298141c258 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 13872
diff changeset
   491
7d298141c258 7199092: NMT: NMT needs to deal overlapped virtual memory ranges
zgu
parents: 13872
diff changeset
   492
      assert(SequenceGenerator::peek() == 1, "Should not have memory activities during sync-point");
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   493
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   494
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   495
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   496
  // now, it is the time to shut whole things off
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   497
  if (_state == NMT_final_shutdown) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   498
    // walk all JavaThreads to delete all recorders
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   499
    SyncThreadRecorderClosure stc;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   500
    Threads::threads_do(&stc);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   501
    // delete global recorder
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   502
    {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   503
      ThreadCritical tc;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   504
      if (_global_recorder != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   505
        delete _global_recorder;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   506
        _global_recorder = NULL;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   507
      }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   508
    }
13300
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   509
    MemRecorder* pending_recorders = get_pending_recorders();
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   510
    if (pending_recorders != NULL) {
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   511
      delete pending_recorders;
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   512
    }
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   513
    // try at a later sync point to ensure MemRecorder instance drops to zero to
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   514
    // completely shutdown NMT
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   515
    if (MemRecorder::_instance_count == 0) {
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   516
      _state = NMT_shutdown;
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   517
      _tracking_level = NMT_off;
38485c548c9f 7182543: NMT ON: Aggregate a few NMT related bugs
zgu
parents: 13195
diff changeset
   518
    }
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   519
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   520
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   521
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   522
/*
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   523
 * Start worker thread.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   524
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   525
bool MemTracker::start_worker() {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   526
  assert(_worker_thread == NULL, "Just Check");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   527
  _worker_thread = new (std::nothrow) MemTrackWorker();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   528
  if (_worker_thread == NULL || _worker_thread->has_error()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   529
    shutdown(NMT_initialization);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   530
    return false;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   531
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   532
  _worker_thread->start();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   533
  return true;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   534
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   535
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   536
/*
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   537
 * We need to collect a JavaThread's per-thread recorder
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   538
 * before it exits.
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   539
 */
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   540
void MemTracker::thread_exiting(JavaThread* thread) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   541
  if (is_on()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   542
    MemRecorder* rec = thread->get_recorder();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   543
    if (rec != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   544
      enqueue_pending_recorder(rec);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   545
      thread->set_recorder(NULL);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   546
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   547
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   548
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   549
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   550
// baseline current memory snapshot
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   551
bool MemTracker::baseline() {
13301
f6dd749390dd 7181986: NMT ON: Assertion failure when running jdi ExpiredRequestDeletionTest
zgu
parents: 13195
diff changeset
   552
  MutexLockerEx lock(_query_lock, true);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   553
  MemSnapshot* snapshot = get_snapshot();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   554
  if (snapshot != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   555
    return _baseline.baseline(*snapshot, false);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   556
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   557
  return false;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   558
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   559
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   560
// print memory usage from current snapshot
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   561
bool MemTracker::print_memory_usage(BaselineOutputer& out, size_t unit, bool summary_only) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   562
  MemBaseline  baseline;
13301
f6dd749390dd 7181986: NMT ON: Assertion failure when running jdi ExpiredRequestDeletionTest
zgu
parents: 13195
diff changeset
   563
  MutexLockerEx lock(_query_lock, true);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   564
  MemSnapshot* snapshot = get_snapshot();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   565
  if (snapshot != NULL && baseline.baseline(*snapshot, summary_only)) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   566
    BaselineReporter reporter(out, unit);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   567
    reporter.report_baseline(baseline, summary_only);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   568
    return true;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   569
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   570
  return false;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   571
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   572
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   573
// compare memory usage between current snapshot and baseline
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   574
bool MemTracker::compare_memory_usage(BaselineOutputer& out, size_t unit, bool summary_only) {
13301
f6dd749390dd 7181986: NMT ON: Assertion failure when running jdi ExpiredRequestDeletionTest
zgu
parents: 13195
diff changeset
   575
  MutexLockerEx lock(_query_lock, true);
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   576
  if (_baseline.baselined()) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   577
    MemBaseline baseline;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   578
    MemSnapshot* snapshot = get_snapshot();
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   579
    if (snapshot != NULL && baseline.baseline(*snapshot, summary_only)) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   580
      BaselineReporter reporter(out, unit);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   581
      reporter.diff_baselines(baseline, _baseline, summary_only);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   582
      return true;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   583
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   584
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   585
  return false;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   586
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   587
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   588
#ifndef PRODUCT
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   589
void MemTracker::walk_stack(int toSkip, char* buf, int len) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   590
  int cur_len = 0;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   591
  char tmp[1024];
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   592
  address pc;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   593
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   594
  while (cur_len < len) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   595
    pc = os::get_caller_pc(toSkip + 1);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   596
    if (pc != NULL && os::dll_address_to_function_name(pc, tmp, sizeof(tmp), NULL)) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   597
      jio_snprintf(&buf[cur_len], (len - cur_len), "%s\n", tmp);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   598
      cur_len = (int)strlen(buf);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   599
    } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   600
      buf[cur_len] = '\0';
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   601
      break;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   602
    }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   603
    toSkip ++;
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   604
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   605
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   606
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   607
void MemTracker::print_tracker_stats(outputStream* st) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   608
  st->print_cr("\nMemory Tracker Stats:");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   609
  st->print_cr("\tMax sequence number = %d", SequenceGenerator::max_seq_num());
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   610
  st->print_cr("\tthead count = %d", _thread_count);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   611
  st->print_cr("\tArena instance = %d", Arena::_instance_count);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   612
  st->print_cr("\tpooled recorder count = %d", _pooled_recorder_count);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   613
  st->print_cr("\tqueued recorder count = %d", _pending_recorder_count);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   614
  st->print_cr("\tmemory recorder instance count = %d", MemRecorder::_instance_count);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   615
  if (_worker_thread != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   616
    st->print_cr("\tWorker thread:");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   617
    st->print_cr("\t\tSync point count = %d", _worker_thread->_sync_point_count);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   618
    st->print_cr("\t\tpending recorder count = %d", _worker_thread->count_pending_recorders());
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   619
    st->print_cr("\t\tmerge count = %d", _worker_thread->_merge_count);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   620
  } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   621
    st->print_cr("\tWorker thread is not started");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   622
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   623
  st->print_cr(" ");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   624
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   625
  if (_snapshot != NULL) {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   626
    _snapshot->print_snapshot_stats(st);
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   627
  } else {
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   628
    st->print_cr("No snapshot");
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   629
  }
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   630
}
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   631
#endif
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents:
diff changeset
   632