0N/A/*
2099N/A * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
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 *
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 *
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.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_OOPS_METHODDATAOOP_HPP
1879N/A#define SHARE_VM_OOPS_METHODDATAOOP_HPP
1879N/A
1879N/A#include "interpreter/bytecodes.hpp"
1879N/A#include "memory/universe.hpp"
1879N/A#include "oops/methodOop.hpp"
1879N/A#include "oops/oop.hpp"
1879N/A#include "runtime/orderAccess.hpp"
1879N/A
0N/Aclass BytecodeStream;
0N/A
0N/A// The MethodData object collects counts and other profile information
0N/A// during zeroth-tier (interpretive) and first-tier execution.
0N/A// The profile is used later by compilation heuristics. Some heuristics
0N/A// enable use of aggressive (or "heroic") optimizations. An aggressive
0N/A// optimization often has a down-side, a corner case that it handles
0N/A// poorly, but which is thought to be rare. The profile provides
0N/A// evidence of this rarity for a given method or even BCI. It allows
0N/A// the compiler to back out of the optimization at places where it
0N/A// has historically been a poor choice. Other heuristics try to use
0N/A// specific information gathered about types observed at a given site.
0N/A//
0N/A// All data in the profile is approximate. It is expected to be accurate
0N/A// on the whole, but the system expects occasional inaccuraces, due to
0N/A// counter overflow, multiprocessor races during data collection, space
0N/A// limitations, missing MDO blocks, etc. Bad or missing data will degrade
0N/A// optimization quality but will not affect correctness. Also, each MDO
0N/A// is marked with its birth-date ("creation_mileage") which can be used
0N/A// to assess the quality ("maturity") of its data.
0N/A//
0N/A// Short (<32-bit) counters are designed to overflow to a known "saturated"
0N/A// state. Also, certain recorded per-BCI events are given one-bit counters
0N/A// which overflow to a saturated state which applied to all counters at
0N/A// that BCI. In other words, there is a small lattice which approximates
0N/A// the ideal of an infinite-precision counter for each event at each BCI,
0N/A// and the lattice quickly "bottoms out" in a state where all counters
0N/A// are taken to be indefinitely large.
0N/A//
0N/A// The reader will find many data races in profile gathering code, starting
0N/A// with invocation counter incrementation. None of these races harm correct
0N/A// execution of the compiled code.
0N/A
941N/A// forward decl
941N/Aclass ProfileData;
941N/A
0N/A// DataLayout
0N/A//
0N/A// Overlay for generic profiling data.
0N/Aclass DataLayout VALUE_OBJ_CLASS_SPEC {
0N/Aprivate:
0N/A // Every data layout begins with a header. This header
0N/A // contains a tag, which is used to indicate the size/layout
0N/A // of the data, 4 bits of flags, which can be used in any way,
0N/A // 4 bits of trap history (none/one reason/many reasons),
0N/A // and a bci, which is used to tie this piece of data to a
0N/A // specific bci in the bytecodes.
0N/A union {
0N/A intptr_t _bits;
0N/A struct {
0N/A u1 _tag;
0N/A u1 _flags;
0N/A u2 _bci;
0N/A } _struct;
0N/A } _header;
0N/A
0N/A // The data layout has an arbitrary number of cells, each sized
0N/A // to accomodate a pointer or an integer.
0N/A intptr_t _cells[1];
0N/A
0N/A // Some types of data layouts need a length field.
0N/A static bool needs_array_len(u1 tag);
0N/A
0N/Apublic:
0N/A enum {
0N/A counter_increment = 1
0N/A };
0N/A
0N/A enum {
0N/A cell_size = sizeof(intptr_t)
0N/A };
0N/A
0N/A // Tag values
0N/A enum {
0N/A no_tag,
0N/A bit_data_tag,
0N/A counter_data_tag,
0N/A jump_data_tag,
0N/A receiver_type_data_tag,
0N/A virtual_call_data_tag,
0N/A ret_data_tag,
0N/A branch_data_tag,
45N/A multi_branch_data_tag,
45N/A arg_info_data_tag
0N/A };
0N/A
0N/A enum {
0N/A // The _struct._flags word is formatted as [trap_state:4 | flags:4].
0N/A // The trap state breaks down further as [recompile:1 | reason:3].
0N/A // This further breakdown is defined in deoptimization.cpp.
0N/A // See Deoptimization::trap_state_reason for an assert that
0N/A // trap_bits is big enough to hold reasons < Reason_RECORDED_LIMIT.
0N/A //
0N/A // The trap_state is collected only if ProfileTraps is true.
0N/A trap_bits = 1+3, // 3: enough to distinguish [0..Reason_RECORDED_LIMIT].
0N/A trap_shift = BitsPerByte - trap_bits,
0N/A trap_mask = right_n_bits(trap_bits),
0N/A trap_mask_in_place = (trap_mask << trap_shift),
0N/A flag_limit = trap_shift,
0N/A flag_mask = right_n_bits(flag_limit),
0N/A first_flag = 0
0N/A };
0N/A
0N/A // Size computation
0N/A static int header_size_in_bytes() {
0N/A return cell_size;
0N/A }
0N/A static int header_size_in_cells() {
0N/A return 1;
0N/A }
0N/A
0N/A static int compute_size_in_bytes(int cell_count) {
0N/A return header_size_in_bytes() + cell_count * cell_size;
0N/A }
0N/A
0N/A // Initialization
0N/A void initialize(u1 tag, u2 bci, int cell_count);
0N/A
0N/A // Accessors
0N/A u1 tag() {
0N/A return _header._struct._tag;
0N/A }
0N/A
0N/A // Return a few bits of trap state. Range is [0..trap_mask].
0N/A // The state tells if traps with zero, one, or many reasons have occurred.
0N/A // It also tells whether zero or many recompilations have occurred.
0N/A // The associated trap histogram in the MDO itself tells whether
0N/A // traps are common or not. If a BCI shows that a trap X has
0N/A // occurred, and the MDO shows N occurrences of X, we make the
0N/A // simplifying assumption that all N occurrences can be blamed
0N/A // on that BCI.
0N/A int trap_state() {
0N/A return ((_header._struct._flags >> trap_shift) & trap_mask);
0N/A }
0N/A
0N/A void set_trap_state(int new_state) {
0N/A assert(ProfileTraps, "used only under +ProfileTraps");
0N/A uint old_flags = (_header._struct._flags & flag_mask);
0N/A _header._struct._flags = (new_state << trap_shift) | old_flags;
0N/A }
0N/A
0N/A u1 flags() {
0N/A return _header._struct._flags;
0N/A }
0N/A
0N/A u2 bci() {
0N/A return _header._struct._bci;
0N/A }
0N/A
0N/A void set_header(intptr_t value) {
0N/A _header._bits = value;
0N/A }
0N/A void release_set_header(intptr_t value) {
0N/A OrderAccess::release_store_ptr(&_header._bits, value);
0N/A }
0N/A intptr_t header() {
0N/A return _header._bits;
0N/A }
0N/A void set_cell_at(int index, intptr_t value) {
0N/A _cells[index] = value;
0N/A }
0N/A void release_set_cell_at(int index, intptr_t value) {
0N/A OrderAccess::release_store_ptr(&_cells[index], value);
0N/A }
0N/A intptr_t cell_at(int index) {
0N/A return _cells[index];
0N/A }
0N/A intptr_t* adr_cell_at(int index) {
0N/A return &_cells[index];
0N/A }
0N/A oop* adr_oop_at(int index) {
0N/A return (oop*)&(_cells[index]);
0N/A }
0N/A
0N/A void set_flag_at(int flag_number) {
0N/A assert(flag_number < flag_limit, "oob");
0N/A _header._struct._flags |= (0x1 << flag_number);
0N/A }
0N/A bool flag_at(int flag_number) {
0N/A assert(flag_number < flag_limit, "oob");
0N/A return (_header._struct._flags & (0x1 << flag_number)) != 0;
0N/A }
0N/A
0N/A // Low-level support for code generation.
0N/A static ByteSize header_offset() {
0N/A return byte_offset_of(DataLayout, _header);
0N/A }
0N/A static ByteSize tag_offset() {
0N/A return byte_offset_of(DataLayout, _header._struct._tag);
0N/A }
0N/A static ByteSize flags_offset() {
0N/A return byte_offset_of(DataLayout, _header._struct._flags);
0N/A }
0N/A static ByteSize bci_offset() {
0N/A return byte_offset_of(DataLayout, _header._struct._bci);
0N/A }
0N/A static ByteSize cell_offset(int index) {
2180N/A return byte_offset_of(DataLayout, _cells) + in_ByteSize(index * cell_size);
0N/A }
0N/A // Return a value which, when or-ed as a byte into _flags, sets the flag.
0N/A static int flag_number_to_byte_constant(int flag_number) {
0N/A assert(0 <= flag_number && flag_number < flag_limit, "oob");
0N/A DataLayout temp; temp.set_header(0);
0N/A temp.set_flag_at(flag_number);
0N/A return temp._header._struct._flags;
0N/A }
0N/A // Return a value which, when or-ed as a word into _header, sets the flag.
0N/A static intptr_t flag_mask_to_header_mask(int byte_constant) {
0N/A DataLayout temp; temp.set_header(0);
0N/A temp._header._struct._flags = byte_constant;
0N/A return temp._header._bits;
0N/A }
941N/A
941N/A // GC support
941N/A ProfileData* data_in();
941N/A void follow_weak_refs(BoolObjectClosure* cl);
0N/A};
0N/A
0N/A
0N/A// ProfileData class hierarchy
0N/Aclass ProfileData;
0N/Aclass BitData;
0N/Aclass CounterData;
0N/Aclass ReceiverTypeData;
0N/Aclass VirtualCallData;
0N/Aclass RetData;
0N/Aclass JumpData;
0N/Aclass BranchData;
0N/Aclass ArrayData;
0N/Aclass MultiBranchData;
45N/Aclass ArgInfoData;
0N/A
0N/A
0N/A// ProfileData
0N/A//
0N/A// A ProfileData object is created to refer to a section of profiling
0N/A// data in a structured way.
0N/Aclass ProfileData : public ResourceObj {
0N/Aprivate:
0N/A#ifndef PRODUCT
0N/A enum {
0N/A tab_width_one = 16,
0N/A tab_width_two = 36
0N/A };
0N/A#endif // !PRODUCT
0N/A
0N/A // This is a pointer to a section of profiling data.
0N/A DataLayout* _data;
0N/A
0N/Aprotected:
0N/A DataLayout* data() { return _data; }
0N/A
0N/A enum {
0N/A cell_size = DataLayout::cell_size
0N/A };
0N/A
0N/Apublic:
0N/A // How many cells are in this?
0N/A virtual int cell_count() {
0N/A ShouldNotReachHere();
0N/A return -1;
0N/A }
0N/A
0N/A // Return the size of this data.
0N/A int size_in_bytes() {
0N/A return DataLayout::compute_size_in_bytes(cell_count());
0N/A }
0N/A
0N/Aprotected:
0N/A // Low-level accessors for underlying data
0N/A void set_intptr_at(int index, intptr_t value) {
0N/A assert(0 <= index && index < cell_count(), "oob");
0N/A data()->set_cell_at(index, value);
0N/A }
0N/A void release_set_intptr_at(int index, intptr_t value) {
0N/A assert(0 <= index && index < cell_count(), "oob");
0N/A data()->release_set_cell_at(index, value);
0N/A }
0N/A intptr_t intptr_at(int index) {
0N/A assert(0 <= index && index < cell_count(), "oob");
0N/A return data()->cell_at(index);
0N/A }
0N/A void set_uint_at(int index, uint value) {
0N/A set_intptr_at(index, (intptr_t) value);
0N/A }
0N/A void release_set_uint_at(int index, uint value) {
0N/A release_set_intptr_at(index, (intptr_t) value);
0N/A }
0N/A uint uint_at(int index) {
0N/A return (uint)intptr_at(index);
0N/A }
0N/A void set_int_at(int index, int value) {
0N/A set_intptr_at(index, (intptr_t) value);
0N/A }
0N/A void release_set_int_at(int index, int value) {
0N/A release_set_intptr_at(index, (intptr_t) value);
0N/A }
0N/A int int_at(int index) {
0N/A return (int)intptr_at(index);
0N/A }
0N/A int int_at_unchecked(int index) {
0N/A return (int)data()->cell_at(index);
0N/A }
0N/A void set_oop_at(int index, oop value) {
0N/A set_intptr_at(index, (intptr_t) value);
0N/A }
0N/A oop oop_at(int index) {
0N/A return (oop)intptr_at(index);
0N/A }
0N/A oop* adr_oop_at(int index) {
0N/A assert(0 <= index && index < cell_count(), "oob");
0N/A return data()->adr_oop_at(index);
0N/A }
0N/A
0N/A void set_flag_at(int flag_number) {
0N/A data()->set_flag_at(flag_number);
0N/A }
0N/A bool flag_at(int flag_number) {
0N/A return data()->flag_at(flag_number);
0N/A }
0N/A
0N/A // two convenient imports for use by subclasses:
0N/A static ByteSize cell_offset(int index) {
0N/A return DataLayout::cell_offset(index);
0N/A }
0N/A static int flag_number_to_byte_constant(int flag_number) {
0N/A return DataLayout::flag_number_to_byte_constant(flag_number);
0N/A }
0N/A
0N/A ProfileData(DataLayout* data) {
0N/A _data = data;
0N/A }
0N/A
0N/Apublic:
0N/A // Constructor for invalid ProfileData.
0N/A ProfileData();
0N/A
0N/A u2 bci() {
0N/A return data()->bci();
0N/A }
0N/A
0N/A address dp() {
0N/A return (address)_data;
0N/A }
0N/A
0N/A int trap_state() {
0N/A return data()->trap_state();
0N/A }
0N/A void set_trap_state(int new_state) {
0N/A data()->set_trap_state(new_state);
0N/A }
0N/A
0N/A // Type checking
0N/A virtual bool is_BitData() { return false; }
0N/A virtual bool is_CounterData() { return false; }
0N/A virtual bool is_JumpData() { return false; }
0N/A virtual bool is_ReceiverTypeData(){ return false; }
0N/A virtual bool is_VirtualCallData() { return false; }
0N/A virtual bool is_RetData() { return false; }
0N/A virtual bool is_BranchData() { return false; }
0N/A virtual bool is_ArrayData() { return false; }
0N/A virtual bool is_MultiBranchData() { return false; }
45N/A virtual bool is_ArgInfoData() { return false; }
45N/A
0N/A
0N/A BitData* as_BitData() {
0N/A assert(is_BitData(), "wrong type");
0N/A return is_BitData() ? (BitData*) this : NULL;
0N/A }
0N/A CounterData* as_CounterData() {
0N/A assert(is_CounterData(), "wrong type");
0N/A return is_CounterData() ? (CounterData*) this : NULL;
0N/A }
0N/A JumpData* as_JumpData() {
0N/A assert(is_JumpData(), "wrong type");
0N/A return is_JumpData() ? (JumpData*) this : NULL;
0N/A }
0N/A ReceiverTypeData* as_ReceiverTypeData() {
0N/A assert(is_ReceiverTypeData(), "wrong type");
0N/A return is_ReceiverTypeData() ? (ReceiverTypeData*)this : NULL;
0N/A }
0N/A VirtualCallData* as_VirtualCallData() {
0N/A assert(is_VirtualCallData(), "wrong type");
0N/A return is_VirtualCallData() ? (VirtualCallData*)this : NULL;
0N/A }
0N/A RetData* as_RetData() {
0N/A assert(is_RetData(), "wrong type");
0N/A return is_RetData() ? (RetData*) this : NULL;
0N/A }
0N/A BranchData* as_BranchData() {
0N/A assert(is_BranchData(), "wrong type");
0N/A return is_BranchData() ? (BranchData*) this : NULL;
0N/A }
0N/A ArrayData* as_ArrayData() {
0N/A assert(is_ArrayData(), "wrong type");
0N/A return is_ArrayData() ? (ArrayData*) this : NULL;
0N/A }
0N/A MultiBranchData* as_MultiBranchData() {
0N/A assert(is_MultiBranchData(), "wrong type");
0N/A return is_MultiBranchData() ? (MultiBranchData*)this : NULL;
0N/A }
45N/A ArgInfoData* as_ArgInfoData() {
45N/A assert(is_ArgInfoData(), "wrong type");
45N/A return is_ArgInfoData() ? (ArgInfoData*)this : NULL;
45N/A }
0N/A
0N/A
0N/A // Subclass specific initialization
0N/A virtual void post_initialize(BytecodeStream* stream, methodDataOop mdo) {}
0N/A
0N/A // GC support
0N/A virtual void follow_contents() {}
0N/A virtual void oop_iterate(OopClosure* blk) {}
0N/A virtual void oop_iterate_m(OopClosure* blk, MemRegion mr) {}
0N/A virtual void adjust_pointers() {}
941N/A virtual void follow_weak_refs(BoolObjectClosure* is_alive_closure) {}
0N/A
0N/A#ifndef SERIALGC
0N/A // Parallel old support
0N/A virtual void follow_contents(ParCompactionManager* cm) {}
0N/A virtual void update_pointers() {}
0N/A#endif // SERIALGC
0N/A
0N/A // CI translation: ProfileData can represent both MethodDataOop data
0N/A // as well as CIMethodData data. This function is provided for translating
0N/A // an oop in a ProfileData to the ci equivalent. Generally speaking,
0N/A // most ProfileData don't require any translation, so we provide the null
0N/A // translation here, and the required translators are in the ci subclasses.
0N/A virtual void translate_from(ProfileData* data) {}
0N/A
0N/A virtual void print_data_on(outputStream* st) {
0N/A ShouldNotReachHere();
0N/A }
0N/A
0N/A#ifndef PRODUCT
0N/A void print_shared(outputStream* st, const char* name);
0N/A void tab(outputStream* st);
0N/A#endif
0N/A};
0N/A
0N/A// BitData
0N/A//
0N/A// A BitData holds a flag or two in its header.
0N/Aclass BitData : public ProfileData {
0N/Aprotected:
0N/A enum {
0N/A // null_seen:
0N/A // saw a null operand (cast/aastore/instanceof)
0N/A null_seen_flag = DataLayout::first_flag + 0
0N/A };
0N/A enum { bit_cell_count = 0 }; // no additional data fields needed.
0N/Apublic:
0N/A BitData(DataLayout* layout) : ProfileData(layout) {
0N/A }
0N/A
0N/A virtual bool is_BitData() { return true; }
0N/A
0N/A static int static_cell_count() {
0N/A return bit_cell_count;
0N/A }
0N/A
0N/A virtual int cell_count() {
0N/A return static_cell_count();
0N/A }
0N/A
0N/A // Accessor
0N/A
0N/A // The null_seen flag bit is specially known to the interpreter.
0N/A // Consulting it allows the compiler to avoid setting up null_check traps.
0N/A bool null_seen() { return flag_at(null_seen_flag); }
0N/A void set_null_seen() { set_flag_at(null_seen_flag); }
0N/A
0N/A
0N/A // Code generation support
0N/A static int null_seen_byte_constant() {
0N/A return flag_number_to_byte_constant(null_seen_flag);
0N/A }
0N/A
0N/A static ByteSize bit_data_size() {
0N/A return cell_offset(bit_cell_count);
0N/A }
0N/A
0N/A#ifndef PRODUCT
0N/A void print_data_on(outputStream* st);
0N/A#endif
0N/A};
0N/A
0N/A// CounterData
0N/A//
0N/A// A CounterData corresponds to a simple counter.
0N/Aclass CounterData : public BitData {
0N/Aprotected:
0N/A enum {
0N/A count_off,
0N/A counter_cell_count
0N/A };
0N/Apublic:
0N/A CounterData(DataLayout* layout) : BitData(layout) {}
0N/A
0N/A virtual bool is_CounterData() { return true; }
0N/A
0N/A static int static_cell_count() {
0N/A return counter_cell_count;
0N/A }
0N/A
0N/A virtual int cell_count() {
0N/A return static_cell_count();
0N/A }
0N/A
0N/A // Direct accessor
0N/A uint count() {
0N/A return uint_at(count_off);
0N/A }
0N/A
0N/A // Code generation support
0N/A static ByteSize count_offset() {
0N/A return cell_offset(count_off);
0N/A }
0N/A static ByteSize counter_data_size() {
0N/A return cell_offset(counter_cell_count);
0N/A }
0N/A
1251N/A void set_count(uint count) {
1251N/A set_uint_at(count_off, count);
1251N/A }
1251N/A
0N/A#ifndef PRODUCT
0N/A void print_data_on(outputStream* st);
0N/A#endif
0N/A};
0N/A
0N/A// JumpData
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/Aclass JumpData : public ProfileData {
0N/Aprotected:
0N/A enum {
0N/A taken_off_set,
0N/A displacement_off_set,
0N/A jump_cell_count
0N/A };
0N/A
0N/A void set_displacement(int displacement) {
0N/A set_int_at(displacement_off_set, displacement);
0N/A }
0N/A
0N/Apublic:
0N/A JumpData(DataLayout* layout) : ProfileData(layout) {
0N/A assert(layout->tag() == DataLayout::jump_data_tag ||
0N/A layout->tag() == DataLayout::branch_data_tag, "wrong type");
0N/A }
0N/A
0N/A virtual bool is_JumpData() { return true; }
0N/A
0N/A static int static_cell_count() {
0N/A return jump_cell_count;
0N/A }
0N/A
0N/A virtual int cell_count() {
0N/A return static_cell_count();
0N/A }
0N/A
0N/A // Direct accessor
0N/A uint taken() {
0N/A return uint_at(taken_off_set);
0N/A }
2739N/A
2739N/A void set_taken(uint cnt) {
2739N/A set_uint_at(taken_off_set, cnt);
2739N/A }
2739N/A
0N/A // Saturating counter
0N/A uint inc_taken() {
0N/A uint cnt = taken() + 1;
0N/A // Did we wrap? Will compiler screw us??
0N/A if (cnt == 0) cnt--;
0N/A set_uint_at(taken_off_set, cnt);
0N/A return cnt;
0N/A }
0N/A
0N/A int displacement() {
0N/A return int_at(displacement_off_set);
0N/A }
0N/A
0N/A // Code generation support
0N/A static ByteSize taken_offset() {
0N/A return cell_offset(taken_off_set);
0N/A }
0N/A
0N/A static ByteSize displacement_offset() {
0N/A return cell_offset(displacement_off_set);
0N/A }
0N/A
0N/A // Specific initialization.
0N/A void post_initialize(BytecodeStream* stream, methodDataOop mdo);
0N/A
0N/A#ifndef PRODUCT
0N/A void print_data_on(outputStream* st);
0N/A#endif
0N/A};
0N/A
0N/A// ReceiverTypeData
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.
0N/Aclass ReceiverTypeData : public CounterData {
0N/Aprotected:
0N/A enum {
0N/A receiver0_offset = counter_cell_count,
0N/A count0_offset,
0N/A receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
0N/A };
0N/A
0N/Apublic:
0N/A ReceiverTypeData(DataLayout* layout) : CounterData(layout) {
0N/A assert(layout->tag() == DataLayout::receiver_type_data_tag ||
0N/A layout->tag() == DataLayout::virtual_call_data_tag, "wrong type");
0N/A }
0N/A
0N/A virtual bool is_ReceiverTypeData() { return true; }
0N/A
0N/A static int static_cell_count() {
0N/A return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count;
0N/A }
0N/A
0N/A virtual int cell_count() {
0N/A return static_cell_count();
0N/A }
0N/A
0N/A // Direct accessors
0N/A static uint row_limit() {
0N/A return TypeProfileWidth;
0N/A }
0N/A static int receiver_cell_index(uint row) {
0N/A return receiver0_offset + row * receiver_type_row_cell_count;
0N/A }
0N/A static int receiver_count_cell_index(uint row) {
0N/A return count0_offset + row * receiver_type_row_cell_count;
0N/A }
0N/A
0N/A // Get the receiver at row. The 'unchecked' version is needed by parallel old
0N/A // gc; it does not assert the receiver is a klass. During compaction of the
0N/A // perm gen, the klass may already have moved, so the is_klass() predicate
0N/A // would fail. The 'normal' version should be used whenever possible.
0N/A klassOop receiver_unchecked(uint row) {
0N/A assert(row < row_limit(), "oob");
0N/A oop recv = oop_at(receiver_cell_index(row));
0N/A return (klassOop)recv;
0N/A }
0N/A
0N/A klassOop receiver(uint row) {
0N/A klassOop recv = receiver_unchecked(row);
0N/A assert(recv == NULL || ((oop)recv)->is_klass(), "wrong type");
0N/A return recv;
0N/A }
0N/A
941N/A void set_receiver(uint row, oop p) {
941N/A assert((uint)row < row_limit(), "oob");
941N/A set_oop_at(receiver_cell_index(row), p);
941N/A }
941N/A
0N/A uint receiver_count(uint row) {
0N/A assert(row < row_limit(), "oob");
0N/A return uint_at(receiver_count_cell_index(row));
0N/A }
0N/A
941N/A void set_receiver_count(uint row, uint count) {
941N/A assert(row < row_limit(), "oob");
941N/A set_uint_at(receiver_count_cell_index(row), count);
941N/A }
941N/A
941N/A void clear_row(uint row) {
941N/A assert(row < row_limit(), "oob");
1251N/A // Clear total count - indicator of polymorphic call site.
1251N/A // The site may look like as monomorphic after that but
1251N/A // it allow to have more accurate profiling information because
1251N/A // there was execution phase change since klasses were unloaded.
1251N/A // If the site is still polymorphic then MDO will be updated
1251N/A // to reflect it. But it could be the case that the site becomes
1251N/A // only bimorphic. Then keeping total count not 0 will be wrong.
1251N/A // Even if we use monomorphic (when it is not) for compilation
1251N/A // we will only have trap, deoptimization and recompile again
1251N/A // with updated MDO after executing method in Interpreter.
1251N/A // An additional receiver will be recorded in the cleaned row
1251N/A // during next call execution.
1251N/A //
1251N/A // Note: our profiling logic works with empty rows in any slot.
1251N/A // We do sorting a profiling info (ciCallProfile) for compilation.
1251N/A //
1251N/A set_count(0);
941N/A set_receiver(row, NULL);
941N/A set_receiver_count(row, 0);
941N/A }
941N/A
0N/A // Code generation support
0N/A static ByteSize receiver_offset(uint row) {
0N/A return cell_offset(receiver_cell_index(row));
0N/A }
0N/A static ByteSize receiver_count_offset(uint row) {
0N/A return cell_offset(receiver_count_cell_index(row));
0N/A }
0N/A static ByteSize receiver_type_data_size() {
0N/A return cell_offset(static_cell_count());
0N/A }
0N/A
0N/A // GC support
0N/A virtual void follow_contents();
0N/A virtual void oop_iterate(OopClosure* blk);
0N/A virtual void oop_iterate_m(OopClosure* blk, MemRegion mr);
0N/A virtual void adjust_pointers();
941N/A virtual void follow_weak_refs(BoolObjectClosure* is_alive_closure);
0N/A
0N/A#ifndef SERIALGC
0N/A // Parallel old support
0N/A virtual void follow_contents(ParCompactionManager* cm);
0N/A virtual void update_pointers();
0N/A#endif // SERIALGC
0N/A
0N/A oop* adr_receiver(uint row) {
0N/A return adr_oop_at(receiver_cell_index(row));
0N/A }
0N/A
0N/A#ifndef PRODUCT
0N/A void print_receiver_data_on(outputStream* st);
0N/A void print_data_on(outputStream* st);
0N/A#endif
0N/A};
0N/A
0N/A// VirtualCallData
0N/A//
0N/A// A VirtualCallData is used to access profiling information about a
0N/A// virtual call. For now, it has nothing more than a ReceiverTypeData.
0N/Aclass VirtualCallData : public ReceiverTypeData {
0N/Apublic:
0N/A VirtualCallData(DataLayout* layout) : ReceiverTypeData(layout) {
0N/A assert(layout->tag() == DataLayout::virtual_call_data_tag, "wrong type");
0N/A }
0N/A
0N/A virtual bool is_VirtualCallData() { return true; }
0N/A
0N/A static int static_cell_count() {
0N/A // At this point we could add more profile state, e.g., for arguments.
0N/A // But for now it's the same size as the base record type.
0N/A return ReceiverTypeData::static_cell_count();
0N/A }
0N/A
0N/A virtual int cell_count() {
0N/A return static_cell_count();
0N/A }
0N/A
0N/A // Direct accessors
0N/A static ByteSize virtual_call_data_size() {
0N/A return cell_offset(static_cell_count());
0N/A }
0N/A
0N/A#ifndef PRODUCT
0N/A void print_data_on(outputStream* st);
0N/A#endif
0N/A};
0N/A
0N/A// RetData
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 data displacement.
0N/Aclass RetData : public CounterData {
0N/Aprotected:
0N/A enum {
0N/A bci0_offset = counter_cell_count,
0N/A count0_offset,
0N/A displacement0_offset,
0N/A ret_row_cell_count = (displacement0_offset + 1) - bci0_offset
0N/A };
0N/A
0N/A void set_bci(uint row, int bci) {
0N/A assert((uint)row < row_limit(), "oob");
0N/A set_int_at(bci0_offset + row * ret_row_cell_count, bci);
0N/A }
0N/A void release_set_bci(uint row, int bci) {
0N/A assert((uint)row < row_limit(), "oob");
0N/A // 'release' when setting the bci acts as a valid flag for other
0N/A // threads wrt bci_count and bci_displacement.
0N/A release_set_int_at(bci0_offset + row * ret_row_cell_count, bci);
0N/A }
0N/A void set_bci_count(uint row, uint count) {
0N/A assert((uint)row < row_limit(), "oob");
0N/A set_uint_at(count0_offset + row * ret_row_cell_count, count);
0N/A }
0N/A void set_bci_displacement(uint row, int disp) {
0N/A set_int_at(displacement0_offset + row * ret_row_cell_count, disp);
0N/A }
0N/A
0N/Apublic:
0N/A RetData(DataLayout* layout) : CounterData(layout) {
0N/A assert(layout->tag() == DataLayout::ret_data_tag, "wrong type");
0N/A }
0N/A
0N/A virtual bool is_RetData() { return true; }
0N/A
0N/A enum {
0N/A no_bci = -1 // value of bci when bci1/2 are not in use.
0N/A };
0N/A
0N/A static int static_cell_count() {
0N/A return counter_cell_count + (uint) BciProfileWidth * ret_row_cell_count;
0N/A }
0N/A
0N/A virtual int cell_count() {
0N/A return static_cell_count();
0N/A }
0N/A
0N/A static uint row_limit() {
0N/A return BciProfileWidth;
0N/A }
0N/A static int bci_cell_index(uint row) {
0N/A return bci0_offset + row * ret_row_cell_count;
0N/A }
0N/A static int bci_count_cell_index(uint row) {
0N/A return count0_offset + row * ret_row_cell_count;
0N/A }
0N/A static int bci_displacement_cell_index(uint row) {
0N/A return displacement0_offset + row * ret_row_cell_count;
0N/A }
0N/A
0N/A // Direct accessors
0N/A int bci(uint row) {
0N/A return int_at(bci_cell_index(row));
0N/A }
0N/A uint bci_count(uint row) {
0N/A return uint_at(bci_count_cell_index(row));
0N/A }
0N/A int bci_displacement(uint row) {
0N/A return int_at(bci_displacement_cell_index(row));
0N/A }
0N/A
0N/A // Interpreter Runtime support
0N/A address fixup_ret(int return_bci, methodDataHandle mdo);
0N/A
0N/A // Code generation support
0N/A static ByteSize bci_offset(uint row) {
0N/A return cell_offset(bci_cell_index(row));
0N/A }
0N/A static ByteSize bci_count_offset(uint row) {
0N/A return cell_offset(bci_count_cell_index(row));
0N/A }
0N/A static ByteSize bci_displacement_offset(uint row) {
0N/A return cell_offset(bci_displacement_cell_index(row));
0N/A }
0N/A
0N/A // Specific initialization.
0N/A void post_initialize(BytecodeStream* stream, methodDataOop mdo);
0N/A
0N/A#ifndef PRODUCT
0N/A void print_data_on(outputStream* st);
0N/A#endif
0N/A};
0N/A
0N/A// BranchData
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/Aclass BranchData : public JumpData {
0N/Aprotected:
0N/A enum {
0N/A not_taken_off_set = jump_cell_count,
0N/A branch_cell_count
0N/A };
0N/A
0N/A void set_displacement(int displacement) {
0N/A set_int_at(displacement_off_set, displacement);
0N/A }
0N/A
0N/Apublic:
0N/A BranchData(DataLayout* layout) : JumpData(layout) {
0N/A assert(layout->tag() == DataLayout::branch_data_tag, "wrong type");
0N/A }
0N/A
0N/A virtual bool is_BranchData() { return true; }
0N/A
0N/A static int static_cell_count() {
0N/A return branch_cell_count;
0N/A }
0N/A
0N/A virtual int cell_count() {
0N/A return static_cell_count();
0N/A }
0N/A
0N/A // Direct accessor
0N/A uint not_taken() {
0N/A return uint_at(not_taken_off_set);
0N/A }
0N/A
2739N/A void set_not_taken(uint cnt) {
2739N/A set_uint_at(not_taken_off_set, cnt);
2739N/A }
2739N/A
0N/A uint inc_not_taken() {
0N/A uint cnt = not_taken() + 1;
0N/A // Did we wrap? Will compiler screw us??
0N/A if (cnt == 0) cnt--;
0N/A set_uint_at(not_taken_off_set, cnt);
0N/A return cnt;
0N/A }
0N/A
0N/A // Code generation support
0N/A static ByteSize not_taken_offset() {
0N/A return cell_offset(not_taken_off_set);
0N/A }
0N/A static ByteSize branch_data_size() {
0N/A return cell_offset(branch_cell_count);
0N/A }
0N/A
0N/A // Specific initialization.
0N/A void post_initialize(BytecodeStream* stream, methodDataOop mdo);
0N/A
0N/A#ifndef PRODUCT
0N/A void print_data_on(outputStream* st);
0N/A#endif
0N/A};
0N/A
0N/A// ArrayData
0N/A//
0N/A// A ArrayData is a base class for accessing profiling data which does
0N/A// not have a statically known size. It consists of an array length
0N/A// and an array start.
0N/Aclass ArrayData : public ProfileData {
0N/Aprotected:
0N/A friend class DataLayout;
0N/A
0N/A enum {
0N/A array_len_off_set,
0N/A array_start_off_set
0N/A };
0N/A
0N/A uint array_uint_at(int index) {
0N/A int aindex = index + array_start_off_set;
0N/A return uint_at(aindex);
0N/A }
0N/A int array_int_at(int index) {
0N/A int aindex = index + array_start_off_set;
0N/A return int_at(aindex);
0N/A }
0N/A oop array_oop_at(int index) {
0N/A int aindex = index + array_start_off_set;
0N/A return oop_at(aindex);
0N/A }
0N/A void array_set_int_at(int index, int value) {
0N/A int aindex = index + array_start_off_set;
0N/A set_int_at(aindex, value);
0N/A }
0N/A
0N/A // Code generation support for subclasses.
0N/A static ByteSize array_element_offset(int index) {
0N/A return cell_offset(array_start_off_set + index);
0N/A }
0N/A
0N/Apublic:
0N/A ArrayData(DataLayout* layout) : ProfileData(layout) {}
0N/A
0N/A virtual bool is_ArrayData() { return true; }
0N/A
0N/A static int static_cell_count() {
0N/A return -1;
0N/A }
0N/A
0N/A int array_len() {
0N/A return int_at_unchecked(array_len_off_set);
0N/A }
0N/A
0N/A virtual int cell_count() {
0N/A return array_len() + 1;
0N/A }
0N/A
0N/A // Code generation support
0N/A static ByteSize array_len_offset() {
0N/A return cell_offset(array_len_off_set);
0N/A }
0N/A static ByteSize array_start_offset() {
0N/A return cell_offset(array_start_off_set);
0N/A }
0N/A};
0N/A
0N/A// MultiBranchData
0N/A//
0N/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/Aclass MultiBranchData : public ArrayData {
0N/Aprotected:
0N/A enum {
0N/A default_count_off_set,
0N/A default_disaplacement_off_set,
0N/A case_array_start
0N/A };
0N/A enum {
0N/A relative_count_off_set,
0N/A relative_displacement_off_set,
0N/A per_case_cell_count
0N/A };
0N/A
0N/A void set_default_displacement(int displacement) {
0N/A array_set_int_at(default_disaplacement_off_set, displacement);
0N/A }
0N/A void set_displacement_at(int index, int displacement) {
0N/A array_set_int_at(case_array_start +
0N/A index * per_case_cell_count +
0N/A relative_displacement_off_set,
0N/A displacement);
0N/A }
0N/A
0N/Apublic:
0N/A MultiBranchData(DataLayout* layout) : ArrayData(layout) {
0N/A assert(layout->tag() == DataLayout::multi_branch_data_tag, "wrong type");
0N/A }
0N/A
0N/A virtual bool is_MultiBranchData() { return true; }
0N/A
0N/A static int compute_cell_count(BytecodeStream* stream);
0N/A
0N/A int number_of_cases() {
0N/A int alen = array_len() - 2; // get rid of default case here.
0N/A assert(alen % per_case_cell_count == 0, "must be even");
0N/A return (alen / per_case_cell_count);
0N/A }
0N/A
0N/A uint default_count() {
0N/A return array_uint_at(default_count_off_set);
0N/A }
0N/A int default_displacement() {
0N/A return array_int_at(default_disaplacement_off_set);
0N/A }
0N/A
0N/A uint count_at(int index) {
0N/A return array_uint_at(case_array_start +
0N/A index * per_case_cell_count +
0N/A relative_count_off_set);
0N/A }
0N/A int displacement_at(int index) {
0N/A return array_int_at(case_array_start +
0N/A index * per_case_cell_count +
0N/A relative_displacement_off_set);
0N/A }
0N/A
0N/A // Code generation support
0N/A static ByteSize default_count_offset() {
0N/A return array_element_offset(default_count_off_set);
0N/A }
0N/A static ByteSize default_displacement_offset() {
0N/A return array_element_offset(default_disaplacement_off_set);
0N/A }
0N/A static ByteSize case_count_offset(int index) {
0N/A return case_array_offset() +
0N/A (per_case_size() * index) +
0N/A relative_count_offset();
0N/A }
0N/A static ByteSize case_array_offset() {
0N/A return array_element_offset(case_array_start);
0N/A }
0N/A static ByteSize per_case_size() {
0N/A return in_ByteSize(per_case_cell_count) * cell_size;
0N/A }
0N/A static ByteSize relative_count_offset() {
0N/A return in_ByteSize(relative_count_off_set) * cell_size;
0N/A }
0N/A static ByteSize relative_displacement_offset() {
0N/A return in_ByteSize(relative_displacement_off_set) * cell_size;
0N/A }
0N/A
0N/A // Specific initialization.
0N/A void post_initialize(BytecodeStream* stream, methodDataOop mdo);
0N/A
0N/A#ifndef PRODUCT
0N/A void print_data_on(outputStream* st);
0N/A#endif
0N/A};
0N/A
45N/Aclass ArgInfoData : public ArrayData {
45N/A
45N/Apublic:
45N/A ArgInfoData(DataLayout* layout) : ArrayData(layout) {
45N/A assert(layout->tag() == DataLayout::arg_info_data_tag, "wrong type");
45N/A }
45N/A
45N/A virtual bool is_ArgInfoData() { return true; }
45N/A
45N/A
45N/A int number_of_args() {
45N/A return array_len();
45N/A }
45N/A
45N/A uint arg_modified(int arg) {
45N/A return array_uint_at(arg);
45N/A }
45N/A
45N/A void set_arg_modified(int arg, uint val) {
45N/A array_set_int_at(arg, val);
45N/A }
45N/A
45N/A#ifndef PRODUCT
45N/A void print_data_on(outputStream* st);
45N/A#endif
45N/A};
45N/A
0N/A// methodDataOop
0N/A//
0N/A// A methodDataOop holds information which has been collected about
0N/A// a method. Its layout looks like this:
0N/A//
0N/A// -----------------------------
0N/A// | header |
0N/A// | klass |
0N/A// -----------------------------
0N/A// | method |
0N/A// | size of the methodDataOop |
0N/A// -----------------------------
0N/A// | Data entries... |
0N/A// | (variable size) |
0N/A// | |
0N/A// . .
0N/A// . .
0N/A// . .
0N/A// | |
0N/A// -----------------------------
0N/A//
0N/A// The data entry area is a heterogeneous array of DataLayouts. Each
0N/A// DataLayout in the array corresponds to a specific bytecode in the
0N/A// method. The entries in the array are sorted by the corresponding
0N/A// bytecode. Access to the data is via resource-allocated ProfileData,
0N/A// which point to the underlying blocks of DataLayout structures.
0N/A//
0N/A// During interpretation, if profiling in enabled, the interpreter
0N/A// maintains a method data pointer (mdp), which points at the entry
0N/A// in the array corresponding to the current bci. In the course of
0N/A// intepretation, when a bytecode is encountered that has profile data
0N/A// associated with it, the entry pointed to by mdp is updated, then the
0N/A// mdp is adjusted to point to the next appropriate DataLayout. If mdp
0N/A// is NULL to begin with, the interpreter assumes that the current method
0N/A// is not (yet) being profiled.
0N/A//
0N/A// In methodDataOop parlance, "dp" is a "data pointer", the actual address
0N/A// of a DataLayout element. A "di" is a "data index", the offset in bytes
0N/A// from the base of the data entry array. A "displacement" is the byte offset
0N/A// in certain ProfileData objects that indicate the amount the mdp must be
0N/A// adjusted in the event of a change in control flow.
0N/A//
0N/A
0N/Aclass methodDataOopDesc : public oopDesc {
0N/A friend class VMStructs;
0N/Aprivate:
0N/A friend class ProfileData;
0N/A
0N/A // Back pointer to the methodOop
0N/A methodOop _method;
0N/A
0N/A // Size of this oop in bytes
0N/A int _size;
0N/A
0N/A // Cached hint for bci_to_dp and bci_to_data
0N/A int _hint_di;
0N/A
0N/A // Whole-method sticky bits and flags
0N/Apublic:
0N/A enum {
2442N/A _trap_hist_limit = 17, // decoupled from Deoptimization::Reason_LIMIT
0N/A _trap_hist_mask = max_jubyte,
0N/A _extra_data_count = 4 // extra DataLayout headers, for trap history
0N/A }; // Public flag values
0N/Aprivate:
0N/A uint _nof_decompiles; // count of all nmethod removals
0N/A uint _nof_overflow_recompiles; // recompile count, excluding recomp. bits
0N/A uint _nof_overflow_traps; // trap count, excluding _trap_hist
0N/A union {
0N/A intptr_t _align;
0N/A u1 _array[_trap_hist_limit];
0N/A } _trap_hist;
0N/A
0N/A // Support for interprocedural escape analysis, from Thomas Kotzmann.
0N/A intx _eflags; // flags on escape information
0N/A intx _arg_local; // bit set of non-escaping arguments
0N/A intx _arg_stack; // bit set of stack-allocatable arguments
0N/A intx _arg_returned; // bit set of returned arguments
0N/A
1703N/A int _creation_mileage; // method mileage at MDO creation
1703N/A
1703N/A // How many invocations has this MDO seen?
1703N/A // These counters are used to determine the exact age of MDO.
1703N/A // We need those because in tiered a method can be concurrently
1703N/A // executed at different levels.
1703N/A InvocationCounter _invocation_counter;
1703N/A // Same for backedges.
1703N/A InvocationCounter _backedge_counter;
2124N/A // Counter values at the time profiling started.
2124N/A int _invocation_counter_start;
2124N/A int _backedge_counter_start;
1703N/A // Number of loops and blocks is computed when compiling the first
1703N/A // time with C1. It is used to determine if method is trivial.
1703N/A short _num_loops;
1703N/A short _num_blocks;
1703N/A // Highest compile level this method has ever seen.
1703N/A u1 _highest_comp_level;
1703N/A // Same for OSR level
1703N/A u1 _highest_osr_comp_level;
1703N/A // Does this method contain anything worth profiling?
1703N/A bool _would_profile;
0N/A
0N/A // Size of _data array in bytes. (Excludes header and extra_data fields.)
0N/A int _data_size;
0N/A
0N/A // Beginning of the data entries
0N/A intptr_t _data[1];
0N/A
0N/A // Helper for size computation
0N/A static int compute_data_size(BytecodeStream* stream);
0N/A static int bytecode_cell_count(Bytecodes::Code code);
0N/A enum { no_profile_data = -1, variable_cell_count = -2 };
0N/A
0N/A // Helper for initialization
0N/A DataLayout* data_layout_at(int data_index) {
0N/A assert(data_index % sizeof(intptr_t) == 0, "unaligned");
0N/A return (DataLayout*) (((address)_data) + data_index);
0N/A }
0N/A
0N/A // Initialize an individual data segment. Returns the size of
0N/A // the segment in bytes.
0N/A int initialize_data(BytecodeStream* stream, int data_index);
0N/A
0N/A // Helper for data_at
0N/A DataLayout* limit_data_position() {
0N/A return (DataLayout*)((address)data_base() + _data_size);
0N/A }
0N/A bool out_of_bounds(int data_index) {
0N/A return data_index >= data_size();
0N/A }
0N/A
0N/A // Give each of the data entries a chance to perform specific
0N/A // data initialization.
0N/A void post_initialize(BytecodeStream* stream);
0N/A
0N/A // hint accessors
0N/A int hint_di() const { return _hint_di; }
0N/A void set_hint_di(int di) {
0N/A assert(!out_of_bounds(di), "hint_di out of bounds");
0N/A _hint_di = di;
0N/A }
0N/A ProfileData* data_before(int bci) {
0N/A // avoid SEGV on this edge case
0N/A if (data_size() == 0)
0N/A return NULL;
0N/A int hint = hint_di();
0N/A if (data_layout_at(hint)->bci() <= bci)
0N/A return data_at(hint);
0N/A return first_data();
0N/A }
0N/A
0N/A // What is the index of the first data entry?
0N/A int first_di() { return 0; }
0N/A
0N/A // Find or create an extra ProfileData:
0N/A ProfileData* bci_to_extra_data(int bci, bool create_if_missing);
0N/A
45N/A // return the argument info cell
45N/A ArgInfoData *arg_info();
45N/A
0N/Apublic:
0N/A static int header_size() {
0N/A return sizeof(methodDataOopDesc)/wordSize;
0N/A }
0N/A
0N/A // Compute the size of a methodDataOop before it is created.
0N/A static int compute_allocation_size_in_bytes(methodHandle method);
0N/A static int compute_allocation_size_in_words(methodHandle method);
0N/A static int compute_extra_data_count(int data_size, int empty_bc_count);
0N/A
0N/A // Determine if a given bytecode can have profile information.
0N/A static bool bytecode_has_profile(Bytecodes::Code code) {
0N/A return bytecode_cell_count(code) != no_profile_data;
0N/A }
0N/A
0N/A // Perform initialization of a new methodDataOop
0N/A void initialize(methodHandle method);
0N/A
0N/A // My size
0N/A int object_size_in_bytes() { return _size; }
0N/A int object_size() {
0N/A return align_object_size(align_size_up(_size, BytesPerWord)/BytesPerWord);
0N/A }
0N/A
0N/A int creation_mileage() const { return _creation_mileage; }
0N/A void set_creation_mileage(int x) { _creation_mileage = x; }
1703N/A
1703N/A int invocation_count() {
1703N/A if (invocation_counter()->carry()) {
1703N/A return InvocationCounter::count_limit;
1703N/A }
1703N/A return invocation_counter()->count();
1703N/A }
1703N/A int backedge_count() {
1703N/A if (backedge_counter()->carry()) {
1703N/A return InvocationCounter::count_limit;
1703N/A }
1703N/A return backedge_counter()->count();
1703N/A }
1703N/A
2124N/A int invocation_count_start() {
2124N/A if (invocation_counter()->carry()) {
2124N/A return 0;
2124N/A }
2124N/A return _invocation_counter_start;
2124N/A }
2124N/A
2124N/A int backedge_count_start() {
2124N/A if (backedge_counter()->carry()) {
2124N/A return 0;
2124N/A }
2124N/A return _backedge_counter_start;
2124N/A }
2124N/A
2124N/A int invocation_count_delta() { return invocation_count() - invocation_count_start(); }
2124N/A int backedge_count_delta() { return backedge_count() - backedge_count_start(); }
2124N/A
2124N/A void reset_start_counters() {
2124N/A _invocation_counter_start = invocation_count();
2124N/A _backedge_counter_start = backedge_count();
2124N/A }
2124N/A
1703N/A InvocationCounter* invocation_counter() { return &_invocation_counter; }
1703N/A InvocationCounter* backedge_counter() { return &_backedge_counter; }
1703N/A
1703N/A void set_would_profile(bool p) { _would_profile = p; }
1703N/A bool would_profile() const { return _would_profile; }
1703N/A
1703N/A int highest_comp_level() { return _highest_comp_level; }
1703N/A void set_highest_comp_level(int level) { _highest_comp_level = level; }
1703N/A int highest_osr_comp_level() { return _highest_osr_comp_level; }
1703N/A void set_highest_osr_comp_level(int level) { _highest_osr_comp_level = level; }
1703N/A
1703N/A int num_loops() const { return _num_loops; }
1703N/A void set_num_loops(int n) { _num_loops = n; }
1703N/A int num_blocks() const { return _num_blocks; }
1703N/A void set_num_blocks(int n) { _num_blocks = n; }
1703N/A
0N/A bool is_mature() const; // consult mileage and ProfileMaturityPercentage
0N/A static int mileage_of(methodOop m);
0N/A
0N/A // Support for interprocedural escape analysis, from Thomas Kotzmann.
0N/A enum EscapeFlag {
0N/A estimated = 1 << 0,
78N/A return_local = 1 << 1,
78N/A return_allocated = 1 << 2,
78N/A allocated_escapes = 1 << 3,
78N/A unknown_modified = 1 << 4
0N/A };
0N/A
0N/A intx eflags() { return _eflags; }
0N/A intx arg_local() { return _arg_local; }
0N/A intx arg_stack() { return _arg_stack; }
0N/A intx arg_returned() { return _arg_returned; }
45N/A uint arg_modified(int a) { ArgInfoData *aid = arg_info();
45N/A assert(a >= 0 && a < aid->number_of_args(), "valid argument number");
45N/A return aid->arg_modified(a); }
0N/A
0N/A void set_eflags(intx v) { _eflags = v; }
0N/A void set_arg_local(intx v) { _arg_local = v; }
0N/A void set_arg_stack(intx v) { _arg_stack = v; }
0N/A void set_arg_returned(intx v) { _arg_returned = v; }
45N/A void set_arg_modified(int a, uint v) { ArgInfoData *aid = arg_info();
45N/A assert(a >= 0 && a < aid->number_of_args(), "valid argument number");
45N/A
45N/A aid->set_arg_modified(a, v); }
0N/A
0N/A void clear_escape_info() { _eflags = _arg_local = _arg_stack = _arg_returned = 0; }
0N/A
0N/A // Location and size of data area
0N/A address data_base() const {
0N/A return (address) _data;
0N/A }
0N/A int data_size() {
0N/A return _data_size;
0N/A }
0N/A
0N/A // Accessors
0N/A methodOop method() { return _method; }
0N/A
0N/A // Get the data at an arbitrary (sort of) data index.
0N/A ProfileData* data_at(int data_index);
0N/A
0N/A // Walk through the data in order.
0N/A ProfileData* first_data() { return data_at(first_di()); }
0N/A ProfileData* next_data(ProfileData* current);
0N/A bool is_valid(ProfileData* current) { return current != NULL; }
0N/A
0N/A // Convert a dp (data pointer) to a di (data index).
0N/A int dp_to_di(address dp) {
0N/A return dp - ((address)_data);
0N/A }
0N/A
0N/A address di_to_dp(int di) {
0N/A return (address)data_layout_at(di);
0N/A }
0N/A
0N/A // bci to di/dp conversion.
0N/A address bci_to_dp(int bci);
0N/A int bci_to_di(int bci) {
0N/A return dp_to_di(bci_to_dp(bci));
0N/A }
0N/A
0N/A // Get the data at an arbitrary bci, or NULL if there is none.
0N/A ProfileData* bci_to_data(int bci);
0N/A
0N/A // Same, but try to create an extra_data record if one is needed:
0N/A ProfileData* allocate_bci_to_data(int bci) {
0N/A ProfileData* data = bci_to_data(bci);
0N/A return (data != NULL) ? data : bci_to_extra_data(bci, true);
0N/A }
0N/A
0N/A // Add a handful of extra data records, for trap tracking.
0N/A DataLayout* extra_data_base() { return limit_data_position(); }
0N/A DataLayout* extra_data_limit() { return (DataLayout*)((address)this + object_size_in_bytes()); }
0N/A int extra_data_size() { return (address)extra_data_limit()
0N/A - (address)extra_data_base(); }
0N/A static DataLayout* next_extra(DataLayout* dp) { return (DataLayout*)((address)dp + in_bytes(DataLayout::cell_offset(0))); }
0N/A
0N/A // Return (uint)-1 for overflow.
0N/A uint trap_count(int reason) const {
0N/A assert((uint)reason < _trap_hist_limit, "oob");
0N/A return (int)((_trap_hist._array[reason]+1) & _trap_hist_mask) - 1;
0N/A }
0N/A // For loops:
0N/A static uint trap_reason_limit() { return _trap_hist_limit; }
0N/A static uint trap_count_limit() { return _trap_hist_mask; }
0N/A uint inc_trap_count(int reason) {
0N/A // Count another trap, anywhere in this method.
0N/A assert(reason >= 0, "must be single trap");
0N/A if ((uint)reason < _trap_hist_limit) {
0N/A uint cnt1 = 1 + _trap_hist._array[reason];
0N/A if ((cnt1 & _trap_hist_mask) != 0) { // if no counter overflow...
0N/A _trap_hist._array[reason] = cnt1;
0N/A return cnt1;
0N/A } else {
0N/A return _trap_hist_mask + (++_nof_overflow_traps);
0N/A }
0N/A } else {
0N/A // Could not represent the count in the histogram.
0N/A return (++_nof_overflow_traps);
0N/A }
0N/A }
0N/A
0N/A uint overflow_trap_count() const {
0N/A return _nof_overflow_traps;
0N/A }
0N/A uint overflow_recompile_count() const {
0N/A return _nof_overflow_recompiles;
0N/A }
0N/A void inc_overflow_recompile_count() {
0N/A _nof_overflow_recompiles += 1;
0N/A }
0N/A uint decompile_count() const {
0N/A return _nof_decompiles;
0N/A }
0N/A void inc_decompile_count() {
0N/A _nof_decompiles += 1;
1206N/A if (decompile_count() > (uint)PerMethodRecompilationCutoff) {
4316N/A method()->set_not_compilable(CompLevel_full_optimization, true, "decompile_count > PerMethodRecompilationCutoff");
1206N/A }
0N/A }
0N/A
0N/A // Support for code generation
0N/A static ByteSize data_offset() {
0N/A return byte_offset_of(methodDataOopDesc, _data[0]);
0N/A }
0N/A
1703N/A static ByteSize invocation_counter_offset() {
1703N/A return byte_offset_of(methodDataOopDesc, _invocation_counter);
1703N/A }
1703N/A static ByteSize backedge_counter_offset() {
1703N/A return byte_offset_of(methodDataOopDesc, _backedge_counter);
1703N/A }
1703N/A
0N/A // GC support
0N/A oop* adr_method() const { return (oop*)&_method; }
0N/A bool object_is_parsable() const { return _size != 0; }
0N/A void set_object_is_parsable(int object_size_in_bytes) { _size = object_size_in_bytes; }
0N/A
0N/A#ifndef PRODUCT
0N/A // printing support for method data
0N/A void print_data_on(outputStream* st);
0N/A#endif
0N/A
0N/A // verification
0N/A void verify_data_on(outputStream* st);
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_OOPS_METHODDATAOOP_HPP