src/share/vm/ci/ciMethodData.cpp

Mon, 07 Jul 2014 10:12:40 +0200

author
stefank
date
Mon, 07 Jul 2014 10:12:40 +0200
changeset 6992
2c6ef90f030a
parent 6680
78bbf4d43a14
child 7535
7ae4e26cb1e0
child 8882
279a5dd96f9b
permissions
-rw-r--r--

8049421: G1 Class Unloading after completing a concurrent mark cycle
Reviewed-by: tschatzl, ehelin, brutisso, coleenp, roland, iveresov
Contributed-by: stefan.karlsson@oracle.com, mikael.gerdin@oracle.com

duke@435 1 /*
drchase@6680 2 * Copyright (c) 2001, 2014, 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 #include "precompiled.hpp"
coleenp@4037 26 #include "ci/ciMetadata.hpp"
stefank@2314 27 #include "ci/ciMethodData.hpp"
minqi@4267 28 #include "ci/ciReplay.hpp"
stefank@2314 29 #include "ci/ciUtilities.hpp"
stefank@2314 30 #include "memory/allocation.inline.hpp"
stefank@2314 31 #include "memory/resourceArea.hpp"
stefank@2314 32 #include "runtime/deoptimization.hpp"
stefank@2314 33 #include "utilities/copy.hpp"
duke@435 34
duke@435 35 // ciMethodData
duke@435 36
duke@435 37 // ------------------------------------------------------------------
duke@435 38 // ciMethodData::ciMethodData
duke@435 39 //
coleenp@4037 40 ciMethodData::ciMethodData(MethodData* md) : ciMetadata(md) {
coleenp@4037 41 assert(md != NULL, "no null method data");
duke@435 42 Copy::zero_to_words((HeapWord*) &_orig, sizeof(_orig) / sizeof(HeapWord));
duke@435 43 _data = NULL;
duke@435 44 _data_size = 0;
duke@435 45 _extra_data_size = 0;
duke@435 46 _current_mileage = 0;
iveresov@2138 47 _invocation_counter = 0;
iveresov@2138 48 _backedge_counter = 0;
duke@435 49 _state = empty_state;
duke@435 50 _saw_free_extra_data = false;
duke@435 51 // Set an initial hint. Don't use set_hint_di() because
duke@435 52 // first_di() may be out of bounds if data_size is 0.
duke@435 53 _hint_di = first_di();
kvn@480 54 // Initialize the escape information (to "don't know.");
kvn@480 55 _eflags = _arg_local = _arg_stack = _arg_returned = 0;
roland@5987 56 _parameters = NULL;
duke@435 57 }
duke@435 58
duke@435 59 // ------------------------------------------------------------------
duke@435 60 // ciMethodData::ciMethodData
duke@435 61 //
coleenp@4037 62 // No MethodData*.
coleenp@4037 63 ciMethodData::ciMethodData() : ciMetadata(NULL) {
duke@435 64 Copy::zero_to_words((HeapWord*) &_orig, sizeof(_orig) / sizeof(HeapWord));
duke@435 65 _data = NULL;
duke@435 66 _data_size = 0;
duke@435 67 _extra_data_size = 0;
duke@435 68 _current_mileage = 0;
iveresov@2138 69 _invocation_counter = 0;
iveresov@2138 70 _backedge_counter = 0;
duke@435 71 _state = empty_state;
duke@435 72 _saw_free_extra_data = false;
duke@435 73 // Set an initial hint. Don't use set_hint_di() because
duke@435 74 // first_di() may be out of bounds if data_size is 0.
duke@435 75 _hint_di = first_di();
kvn@480 76 // Initialize the escape information (to "don't know.");
kvn@480 77 _eflags = _arg_local = _arg_stack = _arg_returned = 0;
roland@5987 78 _parameters = NULL;
duke@435 79 }
duke@435 80
roland@6377 81 void ciMethodData::load_extra_data() {
roland@6377 82 MethodData* mdo = get_MethodData();
roland@6377 83
roland@6377 84 // speculative trap entries also hold a pointer to a Method so need to be translated
roland@6377 85 DataLayout* dp_src = mdo->extra_data_base();
roland@6377 86 DataLayout* end_src = mdo->extra_data_limit();
roland@6377 87 DataLayout* dp_dst = extra_data_base();
roland@6377 88 for (;; dp_src = MethodData::next_extra(dp_src), dp_dst = MethodData::next_extra(dp_dst)) {
roland@6377 89 assert(dp_src < end_src, "moved past end of extra data");
roland@6382 90 // New traps in the MDO can be added as we translate the copy so
roland@6382 91 // look at the entries in the copy.
roland@6382 92 switch(dp_dst->tag()) {
roland@6377 93 case DataLayout::speculative_trap_data_tag: {
roland@6377 94 ciSpeculativeTrapData* data_dst = new ciSpeculativeTrapData(dp_dst);
roland@6377 95 SpeculativeTrapData* data_src = new SpeculativeTrapData(dp_src);
roland@6377 96 data_dst->translate_from(data_src);
roland@6377 97 break;
roland@6377 98 }
roland@6377 99 case DataLayout::bit_data_tag:
roland@6377 100 break;
roland@6377 101 case DataLayout::no_tag:
roland@6377 102 case DataLayout::arg_info_data_tag:
roland@6377 103 // An empty slot or ArgInfoData entry marks the end of the trap data
roland@6377 104 return;
roland@6377 105 default:
roland@6382 106 fatal(err_msg("bad tag = %d", dp_dst->tag()));
roland@6377 107 }
roland@6377 108 }
roland@6377 109 }
roland@6377 110
duke@435 111 void ciMethodData::load_data() {
coleenp@4037 112 MethodData* mdo = get_MethodData();
twisti@5907 113 if (mdo == NULL) {
twisti@5907 114 return;
twisti@5907 115 }
duke@435 116
duke@435 117 // To do: don't copy the data if it is not "ripe" -- require a minimum #
duke@435 118 // of invocations.
duke@435 119
duke@435 120 // Snapshot the data -- actually, take an approximate snapshot of
duke@435 121 // the data. Any concurrently executing threads may be changing the
duke@435 122 // data as we copy it.
coleenp@4037 123 Copy::disjoint_words((HeapWord*) mdo,
coleenp@4037 124 (HeapWord*) &_orig,
coleenp@4037 125 sizeof(_orig) / HeapWordSize);
duke@435 126 Arena* arena = CURRENT_ENV->arena();
duke@435 127 _data_size = mdo->data_size();
duke@435 128 _extra_data_size = mdo->extra_data_size();
duke@435 129 int total_size = _data_size + _extra_data_size;
duke@435 130 _data = (intptr_t *) arena->Amalloc(total_size);
duke@435 131 Copy::disjoint_words((HeapWord*) mdo->data_base(), (HeapWord*) _data, total_size / HeapWordSize);
duke@435 132
duke@435 133 // Traverse the profile data, translating any oops into their
duke@435 134 // ci equivalents.
duke@435 135 ResourceMark rm;
duke@435 136 ciProfileData* ci_data = first_data();
duke@435 137 ProfileData* data = mdo->first_data();
duke@435 138 while (is_valid(ci_data)) {
duke@435 139 ci_data->translate_from(data);
duke@435 140 ci_data = next_data(ci_data);
duke@435 141 data = mdo->next_data(data);
duke@435 142 }
roland@5987 143 if (mdo->parameters_type_data() != NULL) {
roland@5987 144 _parameters = data_layout_at(mdo->parameters_type_data_di());
roland@5987 145 ciParametersTypeData* parameters = new ciParametersTypeData(_parameters);
roland@5987 146 parameters->translate_from(mdo->parameters_type_data());
roland@5987 147 }
roland@5987 148
roland@6377 149 load_extra_data();
roland@6377 150
duke@435 151 // Note: Extra data are all BitData, and do not need translation.
coleenp@4037 152 _current_mileage = MethodData::mileage_of(mdo->method());
iveresov@2138 153 _invocation_counter = mdo->invocation_count();
iveresov@2138 154 _backedge_counter = mdo->backedge_count();
duke@435 155 _state = mdo->is_mature()? mature_state: immature_state;
duke@435 156
duke@435 157 _eflags = mdo->eflags();
duke@435 158 _arg_local = mdo->arg_local();
duke@435 159 _arg_stack = mdo->arg_stack();
duke@435 160 _arg_returned = mdo->arg_returned();
minqi@4267 161 #ifndef PRODUCT
minqi@4267 162 if (ReplayCompiles) {
minqi@4267 163 ciReplay::initialize(this);
minqi@4267 164 }
minqi@4267 165 #endif
duke@435 166 }
duke@435 167
roland@5914 168 void ciReceiverTypeData::translate_receiver_data_from(const ProfileData* data) {
duke@435 169 for (uint row = 0; row < row_limit(); row++) {
coleenp@4037 170 Klass* k = data->as_ReceiverTypeData()->receiver(row);
duke@435 171 if (k != NULL) {
coleenp@4037 172 ciKlass* klass = CURRENT_ENV->get_klass(k);
stefank@6992 173 CURRENT_ENV->ensure_metadata_alive(klass);
duke@435 174 set_receiver(row, klass);
duke@435 175 }
duke@435 176 }
duke@435 177 }
duke@435 178
duke@435 179
roland@5914 180 void ciTypeStackSlotEntries::translate_type_data_from(const TypeStackSlotEntries* entries) {
roland@5921 181 for (int i = 0; i < _number_of_entries; i++) {
roland@5914 182 intptr_t k = entries->type(i);
roland@5914 183 TypeStackSlotEntries::set_type(i, translate_klass(k));
roland@5914 184 }
roland@5914 185 }
roland@5914 186
roland@5921 187 void ciReturnTypeEntry::translate_type_data_from(const ReturnTypeEntry* ret) {
roland@5921 188 intptr_t k = ret->type();
roland@5921 189 set_type(translate_klass(k));
roland@5921 190 }
roland@5921 191
roland@6377 192 void ciSpeculativeTrapData::translate_from(const ProfileData* data) {
roland@6377 193 Method* m = data->as_SpeculativeTrapData()->method();
roland@6377 194 ciMethod* ci_m = CURRENT_ENV->get_method(m);
stefank@6992 195 CURRENT_ENV->ensure_metadata_alive(ci_m);
roland@6377 196 set_method(ci_m);
roland@6377 197 }
roland@6377 198
duke@435 199 // Get the data at an arbitrary (sort of) data index.
duke@435 200 ciProfileData* ciMethodData::data_at(int data_index) {
duke@435 201 if (out_of_bounds(data_index)) {
duke@435 202 return NULL;
duke@435 203 }
duke@435 204 DataLayout* data_layout = data_layout_at(data_index);
duke@435 205
duke@435 206 switch (data_layout->tag()) {
duke@435 207 case DataLayout::no_tag:
duke@435 208 default:
duke@435 209 ShouldNotReachHere();
duke@435 210 return NULL;
duke@435 211 case DataLayout::bit_data_tag:
duke@435 212 return new ciBitData(data_layout);
duke@435 213 case DataLayout::counter_data_tag:
duke@435 214 return new ciCounterData(data_layout);
duke@435 215 case DataLayout::jump_data_tag:
duke@435 216 return new ciJumpData(data_layout);
duke@435 217 case DataLayout::receiver_type_data_tag:
duke@435 218 return new ciReceiverTypeData(data_layout);
duke@435 219 case DataLayout::virtual_call_data_tag:
duke@435 220 return new ciVirtualCallData(data_layout);
duke@435 221 case DataLayout::ret_data_tag:
duke@435 222 return new ciRetData(data_layout);
duke@435 223 case DataLayout::branch_data_tag:
duke@435 224 return new ciBranchData(data_layout);
duke@435 225 case DataLayout::multi_branch_data_tag:
duke@435 226 return new ciMultiBranchData(data_layout);
kvn@480 227 case DataLayout::arg_info_data_tag:
kvn@480 228 return new ciArgInfoData(data_layout);
roland@5914 229 case DataLayout::call_type_data_tag:
roland@5914 230 return new ciCallTypeData(data_layout);
roland@5914 231 case DataLayout::virtual_call_type_data_tag:
roland@5914 232 return new ciVirtualCallTypeData(data_layout);
roland@5987 233 case DataLayout::parameters_type_data_tag:
roland@5987 234 return new ciParametersTypeData(data_layout);
duke@435 235 };
duke@435 236 }
duke@435 237
duke@435 238 // Iteration over data.
duke@435 239 ciProfileData* ciMethodData::next_data(ciProfileData* current) {
duke@435 240 int current_index = dp_to_di(current->dp());
duke@435 241 int next_index = current_index + current->size_in_bytes();
duke@435 242 ciProfileData* next = data_at(next_index);
duke@435 243 return next;
duke@435 244 }
duke@435 245
roland@6377 246 ciProfileData* ciMethodData::bci_to_extra_data(int bci, ciMethod* m, bool& two_free_slots) {
duke@435 247 // bci_to_extra_data(bci) ...
duke@435 248 DataLayout* dp = data_layout_at(data_size());
duke@435 249 DataLayout* end = data_layout_at(data_size() + extra_data_size());
roland@6377 250 two_free_slots = false;
roland@6377 251 for (;dp < end; dp = MethodData::next_extra(dp)) {
roland@6377 252 switch(dp->tag()) {
roland@6377 253 case DataLayout::no_tag:
duke@435 254 _saw_free_extra_data = true; // observed an empty slot (common case)
roland@6377 255 two_free_slots = (MethodData::next_extra(dp)->tag() == DataLayout::no_tag);
duke@435 256 return NULL;
roland@6377 257 case DataLayout::arg_info_data_tag:
roland@6377 258 return NULL; // ArgInfoData is at the end of extra data section.
roland@6377 259 case DataLayout::bit_data_tag:
roland@6377 260 if (m == NULL && dp->bci() == bci) {
roland@6377 261 return new ciBitData(dp);
roland@6377 262 }
roland@6377 263 break;
roland@6377 264 case DataLayout::speculative_trap_data_tag: {
roland@6377 265 ciSpeculativeTrapData* data = new ciSpeculativeTrapData(dp);
roland@6377 266 // data->method() might be null if the MDO is snapshotted
roland@6377 267 // concurrently with a trap
roland@6377 268 if (m != NULL && data->method() == m && dp->bci() == bci) {
roland@6377 269 return data;
roland@6377 270 }
roland@6377 271 break;
duke@435 272 }
roland@6377 273 default:
roland@6377 274 fatal(err_msg("bad tag = %d", dp->tag()));
kvn@480 275 }
roland@6377 276 }
roland@6377 277 return NULL;
roland@6377 278 }
roland@6377 279
roland@6377 280 // Translate a bci to its corresponding data, or NULL.
roland@6377 281 ciProfileData* ciMethodData::bci_to_data(int bci, ciMethod* m) {
roland@6377 282 // If m is not NULL we look for a SpeculativeTrapData entry
roland@6377 283 if (m == NULL) {
roland@6377 284 ciProfileData* data = data_before(bci);
roland@6377 285 for ( ; is_valid(data); data = next_data(data)) {
roland@6377 286 if (data->bci() == bci) {
roland@6377 287 set_hint_di(dp_to_di(data->dp()));
roland@6377 288 return data;
roland@6377 289 } else if (data->bci() > bci) {
roland@6377 290 break;
roland@6377 291 }
duke@435 292 }
duke@435 293 }
roland@6377 294 bool two_free_slots = false;
roland@6377 295 ciProfileData* result = bci_to_extra_data(bci, m, two_free_slots);
roland@6377 296 if (result != NULL) {
roland@6377 297 return result;
roland@6377 298 }
roland@6377 299 if (m != NULL && !two_free_slots) {
roland@6377 300 // We were looking for a SpeculativeTrapData entry we didn't
roland@6377 301 // find. Room is not available for more SpeculativeTrapData
roland@6377 302 // entries, look in the non SpeculativeTrapData entries.
roland@6377 303 return bci_to_data(bci, NULL);
roland@6377 304 }
duke@435 305 return NULL;
duke@435 306 }
duke@435 307
duke@435 308 // Conservatively decode the trap_state of a ciProfileData.
duke@435 309 int ciMethodData::has_trap_at(ciProfileData* data, int reason) {
duke@435 310 typedef Deoptimization::DeoptReason DR_t;
duke@435 311 int per_bc_reason
duke@435 312 = Deoptimization::reason_recorded_per_bytecode_if_any((DR_t) reason);
duke@435 313 if (trap_count(reason) == 0) {
duke@435 314 // Impossible for this trap to have occurred, regardless of trap_state.
duke@435 315 // Note: This happens if the MDO is empty.
duke@435 316 return 0;
duke@435 317 } else if (per_bc_reason == Deoptimization::Reason_none) {
duke@435 318 // We cannot conclude anything; a trap happened somewhere, maybe here.
duke@435 319 return -1;
duke@435 320 } else if (data == NULL) {
duke@435 321 // No profile here, not even an extra_data record allocated on the fly.
duke@435 322 // If there are empty extra_data records, and there had been a trap,
duke@435 323 // there would have been a non-null data pointer. If there are no
duke@435 324 // free extra_data records, we must return a conservative -1.
duke@435 325 if (_saw_free_extra_data)
duke@435 326 return 0; // Q.E.D.
duke@435 327 else
duke@435 328 return -1; // bail with a conservative answer
duke@435 329 } else {
duke@435 330 return Deoptimization::trap_state_has_reason(data->trap_state(), per_bc_reason);
duke@435 331 }
duke@435 332 }
duke@435 333
duke@435 334 int ciMethodData::trap_recompiled_at(ciProfileData* data) {
duke@435 335 if (data == NULL) {
duke@435 336 return (_saw_free_extra_data? 0: -1); // (see previous method)
duke@435 337 } else {
duke@435 338 return Deoptimization::trap_state_is_recompiled(data->trap_state())? 1: 0;
duke@435 339 }
duke@435 340 }
duke@435 341
duke@435 342 void ciMethodData::clear_escape_info() {
duke@435 343 VM_ENTRY_MARK;
coleenp@4037 344 MethodData* mdo = get_MethodData();
kvn@480 345 if (mdo != NULL) {
duke@435 346 mdo->clear_escape_info();
kvn@480 347 ArgInfoData *aid = arg_info();
kvn@480 348 int arg_count = (aid == NULL) ? 0 : aid->number_of_args();
kvn@480 349 for (int i = 0; i < arg_count; i++) {
kvn@480 350 set_arg_modified(i, 0);
kvn@480 351 }
kvn@480 352 }
duke@435 353 _eflags = _arg_local = _arg_stack = _arg_returned = 0;
duke@435 354 }
duke@435 355
coleenp@4037 356 // copy our escape info to the MethodData* if it exists
duke@435 357 void ciMethodData::update_escape_info() {
duke@435 358 VM_ENTRY_MARK;
coleenp@4037 359 MethodData* mdo = get_MethodData();
duke@435 360 if ( mdo != NULL) {
duke@435 361 mdo->set_eflags(_eflags);
duke@435 362 mdo->set_arg_local(_arg_local);
duke@435 363 mdo->set_arg_stack(_arg_stack);
duke@435 364 mdo->set_arg_returned(_arg_returned);
kvn@480 365 int arg_count = mdo->method()->size_of_parameters();
kvn@480 366 for (int i = 0; i < arg_count; i++) {
kvn@480 367 mdo->set_arg_modified(i, arg_modified(i));
kvn@480 368 }
duke@435 369 }
duke@435 370 }
duke@435 371
iveresov@2138 372 void ciMethodData::set_compilation_stats(short loops, short blocks) {
iveresov@2138 373 VM_ENTRY_MARK;
coleenp@4037 374 MethodData* mdo = get_MethodData();
iveresov@2138 375 if (mdo != NULL) {
iveresov@2138 376 mdo->set_num_loops(loops);
iveresov@2138 377 mdo->set_num_blocks(blocks);
iveresov@2138 378 }
iveresov@2138 379 }
iveresov@2138 380
iveresov@2138 381 void ciMethodData::set_would_profile(bool p) {
iveresov@2138 382 VM_ENTRY_MARK;
coleenp@4037 383 MethodData* mdo = get_MethodData();
iveresov@2138 384 if (mdo != NULL) {
iveresov@2138 385 mdo->set_would_profile(p);
iveresov@2138 386 }
iveresov@2138 387 }
iveresov@2138 388
roland@5914 389 void ciMethodData::set_argument_type(int bci, int i, ciKlass* k) {
roland@5914 390 VM_ENTRY_MARK;
roland@5914 391 MethodData* mdo = get_MethodData();
roland@5914 392 if (mdo != NULL) {
roland@5914 393 ProfileData* data = mdo->bci_to_data(bci);
roland@5914 394 if (data->is_CallTypeData()) {
roland@5914 395 data->as_CallTypeData()->set_argument_type(i, k->get_Klass());
roland@5914 396 } else {
roland@5914 397 assert(data->is_VirtualCallTypeData(), "no arguments!");
roland@5914 398 data->as_VirtualCallTypeData()->set_argument_type(i, k->get_Klass());
roland@5914 399 }
roland@5914 400 }
roland@5914 401 }
roland@5914 402
roland@5987 403 void ciMethodData::set_parameter_type(int i, ciKlass* k) {
roland@5987 404 VM_ENTRY_MARK;
roland@5987 405 MethodData* mdo = get_MethodData();
roland@5987 406 if (mdo != NULL) {
roland@5987 407 mdo->parameters_type_data()->set_type(i, k->get_Klass());
roland@5987 408 }
roland@5987 409 }
roland@5987 410
roland@5921 411 void ciMethodData::set_return_type(int bci, ciKlass* k) {
roland@5921 412 VM_ENTRY_MARK;
roland@5921 413 MethodData* mdo = get_MethodData();
roland@5921 414 if (mdo != NULL) {
roland@5921 415 ProfileData* data = mdo->bci_to_data(bci);
roland@5921 416 if (data->is_CallTypeData()) {
roland@5921 417 data->as_CallTypeData()->set_return_type(k->get_Klass());
roland@5921 418 } else {
roland@5921 419 assert(data->is_VirtualCallTypeData(), "no arguments!");
roland@5921 420 data->as_VirtualCallTypeData()->set_return_type(k->get_Klass());
roland@5921 421 }
roland@5921 422 }
roland@5921 423 }
roland@5921 424
duke@435 425 bool ciMethodData::has_escape_info() {
coleenp@4037 426 return eflag_set(MethodData::estimated);
duke@435 427 }
duke@435 428
coleenp@4037 429 void ciMethodData::set_eflag(MethodData::EscapeFlag f) {
duke@435 430 set_bits(_eflags, f);
duke@435 431 }
duke@435 432
coleenp@4037 433 void ciMethodData::clear_eflag(MethodData::EscapeFlag f) {
duke@435 434 clear_bits(_eflags, f);
duke@435 435 }
duke@435 436
coleenp@4037 437 bool ciMethodData::eflag_set(MethodData::EscapeFlag f) const {
duke@435 438 return mask_bits(_eflags, f) != 0;
duke@435 439 }
duke@435 440
duke@435 441 void ciMethodData::set_arg_local(int i) {
duke@435 442 set_nth_bit(_arg_local, i);
duke@435 443 }
duke@435 444
duke@435 445 void ciMethodData::set_arg_stack(int i) {
duke@435 446 set_nth_bit(_arg_stack, i);
duke@435 447 }
duke@435 448
duke@435 449 void ciMethodData::set_arg_returned(int i) {
duke@435 450 set_nth_bit(_arg_returned, i);
duke@435 451 }
duke@435 452
kvn@480 453 void ciMethodData::set_arg_modified(int arg, uint val) {
kvn@480 454 ArgInfoData *aid = arg_info();
kvn@480 455 if (aid == NULL)
kvn@480 456 return;
kvn@480 457 assert(arg >= 0 && arg < aid->number_of_args(), "valid argument number");
kvn@480 458 aid->set_arg_modified(arg, val);
kvn@480 459 }
kvn@480 460
duke@435 461 bool ciMethodData::is_arg_local(int i) const {
duke@435 462 return is_set_nth_bit(_arg_local, i);
duke@435 463 }
duke@435 464
duke@435 465 bool ciMethodData::is_arg_stack(int i) const {
duke@435 466 return is_set_nth_bit(_arg_stack, i);
duke@435 467 }
duke@435 468
duke@435 469 bool ciMethodData::is_arg_returned(int i) const {
duke@435 470 return is_set_nth_bit(_arg_returned, i);
duke@435 471 }
duke@435 472
kvn@480 473 uint ciMethodData::arg_modified(int arg) const {
kvn@480 474 ArgInfoData *aid = arg_info();
kvn@480 475 if (aid == NULL)
kvn@480 476 return 0;
kvn@480 477 assert(arg >= 0 && arg < aid->number_of_args(), "valid argument number");
kvn@480 478 return aid->arg_modified(arg);
kvn@480 479 }
kvn@480 480
duke@435 481 ByteSize ciMethodData::offset_of_slot(ciProfileData* data, ByteSize slot_offset_in_data) {
coleenp@4037 482 // Get offset within MethodData* of the data array
coleenp@4037 483 ByteSize data_offset = MethodData::data_offset();
duke@435 484
duke@435 485 // Get cell offset of the ProfileData within data array
duke@435 486 int cell_offset = dp_to_di(data->dp());
duke@435 487
duke@435 488 // Add in counter_offset, the # of bytes into the ProfileData of counter or flag
duke@435 489 int offset = in_bytes(data_offset) + cell_offset + in_bytes(slot_offset_in_data);
duke@435 490
duke@435 491 return in_ByteSize(offset);
duke@435 492 }
duke@435 493
kvn@480 494 ciArgInfoData *ciMethodData::arg_info() const {
kvn@480 495 // Should be last, have to skip all traps.
kvn@480 496 DataLayout* dp = data_layout_at(data_size());
kvn@480 497 DataLayout* end = data_layout_at(data_size() + extra_data_size());
coleenp@4037 498 for (; dp < end; dp = MethodData::next_extra(dp)) {
kvn@480 499 if (dp->tag() == DataLayout::arg_info_data_tag)
kvn@480 500 return new ciArgInfoData(dp);
kvn@480 501 }
kvn@480 502 return NULL;
kvn@480 503 }
kvn@480 504
kvn@480 505
duke@435 506 // Implementation of the print method.
duke@435 507 void ciMethodData::print_impl(outputStream* st) {
coleenp@4037 508 ciMetadata::print_impl(st);
duke@435 509 }
duke@435 510
minqi@4267 511 void ciMethodData::dump_replay_data(outputStream* out) {
vlivanov@4531 512 ResourceMark rm;
minqi@4267 513 MethodData* mdo = get_MethodData();
minqi@4267 514 Method* method = mdo->method();
minqi@4267 515 Klass* holder = method->method_holder();
minqi@4267 516 out->print("ciMethodData %s %s %s %d %d",
minqi@4267 517 holder->name()->as_quoted_ascii(),
minqi@4267 518 method->name()->as_quoted_ascii(),
minqi@4267 519 method->signature()->as_quoted_ascii(),
minqi@4267 520 _state,
minqi@4267 521 current_mileage());
minqi@4267 522
minqi@4267 523 // dump the contents of the MDO header as raw data
minqi@4267 524 unsigned char* orig = (unsigned char*)&_orig;
minqi@4267 525 int length = sizeof(_orig);
minqi@4267 526 out->print(" orig %d", length);
minqi@4267 527 for (int i = 0; i < length; i++) {
minqi@4267 528 out->print(" %d", orig[i]);
minqi@4267 529 }
minqi@4267 530
minqi@4267 531 // dump the MDO data as raw data
minqi@4267 532 int elements = data_size() / sizeof(intptr_t);
minqi@4267 533 out->print(" data %d", elements);
minqi@4267 534 for (int i = 0; i < elements; i++) {
minqi@4267 535 // We could use INTPTR_FORMAT here but that's a zero justified
minqi@4267 536 // which makes comparing it with the SA version of this output
minqi@4267 537 // harder.
minqi@4267 538 #ifdef _LP64
minqi@4267 539 out->print(" 0x%" FORMAT64_MODIFIER "x", data()[i]);
minqi@4267 540 #else
minqi@4267 541 out->print(" 0x%x", data()[i]);
minqi@4267 542 #endif
minqi@4267 543 }
minqi@4267 544
minqi@4267 545 // The MDO contained oop references as ciObjects, so scan for those
minqi@4267 546 // and emit pairs of offset and klass name so that they can be
minqi@4267 547 // reconstructed at runtime. The first round counts the number of
minqi@4267 548 // oop references and the second actually emits them.
minqi@4267 549 int count = 0;
minqi@4267 550 for (int round = 0; round < 2; round++) {
minqi@4267 551 if (round == 1) out->print(" oops %d", count);
minqi@4267 552 ProfileData* pdata = first_data();
minqi@4267 553 for ( ; is_valid(pdata); pdata = next_data(pdata)) {
minqi@4267 554 if (pdata->is_ReceiverTypeData()) {
minqi@4267 555 ciReceiverTypeData* vdata = (ciReceiverTypeData*)pdata;
minqi@4267 556 for (uint i = 0; i < vdata->row_limit(); i++) {
minqi@4267 557 ciKlass* k = vdata->receiver(i);
minqi@4267 558 if (k != NULL) {
minqi@4267 559 if (round == 0) {
minqi@4267 560 count++;
minqi@4267 561 } else {
drchase@6680 562 out->print(" %d %s", (int)(dp_to_di(vdata->dp() + in_bytes(vdata->receiver_offset(i))) / sizeof(intptr_t)), k->name()->as_quoted_ascii());
minqi@4267 563 }
minqi@4267 564 }
minqi@4267 565 }
minqi@4267 566 } else if (pdata->is_VirtualCallData()) {
minqi@4267 567 ciVirtualCallData* vdata = (ciVirtualCallData*)pdata;
minqi@4267 568 for (uint i = 0; i < vdata->row_limit(); i++) {
minqi@4267 569 ciKlass* k = vdata->receiver(i);
minqi@4267 570 if (k != NULL) {
minqi@4267 571 if (round == 0) {
minqi@4267 572 count++;
minqi@4267 573 } else {
drchase@6680 574 out->print(" %d %s", (int)(dp_to_di(vdata->dp() + in_bytes(vdata->receiver_offset(i))) / sizeof(intptr_t)), k->name()->as_quoted_ascii());
minqi@4267 575 }
minqi@4267 576 }
minqi@4267 577 }
minqi@4267 578 }
minqi@4267 579 }
minqi@4267 580 }
minqi@4267 581 out->cr();
minqi@4267 582 }
minqi@4267 583
duke@435 584 #ifndef PRODUCT
duke@435 585 void ciMethodData::print() {
duke@435 586 print_data_on(tty);
duke@435 587 }
duke@435 588
duke@435 589 void ciMethodData::print_data_on(outputStream* st) {
duke@435 590 ResourceMark rm;
duke@435 591 ciProfileData* data;
duke@435 592 for (data = first_data(); is_valid(data); data = next_data(data)) {
duke@435 593 st->print("%d", dp_to_di(data->dp()));
duke@435 594 st->fill_to(6);
duke@435 595 data->print_data_on(st);
duke@435 596 }
kvn@480 597 st->print_cr("--- Extra data:");
kvn@480 598 DataLayout* dp = data_layout_at(data_size());
kvn@480 599 DataLayout* end = data_layout_at(data_size() + extra_data_size());
roland@6377 600 for (;; dp = MethodData::next_extra(dp)) {
roland@6377 601 assert(dp < end, "moved past end of extra data");
roland@6377 602 switch (dp->tag()) {
roland@6377 603 case DataLayout::no_tag:
roland@6377 604 continue;
roland@6377 605 case DataLayout::bit_data_tag:
kvn@480 606 data = new BitData(dp);
roland@6377 607 break;
roland@6377 608 case DataLayout::arg_info_data_tag:
kvn@480 609 data = new ciArgInfoData(dp);
kvn@480 610 dp = end; // ArgInfoData is at the end of extra data section.
roland@6377 611 break;
roland@6377 612 default:
roland@6377 613 fatal(err_msg("unexpected tag %d", dp->tag()));
kvn@480 614 }
kvn@480 615 st->print("%d", dp_to_di(data->dp()));
kvn@480 616 st->fill_to(6);
kvn@480 617 data->print_data_on(st);
roland@6377 618 if (dp >= end) return;
kvn@480 619 }
duke@435 620 }
duke@435 621
roland@5914 622 void ciTypeEntries::print_ciklass(outputStream* st, intptr_t k) {
roland@5914 623 if (TypeEntries::is_type_none(k)) {
roland@5914 624 st->print("none");
roland@5914 625 } else if (TypeEntries::is_type_unknown(k)) {
roland@5914 626 st->print("unknown");
roland@5914 627 } else {
roland@5914 628 valid_ciklass(k)->print_name_on(st);
roland@5914 629 }
roland@5914 630 if (TypeEntries::was_null_seen(k)) {
roland@5914 631 st->print(" (null seen)");
roland@5914 632 }
roland@5914 633 }
roland@5914 634
roland@5914 635 void ciTypeStackSlotEntries::print_data_on(outputStream* st) const {
roland@5921 636 for (int i = 0; i < _number_of_entries; i++) {
roland@5914 637 _pd->tab(st);
roland@5914 638 st->print("%d: stack (%u) ", i, stack_slot(i));
roland@5914 639 print_ciklass(st, type(i));
roland@5914 640 st->cr();
roland@5914 641 }
roland@5914 642 }
roland@5914 643
roland@5921 644 void ciReturnTypeEntry::print_data_on(outputStream* st) const {
roland@5921 645 _pd->tab(st);
roland@5921 646 st->print("ret ");
roland@5921 647 print_ciklass(st, type());
roland@5921 648 st->cr();
roland@5921 649 }
roland@5921 650
roland@6377 651 void ciCallTypeData::print_data_on(outputStream* st, const char* extra) const {
roland@6377 652 print_shared(st, "ciCallTypeData", extra);
roland@5921 653 if (has_arguments()) {
roland@5921 654 tab(st, true);
roland@5921 655 st->print("argument types");
roland@5921 656 args()->print_data_on(st);
roland@5921 657 }
roland@5921 658 if (has_return()) {
roland@5921 659 tab(st, true);
roland@5921 660 st->print("return type");
roland@5921 661 ret()->print_data_on(st);
roland@5921 662 }
roland@5914 663 }
roland@5914 664
roland@5914 665 void ciReceiverTypeData::print_receiver_data_on(outputStream* st) const {
duke@435 666 uint row;
duke@435 667 int entries = 0;
duke@435 668 for (row = 0; row < row_limit(); row++) {
duke@435 669 if (receiver(row) != NULL) entries++;
duke@435 670 }
duke@435 671 st->print_cr("count(%u) entries(%u)", count(), entries);
duke@435 672 for (row = 0; row < row_limit(); row++) {
duke@435 673 if (receiver(row) != NULL) {
duke@435 674 tab(st);
duke@435 675 receiver(row)->print_name_on(st);
duke@435 676 st->print_cr("(%u)", receiver_count(row));
duke@435 677 }
duke@435 678 }
duke@435 679 }
duke@435 680
roland@6377 681 void ciReceiverTypeData::print_data_on(outputStream* st, const char* extra) const {
roland@6377 682 print_shared(st, "ciReceiverTypeData", extra);
duke@435 683 print_receiver_data_on(st);
duke@435 684 }
duke@435 685
roland@6377 686 void ciVirtualCallData::print_data_on(outputStream* st, const char* extra) const {
roland@6377 687 print_shared(st, "ciVirtualCallData", extra);
duke@435 688 rtd_super()->print_receiver_data_on(st);
duke@435 689 }
roland@5914 690
roland@6377 691 void ciVirtualCallTypeData::print_data_on(outputStream* st, const char* extra) const {
roland@6377 692 print_shared(st, "ciVirtualCallTypeData", extra);
roland@5914 693 rtd_super()->print_receiver_data_on(st);
roland@5921 694 if (has_arguments()) {
roland@5921 695 tab(st, true);
roland@5921 696 st->print("argument types");
roland@5921 697 args()->print_data_on(st);
roland@5921 698 }
roland@5921 699 if (has_return()) {
roland@5921 700 tab(st, true);
roland@5921 701 st->print("return type");
roland@5921 702 ret()->print_data_on(st);
roland@5921 703 }
roland@5914 704 }
roland@5987 705
roland@6377 706 void ciParametersTypeData::print_data_on(outputStream* st, const char* extra) const {
roland@6377 707 st->print_cr("ciParametersTypeData");
roland@5987 708 parameters()->print_data_on(st);
roland@5987 709 }
roland@6377 710
roland@6377 711 void ciSpeculativeTrapData::print_data_on(outputStream* st, const char* extra) const {
roland@6377 712 st->print_cr("ciSpeculativeTrapData");
roland@6377 713 tab(st);
roland@6377 714 method()->print_short_name(st);
roland@6377 715 st->cr();
roland@6377 716 }
duke@435 717 #endif

mercurial