jvmtiCodeBlobEvents.cpp revision 1569
1553N/A * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A#
include "incls/_precompiled.incl" 0N/A// Support class to collect a list of the non-nmethod CodeBlobs in 0N/A// This class actually creates a list of JvmtiCodeBlobDesc - each JvmtiCodeBlobDesc 0N/A// describes a single CodeBlob in the CodeCache. Note that collection is 0N/A// done to a static list - this is because CodeCache::blobs_do is defined 0N/A// as void CodeCache::blobs_do(void f(CodeBlob* nm)) and hence requires 0N/A// a C or static method. 0N/A// CodeBlobCollector collector; 0N/A// JvmtiCodeBlobDesc* blob = collector.first(); 0N/A// while (blob != NULL) { 0N/A// blob = collector.next(); 0N/A // used during a collection 0N/A // collect list of code blobs in the cache 0N/A // iteration support - return first code blob 0N/A // iteration support - return next code blob 0N/A// used during collection 0N/A// called for each CodeBlob in the CodeCache 0N/A// This function filters out nmethods as it is only interested in 0N/A// other CodeBlobs. This function also filters out CodeBlobs that have 0N/A// a duplicate starting address as previous blobs. This is needed to 0N/A// handle the case where multiple stubs are generated into a single 0N/A // check if this starting address has been seen already - the 0N/A // assumption is that stubs are inserted into the list before the 0N/A // enclosing BufferBlobs. 0N/A // record the CodeBlob details as a JvmtiCodeBlobDesc 0N/A// collects a list of CodeBlobs in the CodeCache. 0N/A// The created list is growable array of JvmtiCodeBlobDesc - each one describes 0N/A// a CodeBlob. Note that the list is static - this is because CodeBlob::blobs_do 0N/A// requires a a C or static function so we can't use an instance function. This 0N/A// isn't a problem as the iteration is serial anyway as we need the CodeCache_lock 0N/A// to iterate over the code cache. 0N/A// Note that the CodeBlobs in the CodeCache will include BufferBlobs that may 0N/A// contain multiple stubs. As a profiler is interested in the stubs rather than 0N/A// the enclosing container we first iterate over the stub code descriptors so 0N/A// that the stubs go into the list first. do_blob will then filter out the 0N/A// enclosing blobs if the starting address of the enclosing blobs matches the 0N/A// starting address of first stub generated in the enclosing blob. 0N/A // create the global list 0N/A // iterate over the stub code descriptors and put them in the list first. 0N/A // next iterate over all the non-nmethod code blobs and add them to 0N/A // the list - as noted above this will filter out duplicates and 0N/A // make the global list the instance list so that it can be used 0N/A // for other iterations. 0N/A// Generate a DYNAMIC_CODE_GENERATED event for each non-nmethod code blob. 1553N/A // First collect all the code blobs. This has to be done in a 1553N/A // single pass over the code cache with CodeCache_lock held because 1553N/A // there isn't any safe way to iterate over regular CodeBlobs since 0N/A // they can be freed at any point. 0N/A // iterate over the collected list and post an event for each blob 0N/A// Generate a COMPILED_METHOD_LOAD event for each nnmethod 1553N/A // Walk the CodeCache notifying for live nmethods. The code cache 1553N/A // may be changing while this is happening which is ok since newly 1553N/A // created nmethod will notify normally and nmethods which are freed 1553N/A // Only notify for live nmethods 1569N/A // Lock the nmethod so it can't be freed 1553N/A // Don't hold the lock over the notify or jmethodID creation 0N/A// create a C-heap allocated address location map for an nmethod 0N/A // Generate line numbers using PcDesc and ScopeDesc info