methodDataOop.cpp revision 45
/*
* Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved.
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*
*/
# include "incls/_precompiled.incl"
# include "incls/_methodDataOop.cpp.incl"
// ==================================================================
// DataLayout
//
// Overlay for generic profiling data.
// Some types of data layouts need a length field.
}
// Perform generic initialization of the data. More specific
// initialization occurs in overrides of ProfileData::post_initialize.
for (int i = 0; i < cell_count; i++) {
set_cell_at(i, (intptr_t)0);
}
if (needs_array_len(tag)) {
}
}
// ==================================================================
// ProfileData
//
// A ProfileData object is created to refer to a section of profiling
// data in a structured way.
// Constructor for invalid ProfileData.
ProfileData::ProfileData() {
}
#ifndef PRODUCT
int trap = trap_state();
if (trap != 0) {
char buf[100];
}
if (flags != 0)
}
}
#endif // !PRODUCT
// ==================================================================
// BitData
//
// A BitData corresponds to a one-bit flag. This is used to indicate
// whether a checkcast bytecode has seen a null value.
#ifndef PRODUCT
}
#endif // !PRODUCT
// ==================================================================
// CounterData
//
// A CounterData corresponds to a simple counter.
#ifndef PRODUCT
}
#endif // !PRODUCT
// ==================================================================
// JumpData
//
// A JumpData is used to access profiling information for a direct
// branch. It is a counter, used for counting the number of branches,
// plus a data displacement, used for realigning the data pointer to
// the corresponding target bci.
int target;
} else {
}
}
#ifndef PRODUCT
}
#endif // !PRODUCT
// ==================================================================
// ReceiverTypeData
//
// A ReceiverTypeData is used to access profiling information about a
// dynamic type check. It consists of a counter which counts the total times
// that the check is reached, and a series of (klassOop, count) pairs
// which are used to store a type profile for the receiver of the check.
void ReceiverTypeData::follow_contents() {
}
}
}
#ifndef SERIALGC
}
}
}
#endif // SERIALGC
}
}
}
}
}
}
}
void ReceiverTypeData::adjust_pointers() {
}
}
}
#ifndef SERIALGC
void ReceiverTypeData::update_pointers() {
}
}
}
// boundary test hoisted outside the loop (see klassVTable for an example);
// however, row_limit() is small enough (2) to make that less efficient.
}
}
}
#endif // SERIALGC
#ifndef PRODUCT
int entries = 0;
}
}
}
}
}
}
#endif // !PRODUCT
// ==================================================================
// RetData
//
// A RetData is used to access profiling information for a ret bytecode.
// It is composed of a count of the number of times that the ret has
// been executed, followed by a series of triples of the form
// (bci, count, di) which count the number of times that some bci was the
// target of the ret and cache a corresponding displacement.
}
// release so other threads see a consistent state. bci is used as
// a valid flag for bci_displacement.
OrderAccess::release();
}
// This routine needs to atomically update the RetData structure, so the
// caller needs to hold the RetData_lock before it gets here. Since taking
// the lock can block (and allow GC) and since RetData is a ProfileData is a
// wrapper around a derived oop, taking the lock in _this_ method will
// basically cause the 'this' pointer's _data field to contain junk after the
// lock. We require the caller to take the lock before making the ProfileData
// structure. Currently the only caller is InterpreterRuntime::update_mdp_for_ret
// First find the mdp which corresponds to the return bci.
// Now check to see if any of the cache slots are open.
// Barrier to ensure displacement is written before the bci; allows
// the interpreter to read displacement without fear of race condition.
break;
}
}
return mdp;
}
#ifndef PRODUCT
int entries = 0;
}
}
}
}
#endif // !PRODUCT
// ==================================================================
// BranchData
//
// A BranchData is used to access profiling data for a two-way branch.
// It consists of taken and not_taken counts as well as a data displacement
// for the taken case.
}
#ifndef PRODUCT
taken(), displacement());
}
#endif
// ==================================================================
// MultiBranchData
//
// A MultiBranchData is used to access profiling information for
// a multi-way branch (*switch bytecodes). It consists of a series
// of (count, displacement) pairs, which count the number of times each
// case was taken and specify the data displacment for each branch target.
int cell_count = 0;
} else {
}
return cell_count;
}
methodDataOop mdo) {
int target;
int my_di;
int target_di;
int offset;
}
} else {
}
}
}
#ifndef PRODUCT
int cases = number_of_cases();
for (int i = 0; i < cases; i++) {
count_at(i), displacement_at(i));
}
}
#endif
#ifndef PRODUCT
int nargs = number_of_args();
for (int i = 0; i < nargs; i++) {
}
}
#endif
// ==================================================================
// methodDataOop
//
// A methodDataOop holds information which has been collected about
// a method.
switch (code) {
case Bytecodes::_checkcast:
case Bytecodes::_instanceof:
if (TypeProfileCasts) {
return ReceiverTypeData::static_cell_count();
} else {
return BitData::static_cell_count();
}
case Bytecodes::_invokespecial:
case Bytecodes::_invokestatic:
return CounterData::static_cell_count();
return JumpData::static_cell_count();
case Bytecodes::_invokevirtual:
case Bytecodes::_invokeinterface:
return VirtualCallData::static_cell_count();
return RetData::static_cell_count();
case Bytecodes::_if_icmpeq:
case Bytecodes::_if_icmpne:
case Bytecodes::_if_icmplt:
case Bytecodes::_if_icmpge:
case Bytecodes::_if_icmpgt:
case Bytecodes::_if_icmple:
case Bytecodes::_if_acmpeq:
case Bytecodes::_if_acmpne:
case Bytecodes::_ifnonnull:
return BranchData::static_cell_count();
case Bytecodes::_lookupswitch:
case Bytecodes::_tableswitch:
return variable_cell_count;
}
return no_profile_data;
}
// Compute the size of the profiling information corresponding to
// the current bytecode.
if (cell_count == no_profile_data) {
return 0;
}
if (cell_count == variable_cell_count) {
}
// Note: cell_count might be zero, meaning that there is just
// a DataLayout header, with no extra cells.
}
if (ProfileTraps) {
// Assume that up to 3% of BCIs with no MDP will need to allocate one.
// If the method is large, let the extra BCIs grow numerous (to ~1%).
if (extra_data_count > empty_bc_count)
return extra_data_count;
} else {
return 0;
}
}
// Compute the size of the methodDataOop necessary to store
// profiling information about a given method. Size is in bytes.
int data_size = 0;
int empty_bc_count = 0; // number of bytecodes lacking data
}
// Add some extra DataLayout cells (at least one) to track stray traps.
// Add a cell to record information about modified arguments.
return object_size;
}
// Compute the size of the methodDataOop necessary to store
// profiling information about a given method. Size is in words
return align_object_size(word_size);
}
// Initialize an individual data segment. Returns the size of
// the segment in bytes.
int data_index) {
int cell_count = -1;
switch (c) {
case Bytecodes::_checkcast:
case Bytecodes::_instanceof:
if (TypeProfileCasts) {
} else {
}
break;
case Bytecodes::_invokespecial:
case Bytecodes::_invokestatic:
break;
break;
case Bytecodes::_invokevirtual:
case Bytecodes::_invokeinterface:
break;
break;
case Bytecodes::_if_icmpeq:
case Bytecodes::_if_icmpne:
case Bytecodes::_if_icmplt:
case Bytecodes::_if_icmpge:
case Bytecodes::_if_icmpgt:
case Bytecodes::_if_icmple:
case Bytecodes::_if_acmpeq:
case Bytecodes::_if_acmpne:
case Bytecodes::_ifnonnull:
break;
case Bytecodes::_lookupswitch:
case Bytecodes::_tableswitch:
break;
}
if (cell_count >= 0) {
} else {
return 0;
}
}
// Get the data at an arbitrary (sort of) data index.
if (out_of_bounds(data_index)) {
return NULL;
}
switch (data_layout->tag()) {
case DataLayout::no_tag:
default:
return NULL;
case DataLayout::bit_data_tag:
return new BitData(data_layout);
case DataLayout::counter_data_tag:
return new CounterData(data_layout);
case DataLayout::jump_data_tag:
return new JumpData(data_layout);
case DataLayout::receiver_type_data_tag:
return new ReceiverTypeData(data_layout);
case DataLayout::virtual_call_data_tag:
return new VirtualCallData(data_layout);
case DataLayout::ret_data_tag:
return new RetData(data_layout);
case DataLayout::branch_data_tag:
return new BranchData(data_layout);
case DataLayout::multi_branch_data_tag:
return new MultiBranchData(data_layout);
case DataLayout::arg_info_data_tag:
return new ArgInfoData(data_layout);
};
}
// Iteration over data.
return next;
}
// Give each of the data entries a chance to perform specific
// data initialization.
}
}
// Initialize the methodDataOop corresponding to a given method.
// Set the method back-pointer.
// Initialize flags and trap history.
_nof_decompiles = 0;
_nof_overflow_traps = 0;
sizeof(_trap_hist) / sizeof(HeapWord));
// Go through the bytecodes and allocate and initialize the
// corresponding data cells.
int data_size = 0;
int empty_bc_count = 0; // number of bytecodes lacking data
}
// 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
// least well-defined.
}
// Get a measure of how much mileage the method has on it.
int mileage = 0;
return mileage;
}
bool methodDataOopDesc::is_mature() const {
return true; // some sort of overflow
if (ProfileMaturityPercentage <= 0)
else
}
// Translate a bci to its corresponding data index (di).
}
}
return (address)limit_data_position();
}
// Translate a bci to its corresponding data, or NULL.
return data;
break;
}
}
return bci_to_extra_data(bci, false);
}
// Translate a bci to its corresponding extra data, or NULL.
// No need for "OrderAccess::load_acquire" ops,
// since the data structure is monotonic.
break;
}
}
}
// 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
// trusted too much.
//NO: assert(dp->bci() == bci, "no concurrent allocation");
}
return NULL;
}
return new ArgInfoData(dp);
}
return NULL;
}
#ifndef PRODUCT
}
// No need for "OrderAccess::load_acquire" ops,
// since the data structure is monotonic.
} else {
}
}
}
#endif
// not yet implemented.
}