1 /*
   2  * Copyright 2000-2009 Sun Microsystems, Inc.  All Rights Reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  *
  23  */
  24 
  25 class BytecodeStream;
  26 
  27 // The MethodData object collects counts and other profile information
  28 // during zeroth-tier (interpretive) and first-tier execution.
  29 // The profile is used later by compilation heuristics.  Some heuristics
  30 // enable use of aggressive (or "heroic") optimizations.  An aggressive
  31 // optimization often has a down-side, a corner case that it handles
  32 // poorly, but which is thought to be rare.  The profile provides
  33 // evidence of this rarity for a given method or even BCI.  It allows
  34 // the compiler to back out of the optimization at places where it
  35 // has historically been a poor choice.  Other heuristics try to use
  36 // specific information gathered about types observed at a given site.
  37 //
  38 // All data in the profile is approximate.  It is expected to be accurate
  39 // on the whole, but the system expects occasional inaccuraces, due to
  40 // counter overflow, multiprocessor races during data collection, space
  41 // limitations, missing MDO blocks, etc.  Bad or missing data will degrade
  42 // optimization quality but will not affect correctness.  Also, each MDO
  43 // is marked with its birth-date ("creation_mileage") which can be used
  44 // to assess the quality ("maturity") of its data.
  45 //
  46 // Short (<32-bit) counters are designed to overflow to a known "saturated"
  47 // state.  Also, certain recorded per-BCI events are given one-bit counters
  48 // which overflow to a saturated state which applied to all counters at
  49 // that BCI.  In other words, there is a small lattice which approximates
  50 // the ideal of an infinite-precision counter for each event at each BCI,
  51 // and the lattice quickly "bottoms out" in a state where all counters
  52 // are taken to be indefinitely large.
  53 //
  54 // The reader will find many data races in profile gathering code, starting
  55 // with invocation counter incrementation.  None of these races harm correct
  56 // execution of the compiled code.
  57 
  58 // forward decl
  59 class ProfileData;
  60 
  61 // DataLayout
  62 //
  63 // Overlay for generic profiling data.
  64 class DataLayout VALUE_OBJ_CLASS_SPEC {
  65 private:
  66   // Every data layout begins with a header.  This header
  67   // contains a tag, which is used to indicate the size/layout
  68   // of the data, 4 bits of flags, which can be used in any way,
  69   // 4 bits of trap history (none/one reason/many reasons),
  70   // and a bci, which is used to tie this piece of data to a
  71   // specific bci in the bytecodes.
  72   union {
  73     intptr_t _bits;
  74     struct {
  75       u1 _tag;
  76       u1 _flags;
  77       u2 _bci;
  78     } _struct;
  79   } _header;
  80 
  81   // The data layout has an arbitrary number of cells, each sized
  82   // to accomodate a pointer or an integer.
  83   intptr_t _cells[1];
  84 
  85   // Some types of data layouts need a length field.
  86   static bool needs_array_len(u1 tag);
  87 
  88 public:
  89   enum {
  90     counter_increment = 1
  91   };
  92 
  93   enum {
  94     cell_size = sizeof(intptr_t)
  95   };
  96 
  97   // Tag values
  98   enum {
  99     no_tag,
 100     bit_data_tag,
 101     counter_data_tag,
 102     jump_data_tag,
 103     receiver_type_data_tag,
 104     virtual_call_data_tag,
 105     ret_data_tag,
 106     branch_data_tag,
 107     multi_branch_data_tag,
 108     arg_info_data_tag
 109   };
 110 
 111   enum {
 112     // The _struct._flags word is formatted as [trap_state:4 | flags:4].
 113     // The trap state breaks down further as [recompile:1 | reason:3].
 114     // This further breakdown is defined in deoptimization.cpp.
 115     // See Deoptimization::trap_state_reason for an assert that
 116     // trap_bits is big enough to hold reasons < Reason_RECORDED_LIMIT.
 117     //
 118     // The trap_state is collected only if ProfileTraps is true.
 119     trap_bits = 1+3,  // 3: enough to distinguish [0..Reason_RECORDED_LIMIT].
 120     trap_shift = BitsPerByte - trap_bits,
 121     trap_mask = right_n_bits(trap_bits),
 122     trap_mask_in_place = (trap_mask << trap_shift),
 123     flag_limit = trap_shift,
 124     flag_mask = right_n_bits(flag_limit),
 125     first_flag = 0
 126   };
 127 
 128   // Size computation
 129   static int header_size_in_bytes() {
 130     return cell_size;
 131   }
 132   static int header_size_in_cells() {
 133     return 1;
 134   }
 135 
 136   static int compute_size_in_bytes(int cell_count) {
 137     return header_size_in_bytes() + cell_count * cell_size;
 138   }
 139 
 140   // Initialization
 141   void initialize(u1 tag, u2 bci, int cell_count);
 142 
 143   // Accessors
 144   u1 tag() {
 145     return _header._struct._tag;
 146   }
 147 
 148   // Return a few bits of trap state.  Range is [0..trap_mask].
 149   // The state tells if traps with zero, one, or many reasons have occurred.
 150   // It also tells whether zero or many recompilations have occurred.
 151   // The associated trap histogram in the MDO itself tells whether
 152   // traps are common or not.  If a BCI shows that a trap X has
 153   // occurred, and the MDO shows N occurrences of X, we make the
 154   // simplifying assumption that all N occurrences can be blamed
 155   // on that BCI.
 156   int trap_state() {
 157     return ((_header._struct._flags >> trap_shift) & trap_mask);
 158   }
 159 
 160   void set_trap_state(int new_state) {
 161     assert(ProfileTraps, "used only under +ProfileTraps");
 162     uint old_flags = (_header._struct._flags & flag_mask);
 163     _header._struct._flags = (new_state << trap_shift) | old_flags;
 164   }
 165 
 166   u1 flags() {
 167     return _header._struct._flags;
 168   }
 169 
 170   u2 bci() {
 171     return _header._struct._bci;
 172   }
 173 
 174   void set_header(intptr_t value) {
 175     _header._bits = value;
 176   }
 177   void release_set_header(intptr_t value) {
 178     OrderAccess::release_store_ptr(&_header._bits, value);
 179   }
 180   intptr_t header() {
 181     return _header._bits;
 182   }
 183   void set_cell_at(int index, intptr_t value) {
 184     _cells[index] = value;
 185   }
 186   void release_set_cell_at(int index, intptr_t value) {
 187     OrderAccess::release_store_ptr(&_cells[index], value);
 188   }
 189   intptr_t cell_at(int index) {
 190     return _cells[index];
 191   }
 192   intptr_t* adr_cell_at(int index) {
 193     return &_cells[index];
 194   }
 195   oop* adr_oop_at(int index) {
 196     return (oop*)&(_cells[index]);
 197   }
 198 
 199   void set_flag_at(int flag_number) {
 200     assert(flag_number < flag_limit, "oob");
 201     _header._struct._flags |= (0x1 << flag_number);
 202   }
 203   bool flag_at(int flag_number) {
 204     assert(flag_number < flag_limit, "oob");
 205     return (_header._struct._flags & (0x1 << flag_number)) != 0;
 206   }
 207 
 208   // Low-level support for code generation.
 209   static ByteSize header_offset() {
 210     return byte_offset_of(DataLayout, _header);
 211   }
 212   static ByteSize tag_offset() {
 213     return byte_offset_of(DataLayout, _header._struct._tag);
 214   }
 215   static ByteSize flags_offset() {
 216     return byte_offset_of(DataLayout, _header._struct._flags);
 217   }
 218   static ByteSize bci_offset() {
 219     return byte_offset_of(DataLayout, _header._struct._bci);
 220   }
 221   static ByteSize cell_offset(int index) {
 222     return byte_offset_of(DataLayout, _cells[index]);
 223   }
 224   // Return a value which, when or-ed as a byte into _flags, sets the flag.
 225   static int flag_number_to_byte_constant(int flag_number) {
 226     assert(0 <= flag_number && flag_number < flag_limit, "oob");
 227     DataLayout temp; temp.set_header(0);
 228     temp.set_flag_at(flag_number);
 229     return temp._header._struct._flags;
 230   }
 231   // Return a value which, when or-ed as a word into _header, sets the flag.
 232   static intptr_t flag_mask_to_header_mask(int byte_constant) {
 233     DataLayout temp; temp.set_header(0);
 234     temp._header._struct._flags = byte_constant;
 235     return temp._header._bits;
 236   }
 237 
 238   // GC support
 239   ProfileData* data_in();
 240   void follow_weak_refs(BoolObjectClosure* cl);
 241 };
 242 
 243 
 244 // ProfileData class hierarchy
 245 class ProfileData;
 246 class   BitData;
 247 class     CounterData;
 248 class       ReceiverTypeData;
 249 class         VirtualCallData;
 250 class       RetData;
 251 class   JumpData;
 252 class     BranchData;
 253 class   ArrayData;
 254 class     MultiBranchData;
 255 class     ArgInfoData;
 256 
 257 
 258 // ProfileData
 259 //
 260 // A ProfileData object is created to refer to a section of profiling
 261 // data in a structured way.
 262 class ProfileData : public ResourceObj {
 263 private:
 264 #ifndef PRODUCT
 265   enum {
 266     tab_width_one = 16,
 267     tab_width_two = 36
 268   };
 269 #endif // !PRODUCT
 270 
 271   // This is a pointer to a section of profiling data.
 272   DataLayout* _data;
 273 
 274 protected:
 275   DataLayout* data() { return _data; }
 276 
 277   enum {
 278     cell_size = DataLayout::cell_size
 279   };
 280 
 281 public:
 282   // How many cells are in this?
 283   virtual int cell_count() {
 284     ShouldNotReachHere();
 285     return -1;
 286   }
 287 
 288   // Return the size of this data.
 289   int size_in_bytes() {
 290     return DataLayout::compute_size_in_bytes(cell_count());
 291   }
 292 
 293 protected:
 294   // Low-level accessors for underlying data
 295   void set_intptr_at(int index, intptr_t value) {
 296     assert(0 <= index && index < cell_count(), "oob");
 297     data()->set_cell_at(index, value);
 298   }
 299   void release_set_intptr_at(int index, intptr_t value) {
 300     assert(0 <= index && index < cell_count(), "oob");
 301     data()->release_set_cell_at(index, value);
 302   }
 303   intptr_t intptr_at(int index) {
 304     assert(0 <= index && index < cell_count(), "oob");
 305     return data()->cell_at(index);
 306   }
 307   void set_uint_at(int index, uint value) {
 308     set_intptr_at(index, (intptr_t) value);
 309   }
 310   void release_set_uint_at(int index, uint value) {
 311     release_set_intptr_at(index, (intptr_t) value);
 312   }
 313   uint uint_at(int index) {
 314     return (uint)intptr_at(index);
 315   }
 316   void set_int_at(int index, int value) {
 317     set_intptr_at(index, (intptr_t) value);
 318   }
 319   void release_set_int_at(int index, int value) {
 320     release_set_intptr_at(index, (intptr_t) value);
 321   }
 322   int int_at(int index) {
 323     return (int)intptr_at(index);
 324   }
 325   int int_at_unchecked(int index) {
 326     return (int)data()->cell_at(index);
 327   }
 328   void set_oop_at(int index, oop value) {
 329     set_intptr_at(index, (intptr_t) value);
 330   }
 331   oop oop_at(int index) {
 332     return (oop)intptr_at(index);
 333   }
 334   oop* adr_oop_at(int index) {
 335     assert(0 <= index && index < cell_count(), "oob");
 336     return data()->adr_oop_at(index);
 337   }
 338 
 339   void set_flag_at(int flag_number) {
 340     data()->set_flag_at(flag_number);
 341   }
 342   bool flag_at(int flag_number) {
 343     return data()->flag_at(flag_number);
 344   }
 345 
 346   // two convenient imports for use by subclasses:
 347   static ByteSize cell_offset(int index) {
 348     return DataLayout::cell_offset(index);
 349   }
 350   static int flag_number_to_byte_constant(int flag_number) {
 351     return DataLayout::flag_number_to_byte_constant(flag_number);
 352   }
 353 
 354   ProfileData(DataLayout* data) {
 355     _data = data;
 356   }
 357 
 358 public:
 359   // Constructor for invalid ProfileData.
 360   ProfileData();
 361 
 362   u2 bci() {
 363     return data()->bci();
 364   }
 365 
 366   address dp() {
 367     return (address)_data;
 368   }
 369 
 370   int trap_state() {
 371     return data()->trap_state();
 372   }
 373   void set_trap_state(int new_state) {
 374     data()->set_trap_state(new_state);
 375   }
 376 
 377   // Type checking
 378   virtual bool is_BitData()         { return false; }
 379   virtual bool is_CounterData()     { return false; }
 380   virtual bool is_JumpData()        { return false; }
 381   virtual bool is_ReceiverTypeData(){ return false; }
 382   virtual bool is_VirtualCallData() { return false; }
 383   virtual bool is_RetData()         { return false; }
 384   virtual bool is_BranchData()      { return false; }
 385   virtual bool is_ArrayData()       { return false; }
 386   virtual bool is_MultiBranchData() { return false; }
 387   virtual bool is_ArgInfoData()     { return false; }
 388 
 389 
 390   BitData* as_BitData() {
 391     assert(is_BitData(), "wrong type");
 392     return is_BitData()         ? (BitData*)        this : NULL;
 393   }
 394   CounterData* as_CounterData() {
 395     assert(is_CounterData(), "wrong type");
 396     return is_CounterData()     ? (CounterData*)    this : NULL;
 397   }
 398   JumpData* as_JumpData() {
 399     assert(is_JumpData(), "wrong type");
 400     return is_JumpData()        ? (JumpData*)       this : NULL;
 401   }
 402   ReceiverTypeData* as_ReceiverTypeData() {
 403     assert(is_ReceiverTypeData(), "wrong type");
 404     return is_ReceiverTypeData() ? (ReceiverTypeData*)this : NULL;
 405   }
 406   VirtualCallData* as_VirtualCallData() {
 407     assert(is_VirtualCallData(), "wrong type");
 408     return is_VirtualCallData() ? (VirtualCallData*)this : NULL;
 409   }
 410   RetData* as_RetData() {
 411     assert(is_RetData(), "wrong type");
 412     return is_RetData()         ? (RetData*)        this : NULL;
 413   }
 414   BranchData* as_BranchData() {
 415     assert(is_BranchData(), "wrong type");
 416     return is_BranchData()      ? (BranchData*)     this : NULL;
 417   }
 418   ArrayData* as_ArrayData() {
 419     assert(is_ArrayData(), "wrong type");
 420     return is_ArrayData()       ? (ArrayData*)      this : NULL;
 421   }
 422   MultiBranchData* as_MultiBranchData() {
 423     assert(is_MultiBranchData(), "wrong type");
 424     return is_MultiBranchData() ? (MultiBranchData*)this : NULL;
 425   }
 426   ArgInfoData* as_ArgInfoData() {
 427     assert(is_ArgInfoData(), "wrong type");
 428     return is_ArgInfoData() ? (ArgInfoData*)this : NULL;
 429   }
 430 
 431 
 432   // Subclass specific initialization
 433   virtual void post_initialize(BytecodeStream* stream, methodDataOop mdo) {}
 434 
 435   // GC support
 436   virtual void follow_contents() {}
 437   virtual void oop_iterate(OopClosure* blk) {}
 438   virtual void oop_iterate_m(OopClosure* blk, MemRegion mr) {}
 439   virtual void adjust_pointers() {}
 440   virtual void follow_weak_refs(BoolObjectClosure* is_alive_closure) {}
 441 
 442 #ifndef SERIALGC
 443   // Parallel old support
 444   virtual void follow_contents(ParCompactionManager* cm) {}
 445   virtual void update_pointers() {}
 446   virtual void update_pointers(HeapWord* beg_addr, HeapWord* end_addr) {}
 447 #endif // SERIALGC
 448 
 449   // CI translation: ProfileData can represent both MethodDataOop data
 450   // as well as CIMethodData data. This function is provided for translating
 451   // an oop in a ProfileData to the ci equivalent. Generally speaking,
 452   // most ProfileData don't require any translation, so we provide the null
 453   // translation here, and the required translators are in the ci subclasses.
 454   virtual void translate_from(ProfileData* data) {}
 455 
 456   virtual void print_data_on(outputStream* st) {
 457     ShouldNotReachHere();
 458   }
 459 
 460 #ifndef PRODUCT
 461   void print_shared(outputStream* st, const char* name);
 462   void tab(outputStream* st);
 463 #endif
 464 };
 465 
 466 // BitData
 467 //
 468 // A BitData holds a flag or two in its header.
 469 class BitData : public ProfileData {
 470 protected:
 471   enum {
 472     // null_seen:
 473     //  saw a null operand (cast/aastore/instanceof)
 474     null_seen_flag              = DataLayout::first_flag + 0
 475   };
 476   enum { bit_cell_count = 0 };  // no additional data fields needed.
 477 public:
 478   BitData(DataLayout* layout) : ProfileData(layout) {
 479   }
 480 
 481   virtual bool is_BitData() { return true; }
 482 
 483   static int static_cell_count() {
 484     return bit_cell_count;
 485   }
 486 
 487   virtual int cell_count() {
 488     return static_cell_count();
 489   }
 490 
 491   // Accessor
 492 
 493   // The null_seen flag bit is specially known to the interpreter.
 494   // Consulting it allows the compiler to avoid setting up null_check traps.
 495   bool null_seen()     { return flag_at(null_seen_flag); }
 496   void set_null_seen()    { set_flag_at(null_seen_flag); }
 497 
 498 
 499   // Code generation support
 500   static int null_seen_byte_constant() {
 501     return flag_number_to_byte_constant(null_seen_flag);
 502   }
 503 
 504   static ByteSize bit_data_size() {
 505     return cell_offset(bit_cell_count);
 506   }
 507 
 508 #ifndef PRODUCT
 509   void print_data_on(outputStream* st);
 510 #endif
 511 };
 512 
 513 // CounterData
 514 //
 515 // A CounterData corresponds to a simple counter.
 516 class CounterData : public BitData {
 517 protected:
 518   enum {
 519     count_off,
 520     counter_cell_count
 521   };
 522 public:
 523   CounterData(DataLayout* layout) : BitData(layout) {}
 524 
 525   virtual bool is_CounterData() { return true; }
 526 
 527   static int static_cell_count() {
 528     return counter_cell_count;
 529   }
 530 
 531   virtual int cell_count() {
 532     return static_cell_count();
 533   }
 534 
 535   // Direct accessor
 536   uint count() {
 537     return uint_at(count_off);
 538   }
 539 
 540   // Code generation support
 541   static ByteSize count_offset() {
 542     return cell_offset(count_off);
 543   }
 544   static ByteSize counter_data_size() {
 545     return cell_offset(counter_cell_count);
 546   }
 547 
 548   void set_count(uint count) {
 549     set_uint_at(count_off, count);
 550   }
 551 
 552 #ifndef PRODUCT
 553   void print_data_on(outputStream* st);
 554 #endif
 555 };
 556 
 557 // JumpData
 558 //
 559 // A JumpData is used to access profiling information for a direct
 560 // branch.  It is a counter, used for counting the number of branches,
 561 // plus a data displacement, used for realigning the data pointer to
 562 // the corresponding target bci.
 563 class JumpData : public ProfileData {
 564 protected:
 565   enum {
 566     taken_off_set,
 567     displacement_off_set,
 568     jump_cell_count
 569   };
 570 
 571   void set_displacement(int displacement) {
 572     set_int_at(displacement_off_set, displacement);
 573   }
 574 
 575 public:
 576   JumpData(DataLayout* layout) : ProfileData(layout) {
 577     assert(layout->tag() == DataLayout::jump_data_tag ||
 578       layout->tag() == DataLayout::branch_data_tag, "wrong type");
 579   }
 580 
 581   virtual bool is_JumpData() { return true; }
 582 
 583   static int static_cell_count() {
 584     return jump_cell_count;
 585   }
 586 
 587   virtual int cell_count() {
 588     return static_cell_count();
 589   }
 590 
 591   // Direct accessor
 592   uint taken() {
 593     return uint_at(taken_off_set);
 594   }
 595   // Saturating counter
 596   uint inc_taken() {
 597     uint cnt = taken() + 1;
 598     // Did we wrap? Will compiler screw us??
 599     if (cnt == 0) cnt--;
 600     set_uint_at(taken_off_set, cnt);
 601     return cnt;
 602   }
 603 
 604   int displacement() {
 605     return int_at(displacement_off_set);
 606   }
 607 
 608   // Code generation support
 609   static ByteSize taken_offset() {
 610     return cell_offset(taken_off_set);
 611   }
 612 
 613   static ByteSize displacement_offset() {
 614     return cell_offset(displacement_off_set);
 615   }
 616 
 617   // Specific initialization.
 618   void post_initialize(BytecodeStream* stream, methodDataOop mdo);
 619 
 620 #ifndef PRODUCT
 621   void print_data_on(outputStream* st);
 622 #endif
 623 };
 624 
 625 // ReceiverTypeData
 626 //
 627 // A ReceiverTypeData is used to access profiling information about a
 628 // dynamic type check.  It consists of a counter which counts the total times
 629 // that the check is reached, and a series of (klassOop, count) pairs
 630 // which are used to store a type profile for the receiver of the check.
 631 class ReceiverTypeData : public CounterData {
 632 protected:
 633   enum {
 634     receiver0_offset = counter_cell_count,
 635     count0_offset,
 636     receiver_type_row_cell_count = (count0_offset + 1) - receiver0_offset
 637   };
 638 
 639 public:
 640   ReceiverTypeData(DataLayout* layout) : CounterData(layout) {
 641     assert(layout->tag() == DataLayout::receiver_type_data_tag ||
 642            layout->tag() == DataLayout::virtual_call_data_tag, "wrong type");
 643   }
 644 
 645   virtual bool is_ReceiverTypeData() { return true; }
 646 
 647   static int static_cell_count() {
 648     return counter_cell_count + (uint) TypeProfileWidth * receiver_type_row_cell_count;
 649   }
 650 
 651   virtual int cell_count() {
 652     return static_cell_count();
 653   }
 654 
 655   // Direct accessors
 656   static uint row_limit() {
 657     return TypeProfileWidth;
 658   }
 659   static int receiver_cell_index(uint row) {
 660     return receiver0_offset + row * receiver_type_row_cell_count;
 661   }
 662   static int receiver_count_cell_index(uint row) {
 663     return count0_offset + row * receiver_type_row_cell_count;
 664   }
 665 
 666   // Get the receiver at row.  The 'unchecked' version is needed by parallel old
 667   // gc; it does not assert the receiver is a klass.  During compaction of the
 668   // perm gen, the klass may already have moved, so the is_klass() predicate
 669   // would fail.  The 'normal' version should be used whenever possible.
 670   klassOop receiver_unchecked(uint row) {
 671     assert(row < row_limit(), "oob");
 672     oop recv = oop_at(receiver_cell_index(row));
 673     return (klassOop)recv;
 674   }
 675 
 676   klassOop receiver(uint row) {
 677     klassOop recv = receiver_unchecked(row);
 678     assert(recv == NULL || ((oop)recv)->is_klass(), "wrong type");
 679     return recv;
 680   }
 681 
 682   void set_receiver(uint row, oop p) {
 683     assert((uint)row < row_limit(), "oob");
 684     set_oop_at(receiver_cell_index(row), p);
 685   }
 686 
 687   uint receiver_count(uint row) {
 688     assert(row < row_limit(), "oob");
 689     return uint_at(receiver_count_cell_index(row));
 690   }
 691 
 692   void set_receiver_count(uint row, uint count) {
 693     assert(row < row_limit(), "oob");
 694     set_uint_at(receiver_count_cell_index(row), count);
 695   }
 696 
 697   void clear_row(uint row) {
 698     assert(row < row_limit(), "oob");
 699     // Cleare total count - indicator of polimorphic call site.
 700     // An additional receiver will be recorded in the cleaned row
 701     // during next call execution.
 702     set_count(0);
 703     set_receiver(row, NULL);
 704     set_receiver_count(row, 0);
 705   }
 706 
 707   // Code generation support
 708   static ByteSize receiver_offset(uint row) {
 709     return cell_offset(receiver_cell_index(row));
 710   }
 711   static ByteSize receiver_count_offset(uint row) {
 712     return cell_offset(receiver_count_cell_index(row));
 713   }
 714   static ByteSize receiver_type_data_size() {
 715     return cell_offset(static_cell_count());
 716   }
 717 
 718   // GC support
 719   virtual void follow_contents();
 720   virtual void oop_iterate(OopClosure* blk);
 721   virtual void oop_iterate_m(OopClosure* blk, MemRegion mr);
 722   virtual void adjust_pointers();
 723   virtual void follow_weak_refs(BoolObjectClosure* is_alive_closure);
 724 
 725 #ifndef SERIALGC
 726   // Parallel old support
 727   virtual void follow_contents(ParCompactionManager* cm);
 728   virtual void update_pointers();
 729   virtual void update_pointers(HeapWord* beg_addr, HeapWord* end_addr);
 730 #endif // SERIALGC
 731 
 732   oop* adr_receiver(uint row) {
 733     return adr_oop_at(receiver_cell_index(row));
 734   }
 735 
 736 #ifndef PRODUCT
 737   void print_receiver_data_on(outputStream* st);
 738   void print_data_on(outputStream* st);
 739 #endif
 740 };
 741 
 742 // VirtualCallData
 743 //
 744 // A VirtualCallData is used to access profiling information about a
 745 // virtual call.  For now, it has nothing more than a ReceiverTypeData.
 746 class VirtualCallData : public ReceiverTypeData {
 747 public:
 748   VirtualCallData(DataLayout* layout) : ReceiverTypeData(layout) {
 749     assert(layout->tag() == DataLayout::virtual_call_data_tag, "wrong type");
 750   }
 751 
 752   virtual bool is_VirtualCallData() { return true; }
 753 
 754   static int static_cell_count() {
 755     // At this point we could add more profile state, e.g., for arguments.
 756     // But for now it's the same size as the base record type.
 757     return ReceiverTypeData::static_cell_count();
 758   }
 759 
 760   virtual int cell_count() {
 761     return static_cell_count();
 762   }
 763 
 764   // Direct accessors
 765   static ByteSize virtual_call_data_size() {
 766     return cell_offset(static_cell_count());
 767   }
 768 
 769 #ifndef PRODUCT
 770   void print_data_on(outputStream* st);
 771 #endif
 772 };
 773 
 774 // RetData
 775 //
 776 // A RetData is used to access profiling information for a ret bytecode.
 777 // It is composed of a count of the number of times that the ret has
 778 // been executed, followed by a series of triples of the form
 779 // (bci, count, di) which count the number of times that some bci was the
 780 // target of the ret and cache a corresponding data displacement.
 781 class RetData : public CounterData {
 782 protected:
 783   enum {
 784     bci0_offset = counter_cell_count,
 785     count0_offset,
 786     displacement0_offset,
 787     ret_row_cell_count = (displacement0_offset + 1) - bci0_offset
 788   };
 789 
 790   void set_bci(uint row, int bci) {
 791     assert((uint)row < row_limit(), "oob");
 792     set_int_at(bci0_offset + row * ret_row_cell_count, bci);
 793   }
 794   void release_set_bci(uint row, int bci) {
 795     assert((uint)row < row_limit(), "oob");
 796     // 'release' when setting the bci acts as a valid flag for other
 797     // threads wrt bci_count and bci_displacement.
 798     release_set_int_at(bci0_offset + row * ret_row_cell_count, bci);
 799   }
 800   void set_bci_count(uint row, uint count) {
 801     assert((uint)row < row_limit(), "oob");
 802     set_uint_at(count0_offset + row * ret_row_cell_count, count);
 803   }
 804   void set_bci_displacement(uint row, int disp) {
 805     set_int_at(displacement0_offset + row * ret_row_cell_count, disp);
 806   }
 807 
 808 public:
 809   RetData(DataLayout* layout) : CounterData(layout) {
 810     assert(layout->tag() == DataLayout::ret_data_tag, "wrong type");
 811   }
 812 
 813   virtual bool is_RetData() { return true; }
 814 
 815   enum {
 816     no_bci = -1 // value of bci when bci1/2 are not in use.
 817   };
 818 
 819   static int static_cell_count() {
 820     return counter_cell_count + (uint) BciProfileWidth * ret_row_cell_count;
 821   }
 822 
 823   virtual int cell_count() {
 824     return static_cell_count();
 825   }
 826 
 827   static uint row_limit() {
 828     return BciProfileWidth;
 829   }
 830   static int bci_cell_index(uint row) {
 831     return bci0_offset + row * ret_row_cell_count;
 832   }
 833   static int bci_count_cell_index(uint row) {
 834     return count0_offset + row * ret_row_cell_count;
 835   }
 836   static int bci_displacement_cell_index(uint row) {
 837     return displacement0_offset + row * ret_row_cell_count;
 838   }
 839 
 840   // Direct accessors
 841   int bci(uint row) {
 842     return int_at(bci_cell_index(row));
 843   }
 844   uint bci_count(uint row) {
 845     return uint_at(bci_count_cell_index(row));
 846   }
 847   int bci_displacement(uint row) {
 848     return int_at(bci_displacement_cell_index(row));
 849   }
 850 
 851   // Interpreter Runtime support
 852   address fixup_ret(int return_bci, methodDataHandle mdo);
 853 
 854   // Code generation support
 855   static ByteSize bci_offset(uint row) {
 856     return cell_offset(bci_cell_index(row));
 857   }
 858   static ByteSize bci_count_offset(uint row) {
 859     return cell_offset(bci_count_cell_index(row));
 860   }
 861   static ByteSize bci_displacement_offset(uint row) {
 862     return cell_offset(bci_displacement_cell_index(row));
 863   }
 864 
 865   // Specific initialization.
 866   void post_initialize(BytecodeStream* stream, methodDataOop mdo);
 867 
 868 #ifndef PRODUCT
 869   void print_data_on(outputStream* st);
 870 #endif
 871 };
 872 
 873 // BranchData
 874 //
 875 // A BranchData is used to access profiling data for a two-way branch.
 876 // It consists of taken and not_taken counts as well as a data displacement
 877 // for the taken case.
 878 class BranchData : public JumpData {
 879 protected:
 880   enum {
 881     not_taken_off_set = jump_cell_count,
 882     branch_cell_count
 883   };
 884 
 885   void set_displacement(int displacement) {
 886     set_int_at(displacement_off_set, displacement);
 887   }
 888 
 889 public:
 890   BranchData(DataLayout* layout) : JumpData(layout) {
 891     assert(layout->tag() == DataLayout::branch_data_tag, "wrong type");
 892   }
 893 
 894   virtual bool is_BranchData() { return true; }
 895 
 896   static int static_cell_count() {
 897     return branch_cell_count;
 898   }
 899 
 900   virtual int cell_count() {
 901     return static_cell_count();
 902   }
 903 
 904   // Direct accessor
 905   uint not_taken() {
 906     return uint_at(not_taken_off_set);
 907   }
 908 
 909   uint inc_not_taken() {
 910     uint cnt = not_taken() + 1;
 911     // Did we wrap? Will compiler screw us??
 912     if (cnt == 0) cnt--;
 913     set_uint_at(not_taken_off_set, cnt);
 914     return cnt;
 915   }
 916 
 917   // Code generation support
 918   static ByteSize not_taken_offset() {
 919     return cell_offset(not_taken_off_set);
 920   }
 921   static ByteSize branch_data_size() {
 922     return cell_offset(branch_cell_count);
 923   }
 924 
 925   // Specific initialization.
 926   void post_initialize(BytecodeStream* stream, methodDataOop mdo);
 927 
 928 #ifndef PRODUCT
 929   void print_data_on(outputStream* st);
 930 #endif
 931 };
 932 
 933 // ArrayData
 934 //
 935 // A ArrayData is a base class for accessing profiling data which does
 936 // not have a statically known size.  It consists of an array length
 937 // and an array start.
 938 class ArrayData : public ProfileData {
 939 protected:
 940   friend class DataLayout;
 941 
 942   enum {
 943     array_len_off_set,
 944     array_start_off_set
 945   };
 946 
 947   uint array_uint_at(int index) {
 948     int aindex = index + array_start_off_set;
 949     return uint_at(aindex);
 950   }
 951   int array_int_at(int index) {
 952     int aindex = index + array_start_off_set;
 953     return int_at(aindex);
 954   }
 955   oop array_oop_at(int index) {
 956     int aindex = index + array_start_off_set;
 957     return oop_at(aindex);
 958   }
 959   void array_set_int_at(int index, int value) {
 960     int aindex = index + array_start_off_set;
 961     set_int_at(aindex, value);
 962   }
 963 
 964   // Code generation support for subclasses.
 965   static ByteSize array_element_offset(int index) {
 966     return cell_offset(array_start_off_set + index);
 967   }
 968 
 969 public:
 970   ArrayData(DataLayout* layout) : ProfileData(layout) {}
 971 
 972   virtual bool is_ArrayData() { return true; }
 973 
 974   static int static_cell_count() {
 975     return -1;
 976   }
 977 
 978   int array_len() {
 979     return int_at_unchecked(array_len_off_set);
 980   }
 981 
 982   virtual int cell_count() {
 983     return array_len() + 1;
 984   }
 985 
 986   // Code generation support
 987   static ByteSize array_len_offset() {
 988     return cell_offset(array_len_off_set);
 989   }
 990   static ByteSize array_start_offset() {
 991     return cell_offset(array_start_off_set);
 992   }
 993 };
 994 
 995 // MultiBranchData
 996 //
 997 // A MultiBranchData is used to access profiling information for
 998 // a multi-way branch (*switch bytecodes).  It consists of a series
 999 // of (count, displacement) pairs, which count the number of times each
1000 // case was taken and specify the data displacment for each branch target.
1001 class MultiBranchData : public ArrayData {
1002 protected:
1003   enum {
1004     default_count_off_set,
1005     default_disaplacement_off_set,
1006     case_array_start
1007   };
1008   enum {
1009     relative_count_off_set,
1010     relative_displacement_off_set,
1011     per_case_cell_count
1012   };
1013 
1014   void set_default_displacement(int displacement) {
1015     array_set_int_at(default_disaplacement_off_set, displacement);
1016   }
1017   void set_displacement_at(int index, int displacement) {
1018     array_set_int_at(case_array_start +
1019                      index * per_case_cell_count +
1020                      relative_displacement_off_set,
1021                      displacement);
1022   }
1023 
1024 public:
1025   MultiBranchData(DataLayout* layout) : ArrayData(layout) {
1026     assert(layout->tag() == DataLayout::multi_branch_data_tag, "wrong type");
1027   }
1028 
1029   virtual bool is_MultiBranchData() { return true; }
1030 
1031   static int compute_cell_count(BytecodeStream* stream);
1032 
1033   int number_of_cases() {
1034     int alen = array_len() - 2; // get rid of default case here.
1035     assert(alen % per_case_cell_count == 0, "must be even");
1036     return (alen / per_case_cell_count);
1037   }
1038 
1039   uint default_count() {
1040     return array_uint_at(default_count_off_set);
1041   }
1042   int default_displacement() {
1043     return array_int_at(default_disaplacement_off_set);
1044   }
1045 
1046   uint count_at(int index) {
1047     return array_uint_at(case_array_start +
1048                          index * per_case_cell_count +
1049                          relative_count_off_set);
1050   }
1051   int displacement_at(int index) {
1052     return array_int_at(case_array_start +
1053                         index * per_case_cell_count +
1054                         relative_displacement_off_set);
1055   }
1056 
1057   // Code generation support
1058   static ByteSize default_count_offset() {
1059     return array_element_offset(default_count_off_set);
1060   }
1061   static ByteSize default_displacement_offset() {
1062     return array_element_offset(default_disaplacement_off_set);
1063   }
1064   static ByteSize case_count_offset(int index) {
1065     return case_array_offset() +
1066            (per_case_size() * index) +
1067            relative_count_offset();
1068   }
1069   static ByteSize case_array_offset() {
1070     return array_element_offset(case_array_start);
1071   }
1072   static ByteSize per_case_size() {
1073     return in_ByteSize(per_case_cell_count) * cell_size;
1074   }
1075   static ByteSize relative_count_offset() {
1076     return in_ByteSize(relative_count_off_set) * cell_size;
1077   }
1078   static ByteSize relative_displacement_offset() {
1079     return in_ByteSize(relative_displacement_off_set) * cell_size;
1080   }
1081 
1082   // Specific initialization.
1083   void post_initialize(BytecodeStream* stream, methodDataOop mdo);
1084 
1085 #ifndef PRODUCT
1086   void print_data_on(outputStream* st);
1087 #endif
1088 };
1089 
1090 class ArgInfoData : public ArrayData {
1091 
1092 public:
1093   ArgInfoData(DataLayout* layout) : ArrayData(layout) {
1094     assert(layout->tag() == DataLayout::arg_info_data_tag, "wrong type");
1095   }
1096 
1097   virtual bool is_ArgInfoData() { return true; }
1098 
1099 
1100   int number_of_args() {
1101     return array_len();
1102   }
1103 
1104   uint arg_modified(int arg) {
1105     return array_uint_at(arg);
1106   }
1107 
1108   void set_arg_modified(int arg, uint val) {
1109     array_set_int_at(arg, val);
1110   }
1111 
1112 #ifndef PRODUCT
1113   void print_data_on(outputStream* st);
1114 #endif
1115 };
1116 
1117 // methodDataOop
1118 //
1119 // A methodDataOop holds information which has been collected about
1120 // a method.  Its layout looks like this:
1121 //
1122 // -----------------------------
1123 // | header                    |
1124 // | klass                     |
1125 // -----------------------------
1126 // | method                    |
1127 // | size of the methodDataOop |
1128 // -----------------------------
1129 // | Data entries...           |
1130 // |   (variable size)         |
1131 // |                           |
1132 // .                           .
1133 // .                           .
1134 // .                           .
1135 // |                           |
1136 // -----------------------------
1137 //
1138 // The data entry area is a heterogeneous array of DataLayouts. Each
1139 // DataLayout in the array corresponds to a specific bytecode in the
1140 // method.  The entries in the array are sorted by the corresponding
1141 // bytecode.  Access to the data is via resource-allocated ProfileData,
1142 // which point to the underlying blocks of DataLayout structures.
1143 //
1144 // During interpretation, if profiling in enabled, the interpreter
1145 // maintains a method data pointer (mdp), which points at the entry
1146 // in the array corresponding to the current bci.  In the course of
1147 // intepretation, when a bytecode is encountered that has profile data
1148 // associated with it, the entry pointed to by mdp is updated, then the
1149 // mdp is adjusted to point to the next appropriate DataLayout.  If mdp
1150 // is NULL to begin with, the interpreter assumes that the current method
1151 // is not (yet) being profiled.
1152 //
1153 // In methodDataOop parlance, "dp" is a "data pointer", the actual address
1154 // of a DataLayout element.  A "di" is a "data index", the offset in bytes
1155 // from the base of the data entry array.  A "displacement" is the byte offset
1156 // in certain ProfileData objects that indicate the amount the mdp must be
1157 // adjusted in the event of a change in control flow.
1158 //
1159 
1160 class methodDataOopDesc : public oopDesc {
1161   friend class VMStructs;
1162 private:
1163   friend class ProfileData;
1164 
1165   // Back pointer to the methodOop
1166   methodOop _method;
1167 
1168   // Size of this oop in bytes
1169   int _size;
1170 
1171   // Cached hint for bci_to_dp and bci_to_data
1172   int _hint_di;
1173 
1174   // Whole-method sticky bits and flags
1175 public:
1176   enum {
1177     _trap_hist_limit    = 16,   // decoupled from Deoptimization::Reason_LIMIT
1178     _trap_hist_mask     = max_jubyte,
1179     _extra_data_count   = 4     // extra DataLayout headers, for trap history
1180   }; // Public flag values
1181 private:
1182   uint _nof_decompiles;             // count of all nmethod removals
1183   uint _nof_overflow_recompiles;    // recompile count, excluding recomp. bits
1184   uint _nof_overflow_traps;         // trap count, excluding _trap_hist
1185   union {
1186     intptr_t _align;
1187     u1 _array[_trap_hist_limit];
1188   } _trap_hist;
1189 
1190   // Support for interprocedural escape analysis, from Thomas Kotzmann.
1191   intx              _eflags;          // flags on escape information
1192   intx              _arg_local;       // bit set of non-escaping arguments
1193   intx              _arg_stack;       // bit set of stack-allocatable arguments
1194   intx              _arg_returned;    // bit set of returned arguments
1195 
1196   int _creation_mileage;            // method mileage at MDO creation
1197 
1198   // Size of _data array in bytes.  (Excludes header and extra_data fields.)
1199   int _data_size;
1200 
1201   // Beginning of the data entries
1202   intptr_t _data[1];
1203 
1204   // Helper for size computation
1205   static int compute_data_size(BytecodeStream* stream);
1206   static int bytecode_cell_count(Bytecodes::Code code);
1207   enum { no_profile_data = -1, variable_cell_count = -2 };
1208 
1209   // Helper for initialization
1210   DataLayout* data_layout_at(int data_index) {
1211     assert(data_index % sizeof(intptr_t) == 0, "unaligned");
1212     return (DataLayout*) (((address)_data) + data_index);
1213   }
1214 
1215   // Initialize an individual data segment.  Returns the size of
1216   // the segment in bytes.
1217   int initialize_data(BytecodeStream* stream, int data_index);
1218 
1219   // Helper for data_at
1220   DataLayout* limit_data_position() {
1221     return (DataLayout*)((address)data_base() + _data_size);
1222   }
1223   bool out_of_bounds(int data_index) {
1224     return data_index >= data_size();
1225   }
1226 
1227   // Give each of the data entries a chance to perform specific
1228   // data initialization.
1229   void post_initialize(BytecodeStream* stream);
1230 
1231   // hint accessors
1232   int      hint_di() const  { return _hint_di; }
1233   void set_hint_di(int di)  {
1234     assert(!out_of_bounds(di), "hint_di out of bounds");
1235     _hint_di = di;
1236   }
1237   ProfileData* data_before(int bci) {
1238     // avoid SEGV on this edge case
1239     if (data_size() == 0)
1240       return NULL;
1241     int hint = hint_di();
1242     if (data_layout_at(hint)->bci() <= bci)
1243       return data_at(hint);
1244     return first_data();
1245   }
1246 
1247   // What is the index of the first data entry?
1248   int first_di() { return 0; }
1249 
1250   // Find or create an extra ProfileData:
1251   ProfileData* bci_to_extra_data(int bci, bool create_if_missing);
1252 
1253   // return the argument info cell
1254   ArgInfoData *arg_info();
1255 
1256 public:
1257   static int header_size() {
1258     return sizeof(methodDataOopDesc)/wordSize;
1259   }
1260 
1261   // Compute the size of a methodDataOop before it is created.
1262   static int compute_allocation_size_in_bytes(methodHandle method);
1263   static int compute_allocation_size_in_words(methodHandle method);
1264   static int compute_extra_data_count(int data_size, int empty_bc_count);
1265 
1266   // Determine if a given bytecode can have profile information.
1267   static bool bytecode_has_profile(Bytecodes::Code code) {
1268     return bytecode_cell_count(code) != no_profile_data;
1269   }
1270 
1271   // Perform initialization of a new methodDataOop
1272   void initialize(methodHandle method);
1273 
1274   // My size
1275   int object_size_in_bytes() { return _size; }
1276   int object_size() {
1277     return align_object_size(align_size_up(_size, BytesPerWord)/BytesPerWord);
1278   }
1279 
1280   int      creation_mileage() const  { return _creation_mileage; }
1281   void set_creation_mileage(int x)   { _creation_mileage = x; }
1282   bool is_mature() const;  // consult mileage and ProfileMaturityPercentage
1283   static int mileage_of(methodOop m);
1284 
1285   // Support for interprocedural escape analysis, from Thomas Kotzmann.
1286   enum EscapeFlag {
1287     estimated    = 1 << 0,
1288     return_local = 1 << 1,
1289     return_allocated = 1 << 2,
1290     allocated_escapes = 1 << 3,
1291     unknown_modified = 1 << 4
1292   };
1293 
1294   intx eflags()                                  { return _eflags; }
1295   intx arg_local()                               { return _arg_local; }
1296   intx arg_stack()                               { return _arg_stack; }
1297   intx arg_returned()                            { return _arg_returned; }
1298   uint arg_modified(int a)                       { ArgInfoData *aid = arg_info();
1299                                                    assert(a >= 0 && a < aid->number_of_args(), "valid argument number");
1300                                                    return aid->arg_modified(a); }
1301 
1302   void set_eflags(intx v)                        { _eflags = v; }
1303   void set_arg_local(intx v)                     { _arg_local = v; }
1304   void set_arg_stack(intx v)                     { _arg_stack = v; }
1305   void set_arg_returned(intx v)                  { _arg_returned = v; }
1306   void set_arg_modified(int a, uint v)           { ArgInfoData *aid = arg_info();
1307                                                    assert(a >= 0 && a < aid->number_of_args(), "valid argument number");
1308 
1309                                                    aid->set_arg_modified(a, v); }
1310 
1311   void clear_escape_info()                       { _eflags = _arg_local = _arg_stack = _arg_returned = 0; }
1312 
1313   // Location and size of data area
1314   address data_base() const {
1315     return (address) _data;
1316   }
1317   int data_size() {
1318     return _data_size;
1319   }
1320 
1321   // Accessors
1322   methodOop method() { return _method; }
1323 
1324   // Get the data at an arbitrary (sort of) data index.
1325   ProfileData* data_at(int data_index);
1326 
1327   // Walk through the data in order.
1328   ProfileData* first_data() { return data_at(first_di()); }
1329   ProfileData* next_data(ProfileData* current);
1330   bool is_valid(ProfileData* current) { return current != NULL; }
1331 
1332   // Convert a dp (data pointer) to a di (data index).
1333   int dp_to_di(address dp) {
1334     return dp - ((address)_data);
1335   }
1336 
1337   address di_to_dp(int di) {
1338     return (address)data_layout_at(di);
1339   }
1340 
1341   // bci to di/dp conversion.
1342   address bci_to_dp(int bci);
1343   int bci_to_di(int bci) {
1344     return dp_to_di(bci_to_dp(bci));
1345   }
1346 
1347   // Get the data at an arbitrary bci, or NULL if there is none.
1348   ProfileData* bci_to_data(int bci);
1349 
1350   // Same, but try to create an extra_data record if one is needed:
1351   ProfileData* allocate_bci_to_data(int bci) {
1352     ProfileData* data = bci_to_data(bci);
1353     return (data != NULL) ? data : bci_to_extra_data(bci, true);
1354   }
1355 
1356   // Add a handful of extra data records, for trap tracking.
1357   DataLayout* extra_data_base() { return limit_data_position(); }
1358   DataLayout* extra_data_limit() { return (DataLayout*)((address)this + object_size_in_bytes()); }
1359   int extra_data_size() { return (address)extra_data_limit()
1360                                - (address)extra_data_base(); }
1361   static DataLayout* next_extra(DataLayout* dp) { return (DataLayout*)((address)dp + in_bytes(DataLayout::cell_offset(0))); }
1362 
1363   // Return (uint)-1 for overflow.
1364   uint trap_count(int reason) const {
1365     assert((uint)reason < _trap_hist_limit, "oob");
1366     return (int)((_trap_hist._array[reason]+1) & _trap_hist_mask) - 1;
1367   }
1368   // For loops:
1369   static uint trap_reason_limit() { return _trap_hist_limit; }
1370   static uint trap_count_limit()  { return _trap_hist_mask; }
1371   uint inc_trap_count(int reason) {
1372     // Count another trap, anywhere in this method.
1373     assert(reason >= 0, "must be single trap");
1374     if ((uint)reason < _trap_hist_limit) {
1375       uint cnt1 = 1 + _trap_hist._array[reason];
1376       if ((cnt1 & _trap_hist_mask) != 0) {  // if no counter overflow...
1377         _trap_hist._array[reason] = cnt1;
1378         return cnt1;
1379       } else {
1380         return _trap_hist_mask + (++_nof_overflow_traps);
1381       }
1382     } else {
1383       // Could not represent the count in the histogram.
1384       return (++_nof_overflow_traps);
1385     }
1386   }
1387 
1388   uint overflow_trap_count() const {
1389     return _nof_overflow_traps;
1390   }
1391   uint overflow_recompile_count() const {
1392     return _nof_overflow_recompiles;
1393   }
1394   void inc_overflow_recompile_count() {
1395     _nof_overflow_recompiles += 1;
1396   }
1397   uint decompile_count() const {
1398     return _nof_decompiles;
1399   }
1400   void inc_decompile_count() {
1401     _nof_decompiles += 1;
1402     if (decompile_count() > (uint)PerMethodRecompilationCutoff) {
1403       method()->set_not_compilable();
1404     }
1405   }
1406 
1407   // Support for code generation
1408   static ByteSize data_offset() {
1409     return byte_offset_of(methodDataOopDesc, _data[0]);
1410   }
1411 
1412   // GC support
1413   oop* adr_method() const { return (oop*)&_method; }
1414   bool object_is_parsable() const { return _size != 0; }
1415   void set_object_is_parsable(int object_size_in_bytes) { _size = object_size_in_bytes; }
1416 
1417 #ifndef PRODUCT
1418   // printing support for method data
1419   void print_data_on(outputStream* st);
1420 #endif
1421 
1422   // verification
1423   void verify_data_on(outputStream* st);
1424 };