hotspot/src/share/vm/prims/jvmtiCodeBlobEvents.cpp
// collects a list of CodeBlobs in the CodeCache.
//
// The created list is growable array of JvmtiCodeBlobDesc - each one describes
// a CodeBlob. Note that the list is static - this is because CodeBlob::blobs_do
// requires a a C or static function so we can't use an instance function. This
// isn't a problem as the iteration is serial anyway as we need the CodeCache_lock
// to iterate over the code cache.
//
// Note that the CodeBlobs in the CodeCache will include BufferBlobs that may
// contain multiple stubs. As a profiler is interested in the stubs rather than
// the enclosing container we first iterate over the stub code descriptors so
// that the stubs go into the list first. do_blob will then filter out the
// enclosing blobs if the starting address of the enclosing blobs matches the
// starting address of first stub generated in the enclosing blob.
void CodeBlobCollector::collect() {
{- -------------------------------------------
(1) (assert)
---------------------------------------- -}
assert_locked_or_safepoint(CodeCache_lock);
assert(_global_code_blobs == NULL, "checking");
{- -------------------------------------------
(1) 収集した情報を入れておくための GrowableArray を生成する.
(情報は JvmtiCodeBlobDesc オブジェクトという形で蓄えていく)
(なお, 生成した配列は CodeCache::blobs_do からでも見えるように static なフィールド(_global_code_blobs)に bind している)
---------------------------------------- -}
// create the global list
_global_code_blobs = new (ResourceObj::C_HEAP) GrowableArray<JvmtiCodeBlobDesc*>(50,true);
{- -------------------------------------------
(1) まずは全ての StubCodeDesc に対して iterate し, 情報を溜めていく.
---------------------------------------- -}
// iterate over the stub code descriptors and put them in the list first.
int index = 0;
StubCodeDesc* desc;
while ((desc = StubCodeDesc::desc_for_index(++index)) != NULL) {
_global_code_blobs->append(new JvmtiCodeBlobDesc(desc->name(), desc->begin(), desc->end()));
}
{- -------------------------------------------
(1) 次に, CodeCache 内の全 CodeBlob に対して CodeBlobCollector::do_blob で iterate し, 情報を蓄えていく.
---------------------------------------- -}
// next iterate over all the non-nmethod code blobs and add them to
// the list - as noted above this will filter out duplicates and
// enclosing blobs.
CodeCache::blobs_do(do_blob);
{- -------------------------------------------
(1) 最後に, 収集結果を _code_blobs に移し, static フィールドである _global_code_blobs は NULL に戻す.
---------------------------------------- -}
// make the global list the instance list so that it can be used
// for other iterations.
_code_blobs = _global_code_blobs;
_global_code_blobs = NULL;
}
This document is available under the GNU GENERAL PUBLIC LICENSE Version 2.