changeset 4662:92ef81e2f571

8003557: NPG: Klass* const k should be const Klass* k. Summary: With NPG, const KlassOop klass which is in fact a definition converted to Klass* const, which is not the original intention. The right usage is converting them to const Klass*. Reviewed-by: coleenp, kvn Contributed-by: yumin.qi@oracle.com
author minqi
date Fri, 10 May 2013 08:27:30 -0700
parents c272092594bd
children 1fcfc045b229
files src/share/vm/c1/c1_Runtime1.cpp src/share/vm/classfile/verifier.cpp src/share/vm/classfile/verifier.hpp src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp src/share/vm/gc_implementation/shared/markSweep.cpp src/share/vm/memory/heapInspection.cpp src/share/vm/memory/heapInspection.hpp src/share/vm/memory/universe.cpp src/share/vm/memory/universe.hpp src/share/vm/oops/constantPool.hpp src/share/vm/oops/instanceKlass.cpp src/share/vm/oops/instanceKlass.hpp src/share/vm/oops/klass.cpp src/share/vm/oops/klass.hpp src/share/vm/oops/method.cpp src/share/vm/oops/method.hpp src/share/vm/oops/methodData.hpp src/share/vm/prims/jvm.cpp src/share/vm/prims/jvmtiTagMap.cpp
diffstat 20 files changed, 62 insertions(+), 64 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/c1/c1_Runtime1.cpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/c1/c1_Runtime1.cpp	Fri May 10 08:27:30 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, 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
@@ -1261,7 +1261,7 @@
 
   if (length == 0) return ac_ok;
   if (src->is_typeArray()) {
-    Klass* const klass_oop = src->klass();
+    Klass* klass_oop = src->klass();
     if (klass_oop != dst->klass()) return ac_failed;
     TypeArrayKlass* klass = TypeArrayKlass::cast(klass_oop);
     const int l2es = klass->log2_element_size();
--- a/src/share/vm/classfile/verifier.cpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/classfile/verifier.cpp	Fri May 10 08:27:30 2013 -0700
@@ -362,7 +362,7 @@
 }
 #endif
 
-void ErrorContext::details(outputStream* ss, Method* method) const {
+void ErrorContext::details(outputStream* ss, const Method* method) const {
   if (is_valid()) {
     ss->print_cr("");
     ss->print_cr("Exception Details:");
@@ -435,7 +435,7 @@
   ss->print_cr("");
 }
 
-void ErrorContext::location_details(outputStream* ss, Method* method) const {
+void ErrorContext::location_details(outputStream* ss, const Method* method) const {
   if (_bci != -1 && method != NULL) {
     streamIndentor si(ss);
     const char* bytecode_name = "<invalid>";
@@ -470,7 +470,7 @@
   }
 }
 
-void ErrorContext::bytecode_details(outputStream* ss, Method* method) const {
+void ErrorContext::bytecode_details(outputStream* ss, const Method* method) const {
   if (method != NULL) {
     streamIndentor si(ss);
     ss->indent().print_cr("Bytecode:");
@@ -479,7 +479,7 @@
   }
 }
 
-void ErrorContext::handler_details(outputStream* ss, Method* method) const {
+void ErrorContext::handler_details(outputStream* ss, const Method* method) const {
   if (method != NULL) {
     streamIndentor si(ss);
     ExceptionTable table(method);
@@ -494,7 +494,7 @@
   }
 }
 
-void ErrorContext::stackmap_details(outputStream* ss, Method* method) const {
+void ErrorContext::stackmap_details(outputStream* ss, const Method* method) const {
   if (method != NULL && method->has_stackmap_table()) {
     streamIndentor si(ss);
     ss->indent().print_cr("Stackmap Table:");
--- a/src/share/vm/classfile/verifier.hpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/classfile/verifier.hpp	Fri May 10 08:27:30 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2013, 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
@@ -224,7 +224,7 @@
     _expected.reset_frame();
   }
 
-  void details(outputStream* ss, Method* method) const;
+  void details(outputStream* ss, const Method* method) const;
 
 #ifdef ASSERT
   void print_on(outputStream* str) const {
@@ -237,12 +237,12 @@
 #endif
 
  private:
-  void location_details(outputStream* ss, Method* method) const;
+  void location_details(outputStream* ss, const Method* method) const;
   void reason_details(outputStream* ss) const;
   void frame_details(outputStream* ss) const;
-  void bytecode_details(outputStream* ss, Method* method) const;
-  void handler_details(outputStream* ss, Method* method) const;
-  void stackmap_details(outputStream* ss, Method* method) const;
+  void bytecode_details(outputStream* ss, const Method* method) const;
+  void handler_details(outputStream* ss, const Method* method) const;
+  void stackmap_details(outputStream* ss, const Method* method) const;
 };
 
 // A new instance of this class is created for each class being verified
--- a/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp	Fri May 10 08:27:30 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, 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
@@ -213,7 +213,7 @@
   int random_seed = 17;
   do {
     while (ParCompactionManager::steal_objarray(which, &random_seed, task)) {
-      ObjArrayKlass* const k = (ObjArrayKlass*)task.obj()->klass();
+      ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass();
       k->oop_follow_contents(cm, task.obj(), task.index());
       cm->follow_marking_stacks();
     }
--- a/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp	Fri May 10 08:27:30 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, 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
@@ -187,11 +187,8 @@
 
     // Process ObjArrays one at a time to avoid marking stack bloat.
     ObjArrayTask task;
-    if (_objarray_stack.pop_overflow(task)) {
-      ObjArrayKlass* const k = (ObjArrayKlass*)task.obj()->klass();
-      k->oop_follow_contents(this, task.obj(), task.index());
-    } else if (_objarray_stack.pop_local(task)) {
-      ObjArrayKlass* const k = (ObjArrayKlass*)task.obj()->klass();
+    if (_objarray_stack.pop_overflow(task) || _objarray_stack.pop_local(task)) {
+      ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass();
       k->oop_follow_contents(this, task.obj(), task.index());
     }
   } while (!marking_stacks_empty());
--- a/src/share/vm/gc_implementation/shared/markSweep.cpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/gc_implementation/shared/markSweep.cpp	Fri May 10 08:27:30 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, 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
@@ -95,7 +95,7 @@
     // Process ObjArrays one at a time to avoid marking stack bloat.
     if (!_objarray_stack.is_empty()) {
       ObjArrayTask task = _objarray_stack.pop();
-      ObjArrayKlass* const k = (ObjArrayKlass*)task.obj()->klass();
+      ObjArrayKlass* k = (ObjArrayKlass*)task.obj()->klass();
       k->oop_follow_contents(task.obj(), task.index());
     }
   } while (!_marking_stack.is_empty() || !_objarray_stack.is_empty());
--- a/src/share/vm/memory/heapInspection.cpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/memory/heapInspection.cpp	Fri May 10 08:27:30 2013 -0700
@@ -154,12 +154,12 @@
   }
 }
 
-uint KlassInfoTable::hash(Klass* p) {
+uint KlassInfoTable::hash(const Klass* p) {
   assert(p->is_metadata(), "all klasses are metadata");
   return (uint)(((uintptr_t)p - (uintptr_t)_ref) >> 2);
 }
 
-KlassInfoEntry* KlassInfoTable::lookup(Klass* const k) {
+KlassInfoEntry* KlassInfoTable::lookup(Klass* k) {
   uint         idx = hash(k) % _size;
   assert(_buckets != NULL, "Allocation failure should have been caught");
   KlassInfoEntry*  e   = _buckets[idx].lookup(k);
--- a/src/share/vm/memory/heapInspection.hpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/memory/heapInspection.hpp	Fri May 10 08:27:30 2013 -0700
@@ -189,15 +189,15 @@
   KlassInfoEntry(Klass* k, KlassInfoEntry* next) :
     _klass(k), _instance_count(0), _instance_words(0), _next(next), _index(-1)
   {}
-  KlassInfoEntry* next()     { return _next; }
-  bool is_equal(Klass* k)  { return k == _klass; }
-  Klass* klass()           { return _klass; }
-  long count()               { return _instance_count; }
+  KlassInfoEntry* next() const   { return _next; }
+  bool is_equal(const Klass* k)  { return k == _klass; }
+  Klass* klass()  const      { return _klass; }
+  long count()    const      { return _instance_count; }
   void set_count(long ct)    { _instance_count = ct; }
-  size_t words()             { return _instance_words; }
+  size_t words()  const      { return _instance_words; }
   void set_words(size_t wds) { _instance_words = wds; }
   void set_index(long index) { _index = index; }
-  long index()               { return _index; }
+  long index()    const      { return _index; }
   int compare(KlassInfoEntry* e1, KlassInfoEntry* e2);
   void print_on(outputStream* st) const;
   const char* name() const;
@@ -215,7 +215,7 @@
   KlassInfoEntry* list()           { return _list; }
   void set_list(KlassInfoEntry* l) { _list = l; }
  public:
-  KlassInfoEntry* lookup(Klass* const k);
+  KlassInfoEntry* lookup(Klass* k);
   void initialize() { _list = NULL; }
   void empty();
   void iterate(KlassInfoClosure* cic);
@@ -231,8 +231,8 @@
   HeapWord* _ref;
 
   KlassInfoBucket* _buckets;
-  uint hash(Klass* p);
-  KlassInfoEntry* lookup(Klass* const k); // allocates if not found!
+  uint hash(const Klass* p);
+  KlassInfoEntry* lookup(Klass* k); // allocates if not found!
 
   class AllClassesFinder : public KlassClosure {
     KlassInfoTable *_table;
--- a/src/share/vm/memory/universe.cpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/memory/universe.cpp	Fri May 10 08:27:30 2013 -0700
@@ -1425,25 +1425,25 @@
 }
 
 
-void ActiveMethodOopsCache::add_previous_version(Method* const method) {
+void ActiveMethodOopsCache::add_previous_version(Method* method) {
   assert(Thread::current()->is_VM_thread(),
     "only VMThread can add previous versions");
 
   // Only append the previous method if it is executing on the stack.
   if (method->on_stack()) {
 
-  if (_prev_methods == NULL) {
-    // This is the first previous version so make some space.
-    // Start with 2 elements under the assumption that the class
-    // won't be redefined much.
+    if (_prev_methods == NULL) {
+      // This is the first previous version so make some space.
+      // Start with 2 elements under the assumption that the class
+      // won't be redefined much.
       _prev_methods = new (ResourceObj::C_HEAP, mtClass) GrowableArray<Method*>(2, true);
-  }
+    }
 
-  // RC_TRACE macro has an embedded ResourceMark
-  RC_TRACE(0x00000100,
-    ("add: %s(%s): adding prev version ref for cached method @%d",
-    method->name()->as_C_string(), method->signature()->as_C_string(),
-    _prev_methods->length()));
+    // RC_TRACE macro has an embedded ResourceMark
+    RC_TRACE(0x00000100,
+      ("add: %s(%s): adding prev version ref for cached method @%d",
+        method->name()->as_C_string(), method->signature()->as_C_string(),
+        _prev_methods->length()));
 
     _prev_methods->append(method);
   }
@@ -1464,16 +1464,17 @@
       MetadataFactory::free_metadata(method->method_holder()->class_loader_data(), method);
     } else {
       // RC_TRACE macro has an embedded ResourceMark
-      RC_TRACE(0x00000400, ("add: %s(%s): previous cached method @%d is alive",
-        method->name()->as_C_string(), method->signature()->as_C_string(), i));
+      RC_TRACE(0x00000400,
+        ("add: %s(%s): previous cached method @%d is alive",
+         method->name()->as_C_string(), method->signature()->as_C_string(), i));
     }
   }
 } // end add_previous_version()
 
 
-bool ActiveMethodOopsCache::is_same_method(Method* const method) const {
+bool ActiveMethodOopsCache::is_same_method(const Method* method) const {
   InstanceKlass* ik = InstanceKlass::cast(klass());
-  Method* check_method = ik->method_with_idnum(method_idnum());
+  const Method* check_method = ik->method_with_idnum(method_idnum());
   assert(check_method != NULL, "sanity check");
   if (check_method == method) {
     // done with the easy case
--- a/src/share/vm/memory/universe.hpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/memory/universe.hpp	Fri May 10 08:27:30 2013 -0700
@@ -90,8 +90,8 @@
   ActiveMethodOopsCache()   { _prev_methods = NULL; }
   ~ActiveMethodOopsCache();
 
-  void add_previous_version(Method* const method);
-  bool is_same_method(Method* const method) const;
+  void add_previous_version(Method* method);
+  bool is_same_method(const Method* method) const;
 };
 
 
--- a/src/share/vm/oops/constantPool.hpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/oops/constantPool.hpp	Fri May 10 08:27:30 2013 -0700
@@ -354,7 +354,7 @@
 
   Symbol* klass_name_at(int which);  // Returns the name, w/o resolving.
 
-  Klass* resolved_klass_at(int which) {  // Used by Compiler
+  Klass* resolved_klass_at(int which) const {  // Used by Compiler
     guarantee(tag_at(which).is_klass(), "Corrupted constant pool");
     // Must do an acquire here in case another thread resolved the klass
     // behind our back, lest we later load stale values thru the oop.
--- a/src/share/vm/oops/instanceKlass.cpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/oops/instanceKlass.cpp	Fri May 10 08:27:30 2013 -0700
@@ -2724,7 +2724,7 @@
   OsrList_lock->unlock();
 }
 
-nmethod* InstanceKlass::lookup_osr_nmethod(Method* const m, int bci, int comp_level, bool match_level) const {
+nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_level, bool match_level) const {
   // This is a short non-blocking critical region, so the no safepoint check is ok.
   OsrList_lock->lock_without_safepoint_check();
   nmethod* osr = osr_nmethods_head();
--- a/src/share/vm/oops/instanceKlass.hpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/oops/instanceKlass.hpp	Fri May 10 08:27:30 2013 -0700
@@ -739,7 +739,7 @@
   void set_osr_nmethods_head(nmethod* h)     { _osr_nmethods_head = h; };
   void add_osr_nmethod(nmethod* n);
   void remove_osr_nmethod(nmethod* n);
-  nmethod* lookup_osr_nmethod(Method* const m, int bci, int level, bool match_level) const;
+  nmethod* lookup_osr_nmethod(const Method* m, int bci, int level, bool match_level) const;
 
   // Breakpoint support (see methods on Method* for details)
   BreakpointInfo* breakpoints() const       { return _breakpoints; };
--- a/src/share/vm/oops/klass.cpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/oops/klass.cpp	Fri May 10 08:27:30 2013 -0700
@@ -50,7 +50,7 @@
   if (_name != NULL) _name->increment_refcount();
 }
 
-bool Klass::is_subclass_of(Klass* k) const {
+bool Klass::is_subclass_of(const Klass* k) const {
   // Run up the super chain and check
   if (this == k) return true;
 
--- a/src/share/vm/oops/klass.hpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/oops/klass.hpp	Fri May 10 08:27:30 2013 -0700
@@ -395,7 +395,7 @@
   virtual klassVtable* vtable() const        { return NULL; }
 
   // subclass check
-  bool is_subclass_of(Klass* k) const;
+  bool is_subclass_of(const Klass* k) const;
   // subtype check: true if is_subclass_of, or if k is interface and receiver implements it
   bool is_subtype_of(Klass* k) const {
     juint    off = k->super_check_offset();
--- a/src/share/vm/oops/method.cpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/oops/method.cpp	Fri May 10 08:27:30 2013 -0700
@@ -1581,7 +1581,7 @@
 }
 
 int Method::highest_comp_level() const {
-  MethodData* mdo = method_data();
+  const MethodData* mdo = method_data();
   if (mdo != NULL) {
     return mdo->highest_comp_level();
   } else {
@@ -1590,7 +1590,7 @@
 }
 
 int Method::highest_osr_comp_level() const {
-  MethodData* mdo = method_data();
+  const MethodData* mdo = method_data();
   if (mdo != NULL) {
     return mdo->highest_osr_comp_level();
   } else {
--- a/src/share/vm/oops/method.hpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/oops/method.hpp	Fri May 10 08:27:30 2013 -0700
@@ -996,7 +996,7 @@
   u2  _length;
 
  public:
-  ExceptionTable(Method* m) {
+  ExceptionTable(const Method* m) {
     if (m->has_exception_handler()) {
       _table = m->exception_table_start();
       _length = m->exception_table_length();
--- a/src/share/vm/oops/methodData.hpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/oops/methodData.hpp	Fri May 10 08:27:30 2013 -0700
@@ -1338,9 +1338,9 @@
   void set_would_profile(bool p)              { _would_profile = p;    }
   bool would_profile() const                  { return _would_profile; }
 
-  int highest_comp_level()                    { return _highest_comp_level;      }
+  int highest_comp_level() const              { return _highest_comp_level;      }
   void set_highest_comp_level(int level)      { _highest_comp_level = level;     }
-  int highest_osr_comp_level()                { return _highest_osr_comp_level;  }
+  int highest_osr_comp_level() const          { return _highest_osr_comp_level;  }
   void set_highest_osr_comp_level(int level)  { _highest_osr_comp_level = level; }
 
   int num_loops() const                       { return _num_loops;  }
--- a/src/share/vm/prims/jvm.cpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/prims/jvm.cpp	Fri May 10 08:27:30 2013 -0700
@@ -1710,7 +1710,7 @@
     for (int i = 0; i < num_params; i++) {
       MethodParametersElement* params = mh->method_parameters_start();
       // For a 0 index, give a NULL symbol
-      Symbol* const sym = 0 != params[i].name_cp_index ?
+      Symbol* sym = 0 != params[i].name_cp_index ?
         mh->constants()->symbol_at(params[i].name_cp_index) : NULL;
       int flags = params[i].flags;
       oop param = Reflection::new_parameter(reflected_method, i, sym,
--- a/src/share/vm/prims/jvmtiTagMap.cpp	Wed May 08 21:06:46 2013 -0400
+++ b/src/share/vm/prims/jvmtiTagMap.cpp	Fri May 10 08:27:30 2013 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, 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
@@ -2857,7 +2857,7 @@
 
     // references from the constant pool
     {
-      ConstantPool* const pool = ik->constants();
+      ConstantPool* pool = ik->constants();
       for (int i = 1; i < pool->length(); i++) {
         constantTag tag = pool->tag_at(i).value();
         if (tag.is_string() || tag.is_klass()) {