jvmtiCodeBlobEvents.cpp revision 1472
/*
* 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 "incls/_precompiled.incl"
# include "incls/_jvmtiCodeBlobEvents.cpp.incl"
// Support class to collect a list of the non-nmethod CodeBlobs in
// the CodeCache.
//
// This class actually creates a list of JvmtiCodeBlobDesc - each JvmtiCodeBlobDesc
// describes a single CodeBlob in the CodeCache. Note that collection is
// done to a static list - this is because CodeCache::blobs_do is defined
// as void CodeCache::blobs_do(void f(CodeBlob* nm)) and hence requires
// a C or static method.
//
// Usage :-
//
// CodeBlobCollector collector;
//
// collector.collect();
// JvmtiCodeBlobDesc* blob = collector.first();
// while (blob != NULL) {
// :
// blob = collector.next();
// }
//
class CodeBlobCollector : StackObj {
private:
int _pos; // iterator position
// used during a collection
public:
_code_blobs = NULL;
_pos = -1;
}
~CodeBlobCollector() {
if (_code_blobs != NULL) {
for (int i=0; i<_code_blobs->length(); i++) {
}
delete _code_blobs;
}
}
// collect list of code blobs in the cache
void collect();
// iteration support - return first code blob
JvmtiCodeBlobDesc* first() {
if (_code_blobs->length() == 0) {
return NULL;
}
_pos = 0;
return _code_blobs->at(0);
}
// iteration support - return next code blob
JvmtiCodeBlobDesc* next() {
return NULL;
}
}
};
// used during collection
// called for each CodeBlob in the CodeCache
//
// This function filters out nmethods as it is only interested in
// other CodeBlobs. This function also filters out CodeBlobs that have
// a duplicate starting address as previous blobs. This is needed to
// handle the case where multiple stubs are generated into a single
// BufferBlob.
// ignore nmethods
if (cb->is_nmethod()) {
return;
}
// check if this starting address has been seen already - the
// assumption is that stubs are inserted into the list before the
// enclosing BufferBlobs.
for (int i=0; i<_global_code_blobs->length(); i++) {
return;
}
}
// we must name the CodeBlob - some CodeBlobs already have names :-
// - stubs used by compiled code to call a (static) C++ runtime routine
// - non-relocatable machine code such as the interpreter, stubroutines, etc.
// - various singleton blobs
//
// others are unnamed so we create a name :-
// - OSR adapter (interpreter frame that has been on-stack replaced)
// - I2C and C2I adapters
if (cb->is_runtime_stub()) {
}
if (cb->is_buffer_blob()) {
}
}
}
// record the CodeBlob details as a JvmtiCodeBlobDesc
cb->instructions_end());
}
// 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() {
// create the global list
// iterate over the stub code descriptors and put them in the list first.
int index = 0;
}
// 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.
// make the global list the instance list so that it can be used
// for other iterations.
}
// Generate a DYNAMIC_CODE_GENERATED event for each non-nmethod code blob.
// first collect all the code blobs
{
}
// iterate over the collected list and post an event for each blob
}
return JVMTI_ERROR_NONE;
}
// Support class to describe a nmethod in the CodeCache
class nmethodDesc: public CHeapObj {
private:
public:
}
};
// Support class to collect a list of the nmethod CodeBlobs in
// the CodeCache.
//
// Usage :-
//
// nmethodCollector collector;
//
// collector.collect();
// JvmtiCodeBlobDesc* blob = collector.first();
// while (blob != NULL) {
// :
// blob = collector.next();
// }
//
class nmethodCollector : StackObj {
private:
int _pos; // iteration support
// used during a collection
public:
nmethodCollector() {
_pos = -1;
}
~nmethodCollector() {
}
}
delete _nmethods;
}
}
// collect list of nmethods in the cache
void collect();
// iteration support - return first code blob
nmethodDesc* first() {
return NULL;
}
_pos = 0;
}
// iteration support - return next code blob
nmethodDesc* next() {
return NULL;
}
}
};
// used during collection
// called for each nmethod in the CodeCache
//
// This function simply adds a descriptor for each nmethod to the global list.
// ignore zombies
return;
}
// create the location map for the nmethod.
// record the nmethod details
nm->code_begin(),
map,
}
// collects a list of nmethod in the CodeCache.
//
// The created list is growable array of nmethodDesc - each one describes
// a nmethod and includs its JVMTI address location map.
void nmethodCollector::collect() {
// create the list
// any a descriptor for each nmethod to the list.
// make the list the instance list
}
// Generate a COMPILED_METHOD_LOAD event for each nnmethod
// first collect all nmethods
{
}
// iterate over the list and post an event for each nmethod
}
return JVMTI_ERROR_NONE;
}
// create a C-heap allocated address location map for an nmethod
{
jint map_length = 0;
// Generate line numbers using PcDesc and ScopeDesc info
int pcds_in_method;
if (bci != InvocationEntryBci) {
++map_length;
}
}
}
}