methodDataOop.cpp revision 726
1472N/A * Copyright 2000-2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1472N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A#
include "incls/_precompiled.incl" 0N/A// ================================================================== 0N/A// Overlay for generic profiling data. 0N/A// Some types of data layouts need a length field. 0N/A// Perform generic initialization of the data. More specific 0N/A// initialization occurs in overrides of ProfileData::post_initialize. 0N/A// ================================================================== 0N/A// A ProfileData object is created to refer to a section of profiling 0N/A// data in a structured way. 0N/A// Constructor for invalid ProfileData. 0N/A// ================================================================== 0N/A// A BitData corresponds to a one-bit flag. This is used to indicate 0N/A// whether a checkcast bytecode has seen a null value. 0N/A// ================================================================== 0N/A// A CounterData corresponds to a simple counter. 0N/A// ================================================================== 0N/A// A JumpData is used to access profiling information for a direct 0N/A// branch. It is a counter, used for counting the number of branches, 0N/A// plus a data displacement, used for realigning the data pointer to 0N/A// the corresponding target bci. 0N/A// ================================================================== 0N/A// A ReceiverTypeData is used to access profiling information about a 0N/A// dynamic type check. It consists of a counter which counts the total times 0N/A// that the check is reached, and a series of (klassOop, count) pairs 0N/A// which are used to store a type profile for the receiver of the check. 1273N/A // boundary test hoisted outside the loop (see klassVTable for an example); 0N/A // however, row_limit() is small enough (2) to make that less efficient. 0N/A// ================================================================== 0N/A// A RetData is used to access profiling information for a ret bytecode. 0N/A// It is composed of a count of the number of times that the ret has 0N/A// been executed, followed by a series of triples of the form 0N/A// (bci, count, di) which count the number of times that some bci was the 0N/A// target of the ret and cache a corresponding displacement. 0N/A // release so other threads see a consistent state. bci is used as 0N/A // a valid flag for bci_displacement. 0N/A// This routine needs to atomically update the RetData structure, so the 0N/A// caller needs to hold the RetData_lock before it gets here. Since taking 0N/A// the lock can block (and allow GC) and since RetData is a ProfileData is a 0N/A// wrapper around a derived oop, taking the lock in _this_ method will 0N/A// basically cause the 'this' pointer's _data field to contain junk after the 0N/A// lock. We require the caller to take the lock before making the ProfileData 0N/A// structure. Currently the only caller is InterpreterRuntime::update_mdp_for_ret 0N/A // First find the mdp which corresponds to the return bci. 0N/A // Now check to see if any of the cache slots are open. 0N/A // Barrier to ensure displacement is written before the bci; allows 0N/A // the interpreter to read displacement without fear of race condition. 0N/A// ================================================================== 0N/A// A BranchData is used to access profiling data for a two-way branch. 0N/A// It consists of taken and not_taken counts as well as a data displacement 0N/A// for the taken case. 0N/A// ================================================================== 605N/A// A MultiBranchData is used to access profiling information for 0N/A// a multi-way branch (*switch bytecodes). It consists of a series 0N/A// of (count, displacement) pairs, which count the number of times each 0N/A// case was taken and specify the data displacment for each branch target. 0N/A// ================================================================== 0N/A// A methodDataOop holds information which has been collected about 0N/A// Compute the size of the profiling information corresponding to 0N/A// the current bytecode. 0N/A // Note: cell_count might be zero, meaning that there is just 0N/A // a DataLayout header, with no extra cells. 0N/A // Assume that up to 3% of BCIs with no MDP will need to allocate one. 0N/A // If the method is large, let the extra BCIs grow numerous (to ~1%). 0N/A// Compute the size of the methodDataOop necessary to store 0N/A// profiling information about a given method. Size is in bytes. 0N/A // Add some extra DataLayout cells (at least one) to track stray traps. 0N/A // Add a cell to record information about modified arguments. 0N/A// Compute the size of the methodDataOop necessary to store 0N/A// profiling information about a given method. Size is in words 0N/A// Initialize an individual data segment. Returns the size of 0N/A// the segment in bytes. // %%% should make a type profile for any invokedynamic that takes a ref argument // Get the data at an arbitrary (sort of) data index. // Give each of the data entries a chance to perform specific // Initialize the methodDataOop corresponding to a given method. // Set the method back-pointer. // Initialize flags and trap history. // Go through the bytecodes and allocate and initialize the // corresponding data cells. // Add some extra DataLayout cells (at least one) to track stray traps. // Add a cell to record information about modified arguments. // Set up _args_modified array after traps cells so that // the code for traps cells works. // Set an initial hint. Don't use set_hint_di() because // first_di() may be out of bounds if data_size is 0. // In that situation, _hint_di is never used, but at // Get a measure of how much mileage the method has on it. return true;
// some sort of overflow // Translate a bci to its corresponding data index (di). // Translate a bci to its corresponding data, or NULL. // Translate a bci to its corresponding extra data, or NULL. // No need for "OrderAccess::load_acquire" ops, // since the data structure is monotonic. dp =
end;
// ArgInfoData is at the end of extra data section. // Allocate this one. There is no mutual exclusion, // so two threads could allocate different BCIs to the // same data layout. This means these extra data // records, like most other MDO contents, must not be //NO: assert(dp->bci() == bci, "no concurrent allocation"); // No need for "OrderAccess::load_acquire" ops, // since the data structure is monotonic. dp =
end;
// ArgInfoData is at the end of extra data section.