memTrackWorker.cpp revision 4058
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#include "precompiled.hpp"
#include "runtime/threadCritical.hpp"
#include "services/memTracker.hpp"
#include "services/memTrackWorker.hpp"
#include "utilities/decoder.hpp"
#include "utilities/vmError.hpp"
// create thread uses cgc thread type for now. We should revisit
// the option, or create new thread type.
set_name("MemTrackWorker", 0);
// initial generation circuit buffer
if (!has_error()) {
}
}
NOT_PRODUCT(_sync_point_count = 0;)
NOT_PRODUCT(_merge_count = 0;)
NOT_PRODUCT(_last_gen_in_use = 0;)
}
MemTrackWorker::~MemTrackWorker() {
delete rc;
}
}
}
assert(false, "use nothrow version");
return NULL;
}
}
void MemTrackWorker::start() {
os::start_thread(this);
}
/*
* Native memory tracking worker thread loop:
* 1. merge one generation of memory recorders to staging area
* 2. promote staging data to memory snapshot
*
* This thread can run through safepoint.
*/
void MemTrackWorker::run() {
this->initialize_thread_local_storage();
this->record_stack_base_and_size();
while (!MemTracker::shutdown_in_progress()) {
{
// take a recorder from earliest generation in buffer
}
"infinite loop after dequeue");
}
// merge the recorder into staging area
} else {
NOT_PRODUCT(_merge_count ++;)
}
} else {
// no more recorder to merge, promote staging area
// to snapshot
{
continue;
}
// done with this generation, increment _head pointer
}
// promote this generation data to snapshot
// failed to promote, means out of memory
}
} else {
// check if more data arrived
}
}
}
}
// transits to final shutdown
}
// at synchronization point, where 'safepoint visible' Java threads are blocked
// at a safepoint, and the rest of threads are blocked on ThreadCritical lock.
// The caller MemTracker::sync() already takes ThreadCritical before calling this
// method.
//
// Following tasks are performed:
// 1. add all recorders in pending queue to current generation
// 2. increase generation
"pending queue has infinite loop");
bool out_of_generation_buffer = false;
// check shutdown state inside ThreadCritical
if (MemTracker::shutdown_in_progress()) return;
// append the recorders to the end of the generation
} else {
}
}
}
"after add to current generation has infinite loop");
// we have collected all recorders for this generation. If there is data,
// we need to increment _tail to start a new generation.
}
if (out_of_generation_buffer) {
}
}
#ifndef PRODUCT
int count = 0;
count ++;
}
return count;
}
int MemTrackWorker::count_pending_recorders() const {
int count = 0;
}
}
return count;
}
#endif