ciMethodData.cpp 22.5 KB
Newer Older
D
duke 已提交
1
/*
2
 * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
19 20 21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
D
duke 已提交
22 23 24
 *
 */

25
#include "precompiled.hpp"
26
#include "ci/ciMetadata.hpp"
27
#include "ci/ciMethodData.hpp"
28
#include "ci/ciReplay.hpp"
29 30 31 32 33
#include "ci/ciUtilities.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/deoptimization.hpp"
#include "utilities/copy.hpp"
D
duke 已提交
34 35 36 37 38 39

// ciMethodData

// ------------------------------------------------------------------
// ciMethodData::ciMethodData
//
40 41
ciMethodData::ciMethodData(MethodData* md) : ciMetadata(md) {
  assert(md != NULL, "no null method data");
D
duke 已提交
42 43 44 45 46
  Copy::zero_to_words((HeapWord*) &_orig, sizeof(_orig) / sizeof(HeapWord));
  _data = NULL;
  _data_size = 0;
  _extra_data_size = 0;
  _current_mileage = 0;
I
iveresov 已提交
47 48
  _invocation_counter = 0;
  _backedge_counter = 0;
D
duke 已提交
49 50 51 52 53
  _state = empty_state;
  _saw_free_extra_data = false;
  // Set an initial hint. Don't use set_hint_di() because
  // first_di() may be out of bounds if data_size is 0.
  _hint_di = first_di();
54 55
  // Initialize the escape information (to "don't know.");
  _eflags = _arg_local = _arg_stack = _arg_returned = 0;
56
  _parameters = NULL;
D
duke 已提交
57 58 59 60 61
}

// ------------------------------------------------------------------
// ciMethodData::ciMethodData
//
62 63
// No MethodData*.
ciMethodData::ciMethodData() : ciMetadata(NULL) {
D
duke 已提交
64 65 66 67 68
  Copy::zero_to_words((HeapWord*) &_orig, sizeof(_orig) / sizeof(HeapWord));
  _data = NULL;
  _data_size = 0;
  _extra_data_size = 0;
  _current_mileage = 0;
I
iveresov 已提交
69 70
  _invocation_counter = 0;
  _backedge_counter = 0;
D
duke 已提交
71 72 73 74 75
  _state = empty_state;
  _saw_free_extra_data = false;
  // Set an initial hint. Don't use set_hint_di() because
  // first_di() may be out of bounds if data_size is 0.
  _hint_di = first_di();
76 77
  // Initialize the escape information (to "don't know.");
  _eflags = _arg_local = _arg_stack = _arg_returned = 0;
78
  _parameters = NULL;
D
duke 已提交
79 80
}

81 82 83 84 85 86 87 88 89
void ciMethodData::load_extra_data() {
  MethodData* mdo = get_MethodData();

  // speculative trap entries also hold a pointer to a Method so need to be translated
  DataLayout* dp_src  = mdo->extra_data_base();
  DataLayout* end_src = mdo->extra_data_limit();
  DataLayout* dp_dst  = extra_data_base();
  for (;; dp_src = MethodData::next_extra(dp_src), dp_dst = MethodData::next_extra(dp_dst)) {
    assert(dp_src < end_src, "moved past end of extra data");
90 91 92
    // New traps in the MDO can be added as we translate the copy so
    // look at the entries in the copy.
    switch(dp_dst->tag()) {
93 94 95 96 97 98 99 100 101 102 103 104 105
    case DataLayout::speculative_trap_data_tag: {
      ciSpeculativeTrapData* data_dst = new ciSpeculativeTrapData(dp_dst);
      SpeculativeTrapData* data_src = new SpeculativeTrapData(dp_src);
      data_dst->translate_from(data_src);
      break;
    }
    case DataLayout::bit_data_tag:
      break;
    case DataLayout::no_tag:
    case DataLayout::arg_info_data_tag:
      // An empty slot or ArgInfoData entry marks the end of the trap data
      return;
    default:
106
      fatal(err_msg("bad tag = %d", dp_dst->tag()));
107 108 109 110
    }
  }
}

D
duke 已提交
111
void ciMethodData::load_data() {
112
  MethodData* mdo = get_MethodData();
113 114 115
  if (mdo == NULL) {
    return;
  }
D
duke 已提交
116 117 118 119 120 121 122

  // To do: don't copy the data if it is not "ripe" -- require a minimum #
  // of invocations.

  // Snapshot the data -- actually, take an approximate snapshot of
  // the data.  Any concurrently executing threads may be changing the
  // data as we copy it.
123 124 125
  Copy::disjoint_words((HeapWord*) mdo,
                       (HeapWord*) &_orig,
                       sizeof(_orig) / HeapWordSize);
D
duke 已提交
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
  Arena* arena = CURRENT_ENV->arena();
  _data_size = mdo->data_size();
  _extra_data_size = mdo->extra_data_size();
  int total_size = _data_size + _extra_data_size;
  _data = (intptr_t *) arena->Amalloc(total_size);
  Copy::disjoint_words((HeapWord*) mdo->data_base(), (HeapWord*) _data, total_size / HeapWordSize);

  // Traverse the profile data, translating any oops into their
  // ci equivalents.
  ResourceMark rm;
  ciProfileData* ci_data = first_data();
  ProfileData* data = mdo->first_data();
  while (is_valid(ci_data)) {
    ci_data->translate_from(data);
    ci_data = next_data(ci_data);
    data = mdo->next_data(data);
  }
143 144 145 146 147 148
  if (mdo->parameters_type_data() != NULL) {
    _parameters = data_layout_at(mdo->parameters_type_data_di());
    ciParametersTypeData* parameters = new ciParametersTypeData(_parameters);
    parameters->translate_from(mdo->parameters_type_data());
  }

149 150
  load_extra_data();

D
duke 已提交
151
  // Note:  Extra data are all BitData, and do not need translation.
152
  _current_mileage = MethodData::mileage_of(mdo->method());
I
iveresov 已提交
153 154
  _invocation_counter = mdo->invocation_count();
  _backedge_counter = mdo->backedge_count();
D
duke 已提交
155 156 157 158 159 160
  _state = mdo->is_mature()? mature_state: immature_state;

  _eflags = mdo->eflags();
  _arg_local = mdo->arg_local();
  _arg_stack = mdo->arg_stack();
  _arg_returned  = mdo->arg_returned();
161 162 163 164 165
#ifndef PRODUCT
  if (ReplayCompiles) {
    ciReplay::initialize(this);
  }
#endif
D
duke 已提交
166 167
}

168
void ciReceiverTypeData::translate_receiver_data_from(const ProfileData* data) {
D
duke 已提交
169
  for (uint row = 0; row < row_limit(); row++) {
170
    Klass* k = data->as_ReceiverTypeData()->receiver(row);
D
duke 已提交
171
    if (k != NULL) {
172
      ciKlass* klass = CURRENT_ENV->get_klass(k);
173
      CURRENT_ENV->ensure_metadata_alive(klass);
D
duke 已提交
174 175 176 177 178 179
      set_receiver(row, klass);
    }
  }
}


180
void ciTypeStackSlotEntries::translate_type_data_from(const TypeStackSlotEntries* entries) {
181
  for (int i = 0; i < _number_of_entries; i++) {
182 183 184 185 186
    intptr_t k = entries->type(i);
    TypeStackSlotEntries::set_type(i, translate_klass(k));
  }
}

187 188 189 190 191
void ciReturnTypeEntry::translate_type_data_from(const ReturnTypeEntry* ret) {
  intptr_t k = ret->type();
  set_type(translate_klass(k));
}

192 193 194
void ciSpeculativeTrapData::translate_from(const ProfileData* data) {
  Method* m = data->as_SpeculativeTrapData()->method();
  ciMethod* ci_m = CURRENT_ENV->get_method(m);
195
  CURRENT_ENV->ensure_metadata_alive(ci_m);
196 197 198
  set_method(ci_m);
}

D
duke 已提交
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
// Get the data at an arbitrary (sort of) data index.
ciProfileData* ciMethodData::data_at(int data_index) {
  if (out_of_bounds(data_index)) {
    return NULL;
  }
  DataLayout* data_layout = data_layout_at(data_index);

  switch (data_layout->tag()) {
  case DataLayout::no_tag:
  default:
    ShouldNotReachHere();
    return NULL;
  case DataLayout::bit_data_tag:
    return new ciBitData(data_layout);
  case DataLayout::counter_data_tag:
    return new ciCounterData(data_layout);
  case DataLayout::jump_data_tag:
    return new ciJumpData(data_layout);
  case DataLayout::receiver_type_data_tag:
    return new ciReceiverTypeData(data_layout);
  case DataLayout::virtual_call_data_tag:
    return new ciVirtualCallData(data_layout);
  case DataLayout::ret_data_tag:
    return new ciRetData(data_layout);
  case DataLayout::branch_data_tag:
    return new ciBranchData(data_layout);
  case DataLayout::multi_branch_data_tag:
    return new ciMultiBranchData(data_layout);
227 228
  case DataLayout::arg_info_data_tag:
    return new ciArgInfoData(data_layout);
229 230 231 232
  case DataLayout::call_type_data_tag:
    return new ciCallTypeData(data_layout);
  case DataLayout::virtual_call_type_data_tag:
    return new ciVirtualCallTypeData(data_layout);
233 234
  case DataLayout::parameters_type_data_tag:
    return new ciParametersTypeData(data_layout);
D
duke 已提交
235 236 237 238 239 240 241 242 243 244 245
  };
}

// Iteration over data.
ciProfileData* ciMethodData::next_data(ciProfileData* current) {
  int current_index = dp_to_di(current->dp());
  int next_index = current_index + current->size_in_bytes();
  ciProfileData* next = data_at(next_index);
  return next;
}

246
ciProfileData* ciMethodData::bci_to_extra_data(int bci, ciMethod* m, bool& two_free_slots) {
D
duke 已提交
247 248 249
  // bci_to_extra_data(bci) ...
  DataLayout* dp  = data_layout_at(data_size());
  DataLayout* end = data_layout_at(data_size() + extra_data_size());
250 251 252 253
  two_free_slots = false;
  for (;dp < end; dp = MethodData::next_extra(dp)) {
    switch(dp->tag()) {
    case DataLayout::no_tag:
D
duke 已提交
254
      _saw_free_extra_data = true;  // observed an empty slot (common case)
255
      two_free_slots = (MethodData::next_extra(dp)->tag() == DataLayout::no_tag);
D
duke 已提交
256
      return NULL;
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
    case DataLayout::arg_info_data_tag:
      return NULL; // ArgInfoData is at the end of extra data section.
    case DataLayout::bit_data_tag:
      if (m == NULL && dp->bci() == bci) {
        return new ciBitData(dp);
      }
      break;
    case DataLayout::speculative_trap_data_tag: {
      ciSpeculativeTrapData* data = new ciSpeculativeTrapData(dp);
      // data->method() might be null if the MDO is snapshotted
      // concurrently with a trap
      if (m != NULL && data->method() == m && dp->bci() == bci) {
        return data;
      }
      break;
D
duke 已提交
272
    }
273 274
    default:
      fatal(err_msg("bad tag = %d", dp->tag()));
275
    }
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
  }
  return NULL;
}

// Translate a bci to its corresponding data, or NULL.
ciProfileData* ciMethodData::bci_to_data(int bci, ciMethod* m) {
  // If m is not NULL we look for a SpeculativeTrapData entry
  if (m == NULL) {
    ciProfileData* data = data_before(bci);
    for ( ; is_valid(data); data = next_data(data)) {
      if (data->bci() == bci) {
        set_hint_di(dp_to_di(data->dp()));
        return data;
      } else if (data->bci() > bci) {
        break;
      }
D
duke 已提交
292 293
    }
  }
294 295 296 297 298 299 300 301 302 303 304
  bool two_free_slots = false;
  ciProfileData* result = bci_to_extra_data(bci, m, two_free_slots);
  if (result != NULL) {
    return result;
  }
  if (m != NULL && !two_free_slots) {
    // We were looking for a SpeculativeTrapData entry we didn't
    // find. Room is not available for more SpeculativeTrapData
    // entries, look in the non SpeculativeTrapData entries.
    return bci_to_data(bci, NULL);
  }
D
duke 已提交
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
  return NULL;
}

// Conservatively decode the trap_state of a ciProfileData.
int ciMethodData::has_trap_at(ciProfileData* data, int reason) {
  typedef Deoptimization::DeoptReason DR_t;
  int per_bc_reason
    = Deoptimization::reason_recorded_per_bytecode_if_any((DR_t) reason);
  if (trap_count(reason) == 0) {
    // Impossible for this trap to have occurred, regardless of trap_state.
    // Note:  This happens if the MDO is empty.
    return 0;
  } else if (per_bc_reason == Deoptimization::Reason_none) {
    // We cannot conclude anything; a trap happened somewhere, maybe here.
    return -1;
  } else if (data == NULL) {
    // No profile here, not even an extra_data record allocated on the fly.
    // If there are empty extra_data records, and there had been a trap,
    // there would have been a non-null data pointer.  If there are no
    // free extra_data records, we must return a conservative -1.
    if (_saw_free_extra_data)
      return 0;                 // Q.E.D.
    else
      return -1;                // bail with a conservative answer
  } else {
    return Deoptimization::trap_state_has_reason(data->trap_state(), per_bc_reason);
  }
}

int ciMethodData::trap_recompiled_at(ciProfileData* data) {
  if (data == NULL) {
    return (_saw_free_extra_data? 0: -1);  // (see previous method)
  } else {
    return Deoptimization::trap_state_is_recompiled(data->trap_state())? 1: 0;
  }
}

void ciMethodData::clear_escape_info() {
  VM_ENTRY_MARK;
344
  MethodData* mdo = get_MethodData();
345
  if (mdo != NULL) {
D
duke 已提交
346
    mdo->clear_escape_info();
347 348 349 350 351 352
    ArgInfoData *aid = arg_info();
    int arg_count = (aid == NULL) ? 0 : aid->number_of_args();
    for (int i = 0; i < arg_count; i++) {
      set_arg_modified(i, 0);
    }
  }
D
duke 已提交
353 354 355
  _eflags = _arg_local = _arg_stack = _arg_returned = 0;
}

356
// copy our escape info to the MethodData* if it exists
D
duke 已提交
357 358
void ciMethodData::update_escape_info() {
  VM_ENTRY_MARK;
359
  MethodData* mdo = get_MethodData();
D
duke 已提交
360 361 362 363 364
  if ( mdo != NULL) {
    mdo->set_eflags(_eflags);
    mdo->set_arg_local(_arg_local);
    mdo->set_arg_stack(_arg_stack);
    mdo->set_arg_returned(_arg_returned);
365 366 367 368
    int arg_count = mdo->method()->size_of_parameters();
    for (int i = 0; i < arg_count; i++) {
      mdo->set_arg_modified(i, arg_modified(i));
    }
D
duke 已提交
369 370 371
  }
}

I
iveresov 已提交
372 373
void ciMethodData::set_compilation_stats(short loops, short blocks) {
  VM_ENTRY_MARK;
374
  MethodData* mdo = get_MethodData();
I
iveresov 已提交
375 376 377 378 379 380 381 382
  if (mdo != NULL) {
    mdo->set_num_loops(loops);
    mdo->set_num_blocks(blocks);
  }
}

void ciMethodData::set_would_profile(bool p) {
  VM_ENTRY_MARK;
383
  MethodData* mdo = get_MethodData();
I
iveresov 已提交
384 385 386 387 388
  if (mdo != NULL) {
    mdo->set_would_profile(p);
  }
}

389 390 391 392 393
void ciMethodData::set_argument_type(int bci, int i, ciKlass* k) {
  VM_ENTRY_MARK;
  MethodData* mdo = get_MethodData();
  if (mdo != NULL) {
    ProfileData* data = mdo->bci_to_data(bci);
394 395 396 397 398 399 400
    if (data != NULL) {
      if (data->is_CallTypeData()) {
        data->as_CallTypeData()->set_argument_type(i, k->get_Klass());
      } else {
        assert(data->is_VirtualCallTypeData(), "no arguments!");
        data->as_VirtualCallTypeData()->set_argument_type(i, k->get_Klass());
      }
401 402 403 404
    }
  }
}

405 406 407 408 409 410 411 412
void ciMethodData::set_parameter_type(int i, ciKlass* k) {
  VM_ENTRY_MARK;
  MethodData* mdo = get_MethodData();
  if (mdo != NULL) {
    mdo->parameters_type_data()->set_type(i, k->get_Klass());
  }
}

413 414 415 416 417
void ciMethodData::set_return_type(int bci, ciKlass* k) {
  VM_ENTRY_MARK;
  MethodData* mdo = get_MethodData();
  if (mdo != NULL) {
    ProfileData* data = mdo->bci_to_data(bci);
418 419 420 421 422 423 424
    if (data != NULL) {
      if (data->is_CallTypeData()) {
        data->as_CallTypeData()->set_return_type(k->get_Klass());
      } else {
        assert(data->is_VirtualCallTypeData(), "no arguments!");
        data->as_VirtualCallTypeData()->set_return_type(k->get_Klass());
      }
425 426 427 428
    }
  }
}

D
duke 已提交
429
bool ciMethodData::has_escape_info() {
430
  return eflag_set(MethodData::estimated);
D
duke 已提交
431 432
}

433
void ciMethodData::set_eflag(MethodData::EscapeFlag f) {
D
duke 已提交
434 435 436
  set_bits(_eflags, f);
}

437
void ciMethodData::clear_eflag(MethodData::EscapeFlag f) {
D
duke 已提交
438 439 440
  clear_bits(_eflags, f);
}

441
bool ciMethodData::eflag_set(MethodData::EscapeFlag f) const {
D
duke 已提交
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
  return mask_bits(_eflags, f) != 0;
}

void ciMethodData::set_arg_local(int i) {
  set_nth_bit(_arg_local, i);
}

void ciMethodData::set_arg_stack(int i) {
  set_nth_bit(_arg_stack, i);
}

void ciMethodData::set_arg_returned(int i) {
  set_nth_bit(_arg_returned, i);
}

457 458 459 460 461 462 463 464
void ciMethodData::set_arg_modified(int arg, uint val) {
  ArgInfoData *aid = arg_info();
  if (aid == NULL)
    return;
  assert(arg >= 0 && arg < aid->number_of_args(), "valid argument number");
  aid->set_arg_modified(arg, val);
}

D
duke 已提交
465 466 467 468 469 470 471 472 473 474 475 476
bool ciMethodData::is_arg_local(int i) const {
  return is_set_nth_bit(_arg_local, i);
}

bool ciMethodData::is_arg_stack(int i) const {
  return is_set_nth_bit(_arg_stack, i);
}

bool ciMethodData::is_arg_returned(int i) const {
  return is_set_nth_bit(_arg_returned, i);
}

477 478 479 480 481 482 483 484
uint ciMethodData::arg_modified(int arg) const {
  ArgInfoData *aid = arg_info();
  if (aid == NULL)
    return 0;
  assert(arg >= 0 && arg < aid->number_of_args(), "valid argument number");
  return aid->arg_modified(arg);
}

D
duke 已提交
485
ByteSize ciMethodData::offset_of_slot(ciProfileData* data, ByteSize slot_offset_in_data) {
486 487
  // Get offset within MethodData* of the data array
  ByteSize data_offset = MethodData::data_offset();
D
duke 已提交
488 489 490 491 492 493 494 495 496 497

  // Get cell offset of the ProfileData within data array
  int cell_offset = dp_to_di(data->dp());

  // Add in counter_offset, the # of bytes into the ProfileData of counter or flag
  int offset = in_bytes(data_offset) + cell_offset + in_bytes(slot_offset_in_data);

  return in_ByteSize(offset);
}

498 499 500 501
ciArgInfoData *ciMethodData::arg_info() const {
  // Should be last, have to skip all traps.
  DataLayout* dp  = data_layout_at(data_size());
  DataLayout* end = data_layout_at(data_size() + extra_data_size());
502
  for (; dp < end; dp = MethodData::next_extra(dp)) {
503 504 505 506 507 508 509
    if (dp->tag() == DataLayout::arg_info_data_tag)
      return new ciArgInfoData(dp);
  }
  return NULL;
}


D
duke 已提交
510 511
// Implementation of the print method.
void ciMethodData::print_impl(outputStream* st) {
512
  ciMetadata::print_impl(st);
D
duke 已提交
513 514
}

515
void ciMethodData::dump_replay_data(outputStream* out) {
516
  ResourceMark rm;
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
  MethodData* mdo = get_MethodData();
  Method* method = mdo->method();
  Klass* holder = method->method_holder();
  out->print("ciMethodData %s %s %s %d %d",
             holder->name()->as_quoted_ascii(),
             method->name()->as_quoted_ascii(),
             method->signature()->as_quoted_ascii(),
             _state,
             current_mileage());

  // dump the contents of the MDO header as raw data
  unsigned char* orig = (unsigned char*)&_orig;
  int length = sizeof(_orig);
  out->print(" orig %d", length);
  for (int i = 0; i < length; i++) {
    out->print(" %d", orig[i]);
  }

  // dump the MDO data as raw data
  int elements = data_size() / sizeof(intptr_t);
  out->print(" data %d", elements);
  for (int i = 0; i < elements; i++) {
    // We could use INTPTR_FORMAT here but that's a zero justified
    // which makes comparing it with the SA version of this output
    // harder.
#ifdef _LP64
    out->print(" 0x%" FORMAT64_MODIFIER "x", data()[i]);
#else
    out->print(" 0x%x", data()[i]);
#endif
  }

  // The MDO contained oop references as ciObjects, so scan for those
  // and emit pairs of offset and klass name so that they can be
  // reconstructed at runtime.  The first round counts the number of
  // oop references and the second actually emits them.
  int count = 0;
  for (int round = 0; round < 2; round++) {
    if (round == 1) out->print(" oops %d", count);
    ProfileData* pdata = first_data();
    for ( ; is_valid(pdata); pdata = next_data(pdata)) {
      if (pdata->is_ReceiverTypeData()) {
        ciReceiverTypeData* vdata = (ciReceiverTypeData*)pdata;
        for (uint i = 0; i < vdata->row_limit(); i++) {
          ciKlass* k = vdata->receiver(i);
          if (k != NULL) {
            if (round == 0) {
              count++;
            } else {
566
              out->print(" %d %s", (int)(dp_to_di(vdata->dp() + in_bytes(vdata->receiver_offset(i))) / sizeof(intptr_t)), k->name()->as_quoted_ascii());
567 568 569 570 571 572 573 574 575 576 577
            }
          }
        }
      } else if (pdata->is_VirtualCallData()) {
        ciVirtualCallData* vdata = (ciVirtualCallData*)pdata;
        for (uint i = 0; i < vdata->row_limit(); i++) {
          ciKlass* k = vdata->receiver(i);
          if (k != NULL) {
            if (round == 0) {
              count++;
            } else {
578
              out->print(" %d %s", (int)(dp_to_di(vdata->dp() + in_bytes(vdata->receiver_offset(i))) / sizeof(intptr_t)), k->name()->as_quoted_ascii());
579 580 581 582 583 584 585 586 587
            }
          }
        }
      }
    }
  }
  out->cr();
}

D
duke 已提交
588 589 590 591 592 593 594 595 596 597 598 599 600
#ifndef PRODUCT
void ciMethodData::print() {
  print_data_on(tty);
}

void ciMethodData::print_data_on(outputStream* st) {
  ResourceMark rm;
  ciProfileData* data;
  for (data = first_data(); is_valid(data); data = next_data(data)) {
    st->print("%d", dp_to_di(data->dp()));
    st->fill_to(6);
    data->print_data_on(st);
  }
601 602 603
  st->print_cr("--- Extra data:");
  DataLayout* dp  = data_layout_at(data_size());
  DataLayout* end = data_layout_at(data_size() + extra_data_size());
604 605 606 607 608 609
  for (;; dp = MethodData::next_extra(dp)) {
    assert(dp < end, "moved past end of extra data");
    switch (dp->tag()) {
    case DataLayout::no_tag:
      continue;
    case DataLayout::bit_data_tag:
610
      data = new BitData(dp);
611 612
      break;
    case DataLayout::arg_info_data_tag:
613 614
      data = new ciArgInfoData(dp);
      dp = end; // ArgInfoData is at the end of extra data section.
615 616 617
      break;
    default:
      fatal(err_msg("unexpected tag %d", dp->tag()));
618 619 620 621
    }
    st->print("%d", dp_to_di(data->dp()));
    st->fill_to(6);
    data->print_data_on(st);
622
    if (dp >= end) return;
623
  }
D
duke 已提交
624 625
}

626 627 628 629 630 631 632 633 634 635 636 637 638 639
void ciTypeEntries::print_ciklass(outputStream* st, intptr_t k) {
  if (TypeEntries::is_type_none(k)) {
    st->print("none");
  } else if (TypeEntries::is_type_unknown(k)) {
    st->print("unknown");
  } else {
    valid_ciklass(k)->print_name_on(st);
  }
  if (TypeEntries::was_null_seen(k)) {
    st->print(" (null seen)");
  }
}

void ciTypeStackSlotEntries::print_data_on(outputStream* st) const {
640
  for (int i = 0; i < _number_of_entries; i++) {
641 642 643 644 645 646 647
    _pd->tab(st);
    st->print("%d: stack (%u) ", i, stack_slot(i));
    print_ciklass(st, type(i));
    st->cr();
  }
}

648 649 650 651 652 653 654
void ciReturnTypeEntry::print_data_on(outputStream* st) const {
  _pd->tab(st);
  st->print("ret ");
  print_ciklass(st, type());
  st->cr();
}

655 656
void ciCallTypeData::print_data_on(outputStream* st, const char* extra) const {
  print_shared(st, "ciCallTypeData", extra);
657 658 659 660 661 662 663 664 665 666
  if (has_arguments()) {
    tab(st, true);
    st->print("argument types");
    args()->print_data_on(st);
  }
  if (has_return()) {
    tab(st, true);
    st->print("return type");
    ret()->print_data_on(st);
  }
667 668 669
}

void ciReceiverTypeData::print_receiver_data_on(outputStream* st) const {
D
duke 已提交
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684
  uint row;
  int entries = 0;
  for (row = 0; row < row_limit(); row++) {
    if (receiver(row) != NULL)  entries++;
  }
  st->print_cr("count(%u) entries(%u)", count(), entries);
  for (row = 0; row < row_limit(); row++) {
    if (receiver(row) != NULL) {
      tab(st);
      receiver(row)->print_name_on(st);
      st->print_cr("(%u)", receiver_count(row));
    }
  }
}

685 686
void ciReceiverTypeData::print_data_on(outputStream* st, const char* extra) const {
  print_shared(st, "ciReceiverTypeData", extra);
D
duke 已提交
687 688 689
  print_receiver_data_on(st);
}

690 691
void ciVirtualCallData::print_data_on(outputStream* st, const char* extra) const {
  print_shared(st, "ciVirtualCallData", extra);
D
duke 已提交
692 693
  rtd_super()->print_receiver_data_on(st);
}
694

695 696
void ciVirtualCallTypeData::print_data_on(outputStream* st, const char* extra) const {
  print_shared(st, "ciVirtualCallTypeData", extra);
697
  rtd_super()->print_receiver_data_on(st);
698 699 700 701 702 703 704 705 706 707
  if (has_arguments()) {
    tab(st, true);
    st->print("argument types");
    args()->print_data_on(st);
  }
  if (has_return()) {
    tab(st, true);
    st->print("return type");
    ret()->print_data_on(st);
  }
708
}
709

710 711
void ciParametersTypeData::print_data_on(outputStream* st, const char* extra) const {
  st->print_cr("ciParametersTypeData");
712 713
  parameters()->print_data_on(st);
}
714 715 716 717 718 719 720

void ciSpeculativeTrapData::print_data_on(outputStream* st, const char* extra) const {
  st->print_cr("ciSpeculativeTrapData");
  tab(st);
  method()->print_short_name(st);
  st->cr();
}
D
duke 已提交
721
#endif