diff src/share/vm/runtime/fprofiler.cpp @ 6725:da91efe96a93

6964458: Reimplement class meta-data storage to use native memory Summary: Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland Contributed-by: jmasa <jon.masamitsu@oracle.com>, stefank <stefan.karlsson@oracle.com>, mgerdin <mikael.gerdin@oracle.com>, never <tom.rodriguez@oracle.com>
author coleenp
date Sat, 01 Sep 2012 13:25:18 -0400
parents 1d7922586cf6
children aeaca88565e6
line wrap: on
line diff
--- a/src/share/vm/runtime/fprofiler.cpp	Fri Aug 31 16:39:35 2012 -0700
+++ b/src/share/vm/runtime/fprofiler.cpp	Sat Sep 01 13:25:18 2012 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -288,9 +288,9 @@
   virtual bool is_runtime_stub() const{ return false; }
   virtual void oops_do(OopClosure* f) = 0;
 
-  virtual bool interpreted_match(methodOop m) const { return false; }
-  virtual bool compiled_match(methodOop m ) const { return false; }
-  virtual bool stub_match(methodOop m, const char* name) const { return false; }
+  virtual bool interpreted_match(Method* m) const { return false; }
+  virtual bool compiled_match(Method* m ) const { return false; }
+  virtual bool stub_match(Method* m, const char* name) const { return false; }
   virtual bool adapter_match() const { return false; }
   virtual bool runtimeStub_match(const CodeBlob* stub, const char* name) const { return false; }
   virtual bool unknown_compiled_match(const CodeBlob* cb) const { return false; }
@@ -312,12 +312,12 @@
     st->cr();
   }
 
-  virtual methodOop method()         = 0;
+  virtual Method* method()         = 0;
 
   virtual void print_method_on(outputStream* st) {
     int limit;
     int i;
-    methodOop m = method();
+    Method* m = method();
     Symbol* k = m->klass_name();
     // Print the class name with dots instead of slashes
     limit = k->utf8_length();
@@ -342,7 +342,7 @@
       Symbol* sig = m->signature();
       sig->print_symbol_on(st);
     } else if (MethodHandles::is_signature_polymorphic(m->intrinsic_id()))
-      // compare with methodOopDesc::print_short_name
+      // compare with Method::print_short_name
       MethodHandles::print_as_basic_type_signature_on(st, m->signature(), true);
   }
 
@@ -356,7 +356,7 @@
   }
 
   // for hashing into the table
-  static int hash(methodOop method) {
+  static int hash(Method* method) {
       // The point here is to try to make something fairly unique
       // out of the fields we can read without grabbing any locks
       // since the method may be locked when we need the hash.
@@ -388,24 +388,26 @@
 
 class interpretedNode : public ProfilerNode {
  private:
-   methodOop _method;
+   Method* _method;
+   oop       _class_loader;  // needed to keep metadata for the method alive
  public:
-   interpretedNode(methodOop method, TickPosition where) : ProfilerNode() {
+   interpretedNode(Method* method, TickPosition where) : ProfilerNode() {
      _method = method;
+     _class_loader = method->method_holder()->class_loader();
      update(where);
    }
 
    bool is_interpreted() const { return true; }
 
-   bool interpreted_match(methodOop m) const {
+   bool interpreted_match(Method* m) const {
       return _method == m;
    }
 
    void oops_do(OopClosure* f) {
-     f->do_oop((oop*)&_method);
+     f->do_oop(&_class_loader);
    }
 
-   methodOop method() { return _method; }
+   Method* method() { return _method; }
 
    static void print_title(outputStream* st) {
      st->fill_to(col1);
@@ -425,22 +427,24 @@
 
 class compiledNode : public ProfilerNode {
  private:
-   methodOop _method;
+   Method* _method;
+   oop       _class_loader;  // needed to keep metadata for the method alive
  public:
-   compiledNode(methodOop method, TickPosition where) : ProfilerNode() {
+   compiledNode(Method* method, TickPosition where) : ProfilerNode() {
      _method = method;
+     _class_loader = method->method_holder()->class_loader();
      update(where);
   }
   bool is_compiled()    const { return true; }
 
-  bool compiled_match(methodOop m) const {
+  bool compiled_match(Method* m) const {
     return _method == m;
   }
 
-  methodOop method()         { return _method; }
+  Method* method()         { return _method; }
 
   void oops_do(OopClosure* f) {
-    f->do_oop((oop*)&_method);
+    f->do_oop(&_class_loader);
   }
 
   static void print_title(outputStream* st) {
@@ -460,26 +464,28 @@
 
 class stubNode : public ProfilerNode {
  private:
-  methodOop _method;
+  Method* _method;
+  oop       _class_loader;  // needed to keep metadata for the method alive
   const char* _symbol;   // The name of the nearest VM symbol (for +ProfileVM). Points to a unique string
  public:
-   stubNode(methodOop method, const char* name, TickPosition where) : ProfilerNode() {
+   stubNode(Method* method, const char* name, TickPosition where) : ProfilerNode() {
      _method = method;
+     _class_loader = method->method_holder()->class_loader();
      _symbol = name;
      update(where);
    }
 
    bool is_stub() const { return true; }
 
-   bool stub_match(methodOop m, const char* name) const {
+   void oops_do(OopClosure* f) {
+     f->do_oop(&_class_loader);
+   }
+
+   bool stub_match(Method* m, const char* name) const {
      return (_method == m) && (_symbol == name);
    }
 
-   void oops_do(OopClosure* f) {
-     f->do_oop((oop*)&_method);
-   }
-
-   methodOop method() { return _method; }
+   Method* method() { return _method; }
 
    static void print_title(outputStream* st) {
      st->fill_to(col1);
@@ -512,7 +518,7 @@
 
   bool adapter_match() const { return true; }
 
-  methodOop method()         { return NULL; }
+  Method* method()         { return NULL; }
 
   void oops_do(OopClosure* f) {
     ;
@@ -545,7 +551,7 @@
             (_symbol == name);
   }
 
-  methodOop method() { return NULL; }
+  Method* method() { return NULL; }
 
   static void print_title(outputStream* st) {
     st->fill_to(col1);
@@ -593,7 +599,7 @@
        return !strcmp(((SingletonBlob*)cb)->name(), _name);
   }
 
-  methodOop method()         { return NULL; }
+  Method* method()         { return NULL; }
 
   void oops_do(OopClosure* f) {
     ;
@@ -627,7 +633,7 @@
 
   bool vm_match(const char* name) const { return strcmp(name, _name) == 0; }
 
-  methodOop method()          { return NULL; }
+  Method* method()          { return NULL; }
 
   static int hash(const char* name){
     // Compute a simple hash
@@ -661,7 +667,7 @@
   }
 };
 
-void ThreadProfiler::interpreted_update(methodOop method, TickPosition where) {
+void ThreadProfiler::interpreted_update(Method* method, TickPosition where) {
   int index = entry(ProfilerNode::hash(method));
   if (!table[index]) {
     table[index] = new (this) interpretedNode(method, where);
@@ -678,7 +684,7 @@
   }
 }
 
-void ThreadProfiler::compiled_update(methodOop method, TickPosition where) {
+void ThreadProfiler::compiled_update(Method* method, TickPosition where) {
   int index = entry(ProfilerNode::hash(method));
   if (!table[index]) {
     table[index] = new (this) compiledNode(method, where);
@@ -695,7 +701,7 @@
   }
 }
 
-void ThreadProfiler::stub_update(methodOop method, const char* name, TickPosition where) {
+void ThreadProfiler::stub_update(Method* method, const char* name, TickPosition where) {
   int index = entry(ProfilerNode::hash(method));
   if (!table[index]) {
     table[index] = new (this) stubNode(method, name, where);
@@ -957,7 +963,7 @@
 
   // The frame has been fully validated so we can trust the method and bci
 
-  methodOop method = *fr.interpreter_frame_method_addr();
+  Method* method = *fr.interpreter_frame_method_addr();
 
   interpreted_update(method, where);
 
@@ -984,8 +990,8 @@
         cb = fr.cb();
         localwhere = tp_native;
   }
-  methodOop method = (cb->is_nmethod()) ? ((nmethod *)cb)->method() :
-                                          (methodOop)NULL;
+  Method* method = (cb->is_nmethod()) ? ((nmethod *)cb)->method() :
+                                          (Method*)NULL;
 
   if (method == NULL) {
     if (cb->is_runtime_stub())