From b19113b46c2fd124209b22c0556e5dcf18edcaba Mon Sep 17 00:00:00 2001 From: minqi Date: Fri, 10 May 2013 08:27:30 -0700 Subject: 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 --- src/share/vm/c1/c1_Runtime1.cpp | 4 +-- src/share/vm/classfile/verifier.cpp | 10 +++---- src/share/vm/classfile/verifier.hpp | 12 ++++----- .../gc_implementation/parallelScavenge/pcTasks.cpp | 4 +-- .../parallelScavenge/psCompactionManager.cpp | 9 +++---- .../vm/gc_implementation/shared/markSweep.cpp | 4 +-- src/share/vm/memory/heapInspection.cpp | 4 +-- src/share/vm/memory/heapInspection.hpp | 18 ++++++------- src/share/vm/memory/universe.cpp | 31 +++++++++++----------- src/share/vm/memory/universe.hpp | 4 +-- src/share/vm/oops/constantPool.hpp | 2 +- src/share/vm/oops/instanceKlass.cpp | 2 +- src/share/vm/oops/instanceKlass.hpp | 2 +- src/share/vm/oops/klass.cpp | 2 +- src/share/vm/oops/klass.hpp | 2 +- src/share/vm/oops/method.cpp | 4 +-- src/share/vm/oops/method.hpp | 2 +- src/share/vm/oops/methodData.hpp | 4 +-- src/share/vm/prims/jvm.cpp | 2 +- src/share/vm/prims/jvmtiTagMap.cpp | 4 +-- 20 files changed, 62 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/share/vm/c1/c1_Runtime1.cpp b/src/share/vm/c1/c1_Runtime1.cpp index e274076d0..53d1f5326 100644 --- a/src/share/vm/c1/c1_Runtime1.cpp +++ b/src/share/vm/c1/c1_Runtime1.cpp @@ -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 @@ JRT_LEAF(int, Runtime1::arraycopy(oopDesc* src, int src_pos, oopDesc* dst, int d 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(); diff --git a/src/share/vm/classfile/verifier.cpp b/src/share/vm/classfile/verifier.cpp index fda30acd1..015b8093d 100644 --- a/src/share/vm/classfile/verifier.cpp +++ b/src/share/vm/classfile/verifier.cpp @@ -362,7 +362,7 @@ void TypeOrigin::print_on(outputStream* str) const { } #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 @@ void ErrorContext::reason_details(outputStream* ss) const { 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 = ""; @@ -470,7 +470,7 @@ void ErrorContext::frame_details(outputStream* ss) const { } } -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::bytecode_details(outputStream* ss, Method* method) const { } } -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::handler_details(outputStream* ss, Method* method) const { } } -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:"); diff --git a/src/share/vm/classfile/verifier.hpp b/src/share/vm/classfile/verifier.hpp index bdab7a7e2..bfab2c830 100644 --- a/src/share/vm/classfile/verifier.hpp +++ b/src/share/vm/classfile/verifier.hpp @@ -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 @@ class ErrorContext VALUE_OBJ_CLASS_SPEC { _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 @@ class ErrorContext VALUE_OBJ_CLASS_SPEC { #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 diff --git a/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp b/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp index 3834722fa..ed91fe258 100644 --- a/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp +++ b/src/share/vm/gc_implementation/parallelScavenge/pcTasks.cpp @@ -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 @@ void StealMarkingTask::do_it(GCTaskManager* manager, uint which) { 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(); } diff --git a/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp b/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp index 62c578f33..415d62947 100644 --- a/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp +++ b/src/share/vm/gc_implementation/parallelScavenge/psCompactionManager.cpp @@ -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 @@ void ParCompactionManager::follow_marking_stacks() { // 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()); diff --git a/src/share/vm/gc_implementation/shared/markSweep.cpp b/src/share/vm/gc_implementation/shared/markSweep.cpp index 5e52aa1eb..905869e72 100644 --- a/src/share/vm/gc_implementation/shared/markSweep.cpp +++ b/src/share/vm/gc_implementation/shared/markSweep.cpp @@ -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 @@ void MarkSweep::follow_stack() { // 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()); diff --git a/src/share/vm/memory/heapInspection.cpp b/src/share/vm/memory/heapInspection.cpp index a51ea1d15..d93104954 100644 --- a/src/share/vm/memory/heapInspection.cpp +++ b/src/share/vm/memory/heapInspection.cpp @@ -154,12 +154,12 @@ KlassInfoTable::~KlassInfoTable() { } } -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); diff --git a/src/share/vm/memory/heapInspection.hpp b/src/share/vm/memory/heapInspection.hpp index a5de4551e..ccf39bad5 100644 --- a/src/share/vm/memory/heapInspection.hpp +++ b/src/share/vm/memory/heapInspection.hpp @@ -189,15 +189,15 @@ class KlassInfoEntry: public CHeapObj { 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 @@ class KlassInfoBucket: public CHeapObj { 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 @@ class KlassInfoTable: public StackObj { 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; diff --git a/src/share/vm/memory/universe.cpp b/src/share/vm/memory/universe.cpp index a0849df99..77fc4b846 100644 --- a/src/share/vm/memory/universe.cpp +++ b/src/share/vm/memory/universe.cpp @@ -1425,25 +1425,25 @@ ActiveMethodOopsCache::~ActiveMethodOopsCache() { } -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(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 @@ void ActiveMethodOopsCache::add_previous_version(Method* const method) { 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 diff --git a/src/share/vm/memory/universe.hpp b/src/share/vm/memory/universe.hpp index 48d32f71e..6daf75d2c 100644 --- a/src/share/vm/memory/universe.hpp +++ b/src/share/vm/memory/universe.hpp @@ -90,8 +90,8 @@ class ActiveMethodOopsCache : public CommonMethodOopCache { 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; }; diff --git a/src/share/vm/oops/constantPool.hpp b/src/share/vm/oops/constantPool.hpp index 58cad7a67..eca2dcd9c 100644 --- a/src/share/vm/oops/constantPool.hpp +++ b/src/share/vm/oops/constantPool.hpp @@ -354,7 +354,7 @@ class ConstantPool : public Metadata { 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. diff --git a/src/share/vm/oops/instanceKlass.cpp b/src/share/vm/oops/instanceKlass.cpp index ecb0dcbac..06827e681 100644 --- a/src/share/vm/oops/instanceKlass.cpp +++ b/src/share/vm/oops/instanceKlass.cpp @@ -2724,7 +2724,7 @@ void InstanceKlass::remove_osr_nmethod(nmethod* n) { 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(); diff --git a/src/share/vm/oops/instanceKlass.hpp b/src/share/vm/oops/instanceKlass.hpp index 55b8ff48c..8ee9adc01 100644 --- a/src/share/vm/oops/instanceKlass.hpp +++ b/src/share/vm/oops/instanceKlass.hpp @@ -739,7 +739,7 @@ class InstanceKlass: public Klass { 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; }; diff --git a/src/share/vm/oops/klass.cpp b/src/share/vm/oops/klass.cpp index 06c644c34..52dd26459 100644 --- a/src/share/vm/oops/klass.cpp +++ b/src/share/vm/oops/klass.cpp @@ -50,7 +50,7 @@ void Klass::set_name(Symbol* n) { 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; diff --git a/src/share/vm/oops/klass.hpp b/src/share/vm/oops/klass.hpp index d2a419146..c19b29e59 100644 --- a/src/share/vm/oops/klass.hpp +++ b/src/share/vm/oops/klass.hpp @@ -395,7 +395,7 @@ class Klass : public Metadata { 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(); diff --git a/src/share/vm/oops/method.cpp b/src/share/vm/oops/method.cpp index 74364c3bd..c8a9a36df 100644 --- a/src/share/vm/oops/method.cpp +++ b/src/share/vm/oops/method.cpp @@ -1581,7 +1581,7 @@ int Method::backedge_count() { } 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_comp_level() const { } 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 { diff --git a/src/share/vm/oops/method.hpp b/src/share/vm/oops/method.hpp index b23a3955e..e4bd92352 100644 --- a/src/share/vm/oops/method.hpp +++ b/src/share/vm/oops/method.hpp @@ -996,7 +996,7 @@ class ExceptionTable : public StackObj { 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(); diff --git a/src/share/vm/oops/methodData.hpp b/src/share/vm/oops/methodData.hpp index b9fc63e30..765b91c14 100644 --- a/src/share/vm/oops/methodData.hpp +++ b/src/share/vm/oops/methodData.hpp @@ -1338,9 +1338,9 @@ public: 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; } diff --git a/src/share/vm/prims/jvm.cpp b/src/share/vm/prims/jvm.cpp index 5c31ea1e5..bedfc6190 100644 --- a/src/share/vm/prims/jvm.cpp +++ b/src/share/vm/prims/jvm.cpp @@ -1710,7 +1710,7 @@ JVM_ENTRY(jobjectArray, JVM_GetMethodParameters(JNIEnv *env, jobject method)) 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, diff --git a/src/share/vm/prims/jvmtiTagMap.cpp b/src/share/vm/prims/jvmtiTagMap.cpp index 99e4af5aa..eb68b4296 100644 --- a/src/share/vm/prims/jvmtiTagMap.cpp +++ b/src/share/vm/prims/jvmtiTagMap.cpp @@ -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 @@ inline bool VM_HeapWalkOperation::iterate_over_class(oop java_class) { // 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()) { -- cgit v1.2.3