duke@435: /* acorn@4497: * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #ifndef SHARE_VM_OOPS_METHODDATAOOP_HPP stefank@2314: #define SHARE_VM_OOPS_METHODDATAOOP_HPP stefank@2314: stefank@2314: #include "interpreter/bytecodes.hpp" stefank@2314: #include "memory/universe.hpp" coleenp@4037: #include "oops/method.hpp" stefank@2314: #include "oops/oop.hpp" stefank@2314: #include "runtime/orderAccess.hpp" stefank@2314: duke@435: class BytecodeStream; acorn@4497: class KlassSizeStats; duke@435: duke@435: // The MethodData object collects counts and other profile information duke@435: // during zeroth-tier (interpretive) and first-tier execution. duke@435: // The profile is used later by compilation heuristics. Some heuristics duke@435: // enable use of aggressive (or "heroic") optimizations. An aggressive duke@435: // optimization often has a down-side, a corner case that it handles duke@435: // poorly, but which is thought to be rare. The profile provides duke@435: // evidence of this rarity for a given method or even BCI. It allows duke@435: // the compiler to back out of the optimization at places where it duke@435: // has historically been a poor choice. Other heuristics try to use duke@435: // specific information gathered about types observed at a given site. duke@435: // duke@435: // All data in the profile is approximate. It is expected to be accurate duke@435: // on the whole, but the system expects occasional inaccuraces, due to duke@435: // counter overflow, multiprocessor races during data collection, space duke@435: // limitations, missing MDO blocks, etc. Bad or missing data will degrade duke@435: // optimization quality but will not affect correctness. Also, each MDO duke@435: // is marked with its birth-date ("creation_mileage") which can be used duke@435: // to assess the quality ("maturity") of its data. duke@435: // duke@435: // Short (<32-bit) counters are designed to overflow to a known "saturated" duke@435: // state. Also, certain recorded per-BCI events are given one-bit counters duke@435: // which overflow to a saturated state which applied to all counters at duke@435: // that BCI. In other words, there is a small lattice which approximates duke@435: // the ideal of an infinite-precision counter for each event at each BCI, duke@435: // and the lattice quickly "bottoms out" in a state where all counters duke@435: // are taken to be indefinitely large. duke@435: // duke@435: // The reader will find many data races in profile gathering code, starting duke@435: // with invocation counter incrementation. None of these races harm correct duke@435: // execution of the compiled code. duke@435: ysr@1376: // forward decl ysr@1376: class ProfileData; ysr@1376: duke@435: // DataLayout duke@435: // duke@435: // Overlay for generic profiling data. duke@435: class DataLayout VALUE_OBJ_CLASS_SPEC { twisti@5726: friend class VMStructs; twisti@5726: duke@435: private: duke@435: // Every data layout begins with a header. This header duke@435: // contains a tag, which is used to indicate the size/layout duke@435: // of the data, 4 bits of flags, which can be used in any way, duke@435: // 4 bits of trap history (none/one reason/many reasons), duke@435: // and a bci, which is used to tie this piece of data to a duke@435: // specific bci in the bytecodes. duke@435: union { duke@435: intptr_t _bits; duke@435: struct { duke@435: u1 _tag; duke@435: u1 _flags; duke@435: u2 _bci; duke@435: } _struct; duke@435: } _header; duke@435: duke@435: // The data layout has an arbitrary number of cells, each sized duke@435: // to accomodate a pointer or an integer. duke@435: intptr_t _cells[1]; duke@435: duke@435: // Some types of data layouts need a length field. duke@435: static bool needs_array_len(u1 tag); duke@435: duke@435: public: duke@435: enum { duke@435: counter_increment = 1 duke@435: }; duke@435: duke@435: enum { duke@435: cell_size = sizeof(intptr_t) duke@435: }; duke@435: duke@435: // Tag values duke@435: enum { duke@435: no_tag, duke@435: bit_data_tag, duke@435: counter_data_tag, duke@435: jump_data_tag, duke@435: receiver_type_data_tag, duke@435: virtual_call_data_tag, duke@435: ret_data_tag, duke@435: branch_data_tag, kvn@480: multi_branch_data_tag, roland@5914: arg_info_data_tag, roland@5914: call_type_data_tag, roland@5987: virtual_call_type_data_tag, roland@6377: parameters_type_data_tag, roland@6377: speculative_trap_data_tag duke@435: }; duke@435: duke@435: enum { duke@435: // The _struct._flags word is formatted as [trap_state:4 | flags:4]. duke@435: // The trap state breaks down further as [recompile:1 | reason:3]. duke@435: // This further breakdown is defined in deoptimization.cpp. duke@435: // See Deoptimization::trap_state_reason for an assert that duke@435: // trap_bits is big enough to hold reasons < Reason_RECORDED_LIMIT. duke@435: // duke@435: // The trap_state is collected only if ProfileTraps is true. duke@435: trap_bits = 1+3, // 3: enough to distinguish [0..Reason_RECORDED_LIMIT]. duke@435: trap_shift = BitsPerByte - trap_bits, duke@435: trap_mask = right_n_bits(trap_bits), duke@435: trap_mask_in_place = (trap_mask << trap_shift), duke@435: flag_limit = trap_shift, duke@435: flag_mask = right_n_bits(flag_limit), duke@435: first_flag = 0 duke@435: }; duke@435: duke@435: // Size computation duke@435: static int header_size_in_bytes() { duke@435: return cell_size; duke@435: } duke@435: static int header_size_in_cells() { duke@435: return 1; duke@435: } duke@435: duke@435: static int compute_size_in_bytes(int cell_count) { duke@435: return header_size_in_bytes() + cell_count * cell_size; duke@435: } duke@435: duke@435: // Initialization duke@435: void initialize(u1 tag, u2 bci, int cell_count); duke@435: duke@435: // Accessors duke@435: u1 tag() { duke@435: return _header._struct._tag; duke@435: } duke@435: duke@435: // Return a few bits of trap state. Range is [0..trap_mask]. duke@435: // The state tells if traps with zero, one, or many reasons have occurred. duke@435: // It also tells whether zero or many recompilations have occurred. duke@435: // The associated trap histogram in the MDO itself tells whether duke@435: // traps are common or not. If a BCI shows that a trap X has duke@435: // occurred, and the MDO shows N occurrences of X, we make the duke@435: // simplifying assumption that all N occurrences can be blamed duke@435: // on that BCI. roland@5914: int trap_state() const { duke@435: return ((_header._struct._flags >> trap_shift) & trap_mask); duke@435: } duke@435: duke@435: void set_trap_state(int new_state) { duke@435: assert(ProfileTraps, "used only under +ProfileTraps"); duke@435: uint old_flags = (_header._struct._flags & flag_mask); duke@435: _header._struct._flags = (new_state << trap_shift) | old_flags; duke@435: } duke@435: roland@5914: u1 flags() const { duke@435: return _header._struct._flags; duke@435: } duke@435: roland@5914: u2 bci() const { duke@435: return _header._struct._bci; duke@435: } duke@435: duke@435: void set_header(intptr_t value) { duke@435: _header._bits = value; duke@435: } duke@435: intptr_t header() { duke@435: return _header._bits; duke@435: } duke@435: void set_cell_at(int index, intptr_t value) { duke@435: _cells[index] = value; duke@435: } duke@435: void release_set_cell_at(int index, intptr_t value) { duke@435: OrderAccess::release_store_ptr(&_cells[index], value); duke@435: } roland@5914: intptr_t cell_at(int index) const { duke@435: return _cells[index]; duke@435: } duke@435: duke@435: void set_flag_at(int flag_number) { duke@435: assert(flag_number < flag_limit, "oob"); duke@435: _header._struct._flags |= (0x1 << flag_number); duke@435: } roland@5914: bool flag_at(int flag_number) const { duke@435: assert(flag_number < flag_limit, "oob"); duke@435: return (_header._struct._flags & (0x1 << flag_number)) != 0; duke@435: } duke@435: duke@435: // Low-level support for code generation. duke@435: static ByteSize header_offset() { duke@435: return byte_offset_of(DataLayout, _header); duke@435: } duke@435: static ByteSize tag_offset() { duke@435: return byte_offset_of(DataLayout, _header._struct._tag); duke@435: } duke@435: static ByteSize flags_offset() { duke@435: return byte_offset_of(DataLayout, _header._struct._flags); duke@435: } duke@435: static ByteSize bci_offset() { duke@435: return byte_offset_of(DataLayout, _header._struct._bci); duke@435: } duke@435: static ByteSize cell_offset(int index) { coleenp@2615: return byte_offset_of(DataLayout, _cells) + in_ByteSize(index * cell_size); duke@435: } goetz@6470: #ifdef CC_INTERP goetz@6470: static int cell_offset_in_bytes(int index) { goetz@6470: return (int)offset_of(DataLayout, _cells[index]); goetz@6470: } goetz@6470: #endif // CC_INTERP duke@435: // Return a value which, when or-ed as a byte into _flags, sets the flag. duke@435: static int flag_number_to_byte_constant(int flag_number) { duke@435: assert(0 <= flag_number && flag_number < flag_limit, "oob"); duke@435: DataLayout temp; temp.set_header(0); duke@435: temp.set_flag_at(flag_number); duke@435: return temp._header._struct._flags; duke@435: } duke@435: // Return a value which, when or-ed as a word into _header, sets the flag. duke@435: static intptr_t flag_mask_to_header_mask(int byte_constant) { duke@435: DataLayout temp; temp.set_header(0); duke@435: temp._header._struct._flags = byte_constant; duke@435: return temp._header._bits; duke@435: } ysr@1376: coleenp@4037: ProfileData* data_in(); coleenp@4037: ysr@1376: // GC support coleenp@4037: void clean_weak_klass_links(BoolObjectClosure* cl); duke@435: }; duke@435: duke@435: duke@435: // ProfileData class hierarchy duke@435: class ProfileData; duke@435: class BitData; duke@435: class CounterData; duke@435: class ReceiverTypeData; duke@435: class VirtualCallData; roland@5914: class VirtualCallTypeData; duke@435: class RetData; roland@5914: class CallTypeData; duke@435: class JumpData; duke@435: class BranchData; duke@435: class ArrayData; duke@435: class MultiBranchData; kvn@480: class ArgInfoData; roland@5987: class ParametersTypeData; roland@6377: class SpeculativeTrapData; duke@435: duke@435: // ProfileData duke@435: // duke@435: // A ProfileData object is created to refer to a section of profiling duke@435: // data in a structured way. duke@435: class ProfileData : public ResourceObj { roland@5914: friend class TypeEntries; roland@5921: friend class ReturnTypeEntry; roland@5914: friend class TypeStackSlotEntries; duke@435: private: duke@435: #ifndef PRODUCT duke@435: enum { duke@435: tab_width_one = 16, duke@435: tab_width_two = 36 duke@435: }; duke@435: #endif // !PRODUCT duke@435: duke@435: // This is a pointer to a section of profiling data. duke@435: DataLayout* _data; duke@435: roland@6377: char* print_data_on_helper(const MethodData* md) const; roland@6377: duke@435: protected: duke@435: DataLayout* data() { return _data; } roland@5914: const DataLayout* data() const { return _data; } duke@435: duke@435: enum { duke@435: cell_size = DataLayout::cell_size duke@435: }; duke@435: duke@435: public: duke@435: // How many cells are in this? roland@5914: virtual int cell_count() const { duke@435: ShouldNotReachHere(); duke@435: return -1; duke@435: } duke@435: duke@435: // Return the size of this data. duke@435: int size_in_bytes() { duke@435: return DataLayout::compute_size_in_bytes(cell_count()); duke@435: } duke@435: duke@435: protected: duke@435: // Low-level accessors for underlying data duke@435: void set_intptr_at(int index, intptr_t value) { duke@435: assert(0 <= index && index < cell_count(), "oob"); duke@435: data()->set_cell_at(index, value); duke@435: } duke@435: void release_set_intptr_at(int index, intptr_t value) { duke@435: assert(0 <= index && index < cell_count(), "oob"); duke@435: data()->release_set_cell_at(index, value); duke@435: } roland@5914: intptr_t intptr_at(int index) const { duke@435: assert(0 <= index && index < cell_count(), "oob"); duke@435: return data()->cell_at(index); duke@435: } duke@435: void set_uint_at(int index, uint value) { duke@435: set_intptr_at(index, (intptr_t) value); duke@435: } duke@435: void release_set_uint_at(int index, uint value) { duke@435: release_set_intptr_at(index, (intptr_t) value); duke@435: } roland@5914: uint uint_at(int index) const { duke@435: return (uint)intptr_at(index); duke@435: } duke@435: void set_int_at(int index, int value) { duke@435: set_intptr_at(index, (intptr_t) value); duke@435: } duke@435: void release_set_int_at(int index, int value) { duke@435: release_set_intptr_at(index, (intptr_t) value); duke@435: } roland@5914: int int_at(int index) const { duke@435: return (int)intptr_at(index); duke@435: } roland@5914: int int_at_unchecked(int index) const { duke@435: return (int)data()->cell_at(index); duke@435: } duke@435: void set_oop_at(int index, oop value) { hseigel@5784: set_intptr_at(index, cast_from_oop(value)); duke@435: } roland@5914: oop oop_at(int index) const { hseigel@5784: return cast_to_oop(intptr_at(index)); duke@435: } duke@435: duke@435: void set_flag_at(int flag_number) { duke@435: data()->set_flag_at(flag_number); duke@435: } roland@5914: bool flag_at(int flag_number) const { duke@435: return data()->flag_at(flag_number); duke@435: } duke@435: duke@435: // two convenient imports for use by subclasses: duke@435: static ByteSize cell_offset(int index) { duke@435: return DataLayout::cell_offset(index); duke@435: } duke@435: static int flag_number_to_byte_constant(int flag_number) { duke@435: return DataLayout::flag_number_to_byte_constant(flag_number); duke@435: } duke@435: duke@435: ProfileData(DataLayout* data) { duke@435: _data = data; duke@435: } duke@435: goetz@6470: #ifdef CC_INTERP goetz@6470: // Static low level accessors for DataLayout with ProfileData's semantics. goetz@6470: goetz@6470: static int cell_offset_in_bytes(int index) { goetz@6470: return DataLayout::cell_offset_in_bytes(index); goetz@6470: } goetz@6470: goetz@6470: static void increment_uint_at_no_overflow(DataLayout* layout, int index, goetz@6470: int inc = DataLayout::counter_increment) { goetz@6470: uint count = ((uint)layout->cell_at(index)) + inc; goetz@6470: if (count == 0) return; goetz@6470: layout->set_cell_at(index, (intptr_t) count); goetz@6470: } goetz@6470: goetz@6470: static int int_at(DataLayout* layout, int index) { goetz@6470: return (int)layout->cell_at(index); goetz@6470: } goetz@6470: goetz@6470: static int uint_at(DataLayout* layout, int index) { goetz@6470: return (uint)layout->cell_at(index); goetz@6470: } goetz@6470: goetz@6470: static oop oop_at(DataLayout* layout, int index) { simonis@6483: return cast_to_oop(layout->cell_at(index)); goetz@6470: } goetz@6470: goetz@6470: static void set_intptr_at(DataLayout* layout, int index, intptr_t value) { goetz@6470: layout->set_cell_at(index, (intptr_t) value); goetz@6470: } goetz@6470: goetz@6470: static void set_flag_at(DataLayout* layout, int flag_number) { goetz@6470: layout->set_flag_at(flag_number); goetz@6470: } goetz@6470: #endif // CC_INTERP goetz@6470: duke@435: public: duke@435: // Constructor for invalid ProfileData. duke@435: ProfileData(); duke@435: roland@5914: u2 bci() const { duke@435: return data()->bci(); duke@435: } duke@435: duke@435: address dp() { duke@435: return (address)_data; duke@435: } duke@435: roland@5914: int trap_state() const { duke@435: return data()->trap_state(); duke@435: } duke@435: void set_trap_state(int new_state) { duke@435: data()->set_trap_state(new_state); duke@435: } duke@435: duke@435: // Type checking roland@5914: virtual bool is_BitData() const { return false; } roland@5914: virtual bool is_CounterData() const { return false; } roland@5914: virtual bool is_JumpData() const { return false; } roland@5914: virtual bool is_ReceiverTypeData()const { return false; } roland@5914: virtual bool is_VirtualCallData() const { return false; } roland@5914: virtual bool is_RetData() const { return false; } roland@5914: virtual bool is_BranchData() const { return false; } roland@5914: virtual bool is_ArrayData() const { return false; } roland@5914: virtual bool is_MultiBranchData() const { return false; } roland@5914: virtual bool is_ArgInfoData() const { return false; } roland@5914: virtual bool is_CallTypeData() const { return false; } roland@5914: virtual bool is_VirtualCallTypeData()const { return false; } roland@5987: virtual bool is_ParametersTypeData() const { return false; } roland@6377: virtual bool is_SpeculativeTrapData()const { return false; } kvn@480: duke@435: roland@5914: BitData* as_BitData() const { duke@435: assert(is_BitData(), "wrong type"); duke@435: return is_BitData() ? (BitData*) this : NULL; duke@435: } roland@5914: CounterData* as_CounterData() const { duke@435: assert(is_CounterData(), "wrong type"); duke@435: return is_CounterData() ? (CounterData*) this : NULL; duke@435: } roland@5914: JumpData* as_JumpData() const { duke@435: assert(is_JumpData(), "wrong type"); duke@435: return is_JumpData() ? (JumpData*) this : NULL; duke@435: } roland@5914: ReceiverTypeData* as_ReceiverTypeData() const { duke@435: assert(is_ReceiverTypeData(), "wrong type"); duke@435: return is_ReceiverTypeData() ? (ReceiverTypeData*)this : NULL; duke@435: } roland@5914: VirtualCallData* as_VirtualCallData() const { duke@435: assert(is_VirtualCallData(), "wrong type"); duke@435: return is_VirtualCallData() ? (VirtualCallData*)this : NULL; duke@435: } roland@5914: RetData* as_RetData() const { duke@435: assert(is_RetData(), "wrong type"); duke@435: return is_RetData() ? (RetData*) this : NULL; duke@435: } roland@5914: BranchData* as_BranchData() const { duke@435: assert(is_BranchData(), "wrong type"); duke@435: return is_BranchData() ? (BranchData*) this : NULL; duke@435: } roland@5914: ArrayData* as_ArrayData() const { duke@435: assert(is_ArrayData(), "wrong type"); duke@435: return is_ArrayData() ? (ArrayData*) this : NULL; duke@435: } roland@5914: MultiBranchData* as_MultiBranchData() const { duke@435: assert(is_MultiBranchData(), "wrong type"); duke@435: return is_MultiBranchData() ? (MultiBranchData*)this : NULL; duke@435: } roland@5914: ArgInfoData* as_ArgInfoData() const { kvn@480: assert(is_ArgInfoData(), "wrong type"); kvn@480: return is_ArgInfoData() ? (ArgInfoData*)this : NULL; kvn@480: } roland@5914: CallTypeData* as_CallTypeData() const { roland@5914: assert(is_CallTypeData(), "wrong type"); roland@5914: return is_CallTypeData() ? (CallTypeData*)this : NULL; roland@5914: } roland@5914: VirtualCallTypeData* as_VirtualCallTypeData() const { roland@5914: assert(is_VirtualCallTypeData(), "wrong type"); roland@5914: return is_VirtualCallTypeData() ? (VirtualCallTypeData*)this : NULL; roland@5914: } roland@5987: ParametersTypeData* as_ParametersTypeData() const { roland@5987: assert(is_ParametersTypeData(), "wrong type"); roland@5987: return is_ParametersTypeData() ? (ParametersTypeData*)this : NULL; roland@5987: } roland@6377: SpeculativeTrapData* as_SpeculativeTrapData() const { roland@6377: assert(is_SpeculativeTrapData(), "wrong type"); roland@6377: return is_SpeculativeTrapData() ? (SpeculativeTrapData*)this : NULL; roland@6377: } duke@435: duke@435: duke@435: // Subclass specific initialization coleenp@4037: virtual void post_initialize(BytecodeStream* stream, MethodData* mdo) {} duke@435: duke@435: // GC support coleenp@4037: virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure) {} duke@435: duke@435: // CI translation: ProfileData can represent both MethodDataOop data duke@435: // as well as CIMethodData data. This function is provided for translating duke@435: // an oop in a ProfileData to the ci equivalent. Generally speaking, duke@435: // most ProfileData don't require any translation, so we provide the null duke@435: // translation here, and the required translators are in the ci subclasses. roland@5914: virtual void translate_from(const ProfileData* data) {} duke@435: roland@6377: virtual void print_data_on(outputStream* st, const char* extra = NULL) const { duke@435: ShouldNotReachHere(); duke@435: } duke@435: roland@6377: void print_data_on(outputStream* st, const MethodData* md) const; roland@6377: duke@435: #ifndef PRODUCT roland@6377: void print_shared(outputStream* st, const char* name, const char* extra) const; roland@5914: void tab(outputStream* st, bool first = false) const; duke@435: #endif duke@435: }; duke@435: duke@435: // BitData duke@435: // duke@435: // A BitData holds a flag or two in its header. duke@435: class BitData : public ProfileData { duke@435: protected: duke@435: enum { duke@435: // null_seen: duke@435: // saw a null operand (cast/aastore/instanceof) duke@435: null_seen_flag = DataLayout::first_flag + 0 duke@435: }; duke@435: enum { bit_cell_count = 0 }; // no additional data fields needed. duke@435: public: duke@435: BitData(DataLayout* layout) : ProfileData(layout) { duke@435: } duke@435: roland@5914: virtual bool is_BitData() const { return true; } duke@435: duke@435: static int static_cell_count() { duke@435: return bit_cell_count; duke@435: } duke@435: roland@5914: virtual int cell_count() const { duke@435: return static_cell_count(); duke@435: } duke@435: duke@435: // Accessor duke@435: duke@435: // The null_seen flag bit is specially known to the interpreter. duke@435: // Consulting it allows the compiler to avoid setting up null_check traps. duke@435: bool null_seen() { return flag_at(null_seen_flag); } duke@435: void set_null_seen() { set_flag_at(null_seen_flag); } duke@435: duke@435: duke@435: // Code generation support duke@435: static int null_seen_byte_constant() { duke@435: return flag_number_to_byte_constant(null_seen_flag); duke@435: } duke@435: duke@435: static ByteSize bit_data_size() { duke@435: return cell_offset(bit_cell_count); duke@435: } duke@435: goetz@6470: #ifdef CC_INTERP goetz@6470: static int bit_data_size_in_bytes() { goetz@6470: return cell_offset_in_bytes(bit_cell_count); goetz@6470: } goetz@6470: goetz@6470: static void set_null_seen(DataLayout* layout) { goetz@6470: set_flag_at(layout, null_seen_flag); goetz@6470: } goetz@6470: goetz@6470: static DataLayout* advance(DataLayout* layout) { goetz@6470: return (DataLayout*) (((address)layout) + (ssize_t)BitData::bit_data_size_in_bytes()); goetz@6470: } goetz@6470: #endif // CC_INTERP goetz@6470: duke@435: #ifndef PRODUCT roland@6377: void print_data_on(outputStream* st, const char* extra = NULL) const; duke@435: #endif duke@435: }; duke@435: duke@435: // CounterData duke@435: // duke@435: // A CounterData corresponds to a simple counter. duke@435: class CounterData : public BitData { duke@435: protected: duke@435: enum { duke@435: count_off, duke@435: counter_cell_count duke@435: }; duke@435: public: duke@435: CounterData(DataLayout* layout) : BitData(layout) {} duke@435: roland@5914: virtual bool is_CounterData() const { return true; } duke@435: duke@435: static int static_cell_count() { duke@435: return counter_cell_count; duke@435: } duke@435: roland@5914: virtual int cell_count() const { duke@435: return static_cell_count(); duke@435: } duke@435: duke@435: // Direct accessor roland@5914: uint count() const { duke@435: return uint_at(count_off); duke@435: } duke@435: duke@435: // Code generation support duke@435: static ByteSize count_offset() { duke@435: return cell_offset(count_off); duke@435: } duke@435: static ByteSize counter_data_size() { duke@435: return cell_offset(counter_cell_count); duke@435: } duke@435: kvn@1686: void set_count(uint count) { kvn@1686: set_uint_at(count_off, count); kvn@1686: } kvn@1686: goetz@6470: #ifdef CC_INTERP goetz@6470: static int counter_data_size_in_bytes() { goetz@6470: return cell_offset_in_bytes(counter_cell_count); goetz@6470: } goetz@6470: goetz@6470: static void increment_count_no_overflow(DataLayout* layout) { goetz@6470: increment_uint_at_no_overflow(layout, count_off); goetz@6470: } goetz@6470: goetz@6470: // Support counter decrementation at checkcast / subtype check failed. goetz@6470: static void decrement_count(DataLayout* layout) { goetz@6470: increment_uint_at_no_overflow(layout, count_off, -1); goetz@6470: } goetz@6470: goetz@6470: static DataLayout* advance(DataLayout* layout) { goetz@6470: return (DataLayout*) (((address)layout) + (ssize_t)CounterData::counter_data_size_in_bytes()); goetz@6470: } goetz@6470: #endif // CC_INTERP goetz@6470: duke@435: #ifndef PRODUCT roland@6377: void print_data_on(outputStream* st, const char* extra = NULL) const; duke@435: #endif duke@435: }; duke@435: duke@435: // JumpData duke@435: // duke@435: // A JumpData is used to access profiling information for a direct duke@435: // branch. It is a counter, used for counting the number of branches, duke@435: // plus a data displacement, used for realigning the data pointer to duke@435: // the corresponding target bci. duke@435: class JumpData : public ProfileData { duke@435: protected: duke@435: enum { duke@435: taken_off_set, duke@435: displacement_off_set, duke@435: jump_cell_count duke@435: }; duke@435: duke@435: void set_displacement(int displacement) { duke@435: set_int_at(displacement_off_set, displacement); duke@435: } duke@435: duke@435: public: duke@435: JumpData(DataLayout* layout) : ProfileData(layout) { duke@435: assert(layout->tag() == DataLayout::jump_data_tag || duke@435: layout->tag() == DataLayout::branch_data_tag, "wrong type"); duke@435: } duke@435: roland@5914: virtual bool is_JumpData() const { return true; } duke@435: duke@435: static int static_cell_count() { duke@435: return jump_cell_count; duke@435: } duke@435: roland@5914: virtual int cell_count() const { duke@435: return static_cell_count(); duke@435: } duke@435: duke@435: // Direct accessor roland@5914: uint taken() const { duke@435: return uint_at(taken_off_set); duke@435: } never@3105: never@3105: void set_taken(uint cnt) { never@3105: set_uint_at(taken_off_set, cnt); never@3105: } never@3105: duke@435: // Saturating counter duke@435: uint inc_taken() { duke@435: uint cnt = taken() + 1; duke@435: // Did we wrap? Will compiler screw us?? duke@435: if (cnt == 0) cnt--; duke@435: set_uint_at(taken_off_set, cnt); duke@435: return cnt; duke@435: } duke@435: roland@5914: int displacement() const { duke@435: return int_at(displacement_off_set); duke@435: } duke@435: duke@435: // Code generation support duke@435: static ByteSize taken_offset() { duke@435: return cell_offset(taken_off_set); duke@435: } duke@435: duke@435: static ByteSize displacement_offset() { duke@435: return cell_offset(displacement_off_set); duke@435: } duke@435: goetz@6470: #ifdef CC_INTERP goetz@6470: static void increment_taken_count_no_overflow(DataLayout* layout) { goetz@6470: increment_uint_at_no_overflow(layout, taken_off_set); goetz@6470: } goetz@6470: goetz@6470: static DataLayout* advance_taken(DataLayout* layout) { goetz@6470: return (DataLayout*) (((address)layout) + (ssize_t)int_at(layout, displacement_off_set)); goetz@6470: } goetz@6470: goetz@6470: static uint taken_count(DataLayout* layout) { goetz@6470: return (uint) uint_at(layout, taken_off_set); goetz@6470: } goetz@6470: #endif // CC_INTERP goetz@6470: duke@435: // Specific initialization. coleenp@4037: void post_initialize(BytecodeStream* stream, MethodData* mdo); duke@435: duke@435: #ifndef PRODUCT roland@6377: void print_data_on(outputStream* st, const char* extra = NULL) const; roland@5914: #endif roland@5914: }; roland@5914: roland@5914: // Entries in a ProfileData object to record types: it can either be roland@5914: // none (no profile), unknown (conflicting profile data) or a klass if roland@5914: // a single one is seen. Whether a null reference was seen is also roland@5914: // recorded. No counter is associated with the type and a single type roland@5914: // is tracked (unlike VirtualCallData). roland@5914: class TypeEntries { roland@5914: roland@5914: public: roland@5914: roland@5914: // A single cell is used to record information for a type: roland@5914: // - the cell is initialized to 0 roland@5914: // - when a type is discovered it is stored in the cell roland@5914: // - bit zero of the cell is used to record whether a null reference roland@5914: // was encountered or not roland@5914: // - bit 1 is set to record a conflict in the type information roland@5914: roland@5914: enum { roland@5914: null_seen = 1, roland@5914: type_mask = ~null_seen, roland@5914: type_unknown = 2, roland@5914: status_bits = null_seen | type_unknown, roland@5914: type_klass_mask = ~status_bits roland@5914: }; roland@5914: roland@5914: // what to initialize a cell to roland@5914: static intptr_t type_none() { roland@5914: return 0; roland@5914: } roland@5914: roland@5914: // null seen = bit 0 set? roland@5914: static bool was_null_seen(intptr_t v) { roland@5914: return (v & null_seen) != 0; roland@5914: } roland@5914: roland@5914: // conflicting type information = bit 1 set? roland@5914: static bool is_type_unknown(intptr_t v) { roland@5914: return (v & type_unknown) != 0; roland@5914: } roland@5914: roland@5914: // not type information yet = all bits cleared, ignoring bit 0? roland@5914: static bool is_type_none(intptr_t v) { roland@5914: return (v & type_mask) == 0; roland@5914: } roland@5914: roland@5914: // recorded type: cell without bit 0 and 1 roland@5914: static intptr_t klass_part(intptr_t v) { roland@5914: intptr_t r = v & type_klass_mask; roland@5914: return r; roland@5914: } roland@5914: roland@5914: // type recorded roland@5914: static Klass* valid_klass(intptr_t k) { roland@5914: if (!is_type_none(k) && roland@5914: !is_type_unknown(k)) { roland@6105: Klass* res = (Klass*)klass_part(k); roland@6105: assert(res != NULL, "invalid"); roland@6105: return res; roland@5914: } else { roland@5914: return NULL; roland@5914: } roland@5914: } roland@5914: roland@5914: static intptr_t with_status(intptr_t k, intptr_t in) { roland@5914: return k | (in & status_bits); roland@5914: } roland@5914: roland@5914: static intptr_t with_status(Klass* k, intptr_t in) { roland@5914: return with_status((intptr_t)k, in); roland@5914: } roland@5914: roland@5914: #ifndef PRODUCT roland@5914: static void print_klass(outputStream* st, intptr_t k); roland@5914: #endif roland@5914: roland@5914: // GC support roland@5914: static bool is_loader_alive(BoolObjectClosure* is_alive_cl, intptr_t p); roland@5914: roland@5914: protected: roland@5914: // ProfileData object these entries are part of roland@5914: ProfileData* _pd; roland@5914: // offset within the ProfileData object where the entries start roland@5914: const int _base_off; roland@5914: roland@5914: TypeEntries(int base_off) roland@5914: : _base_off(base_off), _pd(NULL) {} roland@5914: roland@5914: void set_intptr_at(int index, intptr_t value) { roland@5914: _pd->set_intptr_at(index, value); roland@5914: } roland@5914: roland@5914: intptr_t intptr_at(int index) const { roland@5914: return _pd->intptr_at(index); roland@5914: } roland@5914: roland@5914: public: roland@5914: void set_profile_data(ProfileData* pd) { roland@5914: _pd = pd; roland@5914: } roland@5914: }; roland@5914: roland@5914: // Type entries used for arguments passed at a call and parameters on roland@5914: // method entry. 2 cells per entry: one for the type encoded as in roland@5914: // TypeEntries and one initialized with the stack slot where the roland@5914: // profiled object is to be found so that the interpreter can locate roland@5914: // it quickly. roland@5914: class TypeStackSlotEntries : public TypeEntries { roland@5914: roland@5914: private: roland@5914: enum { roland@5914: stack_slot_entry, roland@5914: type_entry, roland@5914: per_arg_cell_count roland@5914: }; roland@5914: roland@5914: // offset of cell for stack slot for entry i within ProfileData object roland@5921: int stack_slot_offset(int i) const { roland@5914: return _base_off + stack_slot_local_offset(i); roland@5914: } roland@5914: roland@5914: protected: roland@5921: const int _number_of_entries; roland@5914: roland@5914: // offset of cell for type for entry i within ProfileData object roland@5921: int type_offset(int i) const { roland@5914: return _base_off + type_local_offset(i); roland@5914: } roland@5914: roland@5914: public: roland@5914: roland@5921: TypeStackSlotEntries(int base_off, int nb_entries) roland@5921: : TypeEntries(base_off), _number_of_entries(nb_entries) {} roland@5914: roland@5987: static int compute_cell_count(Symbol* signature, bool include_receiver, int max); roland@5914: roland@5987: void post_initialize(Symbol* signature, bool has_receiver, bool include_receiver); roland@5914: roland@5914: // offset of cell for stack slot for entry i within this block of cells for a TypeStackSlotEntries roland@5914: static int stack_slot_local_offset(int i) { roland@5921: return i * per_arg_cell_count + stack_slot_entry; roland@5914: } roland@5914: roland@5914: // offset of cell for type for entry i within this block of cells for a TypeStackSlotEntries roland@5914: static int type_local_offset(int i) { roland@5921: return i * per_arg_cell_count + type_entry; roland@5914: } roland@5914: roland@5914: // stack slot for entry i roland@5914: uint stack_slot(int i) const { roland@5921: assert(i >= 0 && i < _number_of_entries, "oob"); roland@5921: return _pd->uint_at(stack_slot_offset(i)); roland@5914: } roland@5914: roland@5914: // set stack slot for entry i roland@5914: void set_stack_slot(int i, uint num) { roland@5921: assert(i >= 0 && i < _number_of_entries, "oob"); roland@5921: _pd->set_uint_at(stack_slot_offset(i), num); roland@5914: } roland@5914: roland@5914: // type for entry i roland@5914: intptr_t type(int i) const { roland@5921: assert(i >= 0 && i < _number_of_entries, "oob"); roland@5921: return _pd->intptr_at(type_offset(i)); roland@5914: } roland@5914: roland@5914: // set type for entry i roland@5914: void set_type(int i, intptr_t k) { roland@5921: assert(i >= 0 && i < _number_of_entries, "oob"); roland@5921: _pd->set_intptr_at(type_offset(i), k); roland@5914: } roland@5914: roland@5914: static ByteSize per_arg_size() { roland@5914: return in_ByteSize(per_arg_cell_count * DataLayout::cell_size); roland@5914: } roland@5914: roland@5914: static int per_arg_count() { roland@5914: return per_arg_cell_count ; roland@5914: } roland@5914: roland@5921: // GC support roland@5921: void clean_weak_klass_links(BoolObjectClosure* is_alive_closure); roland@5914: roland@5921: #ifndef PRODUCT roland@5921: void print_data_on(outputStream* st) const; roland@5921: #endif roland@5921: }; roland@5914: roland@5921: // Type entry used for return from a call. A single cell to record the roland@5921: // type. roland@5921: class ReturnTypeEntry : public TypeEntries { roland@5914: roland@5921: private: roland@5921: enum { roland@5921: cell_count = 1 roland@5921: }; roland@5921: roland@5921: public: roland@5921: ReturnTypeEntry(int base_off) roland@5921: : TypeEntries(base_off) {} roland@5921: roland@5921: void post_initialize() { roland@5921: set_type(type_none()); roland@5921: } roland@5921: roland@5921: intptr_t type() const { roland@5921: return _pd->intptr_at(_base_off); roland@5921: } roland@5921: roland@5921: void set_type(intptr_t k) { roland@5921: _pd->set_intptr_at(_base_off, k); roland@5921: } roland@5921: roland@5921: static int static_cell_count() { roland@5921: return cell_count; roland@5921: } roland@5921: roland@5921: static ByteSize size() { roland@5921: return in_ByteSize(cell_count * DataLayout::cell_size); roland@5921: } roland@5921: roland@5921: ByteSize type_offset() { roland@5921: return DataLayout::cell_offset(_base_off); roland@5921: } roland@5914: roland@5914: // GC support roland@5914: void clean_weak_klass_links(BoolObjectClosure* is_alive_closure); roland@5914: roland@5914: #ifndef PRODUCT roland@5914: void print_data_on(outputStream* st) const; roland@5914: #endif roland@5914: }; roland@5914: roland@5921: // Entries to collect type information at a call: contains arguments roland@5921: // (TypeStackSlotEntries), a return type (ReturnTypeEntry) and a roland@5921: // number of cells. Because the number of cells for the return type is roland@5921: // smaller than the number of cells for the type of an arguments, the roland@5921: // number of cells is used to tell how many arguments are profiled and roland@5921: // whether a return value is profiled. See has_arguments() and roland@5921: // has_return(). roland@5921: class TypeEntriesAtCall { roland@5921: private: roland@5921: static int stack_slot_local_offset(int i) { roland@5921: return header_cell_count() + TypeStackSlotEntries::stack_slot_local_offset(i); roland@5921: } roland@5921: roland@5921: static int argument_type_local_offset(int i) { roland@5921: return header_cell_count() + TypeStackSlotEntries::type_local_offset(i);; roland@5921: } roland@5921: roland@5921: public: roland@5921: roland@5921: static int header_cell_count() { roland@5921: return 1; roland@5921: } roland@5921: roland@5921: static int cell_count_local_offset() { roland@5921: return 0; roland@5921: } roland@5921: roland@5921: static int compute_cell_count(BytecodeStream* stream); roland@5921: roland@5921: static void initialize(DataLayout* dl, int base, int cell_count) { roland@5921: int off = base + cell_count_local_offset(); roland@5921: dl->set_cell_at(off, cell_count - base - header_cell_count()); roland@5921: } roland@5921: roland@5921: static bool arguments_profiling_enabled(); roland@5921: static bool return_profiling_enabled(); roland@5921: roland@5921: // Code generation support roland@5921: static ByteSize cell_count_offset() { roland@5921: return in_ByteSize(cell_count_local_offset() * DataLayout::cell_size); roland@5921: } roland@5921: roland@5921: static ByteSize args_data_offset() { roland@5921: return in_ByteSize(header_cell_count() * DataLayout::cell_size); roland@5921: } roland@5921: roland@5921: static ByteSize stack_slot_offset(int i) { roland@5921: return in_ByteSize(stack_slot_local_offset(i) * DataLayout::cell_size); roland@5921: } roland@5921: roland@5921: static ByteSize argument_type_offset(int i) { roland@5921: return in_ByteSize(argument_type_local_offset(i) * DataLayout::cell_size); roland@5921: } roland@6643: roland@6643: static ByteSize return_only_size() { roland@6643: return ReturnTypeEntry::size() + in_ByteSize(header_cell_count() * DataLayout::cell_size); roland@6643: } roland@6643: roland@5921: }; roland@5921: roland@5914: // CallTypeData roland@5914: // roland@5914: // A CallTypeData is used to access profiling information about a non roland@5921: // virtual call for which we collect type information about arguments roland@5921: // and return value. roland@5914: class CallTypeData : public CounterData { roland@5914: private: roland@5921: // entries for arguments if any roland@5914: TypeStackSlotEntries _args; roland@5921: // entry for return type if any roland@5921: ReturnTypeEntry _ret; roland@5921: roland@5921: int cell_count_global_offset() const { roland@5921: return CounterData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset(); roland@5921: } roland@5921: roland@5921: // number of cells not counting the header roland@5921: int cell_count_no_header() const { roland@5921: return uint_at(cell_count_global_offset()); roland@5921: } roland@5921: roland@5921: void check_number_of_arguments(int total) { roland@5921: assert(number_of_arguments() == total, "should be set in DataLayout::initialize"); roland@5921: } roland@5921: roland@5914: public: roland@5914: CallTypeData(DataLayout* layout) : roland@5921: CounterData(layout), roland@5921: _args(CounterData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()), roland@5921: _ret(cell_count() - ReturnTypeEntry::static_cell_count()) roland@5921: { roland@5914: assert(layout->tag() == DataLayout::call_type_data_tag, "wrong type"); roland@5914: // Some compilers (VC++) don't want this passed in member initialization list roland@5914: _args.set_profile_data(this); roland@5921: _ret.set_profile_data(this); roland@5914: } roland@5914: roland@5921: const TypeStackSlotEntries* args() const { roland@5921: assert(has_arguments(), "no profiling of arguments"); roland@5921: return &_args; roland@5921: } roland@5921: roland@5921: const ReturnTypeEntry* ret() const { roland@5921: assert(has_return(), "no profiling of return value"); roland@5921: return &_ret; roland@5921: } roland@5914: roland@5914: virtual bool is_CallTypeData() const { return true; } roland@5914: roland@5914: static int static_cell_count() { roland@5914: return -1; roland@5914: } roland@5914: roland@5914: static int compute_cell_count(BytecodeStream* stream) { roland@5921: return CounterData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream); roland@5914: } roland@5914: roland@5914: static void initialize(DataLayout* dl, int cell_count) { roland@5921: TypeEntriesAtCall::initialize(dl, CounterData::static_cell_count(), cell_count); roland@5914: } roland@5914: roland@5921: virtual void post_initialize(BytecodeStream* stream, MethodData* mdo); roland@5921: roland@5921: virtual int cell_count() const { roland@5921: return CounterData::static_cell_count() + roland@5921: TypeEntriesAtCall::header_cell_count() + roland@5921: int_at_unchecked(cell_count_global_offset()); roland@5914: } roland@5914: roland@5921: int number_of_arguments() const { roland@5921: return cell_count_no_header() / TypeStackSlotEntries::per_arg_count(); roland@5914: } roland@5914: roland@5914: void set_argument_type(int i, Klass* k) { roland@5921: assert(has_arguments(), "no arguments!"); roland@5914: intptr_t current = _args.type(i); roland@5914: _args.set_type(i, TypeEntries::with_status(k, current)); roland@5914: } roland@5914: roland@5921: void set_return_type(Klass* k) { roland@5921: assert(has_return(), "no return!"); roland@5921: intptr_t current = _ret.type(); roland@5921: _ret.set_type(TypeEntries::with_status(k, current)); roland@5921: } roland@5921: roland@5921: // An entry for a return value takes less space than an entry for an roland@5987: // argument so if the number of cells exceeds the number of cells roland@5987: // needed for an argument, this object contains type information for roland@5987: // at least one argument. roland@5987: bool has_arguments() const { roland@5987: bool res = cell_count_no_header() >= TypeStackSlotEntries::per_arg_count(); roland@5987: assert (!res || TypeEntriesAtCall::arguments_profiling_enabled(), "no profiling of arguments"); roland@5987: return res; roland@5987: } roland@5987: roland@5987: // An entry for a return value takes less space than an entry for an roland@5921: // argument, so if the remainder of the number of cells divided by roland@5921: // the number of cells for an argument is not null, a return value roland@5921: // is profiled in this object. roland@5921: bool has_return() const { roland@5921: bool res = (cell_count_no_header() % TypeStackSlotEntries::per_arg_count()) != 0; roland@5921: assert (!res || TypeEntriesAtCall::return_profiling_enabled(), "no profiling of return values"); roland@5921: return res; roland@5921: } roland@5921: roland@5914: // Code generation support roland@5914: static ByteSize args_data_offset() { roland@5921: return cell_offset(CounterData::static_cell_count()) + TypeEntriesAtCall::args_data_offset(); roland@5914: } roland@5914: roland@5914: // GC support roland@5914: virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure) { roland@5921: if (has_arguments()) { roland@5921: _args.clean_weak_klass_links(is_alive_closure); roland@5921: } roland@5921: if (has_return()) { roland@5921: _ret.clean_weak_klass_links(is_alive_closure); roland@5921: } roland@5914: } roland@5914: roland@5914: #ifndef PRODUCT roland@6377: virtual void print_data_on(outputStream* st, const char* extra = NULL) const; duke@435: #endif duke@435: }; duke@435: duke@435: // ReceiverTypeData duke@435: // duke@435: // A ReceiverTypeData is used to access profiling information about a duke@435: // dynamic type check. It consists of a counter which counts the total times coleenp@4037: // that the check is reached, and a series of (Klass*, count) pairs duke@435: // which are used to store a type profile for the receiver of the check. duke@435: class ReceiverTypeData : public CounterData { duke@435: protected: duke@435: enum { duke@435: receiver0_offset = counter_cell_count, duke@435: count0_offset, duke@435: receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset duke@435: }; duke@435: duke@435: public: duke@435: ReceiverTypeData(DataLayout* layout) : CounterData(layout) { duke@435: assert(layout->tag() == DataLayout::receiver_type_data_tag || roland@5914: layout->tag() == DataLayout::virtual_call_data_tag || roland@5914: layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type"); duke@435: } duke@435: roland@5914: virtual bool is_ReceiverTypeData() const { return true; } duke@435: duke@435: static int static_cell_count() { duke@435: return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count; duke@435: } duke@435: roland@5914: virtual int cell_count() const { duke@435: return static_cell_count(); duke@435: } duke@435: duke@435: // Direct accessors duke@435: static uint row_limit() { duke@435: return TypeProfileWidth; duke@435: } duke@435: static int receiver_cell_index(uint row) { duke@435: return receiver0_offset + row * receiver_type_row_cell_count; duke@435: } duke@435: static int receiver_count_cell_index(uint row) { duke@435: return count0_offset + row * receiver_type_row_cell_count; duke@435: } duke@435: roland@5914: Klass* receiver(uint row) const { duke@435: assert(row < row_limit(), "oob"); duke@435: coleenp@4037: Klass* recv = (Klass*)intptr_at(receiver_cell_index(row)); coleenp@4037: assert(recv == NULL || recv->is_klass(), "wrong type"); duke@435: return recv; duke@435: } duke@435: coleenp@4037: void set_receiver(uint row, Klass* k) { ysr@1376: assert((uint)row < row_limit(), "oob"); coleenp@4037: set_intptr_at(receiver_cell_index(row), (uintptr_t)k); ysr@1376: } ysr@1376: roland@5914: uint receiver_count(uint row) const { duke@435: assert(row < row_limit(), "oob"); duke@435: return uint_at(receiver_count_cell_index(row)); duke@435: } duke@435: ysr@1376: void set_receiver_count(uint row, uint count) { ysr@1376: assert(row < row_limit(), "oob"); ysr@1376: set_uint_at(receiver_count_cell_index(row), count); ysr@1376: } ysr@1376: ysr@1376: void clear_row(uint row) { ysr@1376: assert(row < row_limit(), "oob"); kvn@1686: // Clear total count - indicator of polymorphic call site. kvn@1686: // The site may look like as monomorphic after that but kvn@1686: // it allow to have more accurate profiling information because kvn@1686: // there was execution phase change since klasses were unloaded. kvn@1686: // If the site is still polymorphic then MDO will be updated kvn@1686: // to reflect it. But it could be the case that the site becomes kvn@1686: // only bimorphic. Then keeping total count not 0 will be wrong. kvn@1686: // Even if we use monomorphic (when it is not) for compilation kvn@1686: // we will only have trap, deoptimization and recompile again kvn@1686: // with updated MDO after executing method in Interpreter. kvn@1686: // An additional receiver will be recorded in the cleaned row kvn@1686: // during next call execution. kvn@1686: // kvn@1686: // Note: our profiling logic works with empty rows in any slot. kvn@1686: // We do sorting a profiling info (ciCallProfile) for compilation. kvn@1686: // kvn@1686: set_count(0); ysr@1376: set_receiver(row, NULL); ysr@1376: set_receiver_count(row, 0); ysr@1376: } ysr@1376: duke@435: // Code generation support duke@435: static ByteSize receiver_offset(uint row) { duke@435: return cell_offset(receiver_cell_index(row)); duke@435: } duke@435: static ByteSize receiver_count_offset(uint row) { duke@435: return cell_offset(receiver_count_cell_index(row)); duke@435: } duke@435: static ByteSize receiver_type_data_size() { duke@435: return cell_offset(static_cell_count()); duke@435: } duke@435: duke@435: // GC support coleenp@4037: virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure); duke@435: goetz@6470: #ifdef CC_INTERP goetz@6470: static int receiver_type_data_size_in_bytes() { goetz@6470: return cell_offset_in_bytes(static_cell_count()); goetz@6470: } goetz@6470: goetz@6470: static Klass *receiver_unchecked(DataLayout* layout, uint row) { simonis@6483: Klass* recv = (Klass*)layout->cell_at(receiver_cell_index(row)); simonis@6483: return recv; goetz@6470: } goetz@6470: goetz@6470: static void increment_receiver_count_no_overflow(DataLayout* layout, Klass *rcvr) { goetz@6470: const int num_rows = row_limit(); goetz@6470: // Receiver already exists? goetz@6470: for (int row = 0; row < num_rows; row++) { goetz@6470: if (receiver_unchecked(layout, row) == rcvr) { goetz@6470: increment_uint_at_no_overflow(layout, receiver_count_cell_index(row)); goetz@6470: return; goetz@6470: } goetz@6470: } goetz@6470: // New receiver, find a free slot. goetz@6470: for (int row = 0; row < num_rows; row++) { goetz@6470: if (receiver_unchecked(layout, row) == NULL) { goetz@6470: set_intptr_at(layout, receiver_cell_index(row), (intptr_t)rcvr); goetz@6470: increment_uint_at_no_overflow(layout, receiver_count_cell_index(row)); goetz@6470: return; goetz@6470: } goetz@6470: } goetz@6470: // Receiver did not match any saved receiver and there is no empty row for it. goetz@6470: // Increment total counter to indicate polymorphic case. goetz@6470: increment_count_no_overflow(layout); goetz@6470: } goetz@6470: goetz@6470: static DataLayout* advance(DataLayout* layout) { goetz@6470: return (DataLayout*) (((address)layout) + (ssize_t)ReceiverTypeData::receiver_type_data_size_in_bytes()); goetz@6470: } goetz@6470: #endif // CC_INTERP goetz@6470: duke@435: #ifndef PRODUCT roland@5914: void print_receiver_data_on(outputStream* st) const; roland@6377: void print_data_on(outputStream* st, const char* extra = NULL) const; duke@435: #endif duke@435: }; duke@435: duke@435: // VirtualCallData duke@435: // duke@435: // A VirtualCallData is used to access profiling information about a duke@435: // virtual call. For now, it has nothing more than a ReceiverTypeData. duke@435: class VirtualCallData : public ReceiverTypeData { duke@435: public: duke@435: VirtualCallData(DataLayout* layout) : ReceiverTypeData(layout) { roland@5914: assert(layout->tag() == DataLayout::virtual_call_data_tag || roland@5914: layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type"); duke@435: } duke@435: roland@5914: virtual bool is_VirtualCallData() const { return true; } duke@435: duke@435: static int static_cell_count() { duke@435: // At this point we could add more profile state, e.g., for arguments. duke@435: // But for now it's the same size as the base record type. duke@435: return ReceiverTypeData::static_cell_count(); duke@435: } duke@435: roland@5914: virtual int cell_count() const { duke@435: return static_cell_count(); duke@435: } duke@435: duke@435: // Direct accessors duke@435: static ByteSize virtual_call_data_size() { duke@435: return cell_offset(static_cell_count()); duke@435: } duke@435: goetz@6470: #ifdef CC_INTERP goetz@6470: static int virtual_call_data_size_in_bytes() { goetz@6470: return cell_offset_in_bytes(static_cell_count()); goetz@6470: } goetz@6470: goetz@6470: static DataLayout* advance(DataLayout* layout) { goetz@6470: return (DataLayout*) (((address)layout) + (ssize_t)VirtualCallData::virtual_call_data_size_in_bytes()); goetz@6470: } goetz@6470: #endif // CC_INTERP goetz@6470: duke@435: #ifndef PRODUCT roland@6377: void print_data_on(outputStream* st, const char* extra = NULL) const; roland@5914: #endif roland@5914: }; roland@5914: roland@5914: // VirtualCallTypeData roland@5914: // roland@5914: // A VirtualCallTypeData is used to access profiling information about roland@5914: // a virtual call for which we collect type information about roland@5921: // arguments and return value. roland@5914: class VirtualCallTypeData : public VirtualCallData { roland@5914: private: roland@5921: // entries for arguments if any roland@5914: TypeStackSlotEntries _args; roland@5921: // entry for return type if any roland@5921: ReturnTypeEntry _ret; roland@5921: roland@5921: int cell_count_global_offset() const { roland@5921: return VirtualCallData::static_cell_count() + TypeEntriesAtCall::cell_count_local_offset(); roland@5921: } roland@5921: roland@5921: // number of cells not counting the header roland@5921: int cell_count_no_header() const { roland@5921: return uint_at(cell_count_global_offset()); roland@5921: } roland@5921: roland@5921: void check_number_of_arguments(int total) { roland@5921: assert(number_of_arguments() == total, "should be set in DataLayout::initialize"); roland@5921: } roland@5921: roland@5914: public: roland@5914: VirtualCallTypeData(DataLayout* layout) : roland@5921: VirtualCallData(layout), roland@5921: _args(VirtualCallData::static_cell_count()+TypeEntriesAtCall::header_cell_count(), number_of_arguments()), roland@5921: _ret(cell_count() - ReturnTypeEntry::static_cell_count()) roland@5921: { roland@5914: assert(layout->tag() == DataLayout::virtual_call_type_data_tag, "wrong type"); roland@5914: // Some compilers (VC++) don't want this passed in member initialization list roland@5914: _args.set_profile_data(this); roland@5921: _ret.set_profile_data(this); roland@5914: } roland@5914: roland@5921: const TypeStackSlotEntries* args() const { roland@5921: assert(has_arguments(), "no profiling of arguments"); roland@5921: return &_args; roland@5921: } roland@5921: roland@5921: const ReturnTypeEntry* ret() const { roland@5921: assert(has_return(), "no profiling of return value"); roland@5921: return &_ret; roland@5921: } roland@5914: roland@5914: virtual bool is_VirtualCallTypeData() const { return true; } roland@5914: roland@5914: static int static_cell_count() { roland@5914: return -1; roland@5914: } roland@5914: roland@5914: static int compute_cell_count(BytecodeStream* stream) { roland@5921: return VirtualCallData::static_cell_count() + TypeEntriesAtCall::compute_cell_count(stream); roland@5914: } roland@5914: roland@5914: static void initialize(DataLayout* dl, int cell_count) { roland@5921: TypeEntriesAtCall::initialize(dl, VirtualCallData::static_cell_count(), cell_count); roland@5914: } roland@5914: roland@5921: virtual void post_initialize(BytecodeStream* stream, MethodData* mdo); roland@5921: roland@5921: virtual int cell_count() const { roland@5921: return VirtualCallData::static_cell_count() + roland@5921: TypeEntriesAtCall::header_cell_count() + roland@5921: int_at_unchecked(cell_count_global_offset()); roland@5914: } roland@5914: roland@5921: int number_of_arguments() const { roland@5921: return cell_count_no_header() / TypeStackSlotEntries::per_arg_count(); roland@5914: } roland@5914: roland@5914: void set_argument_type(int i, Klass* k) { roland@5921: assert(has_arguments(), "no arguments!"); roland@5914: intptr_t current = _args.type(i); roland@5914: _args.set_type(i, TypeEntries::with_status(k, current)); roland@5914: } roland@5914: roland@5921: void set_return_type(Klass* k) { roland@5921: assert(has_return(), "no return!"); roland@5921: intptr_t current = _ret.type(); roland@5921: _ret.set_type(TypeEntries::with_status(k, current)); roland@5921: } roland@5921: roland@5921: // An entry for a return value takes less space than an entry for an roland@5921: // argument, so if the remainder of the number of cells divided by roland@5921: // the number of cells for an argument is not null, a return value roland@5921: // is profiled in this object. roland@5921: bool has_return() const { roland@5921: bool res = (cell_count_no_header() % TypeStackSlotEntries::per_arg_count()) != 0; roland@5921: assert (!res || TypeEntriesAtCall::return_profiling_enabled(), "no profiling of return values"); roland@5921: return res; roland@5921: } roland@5921: roland@5987: // An entry for a return value takes less space than an entry for an roland@5987: // argument so if the number of cells exceeds the number of cells roland@5987: // needed for an argument, this object contains type information for roland@5987: // at least one argument. roland@5987: bool has_arguments() const { roland@5987: bool res = cell_count_no_header() >= TypeStackSlotEntries::per_arg_count(); roland@5987: assert (!res || TypeEntriesAtCall::arguments_profiling_enabled(), "no profiling of arguments"); roland@5987: return res; roland@5987: } roland@5987: roland@5914: // Code generation support roland@5914: static ByteSize args_data_offset() { roland@5921: return cell_offset(VirtualCallData::static_cell_count()) + TypeEntriesAtCall::args_data_offset(); roland@5914: } roland@5914: roland@5914: // GC support roland@5914: virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure) { roland@5914: ReceiverTypeData::clean_weak_klass_links(is_alive_closure); roland@5921: if (has_arguments()) { roland@5921: _args.clean_weak_klass_links(is_alive_closure); roland@5921: } roland@5921: if (has_return()) { roland@5921: _ret.clean_weak_klass_links(is_alive_closure); roland@5921: } roland@5914: } roland@5914: roland@5914: #ifndef PRODUCT roland@6377: virtual void print_data_on(outputStream* st, const char* extra = NULL) const; duke@435: #endif duke@435: }; duke@435: duke@435: // RetData duke@435: // duke@435: // A RetData is used to access profiling information for a ret bytecode. duke@435: // It is composed of a count of the number of times that the ret has duke@435: // been executed, followed by a series of triples of the form duke@435: // (bci, count, di) which count the number of times that some bci was the duke@435: // target of the ret and cache a corresponding data displacement. duke@435: class RetData : public CounterData { duke@435: protected: duke@435: enum { duke@435: bci0_offset = counter_cell_count, duke@435: count0_offset, duke@435: displacement0_offset, duke@435: ret_row_cell_count = (displacement0_offset + 1) - bci0_offset duke@435: }; duke@435: duke@435: void set_bci(uint row, int bci) { duke@435: assert((uint)row < row_limit(), "oob"); duke@435: set_int_at(bci0_offset + row * ret_row_cell_count, bci); duke@435: } duke@435: void release_set_bci(uint row, int bci) { duke@435: assert((uint)row < row_limit(), "oob"); duke@435: // 'release' when setting the bci acts as a valid flag for other duke@435: // threads wrt bci_count and bci_displacement. duke@435: release_set_int_at(bci0_offset + row * ret_row_cell_count, bci); duke@435: } duke@435: void set_bci_count(uint row, uint count) { duke@435: assert((uint)row < row_limit(), "oob"); duke@435: set_uint_at(count0_offset + row * ret_row_cell_count, count); duke@435: } duke@435: void set_bci_displacement(uint row, int disp) { duke@435: set_int_at(displacement0_offset + row * ret_row_cell_count, disp); duke@435: } duke@435: duke@435: public: duke@435: RetData(DataLayout* layout) : CounterData(layout) { duke@435: assert(layout->tag() == DataLayout::ret_data_tag, "wrong type"); duke@435: } duke@435: roland@5914: virtual bool is_RetData() const { return true; } duke@435: duke@435: enum { duke@435: no_bci = -1 // value of bci when bci1/2 are not in use. duke@435: }; duke@435: duke@435: static int static_cell_count() { duke@435: return counter_cell_count + (uint) BciProfileWidth * ret_row_cell_count; duke@435: } duke@435: roland@5914: virtual int cell_count() const { duke@435: return static_cell_count(); duke@435: } duke@435: duke@435: static uint row_limit() { duke@435: return BciProfileWidth; duke@435: } duke@435: static int bci_cell_index(uint row) { duke@435: return bci0_offset + row * ret_row_cell_count; duke@435: } duke@435: static int bci_count_cell_index(uint row) { duke@435: return count0_offset + row * ret_row_cell_count; duke@435: } duke@435: static int bci_displacement_cell_index(uint row) { duke@435: return displacement0_offset + row * ret_row_cell_count; duke@435: } duke@435: duke@435: // Direct accessors roland@5914: int bci(uint row) const { duke@435: return int_at(bci_cell_index(row)); duke@435: } roland@5914: uint bci_count(uint row) const { duke@435: return uint_at(bci_count_cell_index(row)); duke@435: } roland@5914: int bci_displacement(uint row) const { duke@435: return int_at(bci_displacement_cell_index(row)); duke@435: } duke@435: duke@435: // Interpreter Runtime support coleenp@4037: address fixup_ret(int return_bci, MethodData* mdo); duke@435: duke@435: // Code generation support duke@435: static ByteSize bci_offset(uint row) { duke@435: return cell_offset(bci_cell_index(row)); duke@435: } duke@435: static ByteSize bci_count_offset(uint row) { duke@435: return cell_offset(bci_count_cell_index(row)); duke@435: } duke@435: static ByteSize bci_displacement_offset(uint row) { duke@435: return cell_offset(bci_displacement_cell_index(row)); duke@435: } duke@435: goetz@6470: #ifdef CC_INTERP goetz@6470: static DataLayout* advance(MethodData *md, int bci); goetz@6470: #endif // CC_INTERP goetz@6470: duke@435: // Specific initialization. coleenp@4037: void post_initialize(BytecodeStream* stream, MethodData* mdo); duke@435: duke@435: #ifndef PRODUCT roland@6377: void print_data_on(outputStream* st, const char* extra = NULL) const; duke@435: #endif duke@435: }; duke@435: duke@435: // BranchData duke@435: // duke@435: // A BranchData is used to access profiling data for a two-way branch. duke@435: // It consists of taken and not_taken counts as well as a data displacement duke@435: // for the taken case. duke@435: class BranchData : public JumpData { duke@435: protected: duke@435: enum { duke@435: not_taken_off_set = jump_cell_count, duke@435: branch_cell_count duke@435: }; duke@435: duke@435: void set_displacement(int displacement) { duke@435: set_int_at(displacement_off_set, displacement); duke@435: } duke@435: duke@435: public: duke@435: BranchData(DataLayout* layout) : JumpData(layout) { duke@435: assert(layout->tag() == DataLayout::branch_data_tag, "wrong type"); duke@435: } duke@435: roland@5914: virtual bool is_BranchData() const { return true; } duke@435: duke@435: static int static_cell_count() { duke@435: return branch_cell_count; duke@435: } duke@435: roland@5914: virtual int cell_count() const { duke@435: return static_cell_count(); duke@435: } duke@435: duke@435: // Direct accessor roland@5914: uint not_taken() const { duke@435: return uint_at(not_taken_off_set); duke@435: } duke@435: never@3105: void set_not_taken(uint cnt) { never@3105: set_uint_at(not_taken_off_set, cnt); never@3105: } never@3105: duke@435: uint inc_not_taken() { duke@435: uint cnt = not_taken() + 1; duke@435: // Did we wrap? Will compiler screw us?? duke@435: if (cnt == 0) cnt--; duke@435: set_uint_at(not_taken_off_set, cnt); duke@435: return cnt; duke@435: } duke@435: duke@435: // Code generation support duke@435: static ByteSize not_taken_offset() { duke@435: return cell_offset(not_taken_off_set); duke@435: } duke@435: static ByteSize branch_data_size() { duke@435: return cell_offset(branch_cell_count); duke@435: } duke@435: goetz@6470: #ifdef CC_INTERP goetz@6470: static int branch_data_size_in_bytes() { goetz@6470: return cell_offset_in_bytes(branch_cell_count); goetz@6470: } goetz@6470: goetz@6470: static void increment_not_taken_count_no_overflow(DataLayout* layout) { goetz@6470: increment_uint_at_no_overflow(layout, not_taken_off_set); goetz@6470: } goetz@6470: goetz@6470: static DataLayout* advance_not_taken(DataLayout* layout) { goetz@6470: return (DataLayout*) (((address)layout) + (ssize_t)BranchData::branch_data_size_in_bytes()); goetz@6470: } goetz@6470: #endif // CC_INTERP goetz@6470: duke@435: // Specific initialization. coleenp@4037: void post_initialize(BytecodeStream* stream, MethodData* mdo); duke@435: duke@435: #ifndef PRODUCT roland@6377: void print_data_on(outputStream* st, const char* extra = NULL) const; duke@435: #endif duke@435: }; duke@435: duke@435: // ArrayData duke@435: // duke@435: // A ArrayData is a base class for accessing profiling data which does duke@435: // not have a statically known size. It consists of an array length duke@435: // and an array start. duke@435: class ArrayData : public ProfileData { duke@435: protected: duke@435: friend class DataLayout; duke@435: duke@435: enum { duke@435: array_len_off_set, duke@435: array_start_off_set duke@435: }; duke@435: roland@5914: uint array_uint_at(int index) const { duke@435: int aindex = index + array_start_off_set; duke@435: return uint_at(aindex); duke@435: } roland@5914: int array_int_at(int index) const { duke@435: int aindex = index + array_start_off_set; duke@435: return int_at(aindex); duke@435: } roland@5914: oop array_oop_at(int index) const { duke@435: int aindex = index + array_start_off_set; duke@435: return oop_at(aindex); duke@435: } duke@435: void array_set_int_at(int index, int value) { duke@435: int aindex = index + array_start_off_set; duke@435: set_int_at(aindex, value); duke@435: } duke@435: goetz@6470: #ifdef CC_INTERP goetz@6470: // Static low level accessors for DataLayout with ArrayData's semantics. goetz@6470: goetz@6470: static void increment_array_uint_at_no_overflow(DataLayout* layout, int index) { goetz@6470: int aindex = index + array_start_off_set; goetz@6470: increment_uint_at_no_overflow(layout, aindex); goetz@6470: } goetz@6470: goetz@6470: static int array_int_at(DataLayout* layout, int index) { goetz@6470: int aindex = index + array_start_off_set; goetz@6470: return int_at(layout, aindex); goetz@6470: } goetz@6470: #endif // CC_INTERP goetz@6470: duke@435: // Code generation support for subclasses. duke@435: static ByteSize array_element_offset(int index) { duke@435: return cell_offset(array_start_off_set + index); duke@435: } duke@435: duke@435: public: duke@435: ArrayData(DataLayout* layout) : ProfileData(layout) {} duke@435: roland@5914: virtual bool is_ArrayData() const { return true; } duke@435: duke@435: static int static_cell_count() { duke@435: return -1; duke@435: } duke@435: roland@5914: int array_len() const { duke@435: return int_at_unchecked(array_len_off_set); duke@435: } duke@435: roland@5914: virtual int cell_count() const { duke@435: return array_len() + 1; duke@435: } duke@435: duke@435: // Code generation support duke@435: static ByteSize array_len_offset() { duke@435: return cell_offset(array_len_off_set); duke@435: } duke@435: static ByteSize array_start_offset() { duke@435: return cell_offset(array_start_off_set); duke@435: } duke@435: }; duke@435: duke@435: // MultiBranchData duke@435: // duke@435: // A MultiBranchData is used to access profiling information for duke@435: // a multi-way branch (*switch bytecodes). It consists of a series duke@435: // of (count, displacement) pairs, which count the number of times each duke@435: // case was taken and specify the data displacment for each branch target. duke@435: class MultiBranchData : public ArrayData { duke@435: protected: duke@435: enum { duke@435: default_count_off_set, duke@435: default_disaplacement_off_set, duke@435: case_array_start duke@435: }; duke@435: enum { duke@435: relative_count_off_set, duke@435: relative_displacement_off_set, duke@435: per_case_cell_count duke@435: }; duke@435: duke@435: void set_default_displacement(int displacement) { duke@435: array_set_int_at(default_disaplacement_off_set, displacement); duke@435: } duke@435: void set_displacement_at(int index, int displacement) { duke@435: array_set_int_at(case_array_start + duke@435: index * per_case_cell_count + duke@435: relative_displacement_off_set, duke@435: displacement); duke@435: } duke@435: duke@435: public: duke@435: MultiBranchData(DataLayout* layout) : ArrayData(layout) { duke@435: assert(layout->tag() == DataLayout::multi_branch_data_tag, "wrong type"); duke@435: } duke@435: roland@5914: virtual bool is_MultiBranchData() const { return true; } duke@435: duke@435: static int compute_cell_count(BytecodeStream* stream); duke@435: roland@5914: int number_of_cases() const { duke@435: int alen = array_len() - 2; // get rid of default case here. duke@435: assert(alen % per_case_cell_count == 0, "must be even"); duke@435: return (alen / per_case_cell_count); duke@435: } duke@435: roland@5914: uint default_count() const { duke@435: return array_uint_at(default_count_off_set); duke@435: } roland@5914: int default_displacement() const { duke@435: return array_int_at(default_disaplacement_off_set); duke@435: } duke@435: roland@5914: uint count_at(int index) const { duke@435: return array_uint_at(case_array_start + duke@435: index * per_case_cell_count + duke@435: relative_count_off_set); duke@435: } roland@5914: int displacement_at(int index) const { duke@435: return array_int_at(case_array_start + duke@435: index * per_case_cell_count + duke@435: relative_displacement_off_set); duke@435: } duke@435: duke@435: // Code generation support duke@435: static ByteSize default_count_offset() { duke@435: return array_element_offset(default_count_off_set); duke@435: } duke@435: static ByteSize default_displacement_offset() { duke@435: return array_element_offset(default_disaplacement_off_set); duke@435: } duke@435: static ByteSize case_count_offset(int index) { duke@435: return case_array_offset() + duke@435: (per_case_size() * index) + duke@435: relative_count_offset(); duke@435: } duke@435: static ByteSize case_array_offset() { duke@435: return array_element_offset(case_array_start); duke@435: } duke@435: static ByteSize per_case_size() { duke@435: return in_ByteSize(per_case_cell_count) * cell_size; duke@435: } duke@435: static ByteSize relative_count_offset() { duke@435: return in_ByteSize(relative_count_off_set) * cell_size; duke@435: } duke@435: static ByteSize relative_displacement_offset() { duke@435: return in_ByteSize(relative_displacement_off_set) * cell_size; duke@435: } duke@435: goetz@6470: #ifdef CC_INTERP goetz@6470: static void increment_count_no_overflow(DataLayout* layout, int index) { goetz@6470: if (index == -1) { goetz@6470: increment_array_uint_at_no_overflow(layout, default_count_off_set); goetz@6470: } else { goetz@6470: increment_array_uint_at_no_overflow(layout, case_array_start + goetz@6470: index * per_case_cell_count + goetz@6470: relative_count_off_set); goetz@6470: } goetz@6470: } goetz@6470: goetz@6470: static DataLayout* advance(DataLayout* layout, int index) { goetz@6470: if (index == -1) { goetz@6470: return (DataLayout*) (((address)layout) + (ssize_t)array_int_at(layout, default_disaplacement_off_set)); goetz@6470: } else { goetz@6470: return (DataLayout*) (((address)layout) + (ssize_t)array_int_at(layout, case_array_start + goetz@6470: index * per_case_cell_count + goetz@6470: relative_displacement_off_set)); goetz@6470: } goetz@6470: } goetz@6470: #endif // CC_INTERP goetz@6470: duke@435: // Specific initialization. coleenp@4037: void post_initialize(BytecodeStream* stream, MethodData* mdo); duke@435: duke@435: #ifndef PRODUCT roland@6377: void print_data_on(outputStream* st, const char* extra = NULL) const; duke@435: #endif duke@435: }; duke@435: kvn@480: class ArgInfoData : public ArrayData { kvn@480: kvn@480: public: kvn@480: ArgInfoData(DataLayout* layout) : ArrayData(layout) { kvn@480: assert(layout->tag() == DataLayout::arg_info_data_tag, "wrong type"); kvn@480: } kvn@480: roland@5914: virtual bool is_ArgInfoData() const { return true; } kvn@480: kvn@480: roland@5914: int number_of_args() const { kvn@480: return array_len(); kvn@480: } kvn@480: roland@5914: uint arg_modified(int arg) const { kvn@480: return array_uint_at(arg); kvn@480: } kvn@480: kvn@480: void set_arg_modified(int arg, uint val) { kvn@480: array_set_int_at(arg, val); kvn@480: } kvn@480: kvn@480: #ifndef PRODUCT roland@6377: void print_data_on(outputStream* st, const char* extra = NULL) const; kvn@480: #endif kvn@480: }; kvn@480: roland@5987: // ParametersTypeData roland@5987: // roland@5987: // A ParametersTypeData is used to access profiling information about roland@5987: // types of parameters to a method roland@5987: class ParametersTypeData : public ArrayData { roland@5987: roland@5987: private: roland@5987: TypeStackSlotEntries _parameters; roland@5987: roland@5987: static int stack_slot_local_offset(int i) { roland@5987: assert_profiling_enabled(); roland@5987: return array_start_off_set + TypeStackSlotEntries::stack_slot_local_offset(i); roland@5987: } roland@5987: roland@5987: static int type_local_offset(int i) { roland@5987: assert_profiling_enabled(); roland@5987: return array_start_off_set + TypeStackSlotEntries::type_local_offset(i); roland@5987: } roland@5987: roland@5987: static bool profiling_enabled(); roland@5987: static void assert_profiling_enabled() { roland@5987: assert(profiling_enabled(), "method parameters profiling should be on"); roland@5987: } roland@5987: roland@5987: public: roland@5987: ParametersTypeData(DataLayout* layout) : ArrayData(layout), _parameters(1, number_of_parameters()) { roland@5987: assert(layout->tag() == DataLayout::parameters_type_data_tag, "wrong type"); roland@5987: // Some compilers (VC++) don't want this passed in member initialization list roland@5987: _parameters.set_profile_data(this); roland@5987: } roland@5987: roland@5987: static int compute_cell_count(Method* m); roland@5987: roland@5987: virtual bool is_ParametersTypeData() const { return true; } roland@5987: roland@5987: virtual void post_initialize(BytecodeStream* stream, MethodData* mdo); roland@5987: roland@5987: int number_of_parameters() const { roland@5987: return array_len() / TypeStackSlotEntries::per_arg_count(); roland@5987: } roland@5987: roland@5987: const TypeStackSlotEntries* parameters() const { return &_parameters; } roland@5987: roland@5987: uint stack_slot(int i) const { roland@5987: return _parameters.stack_slot(i); roland@5987: } roland@5987: roland@5987: void set_type(int i, Klass* k) { roland@5987: intptr_t current = _parameters.type(i); roland@5987: _parameters.set_type(i, TypeEntries::with_status((intptr_t)k, current)); roland@5987: } roland@5987: roland@5987: virtual void clean_weak_klass_links(BoolObjectClosure* is_alive_closure) { roland@5987: _parameters.clean_weak_klass_links(is_alive_closure); roland@5987: } roland@5987: roland@5987: #ifndef PRODUCT roland@6377: virtual void print_data_on(outputStream* st, const char* extra = NULL) const; roland@5987: #endif roland@5987: roland@5987: static ByteSize stack_slot_offset(int i) { roland@5987: return cell_offset(stack_slot_local_offset(i)); roland@5987: } roland@5987: roland@5987: static ByteSize type_offset(int i) { roland@5987: return cell_offset(type_local_offset(i)); roland@5987: } roland@5987: }; roland@5987: roland@6377: // SpeculativeTrapData roland@6377: // roland@6377: // A SpeculativeTrapData is used to record traps due to type roland@6377: // speculation. It records the root of the compilation: that type roland@6377: // speculation is wrong in the context of one compilation (for roland@6377: // method1) doesn't mean it's wrong in the context of another one (for roland@6377: // method2). Type speculation could have more/different data in the roland@6377: // context of the compilation of method2 and it's worthwhile to try an roland@6377: // optimization that failed for compilation of method1 in the context roland@6377: // of compilation of method2. roland@6377: // Space for SpeculativeTrapData entries is allocated from the extra roland@6377: // data space in the MDO. If we run out of space, the trap data for roland@6377: // the ProfileData at that bci is updated. roland@6377: class SpeculativeTrapData : public ProfileData { roland@6377: protected: roland@6377: enum { roland@6377: method_offset, roland@6377: speculative_trap_cell_count roland@6377: }; roland@6377: public: roland@6377: SpeculativeTrapData(DataLayout* layout) : ProfileData(layout) { roland@6377: assert(layout->tag() == DataLayout::speculative_trap_data_tag, "wrong type"); roland@6377: } roland@6377: roland@6377: virtual bool is_SpeculativeTrapData() const { return true; } roland@6377: roland@6377: static int static_cell_count() { roland@6377: return speculative_trap_cell_count; roland@6377: } roland@6377: roland@6377: virtual int cell_count() const { roland@6377: return static_cell_count(); roland@6377: } roland@6377: roland@6377: // Direct accessor roland@6377: Method* method() const { roland@6377: return (Method*)intptr_at(method_offset); roland@6377: } roland@6377: roland@6377: void set_method(Method* m) { roland@6377: set_intptr_at(method_offset, (intptr_t)m); roland@6377: } roland@6377: roland@6377: #ifndef PRODUCT roland@6377: virtual void print_data_on(outputStream* st, const char* extra = NULL) const; roland@6377: #endif roland@6377: }; roland@6377: coleenp@4037: // MethodData* duke@435: // coleenp@4037: // A MethodData* holds information which has been collected about duke@435: // a method. Its layout looks like this: duke@435: // duke@435: // ----------------------------- duke@435: // | header | duke@435: // | klass | duke@435: // ----------------------------- duke@435: // | method | coleenp@4037: // | size of the MethodData* | duke@435: // ----------------------------- duke@435: // | Data entries... | duke@435: // | (variable size) | duke@435: // | | duke@435: // . . duke@435: // . . duke@435: // . . duke@435: // | | duke@435: // ----------------------------- duke@435: // duke@435: // The data entry area is a heterogeneous array of DataLayouts. Each duke@435: // DataLayout in the array corresponds to a specific bytecode in the duke@435: // method. The entries in the array are sorted by the corresponding duke@435: // bytecode. Access to the data is via resource-allocated ProfileData, duke@435: // which point to the underlying blocks of DataLayout structures. duke@435: // duke@435: // During interpretation, if profiling in enabled, the interpreter duke@435: // maintains a method data pointer (mdp), which points at the entry duke@435: // in the array corresponding to the current bci. In the course of duke@435: // intepretation, when a bytecode is encountered that has profile data duke@435: // associated with it, the entry pointed to by mdp is updated, then the duke@435: // mdp is adjusted to point to the next appropriate DataLayout. If mdp duke@435: // is NULL to begin with, the interpreter assumes that the current method duke@435: // is not (yet) being profiled. duke@435: // coleenp@4037: // In MethodData* parlance, "dp" is a "data pointer", the actual address duke@435: // of a DataLayout element. A "di" is a "data index", the offset in bytes duke@435: // from the base of the data entry array. A "displacement" is the byte offset duke@435: // in certain ProfileData objects that indicate the amount the mdp must be duke@435: // adjusted in the event of a change in control flow. duke@435: // duke@435: goetz@6470: CC_INTERP_ONLY(class BytecodeInterpreter;) goetz@6470: coleenp@4037: class MethodData : public Metadata { duke@435: friend class VMStructs; goetz@6470: CC_INTERP_ONLY(friend class BytecodeInterpreter;) duke@435: private: duke@435: friend class ProfileData; duke@435: coleenp@4037: // Back pointer to the Method* coleenp@4037: Method* _method; duke@435: duke@435: // Size of this oop in bytes duke@435: int _size; duke@435: duke@435: // Cached hint for bci_to_dp and bci_to_data duke@435: int _hint_di; duke@435: roland@6382: Mutex _extra_data_lock; roland@6382: coleenp@4037: MethodData(methodHandle method, int size, TRAPS); coleenp@4037: public: coleenp@4037: static MethodData* allocate(ClassLoaderData* loader_data, methodHandle method, TRAPS); roland@6382: MethodData() : _extra_data_lock(Monitor::leaf, "MDO extra data lock") {}; // For ciMethodData coleenp@4037: coleenp@4037: bool is_methodData() const volatile { return true; } coleenp@4037: duke@435: // Whole-method sticky bits and flags duke@435: enum { rbackman@7153: _trap_hist_limit = 20, // decoupled from Deoptimization::Reason_LIMIT duke@435: _trap_hist_mask = max_jubyte, duke@435: _extra_data_count = 4 // extra DataLayout headers, for trap history duke@435: }; // Public flag values duke@435: private: duke@435: uint _nof_decompiles; // count of all nmethod removals duke@435: uint _nof_overflow_recompiles; // recompile count, excluding recomp. bits duke@435: uint _nof_overflow_traps; // trap count, excluding _trap_hist duke@435: union { duke@435: intptr_t _align; duke@435: u1 _array[_trap_hist_limit]; duke@435: } _trap_hist; duke@435: duke@435: // Support for interprocedural escape analysis, from Thomas Kotzmann. duke@435: intx _eflags; // flags on escape information duke@435: intx _arg_local; // bit set of non-escaping arguments duke@435: intx _arg_stack; // bit set of stack-allocatable arguments duke@435: intx _arg_returned; // bit set of returned arguments duke@435: iveresov@2138: int _creation_mileage; // method mileage at MDO creation iveresov@2138: iveresov@2138: // How many invocations has this MDO seen? iveresov@2138: // These counters are used to determine the exact age of MDO. iveresov@2138: // We need those because in tiered a method can be concurrently iveresov@2138: // executed at different levels. iveresov@2138: InvocationCounter _invocation_counter; iveresov@2138: // Same for backedges. iveresov@2138: InvocationCounter _backedge_counter; iveresov@2559: // Counter values at the time profiling started. iveresov@2559: int _invocation_counter_start; iveresov@2559: int _backedge_counter_start; kvn@6429: kvn@6429: #if INCLUDE_RTM_OPT kvn@6429: // State of RTM code generation during compilation of the method kvn@6429: int _rtm_state; kvn@6429: #endif kvn@6429: iveresov@2138: // Number of loops and blocks is computed when compiling the first iveresov@2138: // time with C1. It is used to determine if method is trivial. iveresov@2138: short _num_loops; iveresov@2138: short _num_blocks; iveresov@2138: // Does this method contain anything worth profiling? thartmann@7365: enum WouldProfile {unknown, no_profile, profile}; thartmann@7365: WouldProfile _would_profile; duke@435: duke@435: // Size of _data array in bytes. (Excludes header and extra_data fields.) duke@435: int _data_size; duke@435: roland@5987: // data index for the area dedicated to parameters. -1 if no roland@5987: // parameter profiling. roland@5987: int _parameters_type_data_di; roland@5987: duke@435: // Beginning of the data entries duke@435: intptr_t _data[1]; duke@435: duke@435: // Helper for size computation duke@435: static int compute_data_size(BytecodeStream* stream); duke@435: static int bytecode_cell_count(Bytecodes::Code code); roland@6377: static bool is_speculative_trap_bytecode(Bytecodes::Code code); duke@435: enum { no_profile_data = -1, variable_cell_count = -2 }; duke@435: duke@435: // Helper for initialization coleenp@4037: DataLayout* data_layout_at(int data_index) const { duke@435: assert(data_index % sizeof(intptr_t) == 0, "unaligned"); duke@435: return (DataLayout*) (((address)_data) + data_index); duke@435: } duke@435: duke@435: // Initialize an individual data segment. Returns the size of duke@435: // the segment in bytes. duke@435: int initialize_data(BytecodeStream* stream, int data_index); duke@435: duke@435: // Helper for data_at coleenp@4037: DataLayout* limit_data_position() const { duke@435: return (DataLayout*)((address)data_base() + _data_size); duke@435: } coleenp@4037: bool out_of_bounds(int data_index) const { duke@435: return data_index >= data_size(); duke@435: } duke@435: duke@435: // Give each of the data entries a chance to perform specific duke@435: // data initialization. duke@435: void post_initialize(BytecodeStream* stream); duke@435: duke@435: // hint accessors duke@435: int hint_di() const { return _hint_di; } duke@435: void set_hint_di(int di) { duke@435: assert(!out_of_bounds(di), "hint_di out of bounds"); duke@435: _hint_di = di; duke@435: } duke@435: ProfileData* data_before(int bci) { duke@435: // avoid SEGV on this edge case duke@435: if (data_size() == 0) duke@435: return NULL; duke@435: int hint = hint_di(); duke@435: if (data_layout_at(hint)->bci() <= bci) duke@435: return data_at(hint); duke@435: return first_data(); duke@435: } duke@435: duke@435: // What is the index of the first data entry? coleenp@4037: int first_di() const { return 0; } duke@435: roland@6382: ProfileData* bci_to_extra_data_helper(int bci, Method* m, DataLayout*& dp, bool concurrent); duke@435: // Find or create an extra ProfileData: roland@6377: ProfileData* bci_to_extra_data(int bci, Method* m, bool create_if_missing); duke@435: kvn@480: // return the argument info cell kvn@480: ArgInfoData *arg_info(); kvn@480: roland@5914: enum { roland@5914: no_type_profile = 0, roland@5914: type_profile_jsr292 = 1, roland@5914: type_profile_all = 2 roland@5914: }; roland@5914: roland@5914: static bool profile_jsr292(methodHandle m, int bci); roland@5914: static int profile_arguments_flag(); roland@5914: static bool profile_all_arguments(); roland@5914: static bool profile_arguments_for_invoke(methodHandle m, int bci); roland@5921: static int profile_return_flag(); roland@5921: static bool profile_all_return(); roland@5921: static bool profile_return_for_invoke(methodHandle m, int bci); roland@5987: static int profile_parameters_flag(); roland@5987: static bool profile_parameters_jsr292_only(); roland@5987: static bool profile_all_parameters(); roland@5914: roland@6377: void clean_extra_data(BoolObjectClosure* is_alive); roland@6377: void clean_extra_data_helper(DataLayout* dp, int shift, bool reset = false); roland@6377: void verify_extra_data_clean(BoolObjectClosure* is_alive); roland@6377: duke@435: public: duke@435: static int header_size() { coleenp@4037: return sizeof(MethodData)/wordSize; duke@435: } duke@435: coleenp@4037: // Compute the size of a MethodData* before it is created. duke@435: static int compute_allocation_size_in_bytes(methodHandle method); duke@435: static int compute_allocation_size_in_words(methodHandle method); roland@6377: static int compute_extra_data_count(int data_size, int empty_bc_count, bool needs_speculative_traps); duke@435: duke@435: // Determine if a given bytecode can have profile information. duke@435: static bool bytecode_has_profile(Bytecodes::Code code) { duke@435: return bytecode_cell_count(code) != no_profile_data; duke@435: } duke@435: iignatyev@4908: // reset into original state iignatyev@4908: void init(); duke@435: duke@435: // My size coleenp@4037: int size_in_bytes() const { return _size; } coleenp@4037: int size() const { return align_object_size(align_size_up(_size, BytesPerWord)/BytesPerWord); } acorn@4497: #if INCLUDE_SERVICES acorn@4497: void collect_statistics(KlassSizeStats *sz) const; acorn@4497: #endif duke@435: duke@435: int creation_mileage() const { return _creation_mileage; } duke@435: void set_creation_mileage(int x) { _creation_mileage = x; } iveresov@2138: iveresov@2138: int invocation_count() { iveresov@2138: if (invocation_counter()->carry()) { iveresov@2138: return InvocationCounter::count_limit; iveresov@2138: } iveresov@2138: return invocation_counter()->count(); iveresov@2138: } iveresov@2138: int backedge_count() { iveresov@2138: if (backedge_counter()->carry()) { iveresov@2138: return InvocationCounter::count_limit; iveresov@2138: } iveresov@2138: return backedge_counter()->count(); iveresov@2138: } iveresov@2138: iveresov@2559: int invocation_count_start() { iveresov@2559: if (invocation_counter()->carry()) { iveresov@2559: return 0; iveresov@2559: } iveresov@2559: return _invocation_counter_start; iveresov@2559: } iveresov@2559: iveresov@2559: int backedge_count_start() { iveresov@2559: if (backedge_counter()->carry()) { iveresov@2559: return 0; iveresov@2559: } iveresov@2559: return _backedge_counter_start; iveresov@2559: } iveresov@2559: iveresov@2559: int invocation_count_delta() { return invocation_count() - invocation_count_start(); } iveresov@2559: int backedge_count_delta() { return backedge_count() - backedge_count_start(); } iveresov@2559: iveresov@2559: void reset_start_counters() { iveresov@2559: _invocation_counter_start = invocation_count(); iveresov@2559: _backedge_counter_start = backedge_count(); iveresov@2559: } iveresov@2559: iveresov@2138: InvocationCounter* invocation_counter() { return &_invocation_counter; } iveresov@2138: InvocationCounter* backedge_counter() { return &_backedge_counter; } iveresov@2138: kvn@6429: #if INCLUDE_RTM_OPT kvn@6429: int rtm_state() const { kvn@6429: return _rtm_state; kvn@6429: } kvn@6429: void set_rtm_state(RTMState rstate) { kvn@6429: _rtm_state = (int)rstate; kvn@6429: } kvn@6429: void atomic_set_rtm_state(RTMState rstate) { kvn@6429: Atomic::store((int)rstate, &_rtm_state); kvn@6429: } kvn@6429: kvn@6429: static int rtm_state_offset_in_bytes() { kvn@6429: return offset_of(MethodData, _rtm_state); kvn@6429: } kvn@6429: #endif kvn@6429: thartmann@7365: void set_would_profile(bool p) { _would_profile = p ? profile : no_profile; } thartmann@7365: bool would_profile() const { return _would_profile != no_profile; } iveresov@2138: iveresov@2138: int num_loops() const { return _num_loops; } iveresov@2138: void set_num_loops(int n) { _num_loops = n; } iveresov@2138: int num_blocks() const { return _num_blocks; } iveresov@2138: void set_num_blocks(int n) { _num_blocks = n; } iveresov@2138: duke@435: bool is_mature() const; // consult mileage and ProfileMaturityPercentage coleenp@4037: static int mileage_of(Method* m); duke@435: duke@435: // Support for interprocedural escape analysis, from Thomas Kotzmann. duke@435: enum EscapeFlag { duke@435: estimated = 1 << 0, kvn@513: return_local = 1 << 1, kvn@513: return_allocated = 1 << 2, kvn@513: allocated_escapes = 1 << 3, kvn@513: unknown_modified = 1 << 4 duke@435: }; duke@435: duke@435: intx eflags() { return _eflags; } duke@435: intx arg_local() { return _arg_local; } duke@435: intx arg_stack() { return _arg_stack; } duke@435: intx arg_returned() { return _arg_returned; } kvn@480: uint arg_modified(int a) { ArgInfoData *aid = arg_info(); iignatyev@4908: assert(aid != NULL, "arg_info must be not null"); kvn@480: assert(a >= 0 && a < aid->number_of_args(), "valid argument number"); kvn@480: return aid->arg_modified(a); } duke@435: duke@435: void set_eflags(intx v) { _eflags = v; } duke@435: void set_arg_local(intx v) { _arg_local = v; } duke@435: void set_arg_stack(intx v) { _arg_stack = v; } duke@435: void set_arg_returned(intx v) { _arg_returned = v; } kvn@480: void set_arg_modified(int a, uint v) { ArgInfoData *aid = arg_info(); iignatyev@4908: assert(aid != NULL, "arg_info must be not null"); kvn@480: assert(a >= 0 && a < aid->number_of_args(), "valid argument number"); kvn@480: aid->set_arg_modified(a, v); } duke@435: duke@435: void clear_escape_info() { _eflags = _arg_local = _arg_stack = _arg_returned = 0; } duke@435: duke@435: // Location and size of data area duke@435: address data_base() const { duke@435: return (address) _data; duke@435: } coleenp@4037: int data_size() const { duke@435: return _data_size; duke@435: } duke@435: duke@435: // Accessors coleenp@4037: Method* method() const { return _method; } duke@435: duke@435: // Get the data at an arbitrary (sort of) data index. coleenp@4037: ProfileData* data_at(int data_index) const; duke@435: duke@435: // Walk through the data in order. coleenp@4037: ProfileData* first_data() const { return data_at(first_di()); } coleenp@4037: ProfileData* next_data(ProfileData* current) const; coleenp@4037: bool is_valid(ProfileData* current) const { return current != NULL; } duke@435: duke@435: // Convert a dp (data pointer) to a di (data index). coleenp@4037: int dp_to_di(address dp) const { duke@435: return dp - ((address)_data); duke@435: } duke@435: duke@435: address di_to_dp(int di) { duke@435: return (address)data_layout_at(di); duke@435: } duke@435: duke@435: // bci to di/dp conversion. duke@435: address bci_to_dp(int bci); duke@435: int bci_to_di(int bci) { duke@435: return dp_to_di(bci_to_dp(bci)); duke@435: } duke@435: duke@435: // Get the data at an arbitrary bci, or NULL if there is none. duke@435: ProfileData* bci_to_data(int bci); duke@435: duke@435: // Same, but try to create an extra_data record if one is needed: roland@6377: ProfileData* allocate_bci_to_data(int bci, Method* m) { roland@6377: ProfileData* data = NULL; roland@6377: // If m not NULL, try to allocate a SpeculativeTrapData entry roland@6377: if (m == NULL) { roland@6377: data = bci_to_data(bci); roland@6377: } roland@6377: if (data != NULL) { roland@6377: return data; roland@6377: } roland@6377: data = bci_to_extra_data(bci, m, true); roland@6377: if (data != NULL) { roland@6377: return data; roland@6377: } roland@6377: // If SpeculativeTrapData allocation fails try to allocate a roland@6377: // regular entry roland@6377: data = bci_to_data(bci); roland@6377: if (data != NULL) { roland@6377: return data; roland@6377: } roland@6377: return bci_to_extra_data(bci, NULL, true); duke@435: } duke@435: duke@435: // Add a handful of extra data records, for trap tracking. coleenp@4037: DataLayout* extra_data_base() const { return limit_data_position(); } coleenp@4037: DataLayout* extra_data_limit() const { return (DataLayout*)((address)this + size_in_bytes()); } coleenp@4037: int extra_data_size() const { return (address)extra_data_limit() duke@435: - (address)extra_data_base(); } roland@6377: static DataLayout* next_extra(DataLayout* dp); duke@435: duke@435: // Return (uint)-1 for overflow. duke@435: uint trap_count(int reason) const { duke@435: assert((uint)reason < _trap_hist_limit, "oob"); duke@435: return (int)((_trap_hist._array[reason]+1) & _trap_hist_mask) - 1; duke@435: } duke@435: // For loops: duke@435: static uint trap_reason_limit() { return _trap_hist_limit; } duke@435: static uint trap_count_limit() { return _trap_hist_mask; } duke@435: uint inc_trap_count(int reason) { duke@435: // Count another trap, anywhere in this method. duke@435: assert(reason >= 0, "must be single trap"); duke@435: if ((uint)reason < _trap_hist_limit) { duke@435: uint cnt1 = 1 + _trap_hist._array[reason]; duke@435: if ((cnt1 & _trap_hist_mask) != 0) { // if no counter overflow... duke@435: _trap_hist._array[reason] = cnt1; duke@435: return cnt1; duke@435: } else { duke@435: return _trap_hist_mask + (++_nof_overflow_traps); duke@435: } duke@435: } else { duke@435: // Could not represent the count in the histogram. duke@435: return (++_nof_overflow_traps); duke@435: } duke@435: } duke@435: duke@435: uint overflow_trap_count() const { duke@435: return _nof_overflow_traps; duke@435: } duke@435: uint overflow_recompile_count() const { duke@435: return _nof_overflow_recompiles; duke@435: } duke@435: void inc_overflow_recompile_count() { duke@435: _nof_overflow_recompiles += 1; duke@435: } duke@435: uint decompile_count() const { duke@435: return _nof_decompiles; duke@435: } duke@435: void inc_decompile_count() { duke@435: _nof_decompiles += 1; kvn@1641: if (decompile_count() > (uint)PerMethodRecompilationCutoff) { vlivanov@4539: method()->set_not_compilable(CompLevel_full_optimization, true, "decompile_count > PerMethodRecompilationCutoff"); kvn@1641: } duke@435: } duke@435: roland@5987: // Return pointer to area dedicated to parameters in MDO roland@5987: ParametersTypeData* parameters_type_data() const { roland@5987: return _parameters_type_data_di != -1 ? data_layout_at(_parameters_type_data_di)->data_in()->as_ParametersTypeData() : NULL; roland@5987: } roland@5987: roland@5987: int parameters_type_data_di() const { roland@5987: assert(_parameters_type_data_di != -1, "no args type data"); roland@5987: return _parameters_type_data_di; roland@5987: } roland@5987: duke@435: // Support for code generation duke@435: static ByteSize data_offset() { coleenp@4037: return byte_offset_of(MethodData, _data[0]); duke@435: } duke@435: iveresov@2138: static ByteSize invocation_counter_offset() { coleenp@4037: return byte_offset_of(MethodData, _invocation_counter); iveresov@2138: } iveresov@2138: static ByteSize backedge_counter_offset() { coleenp@4037: return byte_offset_of(MethodData, _backedge_counter); iveresov@2138: } iveresov@2138: roland@5987: static ByteSize parameters_type_data_di_offset() { roland@5987: return byte_offset_of(MethodData, _parameters_type_data_di); roland@5987: } roland@5987: coleenp@4037: // Deallocation support - no pointer fields to deallocate coleenp@4037: void deallocate_contents(ClassLoaderData* loader_data) {} coleenp@4037: duke@435: // GC support coleenp@4037: void set_size(int object_size_in_bytes) { _size = object_size_in_bytes; } coleenp@4037: coleenp@4037: // Printing coleenp@4037: #ifndef PRODUCT coleenp@4037: void print_on (outputStream* st) const; coleenp@4037: #endif coleenp@4037: void print_value_on(outputStream* st) const; duke@435: duke@435: #ifndef PRODUCT duke@435: // printing support for method data coleenp@4037: void print_data_on(outputStream* st) const; duke@435: #endif duke@435: coleenp@4037: const char* internal_name() const { return "{method data}"; } coleenp@4037: duke@435: // verification coleenp@4037: void verify_on(outputStream* st); duke@435: void verify_data_on(outputStream* st); roland@5914: roland@5987: static bool profile_parameters_for_method(methodHandle m); roland@5914: static bool profile_arguments(); roland@6643: static bool profile_arguments_jsr292_only(); roland@5921: static bool profile_return(); roland@5987: static bool profile_parameters(); roland@5921: static bool profile_return_jsr292_only(); roland@6377: roland@6377: void clean_method_data(BoolObjectClosure* is_alive); duke@435: }; stefank@2314: stefank@2314: #endif // SHARE_VM_OOPS_METHODDATAOOP_HPP