methodDataOop.cpp revision 2027
/*
* 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 "precompiled.hpp"
#include "classfile/systemDictionary.hpp"
#include "gc_implementation/shared/markSweep.inline.hpp"
#include "interpreter/bytecode.hpp"
#include "interpreter/bytecodeStream.hpp"
#include "interpreter/linkResolver.hpp"
#include "oops/methodDataOop.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/compilationPolicy.hpp"
#include "runtime/deoptimization.hpp"
#include "runtime/handles.inline.hpp"
// ==================================================================
// 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)) {
}
}
ResourceMark m;
}
// ==================================================================
// 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() {
// This is a set of weak references that need
// to be followed at the end of the strong marking
// phase. Memoize this object so it can be visited
// in the weak roots processing phase.
}
#ifndef SERIALGC
// This is a set of weak references that need
// to be followed at the end of the strong marking
// phase. Memoize this object so it can be visited
// in the weak roots processing phase.
}
#endif // SERIALGC
if (blk->should_remember_mdo()) {
// This is a set of weak references that need
// to be followed at the end of the strong marking
// phase. Memoize this object so it can be visited
// in the weak roots processing phase.
} else { // normal scan
}
}
}
}
// Currently, this interface is called only during card-scanning for
// a young gen gc, in which case this object cannot contribute anything,
// since it does not contain any references that cross out of
// the perm gen. However, for future more general use we allow
// the possibility of calling for instance from more general
// iterators (for example, a future regionalized perm gen for G1,
// or the possibility of moving some references out of perm in
// the case of other collectors). In that case, you will need
// to relax or remove some of the assertions below.
#ifdef ASSERT
// Verify that none of the embedded oop references cross out of
// this generation.
}
}
#endif // ASSERT
return; // Nothing to do, see comment above
#if 0
if (blk->should_remember_mdo()) {
// This is a set of weak references that need
// to be followed at the end of the strong marking
// phase. Memoize this object so it can be visited
// in the weak roots processing phase.
} else { // normal scan
// Test that the current cursor and the two ends of the range
// that we may have skipped iterating over are monotonically ordered;
// this is just a paranoid assertion, just in case represetations
// should change in the future rendering the short-circuit return
// here invalid.
break; // remaining should be outside this mr too
}
}
}
}
#endif
}
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();
case Bytecodes::_invokedynamic:
return CounterData::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;
case Bytecodes::_invokedynamic:
// %%% should make a type profile for any invokedynamic that takes a ref argument
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;
}
return data_layout->data_in();
}
switch (tag()) {
case DataLayout::no_tag:
default:
return NULL;
case DataLayout::bit_data_tag:
return new BitData(this);
case DataLayout::counter_data_tag:
return new CounterData(this);
case DataLayout::jump_data_tag:
return new JumpData(this);
case DataLayout::receiver_type_data_tag:
return new ReceiverTypeData(this);
case DataLayout::virtual_call_data_tag:
return new VirtualCallData(this);
case DataLayout::ret_data_tag:
return new RetData(this);
case DataLayout::branch_data_tag:
return new BranchData(this);
case DataLayout::multi_branch_data_tag:
return new MultiBranchData(this);
case DataLayout::arg_info_data_tag:
return new ArgInfoData(this);
};
}
// 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.
if (TieredCompilation) {
_num_loops = 0;
_num_blocks = 0;
_highest_comp_level = 0;
_would_profile = false;
}
// 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;
if (TieredCompilation) {
} else {
}
return mileage;
}
bool methodDataOopDesc::is_mature() const {
}
// 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.
}