< prev index next >

src/hotspot/share/asm/codeBuffer.cpp

Print this page
*** 26,10 ***
--- 26,11 ---
  #include "code/compiledIC.hpp"
  #include "code/oopRecorder.inline.hpp"
  #include "compiler/disassembler.hpp"
  #include "logging/log.hpp"
  #include "oops/klass.inline.hpp"
+ #include "oops/methodCounters.hpp"
  #include "oops/methodData.hpp"
  #include "oops/oop.inline.hpp"
  #include "runtime/icache.hpp"
  #include "runtime/safepointVerifiers.hpp"
  #include "utilities/align.hpp"

*** 534,10 ***
--- 535,13 ---
            Metadata* m = md->metadata_value();
            if (oop_recorder()->is_real(m)) {
              if (m->is_methodData()) {
                m = ((MethodData*)m)->method();
              }
+             if (m->is_methodCounters()) {
+               m = ((MethodCounters*)m)->method();
+             }
              if (m->is_method()) {
                m = ((Method*)m)->method_holder();
              }
              if (m->is_klass()) {
                append_oop_references(&oops, (Klass*)m);

*** 558,10 ***
--- 562,13 ---
        Metadata* m = oop_recorder()->metadata_at(i);
        if (oop_recorder()->is_real(m)) {
          if (m->is_methodData()) {
            m = ((MethodData*)m)->method();
          }
+         if (m->is_methodCounters()) {
+           m = ((MethodCounters*)m)->method();
+         }
          if (m->is_method()) {
            m = ((Method*)m)->method_holder();
          }
          if (m->is_klass()) {
            append_oop_references(&oops, (Klass*)m);

*** 1000,27 ***
        if (!other->is_allocated() || other == sect) {
          continue;
        }
        guarantee(other->disjoint(sect), "sanity");
      }
!     guarantee(sect->end() <= tend, "sanity");
!     guarantee(sect->end() <= sect->limit(), "sanity");
    }
  }
  
  void CodeBuffer::log_section_sizes(const char* name) {
    if (xtty != nullptr) {
      ttyLocker ttyl;
      // log info about buffer usage
!     xtty->print_cr("<blob name='%s' total_size='%d'>", name, _total_size);
      for (int n = (int) CodeBuffer::SECT_FIRST; n < (int) CodeBuffer::SECT_LIMIT; n++) {
        CodeSection* sect = code_section(n);
        if (!sect->is_allocated() || sect->is_empty())  continue;
!       xtty->print_cr("<sect index='%d' capacity='%d' size='%d' remaining='%d'/>",
!                      n, sect->capacity(), sect->size(), sect->remaining());
      }
!     xtty->print_cr("</blob>");
    }
  }
  
  bool CodeBuffer::finalize_stubs() {
    if (_finalize_stubs && !pd_finalize_stubs()) {
--- 1007,27 ---
        if (!other->is_allocated() || other == sect) {
          continue;
        }
        guarantee(other->disjoint(sect), "sanity");
      }
!     guarantee(sect->end() <= tend, "sanity, sect_end: " PTR_FORMAT " tend: " PTR_FORMAT " size: %d", p2i(sect->end()), p2i(tend), (int)_total_size);
!     guarantee(sect->end() <= sect->limit(), "sanity, sect_end: " PTR_FORMAT " sect_limit: " PTR_FORMAT, p2i(sect->end()), p2i(sect->limit()));
    }
  }
  
  void CodeBuffer::log_section_sizes(const char* name) {
    if (xtty != nullptr) {
      ttyLocker ttyl;
      // log info about buffer usage
!     xtty->head("blob name='%s' total_size='%d'", name, _total_size);
      for (int n = (int) CodeBuffer::SECT_FIRST; n < (int) CodeBuffer::SECT_LIMIT; n++) {
        CodeSection* sect = code_section(n);
        if (!sect->is_allocated() || sect->is_empty())  continue;
!       xtty->elem("sect index='%d' capacity='%d' size='%d' remaining='%d'",
!                  n, sect->capacity(), sect->size(), sect->remaining());
      }
!     xtty->tail("blob");
    }
  }
  
  bool CodeBuffer::finalize_stubs() {
    if (_finalize_stubs && !pd_finalize_stubs()) {

*** 1085,109 ***
      CodeSection* cs = code_section(n);
      cs->print_on(st, code_section_name(n));
    }
  }
  
- // ----- CHeapString -----------------------------------------------------------
- 
- class CHeapString : public CHeapObj<mtCode> {
-  public:
-   CHeapString(const char* str) : _string(os::strdup(str)) {}
-  ~CHeapString() {
-     os::free((void*)_string);
-     _string = nullptr;
-   }
-   const char* string() const { return _string; }
- 
-  private:
-   const char* _string;
- };
- 
- // ----- AsmRemarkCollection ---------------------------------------------------
- 
- class AsmRemarkCollection : public CHeapObj<mtCode> {
-  public:
-   AsmRemarkCollection() : _ref_cnt(1), _remarks(nullptr), _next(nullptr) {}
-  ~AsmRemarkCollection() {
-     assert(is_empty(), "Must 'clear()' before deleting!");
-     assert(_ref_cnt == 0, "No uses must remain when deleting!");
-   }
-   AsmRemarkCollection* reuse() {
-     precond(_ref_cnt > 0);
-     return _ref_cnt++, this;
-   }
- 
-   const char* insert(uint offset, const char* remark);
-   const char* lookup(uint offset) const;
-   const char* next(uint offset) const;
- 
-   bool is_empty() const { return _remarks == nullptr; }
-   uint clear();
- 
-  private:
-   struct Cell : CHeapString {
-     Cell(const char* remark, uint offset) :
-         CHeapString(remark), offset(offset), prev(nullptr), next(nullptr) {}
-     void push_back(Cell* cell) {
-       Cell* head = this;
-       Cell* tail = prev;
-       tail->next = cell;
-       cell->next = head;
-       cell->prev = tail;
-       prev = cell;
-     }
-     uint offset;
-     Cell* prev;
-     Cell* next;
-   };
-   uint  _ref_cnt;
-   Cell* _remarks;
-   // Using a 'mutable' iteration pointer to allow 'const' on lookup/next (that
-   // does not change the state of the list per se), supportig a simplistic
-   // iteration scheme.
-   mutable Cell* _next;
- };
- 
- // ----- DbgStringCollection ---------------------------------------------------
- 
- class DbgStringCollection : public CHeapObj<mtCode> {
-  public:
-   DbgStringCollection() : _ref_cnt(1), _strings(nullptr) {}
-  ~DbgStringCollection() {
-     assert(is_empty(), "Must 'clear()' before deleting!");
-     assert(_ref_cnt == 0, "No uses must remain when deleting!");
-   }
-   DbgStringCollection* reuse() {
-     precond(_ref_cnt > 0);
-     return _ref_cnt++, this;
-   }
- 
-   const char* insert(const char* str);
-   const char* lookup(const char* str) const;
- 
-   bool is_empty() const { return _strings == nullptr; }
-   uint clear();
- 
-  private:
-   struct Cell : CHeapString {
-     Cell(const char* dbgstr) :
-         CHeapString(dbgstr), prev(nullptr), next(nullptr) {}
-     void push_back(Cell* cell) {
-       Cell* head = this;
-       Cell* tail = prev;
-       tail->next = cell;
-       cell->next = head;
-       cell->prev = tail;
-       prev = cell;
-     }
-     Cell* prev;
-     Cell* next;
-   };
-   uint  _ref_cnt;
-   Cell* _strings;
- };
- 
  // ----- AsmRemarks ------------------------------------------------------------
  //
  // Acting as interface to reference counted mapping [offset -> remark], where
  // offset is a byte offset into an instruction stream (CodeBuffer, CodeBlob or
  // other memory buffer) and remark is a string (comment).
--- 1092,10 ---

*** 1195,13 ***
--- 1103,20 ---
  AsmRemarks::AsmRemarks() : _remarks(new AsmRemarkCollection()) {
    assert(_remarks != nullptr, "Allocation failure!");
  }
  
  AsmRemarks::~AsmRemarks() {
+   if (_remarks != nullptr) {
+     clear();
+   }
    assert(_remarks == nullptr, "Must 'clear()' before deleting!");
  }
  
+ void AsmRemarks::init(AsmRemarks& asm_remarks) {
+   asm_remarks._remarks = new AsmRemarkCollection();
+ }
+ 
  const char* AsmRemarks::insert(uint offset, const char* remstr) {
    precond(remstr != nullptr);
    return _remarks->insert(offset, remstr);
  }
  

*** 1214,10 ***
--- 1129,11 ---
    clear();
    _remarks = src._remarks->reuse();
  }
  
  void AsmRemarks::clear() {
+   assert(_remarks != nullptr, "sanity check");
    if (_remarks->clear() == 0) {
      delete _remarks;
    }
    _remarks = nullptr;
  }

*** 1247,13 ***
--- 1163,20 ---
  DbgStrings::DbgStrings() : _strings(new DbgStringCollection()) {
    assert(_strings != nullptr, "Allocation failure!");
  }
  
  DbgStrings::~DbgStrings() {
+   if (_strings != nullptr) {
+     clear();
+   }
    assert(_strings == nullptr, "Must 'clear()' before deleting!");
  }
  
+ void DbgStrings::init(DbgStrings& dbg_strings) {
+   dbg_strings._strings = new DbgStringCollection();
+ }
+ 
  const char* DbgStrings::insert(const char* dbgstr) {
    const char* str = _strings->lookup(dbgstr);
    return str != nullptr ? str : _strings->insert(dbgstr);
  }
  

*** 1266,10 ***
--- 1189,11 ---
    clear();
    _strings = src._strings->reuse();
  }
  
  void DbgStrings::clear() {
+   assert(_strings != nullptr, "sanity check");
    if (_strings->clear() == 0) {
      delete _strings;
    }
    _strings = nullptr;
  }
< prev index next >