src/share/vm/ci/ciMethodData.hpp

Wed, 12 Oct 2011 21:00:13 -0700

author
twisti
date
Wed, 12 Oct 2011 21:00:13 -0700
changeset 3197
5eb9169b1a14
parent 2903
fabcf26ee72f
child 4037
da91efe96a93
permissions
-rw-r--r--

7092712: JSR 292: unloaded invokedynamic call sites can lead to a crash with signature types not on BCP
Reviewed-by: jrose, never

duke@435 1 /*
twisti@2903 2 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_CI_CIMETHODDATA_HPP
stefank@2314 26 #define SHARE_VM_CI_CIMETHODDATA_HPP
stefank@2314 27
stefank@2314 28 #include "ci/ciClassList.hpp"
stefank@2314 29 #include "ci/ciKlass.hpp"
stefank@2314 30 #include "ci/ciObject.hpp"
stefank@2314 31 #include "ci/ciUtilities.hpp"
stefank@2314 32 #include "oops/methodDataOop.hpp"
stefank@2314 33 #include "oops/oop.inline.hpp"
stefank@2314 34
duke@435 35 class ciBitData;
duke@435 36 class ciCounterData;
duke@435 37 class ciJumpData;
duke@435 38 class ciReceiverTypeData;
duke@435 39 class ciRetData;
duke@435 40 class ciBranchData;
duke@435 41 class ciArrayData;
duke@435 42 class ciMultiBranchData;
kvn@480 43 class ciArgInfoData;
duke@435 44
duke@435 45 typedef ProfileData ciProfileData;
duke@435 46
duke@435 47 class ciBitData : public BitData {
duke@435 48 public:
duke@435 49 ciBitData(DataLayout* layout) : BitData(layout) {};
duke@435 50 };
duke@435 51
duke@435 52 class ciCounterData : public CounterData {
duke@435 53 public:
duke@435 54 ciCounterData(DataLayout* layout) : CounterData(layout) {};
duke@435 55 };
duke@435 56
duke@435 57 class ciJumpData : public JumpData {
duke@435 58 public:
duke@435 59 ciJumpData(DataLayout* layout) : JumpData(layout) {};
duke@435 60 };
duke@435 61
duke@435 62 class ciReceiverTypeData : public ReceiverTypeData {
duke@435 63 public:
duke@435 64 ciReceiverTypeData(DataLayout* layout) : ReceiverTypeData(layout) {};
duke@435 65
duke@435 66 void set_receiver(uint row, ciKlass* recv) {
duke@435 67 assert((uint)row < row_limit(), "oob");
duke@435 68 set_intptr_at(receiver0_offset + row * receiver_type_row_cell_count,
duke@435 69 (intptr_t) recv);
duke@435 70 }
duke@435 71
duke@435 72 ciKlass* receiver(uint row) {
duke@435 73 assert((uint)row < row_limit(), "oob");
duke@435 74 ciObject* recv = (ciObject*)intptr_at(receiver0_offset + row * receiver_type_row_cell_count);
duke@435 75 assert(recv == NULL || recv->is_klass(), "wrong type");
duke@435 76 return (ciKlass*)recv;
duke@435 77 }
duke@435 78
duke@435 79 // Copy & translate from oop based ReceiverTypeData
duke@435 80 virtual void translate_from(ProfileData* data) {
duke@435 81 translate_receiver_data_from(data);
duke@435 82 }
duke@435 83 void translate_receiver_data_from(ProfileData* data);
duke@435 84 #ifndef PRODUCT
duke@435 85 void print_data_on(outputStream* st);
duke@435 86 void print_receiver_data_on(outputStream* st);
duke@435 87 #endif
duke@435 88 };
duke@435 89
duke@435 90 class ciVirtualCallData : public VirtualCallData {
duke@435 91 // Fake multiple inheritance... It's a ciReceiverTypeData also.
duke@435 92 ciReceiverTypeData* rtd_super() { return (ciReceiverTypeData*) this; }
duke@435 93
duke@435 94 public:
duke@435 95 ciVirtualCallData(DataLayout* layout) : VirtualCallData(layout) {};
duke@435 96
duke@435 97 void set_receiver(uint row, ciKlass* recv) {
duke@435 98 rtd_super()->set_receiver(row, recv);
duke@435 99 }
duke@435 100
duke@435 101 ciKlass* receiver(uint row) {
duke@435 102 return rtd_super()->receiver(row);
duke@435 103 }
duke@435 104
duke@435 105 // Copy & translate from oop based VirtualCallData
duke@435 106 virtual void translate_from(ProfileData* data) {
duke@435 107 rtd_super()->translate_receiver_data_from(data);
duke@435 108 }
duke@435 109 #ifndef PRODUCT
duke@435 110 void print_data_on(outputStream* st);
duke@435 111 #endif
duke@435 112 };
duke@435 113
duke@435 114
duke@435 115 class ciRetData : public RetData {
duke@435 116 public:
duke@435 117 ciRetData(DataLayout* layout) : RetData(layout) {};
duke@435 118 };
duke@435 119
duke@435 120 class ciBranchData : public BranchData {
duke@435 121 public:
duke@435 122 ciBranchData(DataLayout* layout) : BranchData(layout) {};
duke@435 123 };
duke@435 124
duke@435 125 class ciArrayData : public ArrayData {
duke@435 126 public:
duke@435 127 ciArrayData(DataLayout* layout) : ArrayData(layout) {};
duke@435 128 };
duke@435 129
duke@435 130 class ciMultiBranchData : public MultiBranchData {
duke@435 131 public:
duke@435 132 ciMultiBranchData(DataLayout* layout) : MultiBranchData(layout) {};
duke@435 133 };
duke@435 134
kvn@480 135 class ciArgInfoData : public ArgInfoData {
kvn@480 136 public:
kvn@480 137 ciArgInfoData(DataLayout* layout) : ArgInfoData(layout) {};
kvn@480 138 };
kvn@480 139
duke@435 140 // ciMethodData
duke@435 141 //
duke@435 142 // This class represents a methodDataOop in the HotSpot virtual
duke@435 143 // machine.
duke@435 144
duke@435 145 class ciMethodData : public ciObject {
duke@435 146 CI_PACKAGE_ACCESS
duke@435 147
duke@435 148 private:
duke@435 149 // Size in bytes
duke@435 150 int _data_size;
duke@435 151 int _extra_data_size;
duke@435 152
duke@435 153 // Data entries
duke@435 154 intptr_t* _data;
duke@435 155
duke@435 156 // Cached hint for data_before()
duke@435 157 int _hint_di;
duke@435 158
duke@435 159 // Is data attached? And is it mature?
duke@435 160 enum { empty_state, immature_state, mature_state };
duke@435 161 u_char _state;
duke@435 162
duke@435 163 // Set this true if empty extra_data slots are ever witnessed.
duke@435 164 u_char _saw_free_extra_data;
duke@435 165
duke@435 166 // Support for interprocedural escape analysis
duke@435 167 intx _eflags; // flags on escape information
duke@435 168 intx _arg_local; // bit set of non-escaping arguments
duke@435 169 intx _arg_stack; // bit set of stack-allocatable arguments
duke@435 170 intx _arg_returned; // bit set of returned arguments
duke@435 171
duke@435 172 // Maturity of the oop when the snapshot is taken.
duke@435 173 int _current_mileage;
duke@435 174
iveresov@2138 175 // These counters hold the age of MDO in tiered. In tiered we can have the same method
iveresov@2138 176 // running at different compilation levels concurrently. So, in order to precisely measure
iveresov@2138 177 // its maturity we need separate counters.
iveresov@2138 178 int _invocation_counter;
iveresov@2138 179 int _backedge_counter;
iveresov@2138 180
duke@435 181 // Coherent snapshot of original header.
duke@435 182 methodDataOopDesc _orig;
duke@435 183
duke@435 184 ciMethodData(methodDataHandle h_md);
duke@435 185 ciMethodData();
duke@435 186
duke@435 187 // Accessors
kvn@480 188 int data_size() const { return _data_size; }
kvn@480 189 int extra_data_size() const { return _extra_data_size; }
kvn@480 190 intptr_t * data() const { return _data; }
duke@435 191
duke@435 192 methodDataOop get_methodDataOop() const {
duke@435 193 if (handle() == NULL) return NULL;
duke@435 194 methodDataOop mdo = (methodDataOop)get_oop();
duke@435 195 assert(mdo != NULL, "illegal use of unloaded method data");
duke@435 196 return mdo;
duke@435 197 }
duke@435 198
duke@435 199 const char* type_string() { return "ciMethodData"; }
duke@435 200
duke@435 201 void print_impl(outputStream* st);
duke@435 202
kvn@480 203 DataLayout* data_layout_at(int data_index) const {
duke@435 204 assert(data_index % sizeof(intptr_t) == 0, "unaligned");
duke@435 205 return (DataLayout*) (((address)_data) + data_index);
duke@435 206 }
duke@435 207
duke@435 208 bool out_of_bounds(int data_index) {
duke@435 209 return data_index >= data_size();
duke@435 210 }
duke@435 211
duke@435 212 // hint accessors
duke@435 213 int hint_di() const { return _hint_di; }
duke@435 214 void set_hint_di(int di) {
duke@435 215 assert(!out_of_bounds(di), "hint_di out of bounds");
duke@435 216 _hint_di = di;
duke@435 217 }
duke@435 218 ciProfileData* data_before(int bci) {
duke@435 219 // avoid SEGV on this edge case
duke@435 220 if (data_size() == 0)
duke@435 221 return NULL;
duke@435 222 int hint = hint_di();
duke@435 223 if (data_layout_at(hint)->bci() <= bci)
duke@435 224 return data_at(hint);
duke@435 225 return first_data();
duke@435 226 }
duke@435 227
duke@435 228
duke@435 229 // What is the index of the first data entry?
duke@435 230 int first_di() { return 0; }
duke@435 231
kvn@480 232 ciArgInfoData *arg_info() const;
kvn@480 233
duke@435 234 public:
duke@435 235 bool is_method_data() { return true; }
twisti@2903 236
twisti@2903 237 void set_mature() { _state = mature_state; }
twisti@2903 238
twisti@2903 239 bool is_empty() { return _state == empty_state; }
duke@435 240 bool is_mature() { return _state == mature_state; }
duke@435 241
duke@435 242 int creation_mileage() { return _orig.creation_mileage(); }
duke@435 243 int current_mileage() { return _current_mileage; }
duke@435 244
iveresov@2138 245 int invocation_count() { return _invocation_counter; }
iveresov@2138 246 int backedge_count() { return _backedge_counter; }
iveresov@2138 247 // Transfer information about the method to methodDataOop.
iveresov@2138 248 // would_profile means we would like to profile this method,
iveresov@2138 249 // meaning it's not trivial.
iveresov@2138 250 void set_would_profile(bool p);
iveresov@2138 251 // Also set the numer of loops and blocks in the method.
iveresov@2138 252 // Again, this is used to determine if a method is trivial.
iveresov@2138 253 void set_compilation_stats(short loops, short blocks);
iveresov@2138 254
duke@435 255 void load_data();
duke@435 256
duke@435 257 // Convert a dp (data pointer) to a di (data index).
duke@435 258 int dp_to_di(address dp) {
duke@435 259 return dp - ((address)_data);
duke@435 260 }
duke@435 261
duke@435 262 // Get the data at an arbitrary (sort of) data index.
duke@435 263 ciProfileData* data_at(int data_index);
duke@435 264
duke@435 265 // Walk through the data in order.
duke@435 266 ciProfileData* first_data() { return data_at(first_di()); }
duke@435 267 ciProfileData* next_data(ciProfileData* current);
duke@435 268 bool is_valid(ciProfileData* current) { return current != NULL; }
duke@435 269
duke@435 270 // Get the data at an arbitrary bci, or NULL if there is none.
duke@435 271 ciProfileData* bci_to_data(int bci);
duke@435 272 ciProfileData* bci_to_extra_data(int bci, bool create_if_missing);
duke@435 273
duke@435 274 uint overflow_trap_count() const {
duke@435 275 return _orig.overflow_trap_count();
duke@435 276 }
duke@435 277 uint overflow_recompile_count() const {
duke@435 278 return _orig.overflow_recompile_count();
duke@435 279 }
duke@435 280 uint decompile_count() const {
duke@435 281 return _orig.decompile_count();
duke@435 282 }
duke@435 283 uint trap_count(int reason) const {
duke@435 284 return _orig.trap_count(reason);
duke@435 285 }
duke@435 286 uint trap_reason_limit() const { return _orig.trap_reason_limit(); }
duke@435 287 uint trap_count_limit() const { return _orig.trap_count_limit(); }
duke@435 288
duke@435 289 // Helpful query functions that decode trap_state.
duke@435 290 int has_trap_at(ciProfileData* data, int reason);
duke@435 291 int has_trap_at(int bci, int reason) {
duke@435 292 return has_trap_at(bci_to_data(bci), reason);
duke@435 293 }
duke@435 294 int trap_recompiled_at(ciProfileData* data);
duke@435 295 int trap_recompiled_at(int bci) {
duke@435 296 return trap_recompiled_at(bci_to_data(bci));
duke@435 297 }
duke@435 298
duke@435 299 void clear_escape_info();
duke@435 300 bool has_escape_info();
duke@435 301 void update_escape_info();
duke@435 302
duke@435 303 void set_eflag(methodDataOopDesc::EscapeFlag f);
duke@435 304 void clear_eflag(methodDataOopDesc::EscapeFlag f);
duke@435 305 bool eflag_set(methodDataOopDesc::EscapeFlag f) const;
duke@435 306
duke@435 307 void set_arg_local(int i);
duke@435 308 void set_arg_stack(int i);
duke@435 309 void set_arg_returned(int i);
kvn@480 310 void set_arg_modified(int arg, uint val);
duke@435 311
duke@435 312 bool is_arg_local(int i) const;
duke@435 313 bool is_arg_stack(int i) const;
duke@435 314 bool is_arg_returned(int i) const;
kvn@480 315 uint arg_modified(int arg) const;
duke@435 316
duke@435 317 // Code generation helper
duke@435 318 ByteSize offset_of_slot(ciProfileData* data, ByteSize slot_offset_in_data);
duke@435 319 int byte_offset_of_slot(ciProfileData* data, ByteSize slot_offset_in_data) { return in_bytes(offset_of_slot(data, slot_offset_in_data)); }
duke@435 320
duke@435 321 #ifndef PRODUCT
duke@435 322 // printing support for method data
duke@435 323 void print();
duke@435 324 void print_data_on(outputStream* st);
duke@435 325 #endif
duke@435 326 };
stefank@2314 327
stefank@2314 328 #endif // SHARE_VM_CI_CIMETHODDATA_HPP

mercurial