2362N/A * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. 0N/A * Redistribution and use in source and binary forms, with or without 0N/A * modification, are permitted provided that the following conditions 0N/A * - Redistributions of source code must retain the above copyright 0N/A * notice, this list of conditions and the following disclaimer. 0N/A * - Redistributions in binary form must reproduce the above copyright 0N/A * notice, this list of conditions and the following disclaimer in the 0N/A * documentation and/or other materials provided with the distribution. 2362N/A * - Neither the name of Oracle nor the names of its 0N/A * contributors may be used to endorse or promote products derived 0N/A * from this software without specific prior written permission. 0N/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 0N/A * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 0N/A * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 0N/A * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 0N/A * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 0N/A * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 0N/A * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 0N/A * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 0N/A * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 0N/A * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 0N/A * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4378N/A * This source code is provided to illustrate the usage of a given feature 4378N/A * or technique and has been deliberately simplified. Additional steps 4378N/A * required for a production-quality application, such as security checks, 4378N/A * input validation and proper error handling, might not be present in 0N/A/* Thread Local Storage Table and method entry/exit handling. */ 0N/A * The tls table items have a key of it's serial number, but may be 0N/A * searched via a walk of the table looking for a jthread match. 0N/A * This isn't a performance 0N/A * issue because the table index should normally be stored in the 0N/A * Thread Local Storage for the thread. The table is only searched 0N/A * when the jthread is seen before the Thread Local Storage is set 0N/A * (e.g. before VM_INIT or the ThreadStart). 0N/A * The key is only used when we need to lookup a tls table entry by 0N/A * way of it's serial number, which should be unique per thread. 0N/A * Each active thread that we have seen should have a unique TlsIndex 0N/A * which is an index into this table. 0N/A * For cpu=times, each table entry will have a stack to hold the method 0N/A * that have been called, effectively keeping an active stack trace 0N/A * for the thread. As each method exits, the statistics for the trace 0N/A * associated with the current stack contents is updated. 0N/A * For cpu=samples, each thread is checked to see if it's runnable, 0N/A * and not suspended, and has a stack associated with it, and then 0N/A * that stack trace is updated with an additional 'hit'. 0N/A * This file also contains the dump logic for owned monitors, and for 0N/A * Initial number of stack elements to track per thread. This 0N/A * value should be set to a reasonable guess as to the number of 0N/A * methods deep a thread calls. This stack doubles in size for each 0N/A * reallocation and does not shrink. 0N/A/* Private internal functions. */ 0N/A /* Free up any allocated space in this TlsInfo structure */ 0N/A "thread=%p, monitor=0x%08x, " 0N/A "tracker_status=%d\n",
0N/A/* Find thread with certain object index */ 0N/A/* Get various lists on known threads */ 0N/A /* Local reference gets freed by caller */ 0N/A /* If we don't use the local reference, delete it now */ 0N/A /* If this method is on the stack, just return */ 0N/A /* It wasn't found, create a new stack */ 0N/A /* Create a new stack */ 0N/A /* The depth of frames we should keep track for reporting */ 0N/A /* Create a trace entry */ 0N/A /* Calculate time spent */ 0N/A /* A 0 trace at this time means the thread is in unknown territory. 0N/A * The trace serial number MUST be a valid serial number, so we use 0N/A * the system trace (empty) just so it has a valid trace. 0N/A/* External interfaces */ 0N/A/* Mark a new or existing entry as being an agent thread */ 0N/A "--------------------- TLS Table ------------------------\n");
0N/A "----------------------------------------------------------\n");
0N/A /* Sample thread stack for last time, do NOT free the entry yet. */ 0N/A/* Sample ALL threads and update the trace costs */ 0N/A /* Get buffers to hold thread list and serial number list */ 0N/A /* Get list of threads and serial numbers */ 0N/A /* Increment the cost on the traces for these threads */ 0N/A /* Loop over local refs and free them */ 0N/A /* Free up allocated space */ 0N/A/* For all TLS entries, update the last_trace on all threads */ 0N/A /* Get buffers to hold thread list and serial number list */ 0N/A /* Get list of threads, serial numbers, and info pointers */ 0N/A /* Get all stack trace index's for all these threadss */ 0N/A /* Loop over traces and update last_trace's */ 0N/A /* Free up all allocated space */