src/share/vm/ci/ciMethodData.hpp

Tue, 18 Jun 2013 12:31:07 -0700

author
johnc
date
Tue, 18 Jun 2013 12:31:07 -0700
changeset 5277
01522ca68fc7
parent 4267
bd7a7ce2e264
child 5907
c775af091fe9
permissions
-rw-r--r--

8015237: Parallelize string table scanning during strong root processing
Summary: Parallelize the scanning of the intern string table by having each GC worker claim a given number of buckets. Changes were also reviewed by Per Liden <per.liden@oracle.com>.
Reviewed-by: tschatzl, stefank, twisti

duke@435 1 /*
coleenp@4037 2 * Copyright (c) 2001, 2012, 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"
coleenp@4037 32 #include "oops/methodData.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");
coleenp@4037 74 ciKlass* recv = (ciKlass*)intptr_at(receiver0_offset + row * receiver_type_row_cell_count);
duke@435 75 assert(recv == NULL || recv->is_klass(), "wrong type");
coleenp@4037 76 return 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 //
coleenp@4037 142 // This class represents a MethodData* in the HotSpot virtual
duke@435 143 // machine.
duke@435 144
coleenp@4037 145 class ciMethodData : public ciMetadata {
duke@435 146 CI_PACKAGE_ACCESS
minqi@4267 147 friend class ciReplay;
duke@435 148
duke@435 149 private:
duke@435 150 // Size in bytes
duke@435 151 int _data_size;
duke@435 152 int _extra_data_size;
duke@435 153
duke@435 154 // Data entries
duke@435 155 intptr_t* _data;
duke@435 156
duke@435 157 // Cached hint for data_before()
duke@435 158 int _hint_di;
duke@435 159
duke@435 160 // Is data attached? And is it mature?
duke@435 161 enum { empty_state, immature_state, mature_state };
duke@435 162 u_char _state;
duke@435 163
duke@435 164 // Set this true if empty extra_data slots are ever witnessed.
duke@435 165 u_char _saw_free_extra_data;
duke@435 166
duke@435 167 // Support for interprocedural escape analysis
duke@435 168 intx _eflags; // flags on escape information
duke@435 169 intx _arg_local; // bit set of non-escaping arguments
duke@435 170 intx _arg_stack; // bit set of stack-allocatable arguments
duke@435 171 intx _arg_returned; // bit set of returned arguments
duke@435 172
duke@435 173 // Maturity of the oop when the snapshot is taken.
duke@435 174 int _current_mileage;
duke@435 175
iveresov@2138 176 // These counters hold the age of MDO in tiered. In tiered we can have the same method
iveresov@2138 177 // running at different compilation levels concurrently. So, in order to precisely measure
iveresov@2138 178 // its maturity we need separate counters.
iveresov@2138 179 int _invocation_counter;
iveresov@2138 180 int _backedge_counter;
iveresov@2138 181
duke@435 182 // Coherent snapshot of original header.
coleenp@4037 183 MethodData _orig;
duke@435 184
coleenp@4037 185 ciMethodData(MethodData* md);
duke@435 186 ciMethodData();
duke@435 187
duke@435 188 // Accessors
kvn@480 189 int data_size() const { return _data_size; }
kvn@480 190 int extra_data_size() const { return _extra_data_size; }
kvn@480 191 intptr_t * data() const { return _data; }
duke@435 192
coleenp@4037 193 MethodData* get_MethodData() const {
coleenp@4037 194 return (MethodData*)_metadata;
duke@435 195 }
duke@435 196
duke@435 197 const char* type_string() { return "ciMethodData"; }
duke@435 198
duke@435 199 void print_impl(outputStream* st);
duke@435 200
kvn@480 201 DataLayout* data_layout_at(int data_index) const {
duke@435 202 assert(data_index % sizeof(intptr_t) == 0, "unaligned");
duke@435 203 return (DataLayout*) (((address)_data) + data_index);
duke@435 204 }
duke@435 205
duke@435 206 bool out_of_bounds(int data_index) {
duke@435 207 return data_index >= data_size();
duke@435 208 }
duke@435 209
duke@435 210 // hint accessors
duke@435 211 int hint_di() const { return _hint_di; }
duke@435 212 void set_hint_di(int di) {
duke@435 213 assert(!out_of_bounds(di), "hint_di out of bounds");
duke@435 214 _hint_di = di;
duke@435 215 }
duke@435 216 ciProfileData* data_before(int bci) {
duke@435 217 // avoid SEGV on this edge case
duke@435 218 if (data_size() == 0)
duke@435 219 return NULL;
duke@435 220 int hint = hint_di();
duke@435 221 if (data_layout_at(hint)->bci() <= bci)
duke@435 222 return data_at(hint);
duke@435 223 return first_data();
duke@435 224 }
duke@435 225
duke@435 226
duke@435 227 // What is the index of the first data entry?
duke@435 228 int first_di() { return 0; }
duke@435 229
kvn@480 230 ciArgInfoData *arg_info() const;
kvn@480 231
duke@435 232 public:
coleenp@4037 233 bool is_method_data() const { return true; }
twisti@2903 234
twisti@2903 235 void set_mature() { _state = mature_state; }
twisti@2903 236
twisti@2903 237 bool is_empty() { return _state == empty_state; }
duke@435 238 bool is_mature() { return _state == mature_state; }
duke@435 239
duke@435 240 int creation_mileage() { return _orig.creation_mileage(); }
duke@435 241 int current_mileage() { return _current_mileage; }
duke@435 242
iveresov@2138 243 int invocation_count() { return _invocation_counter; }
iveresov@2138 244 int backedge_count() { return _backedge_counter; }
coleenp@4037 245 // Transfer information about the method to MethodData*.
iveresov@2138 246 // would_profile means we would like to profile this method,
iveresov@2138 247 // meaning it's not trivial.
iveresov@2138 248 void set_would_profile(bool p);
iveresov@2138 249 // Also set the numer of loops and blocks in the method.
iveresov@2138 250 // Again, this is used to determine if a method is trivial.
iveresov@2138 251 void set_compilation_stats(short loops, short blocks);
iveresov@2138 252
duke@435 253 void load_data();
duke@435 254
duke@435 255 // Convert a dp (data pointer) to a di (data index).
duke@435 256 int dp_to_di(address dp) {
duke@435 257 return dp - ((address)_data);
duke@435 258 }
duke@435 259
duke@435 260 // Get the data at an arbitrary (sort of) data index.
duke@435 261 ciProfileData* data_at(int data_index);
duke@435 262
duke@435 263 // Walk through the data in order.
duke@435 264 ciProfileData* first_data() { return data_at(first_di()); }
duke@435 265 ciProfileData* next_data(ciProfileData* current);
duke@435 266 bool is_valid(ciProfileData* current) { return current != NULL; }
duke@435 267
duke@435 268 // Get the data at an arbitrary bci, or NULL if there is none.
duke@435 269 ciProfileData* bci_to_data(int bci);
duke@435 270 ciProfileData* bci_to_extra_data(int bci, bool create_if_missing);
duke@435 271
duke@435 272 uint overflow_trap_count() const {
duke@435 273 return _orig.overflow_trap_count();
duke@435 274 }
duke@435 275 uint overflow_recompile_count() const {
duke@435 276 return _orig.overflow_recompile_count();
duke@435 277 }
duke@435 278 uint decompile_count() const {
duke@435 279 return _orig.decompile_count();
duke@435 280 }
duke@435 281 uint trap_count(int reason) const {
duke@435 282 return _orig.trap_count(reason);
duke@435 283 }
duke@435 284 uint trap_reason_limit() const { return _orig.trap_reason_limit(); }
duke@435 285 uint trap_count_limit() const { return _orig.trap_count_limit(); }
duke@435 286
duke@435 287 // Helpful query functions that decode trap_state.
duke@435 288 int has_trap_at(ciProfileData* data, int reason);
duke@435 289 int has_trap_at(int bci, int reason) {
duke@435 290 return has_trap_at(bci_to_data(bci), reason);
duke@435 291 }
duke@435 292 int trap_recompiled_at(ciProfileData* data);
duke@435 293 int trap_recompiled_at(int bci) {
duke@435 294 return trap_recompiled_at(bci_to_data(bci));
duke@435 295 }
duke@435 296
duke@435 297 void clear_escape_info();
duke@435 298 bool has_escape_info();
duke@435 299 void update_escape_info();
duke@435 300
coleenp@4037 301 void set_eflag(MethodData::EscapeFlag f);
coleenp@4037 302 void clear_eflag(MethodData::EscapeFlag f);
coleenp@4037 303 bool eflag_set(MethodData::EscapeFlag f) const;
duke@435 304
duke@435 305 void set_arg_local(int i);
duke@435 306 void set_arg_stack(int i);
duke@435 307 void set_arg_returned(int i);
kvn@480 308 void set_arg_modified(int arg, uint val);
duke@435 309
duke@435 310 bool is_arg_local(int i) const;
duke@435 311 bool is_arg_stack(int i) const;
duke@435 312 bool is_arg_returned(int i) const;
kvn@480 313 uint arg_modified(int arg) const;
duke@435 314
duke@435 315 // Code generation helper
duke@435 316 ByteSize offset_of_slot(ciProfileData* data, ByteSize slot_offset_in_data);
duke@435 317 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 318
duke@435 319 #ifndef PRODUCT
duke@435 320 // printing support for method data
duke@435 321 void print();
duke@435 322 void print_data_on(outputStream* st);
duke@435 323 #endif
minqi@4267 324 void dump_replay_data(outputStream* out);
duke@435 325 };
stefank@2314 326
stefank@2314 327 #endif // SHARE_VM_CI_CIMETHODDATA_HPP

mercurial